* [PATCH] writeback: Avoid skipping inode writeback
@ 2022-05-05 13:47 Jing Xia
2022-05-05 15:40 ` Jan Kara
2022-05-09 6:46 ` Christoph Hellwig
0 siblings, 2 replies; 5+ messages in thread
From: Jing Xia @ 2022-05-05 13:47 UTC (permalink / raw)
To: viro; +Cc: jack, jing.xia, jing.xia.mail, linux-fsdevel, linux-kernel
We have run into an issue that a task gets stuck in
balance_dirty_pages_ratelimited() when perform I/O stress testing.
The reason we observed is that an I_DIRTY_PAGES inode with lots
of dirty pages is in b_dirty_time list and standard background
writeback cannot writeback the inode.
After studing the relevant code, the following scenario may lead
to the issue:
task1 task2
----- -----
fuse_flush
write_inode_now //in b_dirty_time
writeback_single_inode
__writeback_single_inode
fuse_write_end
filemap_dirty_folio
__xa_set_mark:PAGECACHE_TAG_DIRTY
lock inode->i_lock
if mapping tagged PAGECACHE_TAG_DIRTY
inode->i_state |= I_DIRTY_PAGES
unlock inode->i_lock
__mark_inode_dirty:I_DIRTY_PAGES
lock inode->i_lock
-was dirty,inode stays in
-b_dirty_time
unlock inode->i_lock
if(!(inode->i_state & I_DIRTY_All))
-not true,so nothing done
This patch moves the dirty inode to b_dirty list when the inode
currently is not queued in b_io or b_more_io list at the end of
writeback_single_inode.
Signed-off-by: Jing Xia <jing.xia@unisoc.com>
---
fs/fs-writeback.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 591fe9cf1659..d7763feaf14a 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1712,6 +1712,9 @@ static int writeback_single_inode(struct inode *inode,
*/
if (!(inode->i_state & I_DIRTY_ALL))
inode_cgwb_move_to_attached(inode, wb);
+ else if (!(inode->i_state & I_SYNC_QUEUED) && (inode->i_state & I_DIRTY))
+ redirty_tail_locked(inode, wb);
+
spin_unlock(&wb->list_lock);
inode_sync_complete(inode);
out:
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] writeback: Avoid skipping inode writeback
2022-05-05 13:47 [PATCH] writeback: Avoid skipping inode writeback Jing Xia
@ 2022-05-05 15:40 ` Jan Kara
2022-05-09 9:37 ` jing xia
2022-05-09 6:46 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: Jan Kara @ 2022-05-05 15:40 UTC (permalink / raw)
To: Jing Xia; +Cc: viro, jack, jing.xia.mail, linux-fsdevel, linux-kernel
On Thu 05-05-22 21:47:31, Jing Xia wrote:
> We have run into an issue that a task gets stuck in
> balance_dirty_pages_ratelimited() when perform I/O stress testing.
> The reason we observed is that an I_DIRTY_PAGES inode with lots
> of dirty pages is in b_dirty_time list and standard background
> writeback cannot writeback the inode.
> After studing the relevant code, the following scenario may lead
> to the issue:
>
> task1 task2
> ----- -----
> fuse_flush
> write_inode_now //in b_dirty_time
> writeback_single_inode
> __writeback_single_inode
> fuse_write_end
> filemap_dirty_folio
> __xa_set_mark:PAGECACHE_TAG_DIRTY
> lock inode->i_lock
> if mapping tagged PAGECACHE_TAG_DIRTY
> inode->i_state |= I_DIRTY_PAGES
> unlock inode->i_lock
> __mark_inode_dirty:I_DIRTY_PAGES
> lock inode->i_lock
> -was dirty,inode stays in
> -b_dirty_time
> unlock inode->i_lock
>
> if(!(inode->i_state & I_DIRTY_All))
> -not true,so nothing done
>
> This patch moves the dirty inode to b_dirty list when the inode
> currently is not queued in b_io or b_more_io list at the end of
> writeback_single_inode.
>
> Signed-off-by: Jing Xia <jing.xia@unisoc.com>
Thanks for report and the fix! The patch looks good so feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Also please add tags:
CC: stable@vger.kernel.org
Fixes: 0ae45f63d4ef ("vfs: add support for a lazytime mount option")
Thanks.
Honza
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 591fe9cf1659..d7763feaf14a 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1712,6 +1712,9 @@ static int writeback_single_inode(struct inode *inode,
> */
> if (!(inode->i_state & I_DIRTY_ALL))
> inode_cgwb_move_to_attached(inode, wb);
> + else if (!(inode->i_state & I_SYNC_QUEUED) && (inode->i_state & I_DIRTY))
> + redirty_tail_locked(inode, wb);
> +
> spin_unlock(&wb->list_lock);
> inode_sync_complete(inode);
> out:
> --
> 2.17.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] writeback: Avoid skipping inode writeback
2022-05-05 13:47 [PATCH] writeback: Avoid skipping inode writeback Jing Xia
2022-05-05 15:40 ` Jan Kara
@ 2022-05-09 6:46 ` Christoph Hellwig
2022-05-09 9:41 ` jing xia
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2022-05-09 6:46 UTC (permalink / raw)
To: Jing Xia; +Cc: viro, jack, jing.xia.mail, linux-fsdevel, linux-kernel
On Thu, May 05, 2022 at 09:47:31PM +0800, Jing Xia wrote:
> if (!(inode->i_state & I_DIRTY_ALL))
> inode_cgwb_move_to_attached(inode, wb);
> + else if (!(inode->i_state & I_SYNC_QUEUED) && (inode->i_state & I_DIRTY))
Please turn this into
else if ((inode->i_state & I_DIRTY) &&
!(inode->i_state & I_SYNC_QUEUED))
to keep it a little more readable.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] writeback: Avoid skipping inode writeback
2022-05-05 15:40 ` Jan Kara
@ 2022-05-09 9:37 ` jing xia
0 siblings, 0 replies; 5+ messages in thread
From: jing xia @ 2022-05-09 9:37 UTC (permalink / raw)
To: Jan Kara; +Cc: Jing Xia, viro, linux-fsdevel, linux-kernel
Thanks, I'll update the patch.
On Thu, May 5, 2022 at 11:40 PM Jan Kara <jack@suse.cz> wrote:
>
> On Thu 05-05-22 21:47:31, Jing Xia wrote:
> > We have run into an issue that a task gets stuck in
> > balance_dirty_pages_ratelimited() when perform I/O stress testing.
> > The reason we observed is that an I_DIRTY_PAGES inode with lots
> > of dirty pages is in b_dirty_time list and standard background
> > writeback cannot writeback the inode.
> > After studing the relevant code, the following scenario may lead
> > to the issue:
> >
> > task1 task2
> > ----- -----
> > fuse_flush
> > write_inode_now //in b_dirty_time
> > writeback_single_inode
> > __writeback_single_inode
> > fuse_write_end
> > filemap_dirty_folio
> > __xa_set_mark:PAGECACHE_TAG_DIRTY
> > lock inode->i_lock
> > if mapping tagged PAGECACHE_TAG_DIRTY
> > inode->i_state |= I_DIRTY_PAGES
> > unlock inode->i_lock
> > __mark_inode_dirty:I_DIRTY_PAGES
> > lock inode->i_lock
> > -was dirty,inode stays in
> > -b_dirty_time
> > unlock inode->i_lock
> >
> > if(!(inode->i_state & I_DIRTY_All))
> > -not true,so nothing done
> >
> > This patch moves the dirty inode to b_dirty list when the inode
> > currently is not queued in b_io or b_more_io list at the end of
> > writeback_single_inode.
> >
> > Signed-off-by: Jing Xia <jing.xia@unisoc.com>
>
> Thanks for report and the fix! The patch looks good so feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> Also please add tags:
>
> CC: stable@vger.kernel.org
> Fixes: 0ae45f63d4ef ("vfs: add support for a lazytime mount option")
>
> Thanks.
> Honza
>
> > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> > index 591fe9cf1659..d7763feaf14a 100644
> > --- a/fs/fs-writeback.c
> > +++ b/fs/fs-writeback.c
> > @@ -1712,6 +1712,9 @@ static int writeback_single_inode(struct inode *inode,
> > */
> > if (!(inode->i_state & I_DIRTY_ALL))
> > inode_cgwb_move_to_attached(inode, wb);
> > + else if (!(inode->i_state & I_SYNC_QUEUED) && (inode->i_state & I_DIRTY))
> > + redirty_tail_locked(inode, wb);
> > +
> > spin_unlock(&wb->list_lock);
> > inode_sync_complete(inode);
> > out:
> > --
> > 2.17.1
> >
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] writeback: Avoid skipping inode writeback
2022-05-09 6:46 ` Christoph Hellwig
@ 2022-05-09 9:41 ` jing xia
0 siblings, 0 replies; 5+ messages in thread
From: jing xia @ 2022-05-09 9:41 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jing Xia, viro, Jan Kara, linux-fsdevel, linux-kernel
On Mon, May 9, 2022 at 2:46 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Thu, May 05, 2022 at 09:47:31PM +0800, Jing Xia wrote:
> > if (!(inode->i_state & I_DIRTY_ALL))
> > inode_cgwb_move_to_attached(inode, wb);
> > + else if (!(inode->i_state & I_SYNC_QUEUED) && (inode->i_state & I_DIRTY))
>
> Please turn this into
>
> else if ((inode->i_state & I_DIRTY) &&
> !(inode->i_state & I_SYNC_QUEUED))
>
> to keep it a little more readable.
>
> Otherwise looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Ok. And thanks for the review.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-09 9:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 13:47 [PATCH] writeback: Avoid skipping inode writeback Jing Xia
2022-05-05 15:40 ` Jan Kara
2022-05-09 9:37 ` jing xia
2022-05-09 6:46 ` Christoph Hellwig
2022-05-09 9:41 ` jing xia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®