IO hang due to f2fs checkpoint and writeback stuck
Hi Chao, Jaegeuk,
I have received an issue report that indicates that system is stuck on IO due to f2fs checkpoint and writeback stuck waiting on each other as explained below.
WB thread -
----------
io_schedulewait_on_page_bitf2fs_wait_on_page_writeback -> It is waiting for node
node page writeback whose bio is in the plug list of CP thread below.f2fs_update_data_blkaddrf2fs_outplace_write_dataf2fs_do_write_data_page__write_data_page__f2fs_write_data_pagesf2fs_write_data_pagesdo_writepages
CP thread -
-----------
__f2fs_write_data_pages -> It is for the same inode above that is under WB (which
is waiting for node page writeback). In this context, there is nothing to be written as the data is already under WB.filemap_fdatawritef2fs_sync_dirty_inodes -> It just loops here in f2fs_sync_dirty_inodes() until
f2fs_remove_dirty_inode() has been done by the WB thread above.block_operationsf2fs_write_checkpoint
The CP thread somehow has the node page bio in its plug list that cannot be submitted until end of block_operations() and CP thread is blocked on WB of an inode who is again waiting for io pending in CP plug list. Both the stacks are stuck on for each other.
The below patch helped to solve the issue, please review and suggest if this seems to be okay. Since anyways we are doing cond_resched(), I thought it will be good to flush the plug list as well (in this issue case, it will loop for the same inode again and again).
fs/f2fs/checkpoint.c +4 -2
@@ -1071,10 +1071,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)iput (inode);/* We need to give cpu to another writers. */ -if (ino == cur_ino) +if (ino == cur_ino) { +blk_flush_plug (current);cond_resched (); -else + }else { ino = cur_ino; + } }else {/* * We should submit bio, since it exists several
Thanks,
Signature · 9 lines
-- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum. _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit 1f5f11a3c41e2b23288b2769435a00f74e02496b
Author: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700
f2fs: remove blk_plugging in block_operations
blk_plugging doesn't seem to give any benefit.
How about backporting this patch?
Quoted 62 lines · Sahitya Tummala
Hi Chao, Jaegeuk,
I have received an issue report that indicates that system is stuck on IO due to f2fs checkpoint and writeback stuck waiting on each other as explained below.
WB thread -
----------
io_schedulewait_on_page_bitf2fs_wait_on_page_writeback-> It is waiting for node
node page writeback whose bio is in the plug list of CP thread below.f2fs_update_data_blkaddrf2fs_outplace_write_dataf2fs_do_write_data_page__write_data_page__f2fs_write_data_pagesf2fs_write_data_pagesdo_writepagesCP thread -
-----------
__f2fs_write_data_pages-> It is for the same inode above that is under WB (which
is waiting for node page writeback). In this context, there is nothing to be written as the data is already under WB.filemap_fdatawritef2fs_sync_dirty_inodes-> It just loops here inf2fs_sync_dirty_inodes()until
f2fs_remove_dirty_inode()has been done by the WB thread above.block_operationsf2fs_write_checkpointThe CP thread somehow has the node page bio in its plug list that cannot be submitted until end of
block_operations()and CP thread is blocked on WB of an inode who is again waiting for io pending in CP plug list. Both the stacks are stuck on for each other.The below patch helped to solve the issue, please review and suggest if this seems to be okay. Since anyways we are doing
cond_resched(), I thought it will be good to flush the plug list as well (in this issue case, it will loop for the same inode again and again).fs/f2fs/checkpoint.c +4
-2@@ -1071,10 +1071,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)iput (inode);/* We need to give cpu to another writers. */ -if (ino == cur_ino) +if (ino == cur_ino) { +blk_flush_plug (current);cond_resched (); -else + }else { ino = cur_ino; + } }else {/* * We should submit bio, since it exists several
Quoted 2 lines
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 6 lines · Chao Yu
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit
1f5f11a3c41e2b23288b2769435a00f74e02496b
Quoted 8 lines
Author: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700f2fs: remove
blk_plugginginblock_operations
blk_pluggingdoesn't seem to give any benefit.How about backporting this patch?
Yeah, also notice that
commit bd900d4580107c899d43b262fbbd995f11097a43
Author: Jens Axboe <[email protected]> Date: Mon Apr 18 22:06:57 2011 +0200
block: kill blk_flush_plug_list() export
With all drivers and file systems converted, we only have in-core use of this function. So remove the export.
blk_flush_plug_list() is not an exported symbol for now except for in-core use, as well as blk_flush_plug().
Thanks,
Gao Xiang
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 24 lines · Gao Xiang
Quoted 6 lines · Chao Yu
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit
1f5f11a3c41e2b23288b2769435a00f74e02496bQuoted 8 lines
Author: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700f2fs: remove
blk_plugginginblock_operations
blk_pluggingdoesn't seem to give any benefit.How about backporting this patch?
Yeah, also notice that
commit
bd900d4580107c899d43b262fbbd995f11097a43Author: Jens Axboe <[email protected]> Date: Mon Apr 18 22:06:57 2011 +0200block: kill
blk_flush_plug_list()export
Quoted 8 lines
With all drivers and file systems converted, we only have in-core use of this function. So remove the export.
Reporteed-by Christoph Hellwig <[email protected]>Signed-off-by Jens Axboe <[email protected]>
blk_flush_plug_list()is not an exported symbol for now except for in-core use, as well asblk_flush_plug().
Thanks for the reminder. :)
Quoted 6 lines
Thanks,
Gao Xiang.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Chao,
Quoted 6 lines · Chao Yu
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit
1f5f11a3c41e2b23288b2769435a00f74e02496b
Quoted 8 lines
Author: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700f2fs: remove
blk_plugginginblock_operations
blk_pluggingdoesn't seem to give any benefit.How about backporting this patch?
Yes, I have noticed that patch. But we have nested pluglists in the block_operations path. Hence, I was not sure if that patch alone can help.
1. At the start of block_operations
2. Inside __f2fs_write_data_pages() that gets called from f2fs_sync_dirty_inodes()->filemap_fdatawrite()
Do you know the possible path for this issue scenario to happen? Where does in the CP path before even f2fs_sync_node_pages() is done, the node pages cab be submitted for io and get attached to CP plug list?
Thanks,
Quoted 66 lines · Sahitya Tummala
Quoted 64 lines
Hi Chao, Jaegeuk,
I have received an issue report that indicates that system is stuck on IO due to f2fs checkpoint and writeback stuck waiting on each other as explained below.
WB thread -
----------
io_schedulewait_on_page_bitf2fs_wait_on_page_writeback-> It is waiting for node
node page writeback whose bio is in the plug list of CP thread below.f2fs_update_data_blkaddrf2fs_outplace_write_dataf2fs_do_write_data_page__write_data_page__f2fs_write_data_pagesf2fs_write_data_pagesdo_writepagesCP thread -
-----------
__f2fs_write_data_pages-> It is for the same inode above that is under WB (which
is waiting for node page writeback). In this context, there is nothing to be written as the data is already under WB.filemap_fdatawritef2fs_sync_dirty_inodes-> It just loops here inf2fs_sync_dirty_inodes()until
f2fs_remove_dirty_inode()has been done by the WB thread above.block_operationsf2fs_write_checkpointThe CP thread somehow has the node page bio in its plug list that cannot be submitted until end of
block_operations()and CP thread is blocked on WB of an inode who is again waiting for io pending in CP plug list. Both the stacks are stuck on for each other.The below patch helped to solve the issue, please review and suggest if this seems to be okay. Since anyways we are doing
cond_resched(), I thought it will be good to flush the plug list as well (in this issue case, it will loop for the same inode again and again).fs/f2fs/checkpoint.c +4
-2@@ -1071,10 +1071,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)iput (inode);/* We need to give cpu to another writers. */ -if (ino == cur_ino) +if (ino == cur_ino) { +blk_flush_plug (current);cond_resched (); -else + }else { ino = cur_ino; + } }else {/* * We should submit bio, since it exists several Thanks,
Signature · 9 lines
-- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum. _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 16 lines · Sahitya Tummala
Hi Chao,
Quoted 13 lines · Chao Yu
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit
1f5f11a3c41e2b23288b2769435a00f74e02496bAuthor: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700f2fs: remove
blk_plugginginblock_operations
blk_pluggingdoesn't seem to give any benefit.
Quoted 8 lines
Quoted 1 line
How about backporting this patch?
Yes, I have noticed that patch. But we have nested pluglists in the
block_operationspath. Hence, I was not sure if that patch alone can help.
1. At the start ofblock_operations
2. Inside__f2fs_write_data_pages()that gets called from f2fs_sync_dirty_inodes()->filemap_fdatawrite()
Would be more safe to call io_schedule() in f2fs_sync_dirty_inodes()?
- io_schedule()
- schedule()
- sched_submit_work()
- blk_schedule_flush_plug()
- blk_flush_plug_list()
Quoted 3 lines
Do you know the possible path for this issue scenario to happen?> Where does in the CP path before even
f2fs_sync_node_pages()is done, the node pages cab be submitted for io and get attached to CP plug list?
Maybe:
writeback_inodes_wb
blk_start_plug ---plugged
__writeback_inodes_wb
writeback_sb_inodes
__writeback_single_inode
do_writepages
f2fs_write_node_pages
blk_start_plug ---plugged
f2fs_sync_node_pages
__write_node_page(do_balance=true) --submit node page to plug
f2fs_balance_fs
f2fs_balance_fs_bg
f2fs_sync_fs
f2fs_write_checkpoint
or
f2fs_gc
f2fs_write_checkpoint
blk_start_plug blk_finish_plug
Thanks,
Quoted 67 lines
Thanks,
Quoted 64 lines · Sahitya Tummala
Quoted 62 lines
Hi Chao, Jaegeuk,
I have received an issue report that indicates that system is stuck on IO due to f2fs checkpoint and writeback stuck waiting on each other as explained below.
WB thread -
----------
io_schedulewait_on_page_bitf2fs_wait_on_page_writeback-> It is waiting for node
node page writeback whose bio is in the plug list of CP thread below.f2fs_update_data_blkaddrf2fs_outplace_write_dataf2fs_do_write_data_page__write_data_page__f2fs_write_data_pagesf2fs_write_data_pagesdo_writepagesCP thread -
-----------
__f2fs_write_data_pages-> It is for the same inode above that is under WB (which
is waiting for node page writeback). In this context, there is nothing to be written as the data is already under WB.filemap_fdatawritef2fs_sync_dirty_inodes-> It just loops here inf2fs_sync_dirty_inodes()until
f2fs_remove_dirty_inode()has been done by the WB thread above.block_operationsf2fs_write_checkpointThe CP thread somehow has the node page bio in its plug list that cannot be submitted until end of
block_operations()and CP thread is blocked on WB of an inode who is again waiting for io pending in CP plug list. Both the stacks are stuck on for each other.The below patch helped to solve the issue, please review and suggest if this seems to be okay. Since anyways we are doing
cond_resched(), I thought it will be good to flush the plug list as well (in this issue case, it will loop for the same inode again and again).fs/f2fs/checkpoint.c +4
-2@@ -1071,10 +1071,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)iput (inode);/* We need to give cpu to another writers. */ -if (ino == cur_ino) +if (ino == cur_ino) { +blk_flush_plug (current);cond_resched (); -else + }else { ino = cur_ino; + } }else {/* * We should submit bio, since it exists several
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 26 lines · Chao Yu
Quoted 16 lines · Sahitya Tummala
Hi Chao,
Quoted 13 lines · Chao Yu
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit
1f5f11a3c41e2b23288b2769435a00f74e02496bAuthor: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700f2fs: remove
blk_plugginginblock_operations
blk_pluggingdoesn't seem to give any benefit.Quoted 8 lines
Quoted 1 line
How about backporting this patch?
Yes, I have noticed that patch. But we have nested pluglists in the
block_operationspath. Hence, I was not sure if that patch alone can help.
1. At the start ofblock_operations
2. Inside__f2fs_write_data_pages()that gets called from f2fs_sync_dirty_inodes()->filemap_fdatawrite()
Quoted 8 lines
Would be more safe to call
io_schedule()inf2fs_sync_dirty_inodes()?-
io_schedule()
-schedule()
-sched_submit_work()
-blk_schedule_flush_plug()
-blk_flush_plug_list()
With Jaegeuk's patch, we will only have the plug list in CP path - inside __f2fs_write_data_pages(), which can now be flushed as its not nested anymore.
blk_start_plug(&plug);
ret = f2fs_write_cache_pages(mapping, wbc, io_type);
blk_finish_plug(&plug);Earlier this blk_finish_plug() will not flush the plug list as the bios are attached to the outer plug from block_operations. So I think Jaegeuk's patch alone also can help this issue.
Quoted 24 lines
Quoted 3 lines
Do you know the possible path for this issue scenario to happen?> Where does in the CP path before even
f2fs_sync_node_pages()is done, the node pages cab be submitted for io and get attached to CP plug list?Maybe:
writeback_inodes_wb
blk_start_plug---plugged
__writeback_inodes_wb
writeback_sb_inodes__writeback_single_inode do_writepages f2fs_write_node_pages blk_start_plug ---plugged f2fs_sync_node_pages __write_node_page(do_balance=true) --submit node page to plug f2fs_balance_fs f2fs_balance_fs_bg f2fs_sync_fs f2fs_write_checkpoint or f2fs_gc f2fs_write_checkpoint blk_start_plug
Quoted 2 lines
blk_finish_plug
Hmmm, but from ramdumps the CP thread stack is shown as below.
f2fs_sync_filef2fs_do_sync_filef2fs_sync_fsf2fs_write_checkpoint
Thanks,
Quoted 72 lines
Thanks,
Quoted 70 lines
Thanks,
Quoted 66 lines · Sahitya Tummala
Quoted 64 lines
Hi Chao, Jaegeuk,
I have received an issue report that indicates that system is stuck on IO due to f2fs checkpoint and writeback stuck waiting on each other as explained below.
WB thread -
----------
io_schedulewait_on_page_bitf2fs_wait_on_page_writeback-> It is waiting for node
node page writeback whose bio is in the plug list of CP thread below.f2fs_update_data_blkaddrf2fs_outplace_write_dataf2fs_do_write_data_page__write_data_page__f2fs_write_data_pagesf2fs_write_data_pagesdo_writepagesCP thread -
-----------
__f2fs_write_data_pages-> It is for the same inode above that is under WB (which
is waiting for node page writeback). In this context, there is nothing to be written as the data is already under WB.filemap_fdatawritef2fs_sync_dirty_inodes-> It just loops here inf2fs_sync_dirty_inodes()until
f2fs_remove_dirty_inode()has been done by the WB thread above.block_operationsf2fs_write_checkpointThe CP thread somehow has the node page bio in its plug list that cannot be submitted until end of
block_operations()and CP thread is blocked on WB of an inode who is again waiting for io pending in CP plug list. Both the stacks are stuck on for each other.The below patch helped to solve the issue, please review and suggest if this seems to be okay. Since anyways we are doing
cond_resched(), I thought it will be good to flush the plug list as well (in this issue case, it will loop for the same inode again and again).fs/f2fs/checkpoint.c +4
-2@@ -1071,10 +1071,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)iput (inode);/* We need to give cpu to another writers. */ -if (ino == cur_ino) +if (ino == cur_ino) { +blk_flush_plug (current);cond_resched (); -else + }else { ino = cur_ino; + } }else {/* * We should submit bio, since it exists several Thanks,
Signature · 9 lines
-- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum. _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 40 lines · Sahitya Tummala
Quoted 26 lines · Chao Yu
Quoted 16 lines · Sahitya Tummala
Hi Chao,
Quoted 13 lines · Chao Yu
Hi Sahitya,
It looks block plug has already been removed by Jaegeuk with below commit:
commit
1f5f11a3c41e2b23288b2769435a00f74e02496bAuthor: Jaegeuk Kim <[email protected]> Date: Fri May 8 12:25:45 2020 -0700f2fs: remove
blk_plugginginblock_operations
blk_pluggingdoesn't seem to give any benefit.Quoted 8 lines
Quoted 1 line
How about backporting this patch?
Yes, I have noticed that patch. But we have nested pluglists in the
block_operationspath. Hence, I was not sure if that patch alone can help.
1. At the start ofblock_operations
2. Inside__f2fs_write_data_pages()that gets called from f2fs_sync_dirty_inodes()->filemap_fdatawrite()Quoted 8 lines
Would be more safe to call
io_schedule()inf2fs_sync_dirty_inodes()?-
io_schedule()
-schedule()
-sched_submit_work()
-blk_schedule_flush_plug()
-blk_flush_plug_list()With Jaegeuk's patch, we will only have the plug list in CP path - inside
__f2fs_write_data_pages(), which can now be flushed as its not nested anymore.
Quoted 5 lines
blk_start_plug(&plug); ret = f2fs_write_cache_pages(mapping, wbc, io_type); blk_finish_plug(&plug);Earlier this
blk_finish_plug()will not flush the plug list as the bios
Oh, correct, because blk_finish_plug() will check caller passed &plug and plug assigned in current structure...
void blk_finish_plug(struct blk_plug *plug)
{
if (plug != current->plug)
return;
blk_flush_plug_list(plug, false);
current->plug = NULL;
}Quoted 30 lines
are attached to the outer plug from
block_operations. So I think Jaegeuk's patch alone also can help this issue.Quoted 24 lines
Quoted 3 lines
Do you know the possible path for this issue scenario to happen?> Where does in the CP path before even
f2fs_sync_node_pages()is done, the node pages cab be submitted for io and get attached to CP plug list?Maybe:
writeback_inodes_wb
blk_start_plug---plugged
__writeback_inodes_wb
writeback_sb_inodes__writeback_single_inode do_writepages f2fs_write_node_pages blk_start_plug ---plugged f2fs_sync_node_pages __write_node_page(do_balance=true) --submit node page to plug f2fs_balance_fs f2fs_balance_fs_bg f2fs_sync_fs f2fs_write_checkpoint or f2fs_gc f2fs_write_checkpoint blk_start_plugQuoted 2 lines
blk_finish_plug
Quoted 6 lines
Hmmm, but from ramdumps the CP thread stack is shown as below.
f2fs_sync_filef2fs_do_sync_filef2fs_sync_fsf2fs_write_checkpoint
Alright, then, I don't think there is another plug in block_operation()'s caller.
Thanks,
Quoted 76 lines
Thanks,
Quoted 72 lines
Thanks,
Quoted 70 lines
Thanks,
Quoted 66 lines · Sahitya Tummala
Quoted 64 lines
Hi Chao, Jaegeuk,
I have received an issue report that indicates that system is stuck on IO due to f2fs checkpoint and writeback stuck waiting on each other as explained below.
WB thread -
----------
io_schedulewait_on_page_bitf2fs_wait_on_page_writeback-> It is waiting for node
node page writeback whose bio is in the plug list of CP thread below.f2fs_update_data_blkaddrf2fs_outplace_write_dataf2fs_do_write_data_page__write_data_page__f2fs_write_data_pagesf2fs_write_data_pagesdo_writepagesCP thread -
-----------
__f2fs_write_data_pages-> It is for the same inode above that is under WB (which
is waiting for node page writeback). In this context, there is nothing to be written as the data is already under WB.filemap_fdatawritef2fs_sync_dirty_inodes-> It just loops here inf2fs_sync_dirty_inodes()until
f2fs_remove_dirty_inode()has been done by the WB thread above.block_operationsf2fs_write_checkpointThe CP thread somehow has the node page bio in its plug list that cannot be submitted until end of
block_operations()and CP thread is blocked on WB of an inode who is again waiting for io pending in CP plug list. Both the stacks are stuck on for each other.The below patch helped to solve the issue, please review and suggest if this seems to be okay. Since anyways we are doing
cond_resched(), I thought it will be good to flush the plug list as well (in this issue case, it will loop for the same inode again and again).fs/f2fs/checkpoint.c +4
-2@@ -1071,10 +1071,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)iput (inode);/* We need to give cpu to another writers. */ -if (ino == cur_ino) +if (ino == cur_ino) { +blk_flush_plug (current);cond_resched (); -else + }else { ino = cur_ino; + } }else {/* * We should submit bio, since it exists several Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel