f2fs: stop gc/discard thread after fs shutdown
authorChao Yu <yuchao0@huawei.com>
Thu, 18 Jan 2018 09:23:29 +0000 (17:23 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 27 Jan 2018 21:30:32 +0000 (13:30 -0800)
Once filesystem shuts down, daemons like gc/discard thread should be
aware of it, and do exit, in addtion, drop all cached pending discard
commands and turn off real-time discard mode.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/segment.c

index 2508be234e55b10d378b7f54509305c7c92003a0..b91283f3fe38a584b2bc1cc617cd76acdc524a4e 100644 (file)
@@ -2726,6 +2726,7 @@ void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
 bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
 void init_discard_policy(struct discard_policy *dpolicy, int discard_type,
                                                unsigned int granularity);
+void drop_discard_cmd(struct f2fs_sb_info *sbi);
 void stop_discard_thread(struct f2fs_sb_info *sbi);
 bool f2fs_wait_discard_bios(struct f2fs_sb_info *sbi);
 void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc);
index 038aca3c7207cfd00a856670768fae635fbf73eb..40a349c8a0f21240251900e9b5f9de1aea4d7d32 100644 (file)
@@ -1865,6 +1865,13 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
                ret = -EINVAL;
                goto out;
        }
+
+       stop_gc_thread(sbi);
+       stop_discard_thread(sbi);
+
+       drop_discard_cmd(sbi);
+       clear_opt(sbi, DISCARD);
+
        f2fs_update_time(sbi, REQ_TIME);
 out:
        mnt_drop_write_file(filp);
index 2e8e054db49dbc3bcfb0b61ec2ecbf3ef1f8f7d9..e5739ce23a72bb3454d3d3f0306cb448ff989a13 100644 (file)
@@ -1263,6 +1263,11 @@ static bool __drop_discard_cmd(struct f2fs_sb_info *sbi)
        return dropped;
 }
 
+void drop_discard_cmd(struct f2fs_sb_info *sbi)
+{
+       __drop_discard_cmd(sbi);
+}
+
 static unsigned int __wait_one_discard_bio(struct f2fs_sb_info *sbi,
                                                        struct discard_cmd *dc)
 {