]> git.neil.brown.name Git - LaFS.git/commitdiff
refcount the prime_sb so fs doesn't disappear.
authorNeilBrown <neilb@suse.de>
Sun, 25 Jul 2010 09:22:48 +0000 (19:22 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 9 Aug 2010 01:58:12 +0000 (11:58 +1000)
use prime_sb->s_active to refcount the main fs when a snapshot
or subset is mounted, so the fs doesn't disappear on us.

Signed-off-by: NeilBrown <neilb@suse.de>
snapshot.c
super.c

index 2cfc1dd285eaa341e23bf850a455b045d30e7d54..c50932664249a095b27ffbe82d9f6316932338fa 100644 (file)
@@ -143,7 +143,6 @@ lafs_snap_get_sb(struct file_system_type *fstype,
                err = -ENOMEM;
                goto fail;
        }
-       /* FIXME Inc refcount here?? */
        sk->k.fs = fs;
        sk->ssnum = s;
        
@@ -161,6 +160,8 @@ lafs_snap_get_sb(struct file_system_type *fstype,
                struct datablock *b;
                sb->s_flags = flags | MS_RDONLY;
 
+               atomic_inc(&fs->prime_sb->s_active);
+
                fs->ss[s].root = sk->k.root = iget_locked(sb, 0);
                b = lafs_get_block(fs->ss[s].root, 0, NULL, GFP_KERNEL,
                                   MKREF(snap));
@@ -204,6 +205,7 @@ static void lafs_snap_kill_sb(struct super_block *sb)
        kill_anon_super(sb);
        kfree(sb->s_fs_info);
        printk("Generic_shutdown_super called\n");
+       deactivate_super(fs->prime_sb);
 }
 
 struct file_system_type lafs_snap_fs_type = {
diff --git a/super.c b/super.c
index e5036c6430e08468147ae6f4280cd041dadb3966..256d05f68f426714c15e5c4725890325c9c4901a 100644 (file)
--- a/super.c
+++ b/super.c
@@ -1040,6 +1040,7 @@ lafs_get_subset(struct file_system_type *fs_type,
                sb->s_root = d_alloc_root(rootdir);
                sb->s_op = fs->prime_sb->s_op;
                sb->s_flags |= MS_ACTIVE;
+               atomic_inc(&fs->prime_sb->s_active);
        }
        if (!err)
                simple_set_mnt(mnt, sb);
@@ -1053,7 +1054,9 @@ out_noput:
 
 static void lafs_kill_subset(struct super_block *sb)
 {
+       struct fs *fs = fs_from_sb(sb);
        kill_anon_super(sb);
+       deactivate_super(fs->prime_sb);
 }
 
 struct file_system_type lafs_fs_type = {