linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix an infinite loop when flush nodes in cp
@ 2016-11-16  9:26 Yunlei He
  2016-11-17  6:43 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Yunlei He @ 2016-11-16  9:26 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei

Thread A			Thread B

- write_checkpoint
 - block_operations
   -blk_start_plug
    -sync_node_pages		- f2fs_do_sync_file
				 - fsync_node_pages
				  - f2fs_wait_on_page_writeback

Thread A wait for global F2FS_DIRTY_NODES decreased to zero,
it start a plug list, some requests have been added to this list.
Thread B lock one dirty node page, and wait this page write back.
But this page has been in plug list of thread A with PG_writeback flag.
Thread A keep on running and its plug list has no chance to finish,
so it seems a deadlock between cp and fsync path.

This patch add a wait on page write back before set node page dirty
to avoid this problem.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Pengyang Hou <houpengyang@huawei.com>
---
 fs/f2fs/node.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 38cc07d..1de25f8 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1410,6 +1410,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
 			"Retry to write fsync mark: ino=%u, idx=%lx",
 					ino, last_page->index);
 		lock_page(last_page);
+		f2fs_wait_on_page_writeback(last_page, NODE, true);
 		set_page_dirty(last_page);
 		unlock_page(last_page);
 		goto retry;
-- 
2.10.1


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] f2fs: fix an infinite loop when flush nodes in cp
  2016-11-16  9:26 [PATCH] f2fs: fix an infinite loop when flush nodes in cp Yunlei He
@ 2016-11-17  6:43 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2016-11-17  6:43 UTC (permalink / raw)
  To: Yunlei He, linux-f2fs-devel, jaegeuk; +Cc: heyunlei

On 2016/11/16 17:26, Yunlei He wrote:
> Thread A			Thread B
> 
> - write_checkpoint
>  - block_operations
>    -blk_start_plug
>     -sync_node_pages		- f2fs_do_sync_file
> 				 - fsync_node_pages
> 				  - f2fs_wait_on_page_writeback
> 
> Thread A wait for global F2FS_DIRTY_NODES decreased to zero,
> it start a plug list, some requests have been added to this list.
> Thread B lock one dirty node page, and wait this page write back.
> But this page has been in plug list of thread A with PG_writeback flag.
> Thread A keep on running and its plug list has no chance to finish,
> so it seems a deadlock between cp and fsync path.
> 
> This patch add a wait on page write back before set node page dirty
> to avoid this problem.
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> Signed-off-by: Pengyang Hou <houpengyang@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>


------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-17  6:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16  9:26 [PATCH] f2fs: fix an infinite loop when flush nodes in cp Yunlei He
2016-11-17  6:43 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).