From: Neil Brown Date: Mon, 19 Jul 2010 08:27:09 +0000 (+1000) Subject: Use inline to map sb to fs X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=16647d29aa7b43d9fba7d904cfab20a4f1751166;p=LaFS.git Use inline to map sb to fs because we are about to make the conversion slightly more complex Signed-off-by: NeilBrown --- diff --git a/inode.c b/inode.c index 8b9d9cf..4741279 100644 --- a/inode.c +++ b/inode.c @@ -77,8 +77,7 @@ lafs_iget(struct super_block *sb, ino_t inum, int async) /* FIXME always use this branch? * FIXME is this OK for all sub-filesystems? */ - struct fs *fs = sb->s_fs_info; - inodefile = fs->ss[0].root; + inodefile = fs_from_sb(sb)->ss[0].root; } if (async) { @@ -181,9 +180,8 @@ lafs_iget(struct super_block *sb, ino_t inum, int async) unlock_new_inode(ino); out: if (b && test_and_clear_bit(B_Async, &b->b.flags)) { - struct fs *fs = sb->s_fs_info; putdref(b, MKREF(async)); - lafs_wake_cleaner(fs); + lafs_wake_cleaner(fs_from_sb(sb)); } putdref(b, MKREF(iget)); return ino; diff --git a/lafs.h b/lafs.h index 6ee9f19..9f6249e 100644 --- a/lafs.h +++ b/lafs.h @@ -331,12 +331,17 @@ static inline u64 encode_time(struct timespec *ts) return t | tn; } -static inline struct fs *fs_from_inode(struct inode *ino) +static inline struct fs *fs_from_sb(struct super_block *sb) { - struct fs *fs = ino->i_sb->s_fs_info; + struct fs *fs = sb->s_fs_info; return fs; } +static inline struct fs *fs_from_inode(struct inode *ino) +{ + return fs_from_sb(ino->i_sb); +} + static inline int set_phase(struct block *b, int ph) { if (b->inode->i_ino == 0 && b->fileaddr == 0) diff --git a/snapshot.c b/snapshot.c index 3930ba4..9204557 100644 --- a/snapshot.c +++ b/snapshot.c @@ -98,7 +98,7 @@ lafs_snap_get_sb(struct file_system_type *fstype, err = -EINVAL; if (sb->s_type != &lafs_fs_type) goto fail; - fs = sb->s_fs_info; + fs = fs_from_sb(sb); for (s = 1; s < fs->maxsnapshot; s++) { struct datablock *b; @@ -174,7 +174,7 @@ fail: static void lafs_snap_kill_sb(struct super_block *sb) { - struct fs *fs = sb->s_fs_info; + struct fs *fs = fs_from_sb(sb); printk("Generic_shutdown_super being called....\n"); generic_shutdown_super(sb); diff --git a/super.c b/super.c index 4b0ddbe..5e3ecd5 100644 --- a/super.c +++ b/super.c @@ -641,7 +641,7 @@ static int show_orphans(struct fs *fs) static void lafs_kill_sb(struct super_block *sb) { - struct fs *fs = sb->s_fs_info; + struct fs *fs = fs_from_sb(sb); /* Release the 'struct fs' */ int i; @@ -713,7 +713,7 @@ static void lafs_kill_sb(struct super_block *sb) static void lafs_put_super(struct super_block *sb) { - struct fs *fs = sb->s_fs_info; + struct fs *fs = fs_from_sb(sb); int ss; struct lafs_inode *li; @@ -835,7 +835,7 @@ lafs_get_sb(struct file_system_type *fs_type, } /* So they seem to be the same - better create our - * s_fs_info structure and fill it in + * 'fs' structure and fill it in */ err = lafs_load(fs, &op, newest); if (err) @@ -1000,12 +1000,11 @@ void lafs_destroy_inode(struct inode *inode) static int lafs_sync_fs(struct super_block *sb, int wait) { - struct fs *fs = sb->s_fs_info; if (!wait) /* We only reach here if s_dirt was set, so it * is reasonable to force a checkpoint. */ - lafs_checkpoint_start(fs); + lafs_checkpoint_start(fs_from_sb(sb)); else printk("FIXME I should wait for the checkpoint to finish\n"); return 0;