Skip to content

Commit 2554743

Browse files
bbkzzJaegeuk Kim
authored andcommitted
f2fs: don't call f2fs_issue_discard_timeout() when discard_cmd_cnt is 0 in f2fs_put_super()
No need to call f2fs_issue_discard_timeout() in f2fs_put_super, when no discard command requires issue. Since the caller of f2fs_issue_discard_timeout() usually judges the number of discard commands before using it. Let's move this logic to f2fs_issue_discard_timeout(). By the way, use f2fs_realtime_discard_enable to simplify the code. Reported-by: kernel test robot <[email protected]> Signed-off-by: Yangtao Li <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 15e38ee commit 2554743

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

fs/f2fs/segment.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,9 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi)
16611661
struct discard_policy dpolicy;
16621662
bool dropped;
16631663

1664+
if (!atomic_read(&dcc->discard_cmd_cnt))
1665+
return false;
1666+
16641667
__init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT,
16651668
dcc->discard_granularity);
16661669
__issue_discard_cmd(sbi, &dpolicy);
@@ -2116,8 +2119,7 @@ static void destroy_discard_cmd_control(struct f2fs_sb_info *sbi)
21162119
* Recovery can cache discard commands, so in error path of
21172120
* fill_super(), it needs to give a chance to handle them.
21182121
*/
2119-
if (unlikely(atomic_read(&dcc->discard_cmd_cnt)))
2120-
f2fs_issue_discard_timeout(sbi);
2122+
f2fs_issue_discard_timeout(sbi);
21212123

21222124
kfree(dcc);
21232125
SM_I(sbi)->dcc_info = NULL;

fs/f2fs/super.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,8 +1581,7 @@ static void f2fs_put_super(struct super_block *sb)
15811581
/* be sure to wait for any on-going discard commands */
15821582
dropped = f2fs_issue_discard_timeout(sbi);
15831583

1584-
if ((f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) &&
1585-
!sbi->discard_blks && !dropped) {
1584+
if (f2fs_realtime_discard_enable(sbi) && !sbi->discard_blks && !dropped) {
15861585
struct cp_control cpc = {
15871586
.reason = CP_UMOUNT | CP_TRIMMED,
15881587
};
@@ -2233,7 +2232,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
22332232
bool no_discard = !test_opt(sbi, DISCARD);
22342233
bool no_compress_cache = !test_opt(sbi, COMPRESS_CACHE);
22352234
bool block_unit_discard = f2fs_block_unit_discard(sbi);
2236-
struct discard_cmd_control *dcc;
22372235
#ifdef CONFIG_QUOTA
22382236
int i, j;
22392237
#endif
@@ -2420,10 +2418,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
24202418
goto restore_flush;
24212419
need_stop_discard = true;
24222420
} else {
2423-
dcc = SM_I(sbi)->dcc_info;
24242421
f2fs_stop_discard_thread(sbi);
2425-
if (atomic_read(&dcc->discard_cmd_cnt))
2426-
f2fs_issue_discard_timeout(sbi);
2422+
f2fs_issue_discard_timeout(sbi);
24272423
need_restart_discard = true;
24282424
}
24292425
}

0 commit comments

Comments
 (0)