Re: [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard

From: Chao Yu
Date: Wed Aug 11 2021 - 09:44:58 EST


On 2021/8/11 21:18, Yangtao Li wrote:
From: Fengnan Chang <changfengnan@xxxxxxxx>

Don't create discard thread when device not support realtime discard.

Signed-off-by: Fengnan Chang <changfengnan@xxxxxxxx>
Signed-off-by: Yangtao Li <frank.li@xxxxxxxx>
---
fs/f2fs/segment.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 363779a4402d..bc4ac46f3041 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2161,6 +2161,8 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
init_waitqueue_head(&dcc->discard_wait_queue);
SM_I(sbi)->dcc_info = dcc;
init_thread:
+ if (!f2fs_realtime_discard_enable(sbi))

How about below case:
- mount -o nodiscard <dev> <mp>
- mount -o remount,discard <dev> <mp>

Thanks,

+ return err;
dcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,
"f2fs_discard-%u:%u", MAJOR(dev), MINOR(dev));
if (IS_ERR(dcc->f2fs_issue_discard)) {