OSDN Git Service

f2fs: stop issue discard if something wrong with f2fs
authorYunlei He <heyunlei@huawei.com>
Fri, 13 Apr 2018 03:08:05 +0000 (11:08 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 9 Jul 2018 00:28:41 +0000 (17:28 -0700)
v4->v5: move data corruption check to __submit_discard_cmd, in order to
control discard io submitted more accurately, besides, increase async
thread wait time if data corruption detected.

This patch stop async thread and umount process to issue discard
if something wrong with f2fs, which is similar to fstrim.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index a7f0e59..d4b787b 100644 (file)
@@ -1044,6 +1044,9 @@ static void __submit_discard_cmd(struct f2fs_sb_info *sbi,
        if (dc->state != D_PREP)
                return;
 
+       if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+               return;
+
        trace_f2fs_issue_discard(dc->bdev, dc->start, dc->len);
 
        dc->error = __blkdev_issue_discard(dc->bdev,
@@ -1475,6 +1478,10 @@ static int issue_discard_thread(void *data)
                        continue;
                if (kthread_should_stop())
                        return 0;
+               if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
+                       wait_ms = dpolicy.max_interval;
+                       continue;
+               }
 
                if (dcc->discard_wake)
                        dcc->discard_wake = 0;