f2fs: add un/freeze_fs into super_operations
authorChangman Lee <cm224.lee@samsung.com>
Tue, 29 Jan 2013 09:30:07 +0000 (18:30 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Mon, 11 Feb 2013 22:15:00 +0000 (07:15 +0900)
This patch supports ioctl FIFREEZE and FITHAW to snapshot filesystem.
Before calling f2fs_freeze, all writers would be suspended and sync_fs
would be completed. So no f2fs has to do something.
Just background gc operation should be skipped due to generate dirty
nodes and data until unfreeze.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/gc.c
fs/f2fs/inode.c
fs/f2fs/super.c

index c386910dacc53b5300f019eec517fa88a04461bc..9b5d0aad5daf7cd5cf14f7a0639f37f1ca2b7ee2 100644 (file)
@@ -44,6 +44,11 @@ static int gc_thread_func(void *data)
                if (kthread_should_stop())
                        break;
 
+               if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) {
+                       wait_ms = GC_THREAD_MAX_SLEEP_TIME;
+                       continue;
+               }
+
                f2fs_balance_fs(sbi);
 
                if (!test_opt(sbi, BG_GC))
index 340a21be5a76c0eb7c123fcd189caad4487ec6b4..62433c63e2db9d3d0a27a56b000e34d91fe3a58b 100644 (file)
@@ -278,6 +278,7 @@ void f2fs_evict_inode(struct inode *inode)
        if (inode->i_nlink || is_bad_inode(inode))
                goto no_delete;
 
+       sb_start_intwrite(inode->i_sb);
        set_inode_flag(F2FS_I(inode), FI_NO_ALLOC);
        i_size_write(inode, 0);
 
@@ -285,6 +286,7 @@ void f2fs_evict_inode(struct inode *inode)
                f2fs_truncate(inode);
 
        remove_inode_page(inode);
+       sb_end_intwrite(inode->i_sb);
 no_delete:
        clear_inode(inode);
 }
index 25656b6869a4fefddbb24687f12c5b77933475b5..0b18aee2ed25bc5640e928119f7ffec185316105 100644 (file)
@@ -143,6 +143,22 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
        return 0;
 }
 
+static int f2fs_freeze(struct super_block *sb)
+{
+       int err;
+
+       if (sb->s_flags & MS_RDONLY)
+               return 0;
+
+       err = f2fs_sync_fs(sb, 1);
+       return err;
+}
+
+static int f2fs_unfreeze(struct super_block *sb)
+{
+       return 0;
+}
+
 static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        struct super_block *sb = dentry->d_sb;
@@ -213,6 +229,8 @@ static struct super_operations f2fs_sops = {
        .evict_inode    = f2fs_evict_inode,
        .put_super      = f2fs_put_super,
        .sync_fs        = f2fs_sync_fs,
+       .freeze_fs      = f2fs_freeze,
+       .unfreeze_fs    = f2fs_unfreeze,
        .statfs         = f2fs_statfs,
 };
 
This page took 0.031584 seconds and 5 git commands to generate.