Commit 25547439 authored by Yangtao Li's avatar Yangtao Li Committed by Jaegeuk Kim

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: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarYangtao Li <frank.li@vivo.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 15e38ee4
...@@ -1661,6 +1661,9 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi) ...@@ -1661,6 +1661,9 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi)
struct discard_policy dpolicy; struct discard_policy dpolicy;
bool dropped; bool dropped;
if (!atomic_read(&dcc->discard_cmd_cnt))
return false;
__init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT, __init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT,
dcc->discard_granularity); dcc->discard_granularity);
__issue_discard_cmd(sbi, &dpolicy); __issue_discard_cmd(sbi, &dpolicy);
...@@ -2116,8 +2119,7 @@ static void destroy_discard_cmd_control(struct f2fs_sb_info *sbi) ...@@ -2116,8 +2119,7 @@ static void destroy_discard_cmd_control(struct f2fs_sb_info *sbi)
* Recovery can cache discard commands, so in error path of * Recovery can cache discard commands, so in error path of
* fill_super(), it needs to give a chance to handle them. * fill_super(), it needs to give a chance to handle them.
*/ */
if (unlikely(atomic_read(&dcc->discard_cmd_cnt))) f2fs_issue_discard_timeout(sbi);
f2fs_issue_discard_timeout(sbi);
kfree(dcc); kfree(dcc);
SM_I(sbi)->dcc_info = NULL; SM_I(sbi)->dcc_info = NULL;
......
...@@ -1581,8 +1581,7 @@ static void f2fs_put_super(struct super_block *sb) ...@@ -1581,8 +1581,7 @@ static void f2fs_put_super(struct super_block *sb)
/* be sure to wait for any on-going discard commands */ /* be sure to wait for any on-going discard commands */
dropped = f2fs_issue_discard_timeout(sbi); dropped = f2fs_issue_discard_timeout(sbi);
if ((f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) && if (f2fs_realtime_discard_enable(sbi) && !sbi->discard_blks && !dropped) {
!sbi->discard_blks && !dropped) {
struct cp_control cpc = { struct cp_control cpc = {
.reason = CP_UMOUNT | CP_TRIMMED, .reason = CP_UMOUNT | CP_TRIMMED,
}; };
...@@ -2233,7 +2232,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) ...@@ -2233,7 +2232,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
bool no_discard = !test_opt(sbi, DISCARD); bool no_discard = !test_opt(sbi, DISCARD);
bool no_compress_cache = !test_opt(sbi, COMPRESS_CACHE); bool no_compress_cache = !test_opt(sbi, COMPRESS_CACHE);
bool block_unit_discard = f2fs_block_unit_discard(sbi); bool block_unit_discard = f2fs_block_unit_discard(sbi);
struct discard_cmd_control *dcc;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
int i, j; int i, j;
#endif #endif
...@@ -2420,10 +2418,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) ...@@ -2420,10 +2418,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
goto restore_flush; goto restore_flush;
need_stop_discard = true; need_stop_discard = true;
} else { } else {
dcc = SM_I(sbi)->dcc_info;
f2fs_stop_discard_thread(sbi); f2fs_stop_discard_thread(sbi);
if (atomic_read(&dcc->discard_cmd_cnt)) f2fs_issue_discard_timeout(sbi);
f2fs_issue_discard_timeout(sbi);
need_restart_discard = true; need_restart_discard = true;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment