From: NeilBrown Date: Mon, 7 Mar 2011 05:48:37 +0000 (+1100) Subject: Add 'filesys' pointer to lafs_inode X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=077a81d6e714d7413a2fc2e1c3fd1e17919a5bae;p=LaFS.git Add 'filesys' pointer to lafs_inode This is the first patch in a series to switch from having one struct super_block for each subset filesystem, to only having one for each snapshot. i.e. one which is writable and some number which are read-only snapshots. The struct super_block described the primary filesystem and all of the subset filesystems. Signed-off-by: NeilBrown --- diff --git a/inode.c b/inode.c index 9948ede..e385afe 100644 --- a/inode.c +++ b/inode.c @@ -149,6 +149,8 @@ lafs_iget(struct super_block *sb, ino_t inum, int async) return ERR_PTR(-ENOENT); } + LAFSI(ino)->filesys = igrab(inodefile); + /* surprisingly the inode bdi does not default to the * super_blocks bdi... */ diff --git a/roll.c b/roll.c index 664884b..f1dd269 100644 --- a/roll.c +++ b/roll.c @@ -793,6 +793,7 @@ lafs_mount(struct fs *fs) fs->rolled = 0; fs->ss[0].root = ino = iget_locked(fs->prime_sb, 0); + LAFSI(ino)->filesys = ino; k->root = ino; err = -ENOMEM; diff --git a/snapshot.c b/snapshot.c index 1bdeb97..4489ed3 100644 --- a/snapshot.c +++ b/snapshot.c @@ -168,6 +168,7 @@ lafs_snap_get_sb(struct file_system_type *fstype, atomic_inc(&fs->prime_sb->s_active); fs->ss[s].root = sk->k.root = iget_locked(sb, 0); + LAFSI(fs->ss[s].root)->filesys = fs->ss[s].root; b = lafs_get_block(fs->ss[s].root, 0, NULL, GFP_KERNEL, MKREF(snap)); b->b.physaddr = fs->ss[s].root_addr; diff --git a/state.h b/state.h index 8f27841..903682a 100644 --- a/state.h +++ b/state.h @@ -554,6 +554,7 @@ enum { /* indexing info stays in the block, not in the inode */ struct lafs_inode { struct inode vfs_inode; + struct inode *filesys; /* Inode of containing TypeInodeFile */ struct indexblock *iblock; struct datablock *dblock; long cblocks, /* data blocks which are commited to this file */ diff --git a/super.c b/super.c index 68f0c35..3137913 100644 --- a/super.c +++ b/super.c @@ -1336,6 +1336,7 @@ static void kfree_inode(struct rcu_head *head) void lafs_destroy_inode(struct inode *inode) { struct datablock *db; + struct inode *fsys = LAFSI(inode)->filesys; BUG_ON(!list_empty(&inode->i_sb_list)); // Cannot test i_list as dispose_list just does list_del @@ -1345,6 +1346,10 @@ void lafs_destroy_inode(struct inode *inode) set_bit(I_Destroyed, &LAFSI(inode)->iflags); putdref(db, MKREF(destroy)); } else { + if (fsys != inode) + iput(fsys); + LAFSI(inode)->filesys = NULL; + spin_lock(&inode->i_data.private_lock); if (LAFSI(inode)->iblock) LAFS_BUG(atomic_read(&LAFSI(inode)->iblock->b.refcnt),