Skip to content

Commit 7bcd0cf

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: don't trigger data flush in foreground operation
Data flush can generate heavy IO and cause long latency during flush, so it's not appropriate to trigger it in foreground operation. And also, we may face below potential deadlock during data flush: - f2fs_write_multi_pages - f2fs_write_raw_pages - f2fs_write_single_data_page - f2fs_balance_fs - f2fs_balance_fs_bg - f2fs_sync_dirty_inodes - filemap_fdatawrite -- stuck on flush same cluster Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 62f63ee commit 7bcd0cf

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

fs/f2fs/f2fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3236,7 +3236,7 @@ void f2fs_drop_inmem_pages(struct inode *inode);
32363236
void f2fs_drop_inmem_page(struct inode *inode, struct page *page);
32373237
int f2fs_commit_inmem_pages(struct inode *inode);
32383238
void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need);
3239-
void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi);
3239+
void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi, bool from_bg);
32403240
int f2fs_issue_flush(struct f2fs_sb_info *sbi, nid_t ino);
32413241
int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi);
32423242
int f2fs_flush_device_cache(struct f2fs_sb_info *sbi);

fs/f2fs/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int gc_thread_func(void *data)
113113
prefree_segments(sbi), free_segments(sbi));
114114

115115
/* balancing f2fs's metadata periodically */
116-
f2fs_balance_fs_bg(sbi);
116+
f2fs_balance_fs_bg(sbi, true);
117117
next:
118118
sb_end_write(sbi->sb);
119119

fs/f2fs/node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
19761976
goto skip_write;
19771977

19781978
/* balancing f2fs's metadata in background */
1979-
f2fs_balance_fs_bg(sbi);
1979+
f2fs_balance_fs_bg(sbi, true);
19801980

19811981
/* collect a number of dirty node pages and write together */
19821982
if (wbc->sync_mode != WB_SYNC_ALL &&

fs/f2fs/segment.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
496496

497497
/* balance_fs_bg is able to be pending */
498498
if (need && excess_cached_nats(sbi))
499-
f2fs_balance_fs_bg(sbi);
499+
f2fs_balance_fs_bg(sbi, false);
500500

501501
if (!f2fs_is_checkpoint_ready(sbi))
502502
return;
@@ -511,7 +511,7 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
511511
}
512512
}
513513

514-
void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
514+
void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi, bool from_bg)
515515
{
516516
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
517517
return;
@@ -540,7 +540,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
540540
excess_dirty_nats(sbi) ||
541541
excess_dirty_nodes(sbi) ||
542542
f2fs_time_over(sbi, CP_TIME)) {
543-
if (test_opt(sbi, DATA_FLUSH)) {
543+
if (test_opt(sbi, DATA_FLUSH) && from_bg) {
544544
struct blk_plug plug;
545545

546546
mutex_lock(&sbi->flush_lock);

0 commit comments

Comments
 (0)