diff options
| author | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-03-28 18:07:38 -0700 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2017-05-21 18:39:57 +0200 |
| commit | 029886f8a4e483e21a2536c97012fef4cca071da (patch) | |
| tree | f0785851d06c8bedf2d4c1d79c762fac94d93a85 /fs/f2fs/data.c | |
| parent | a896223c829b21889069cecd23c3992a0e35d501 (diff) | |
f2fs: avoid IO split due to mixed WB_SYNC_ALL and WB_SYNC_NONE
If two threads try to flush dirty pages in different inodes respectively,
f2fs_write_data_pages() will produce WRITE and WRITE_SYNC one at a time,
resulting in a lot of 4KB seperated IOs.
So, this patch gives higher priority to WB_SYNC_ALL IOs and gathers write
IOs with a big WRITE_SYNC'ed bio.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
| -rw-r--r-- | fs/f2fs/data.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index bc600520b..0fe05bd22 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1601,8 +1601,10 @@ continue_unlock: last_idx = page->index; } - if (--wbc->nr_to_write <= 0 && - wbc->sync_mode == WB_SYNC_NONE) { + /* give a priority to WB_SYNC threads */ + if ((atomic_read(&F2FS_M_SB(mapping)->wb_sync_req) || + --wbc->nr_to_write <= 0) && + wbc->sync_mode == WB_SYNC_NONE) { done = 1; break; } @@ -1658,9 +1660,18 @@ static int f2fs_write_data_pages(struct address_space *mapping, trace_f2fs_writepages(mapping->host, wbc, DATA); + /* to avoid spliting IOs due to mixed WB_SYNC_ALL and WB_SYNC_NONE */ + if (wbc->sync_mode == WB_SYNC_ALL) + atomic_inc(&sbi->wb_sync_req); + else if (atomic_read(&sbi->wb_sync_req)) + goto skip_write; + blk_start_plug(&plug); ret = f2fs_write_cache_pages(mapping, wbc); blk_finish_plug(&plug); + + if (wbc->sync_mode == WB_SYNC_ALL) + atomic_dec(&sbi->wb_sync_req); /* * if some pages were truncated, we cannot guarantee its mapping->host * to detect pending bios. |
