f2fs: trigger correct checkpoint during umount
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 15 Jan 2015 00:34:24 +0000 (16:34 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 12 Feb 2015 01:04:32 +0000 (17:04 -0800)
This patch fixes to trigger checkpoint with umount flag when kill_sb was called.
In kill_sb, f2fs_sync_fs was finally called, but at this time, f2fs can't do
checkpoint with CP_UMOUNT.
After then, f2fs_put_super is not doing checkpoint, since it is not dirty.

So, this patch adds a flag to indicate f2fs_sync_fs is called during umount.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/super.c

index c2cf040d528467e68ac04cf5c752ce8e41fd4bae..1795ce23111837171c953270bd23fd8574a6d193 100644 (file)
@@ -525,6 +525,7 @@ struct f2fs_sb_info {
        struct f2fs_super_block *raw_super;     /* raw super block pointer */
        int s_dirty;                            /* dirty flag for checkpoint */
        bool need_fsck;                         /* need fsck.f2fs to fix */
+       bool s_closing;                         /* specify unmounting */
 
        /* for node-related operations */
        struct f2fs_nm_info *nm_info;           /* node manager */
index 0e97974bbbbdca71196109d80f40a814b5648ced..84f95cd4076a8742a47f53644263f93df7833ccd 100644 (file)
@@ -487,7 +487,8 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
        if (sync) {
                struct cp_control cpc;
 
-               cpc.reason = test_opt(sbi, FASTBOOT) ? CP_UMOUNT : CP_SYNC;
+               cpc.reason = (test_opt(sbi, FASTBOOT) || sbi->s_closing) ?
+                                                       CP_UMOUNT : CP_SYNC;
                mutex_lock(&sbi->gc_mutex);
                write_checkpoint(sbi, &cpc);
                mutex_unlock(&sbi->gc_mutex);
@@ -1190,11 +1191,18 @@ static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags,
        return mount_bdev(fs_type, flags, dev_name, data, f2fs_fill_super);
 }
 
+static void kill_f2fs_super(struct super_block *sb)
+{
+       if (sb->s_root)
+               F2FS_SB(sb)->s_closing = true;
+       kill_block_super(sb);
+}
+
 static struct file_system_type f2fs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "f2fs",
        .mount          = f2fs_mount,
-       .kill_sb        = kill_block_super,
+       .kill_sb        = kill_f2fs_super,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("f2fs");