Chao Yu 344150999b f2fs: fix to avoid potential deadlock
Quoted from Jing Xia's report, there is a potential deadlock may happen
between kworker and checkpoint as below:

[T:writeback]				[T:checkpoint]
- wb_writeback
 - blk_start_plug
bio contains NodeA was plugged in writeback threads
					- do_writepages  -- sync write inodeB, inc wb_sync_req[DATA]
					 - f2fs_write_data_pages
					  - f2fs_write_single_data_page -- write last dirty page
					   - f2fs_do_write_data_page
					    - set_page_writeback  -- clear page dirty flag and
					    PAGECACHE_TAG_DIRTY tag in radix tree
					    - f2fs_outplace_write_data
					     - f2fs_update_data_blkaddr
					      - f2fs_wait_on_page_writeback -- wait NodeA to writeback here
					   - inode_dec_dirty_pages
 - writeback_sb_inodes
  - writeback_single_inode
   - do_writepages
    - f2fs_write_data_pages -- skip writepages due to wb_sync_req[DATA]
     - wbc->pages_skipped += get_dirty_pages() -- PAGECACHE_TAG_DIRTY is not set but get_dirty_pages() returns one
  - requeue_inode -- requeue inode to wb->b_dirty queue due to non-zero.pages_skipped
 - blk_finish_plug

Let's try to avoid deadlock condition by forcing unplugging previous bio via
blk_finish_plug(current->plug) once we'v skipped writeback in writepages()
due to valid sbi->wb_sync_req[DATA/NODE].

Fixes: 687de7f1010c ("f2fs: avoid IO split due to mixed WB_SYNC_ALL and WB_SYNC_NONE")
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Signed-off-by: Jing Xia <jing.xia@unisoc.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-03-03 13:30:48 -08:00
..
2022-01-22 08:33:37 +02:00
2021-08-19 09:02:55 +09:00
2022-01-22 08:33:38 +02:00
2022-01-22 10:59:32 +02:00
2022-01-19 23:14:34 -06:00
2021-11-09 10:02:51 -08:00
2021-10-25 19:11:50 -07:00
2022-01-12 11:11:34 -08:00
2021-12-03 18:44:06 +01:00
2022-01-12 15:46:11 -08:00
2022-01-22 08:33:38 +02:00
2022-01-12 11:11:34 -08:00
2022-01-12 15:46:11 -08:00
2022-01-22 08:33:37 +02:00
2021-11-03 09:23:25 -07:00
2022-01-20 13:39:13 +02:00
2022-01-22 08:33:38 +02:00
2022-01-23 06:20:44 +02:00
2022-01-22 08:33:37 +02:00
2022-01-10 11:48:37 -08:00
\n
2021-11-06 16:40:48 -07:00
2022-01-16 10:15:32 +02:00
2021-08-19 09:02:55 +09:00
2022-01-22 11:04:27 +02:00
2021-12-17 16:56:35 +09:00
2022-01-22 08:33:34 +02:00
2021-11-17 09:26:09 +01:00
2022-01-12 13:45:12 -08:00
2022-01-22 08:33:35 +02:00
2022-01-21 16:07:21 +02:00
2022-01-07 13:40:39 +00:00
2022-01-22 08:33:38 +02:00
2022-01-22 08:33:36 +02:00
2022-01-22 08:33:36 +02:00
2022-01-22 08:33:38 +02:00
2021-08-10 17:57:22 +02:00