summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorYangtao Li <frank.li@vivo.com>2023-01-13 03:14:04 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2023-01-31 10:47:45 -0800
commitb1c5ef26e4e80277641afcfedffe598c3023c095 (patch)
tree670bff7fdd893a8700da92319410981fed40c800 /fs/f2fs/segment.c
parentc1085957dece02bda586cbffc1328f3bca09325f (diff)
downloadlinux-stable-b1c5ef26e4e80277641afcfedffe598c3023c095.tar.gz
linux-stable-b1c5ef26e4e80277641afcfedffe598c3023c095.tar.bz2
linux-stable-b1c5ef26e4e80277641afcfedffe598c3023c095.zip
f2fs: return true if all cmd were issued or no cmd need to be issued for f2fs_issue_discard_timeout()
f2fs_issue_discard_timeout() returns whether discard cmds are dropped, which does not match the meaning of the function. Let's change it to return whether all discard cmd are issued. After commit 4d67490498ac ("f2fs: Don't create discard thread when device doesn't support realtime discard"), f2fs_issue_discard_timeout() is alse called by f2fs_remount(). Since the comments of f2fs_issue_discard_timeout() doesn't make much sense, let's update it. Signed-off-by: Yangtao Li <frank.li@vivo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 5e603b808487..95a5e6ef7e80 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1656,7 +1656,14 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
}
}
-/* This comes from f2fs_put_super */
+/**
+ * f2fs_issue_discard_timeout() - Issue all discard cmd within UMOUNT_DISCARD_TIMEOUT
+ * @sbi: the f2fs_sb_info data for discard cmd to issue
+ *
+ * When UMOUNT_DISCARD_TIMEOUT is exceeded, all remaining discard commands will be dropped
+ *
+ * Return true if issued all discard cmd or no discard cmd need issue, otherwise return false.
+ */
bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi)
{
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
@@ -1664,7 +1671,7 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi)
bool dropped;
if (!atomic_read(&dcc->discard_cmd_cnt))
- return false;
+ return true;
__init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT,
dcc->discard_granularity);
@@ -1675,7 +1682,7 @@ bool f2fs_issue_discard_timeout(struct f2fs_sb_info *sbi)
__wait_all_discard_cmd(sbi, NULL);
f2fs_bug_on(sbi, atomic_read(&dcc->discard_cmd_cnt));
- return dropped;
+ return !dropped;
}
static int issue_discard_thread(void *data)