From d32ab5354797c4a10f9e6f6d9a885a6493a01856 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 3 Oct 2010 20:04:27 +1100 Subject: [PATCH] Return ref on sb as well as ino from lafs_iget_fs As the sb might not be mounted, we need to hold a reference. Signed-off-by: NeilBrown --- clean.c | 17 +++++++++-------- inode.c | 4 +++- lafs.h | 13 +++++++++++++ orphan.c | 4 ++-- roll.c | 10 +++++----- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/clean.c b/clean.c index ed37560..8a608be 100644 --- a/clean.c +++ b/clean.c @@ -301,7 +301,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc) ino->i_ino != inum || ino_from_sb(ino->i_sb)->i_ino != fsnum) { if (ino) - iput(ino); + lafs_iput_fs(ino); if (fsnum) { struct inode *fsino = lafs_iget_fs(fs, 0, fsnum, ASYNC); @@ -311,10 +311,11 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc) /* skip this inode as filesystem * is newer */ - iput(fsino); + lafs_iput_fs(fsino); ino = NULL; goto skip_inode; - } + } else + lafs_iput_fs(fsino); } ino = lafs_iget_fs(fs, fsnum, inum, ASYNC); } @@ -349,7 +350,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc) if (!test_and_set_bit(B_Cleaning, &b->b.flags)) { getdref(b, MKREF(cleaning)); - igrab(ino); + lafs_igrab_fs(ino); } if (LAFSI(ino)->type == TypeInodeFile || LAFSI(ino)->type == TypeDir) { @@ -384,7 +385,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc) list_del_init(&b->cleaning); if (test_and_clear_bit(B_Cleaning, &b->b.flags)) { putdref(b, MKREF(cleaning)); - iput(ino); + lafs_iput_fs(ino); } } putdref(b, MKREF(cleaning)); @@ -415,7 +416,7 @@ static void cleaner_parse(struct fs *fs, struct toclean *tc) tc->desc->block_cnt = cpu_to_le16(bcnt-1); } if (ino) - iput(ino); + lafs_iput_fs(ino); } /* Process all blocks that have been found to possibly need to be @@ -487,7 +488,7 @@ static int cleaner_process(struct fs *fs, struct toclean *tc) ino = b->b.inode; putdref(b, MKREF(cleaning)); - iput(ino); + lafs_iput_fs(ino); putref(cb, MKREF(clean2)); if (rv) break; @@ -539,7 +540,7 @@ void lafs_unclean(struct datablock *db) */ list_del_init(&db->cleaning); putdref(db, MKREF(cleaning)); - iput(db->b.inode); + lafs_iput_fs(db->b.inode); if (test_and_clear_bit(B_Async, &db->b.flags)) { putdref(db, MKREF(async)); lafs_wake_thread(fs); diff --git a/inode.c b/inode.c index 679371d..15d5276 100644 --- a/inode.c +++ b/inode.c @@ -231,8 +231,10 @@ lafs_iget_fs(struct fs *fs, int fsnum, int inum, int async) printk("get inode %d\n", inum); rv = lafs_iget(filesys->i_sb, inum, async); iput(filesys); - } else + } else { rv = lafs_iget(sb, inum, async); + atomic_inc(&sb->s_active); + } return rv; } diff --git a/lafs.h b/lafs.h index 8dfae2b..397330e 100644 --- a/lafs.h +++ b/lafs.h @@ -153,6 +153,19 @@ struct datablock *lafs_inode_dblock(struct inode *ino, int async, REFARG); struct datablock *lafs_inode_get_dblock(struct inode *ino, REFARG); int lafs_inode_handle_orphan(struct datablock *b); +static inline void lafs_iput_fs(struct inode *ino) +{ + struct super_block *sb = ino->i_sb; + iput(ino); + deactivate_super(sb); +} + +static inline void lafs_igrab_fs(struct inode *ino) +{ + igrab(ino); + atomic_inc(&ino->i_sb->s_active); +} + struct datablock *lafs_get_block(struct inode *ino, unsigned long index, struct page *p, int gfp, REFARG); #if DEBUG_REF diff --git a/orphan.c b/orphan.c index 0ba1f35..9e93676 100644 --- a/orphan.c +++ b/orphan.c @@ -411,7 +411,7 @@ again: unmap_dblock(ob1, or); bbl->orphan_slot = b->orphan_slot; putdref(bbl, MKREF(orphan_blk)); - iput(bino); + lafs_iput_fs(bino); lafs_dirty_dblock(ob1); lafs_dirty_dblock(ob2); @@ -718,7 +718,7 @@ void lafs_add_orphans(struct fs *fs, struct inode *ino, int count) or[slot].type = 0; putdref(ob, MKREF(add_orphan)); } - iput(oino); + lafs_iput_fs(oino); } unmap_dblock(db, or); putdref(db, MKREF(add_orphans)); diff --git a/roll.c b/roll.c index a4dea4b..b28e5e3 100644 --- a/roll.c +++ b/roll.c @@ -216,7 +216,7 @@ roll_mini(struct fs *fs, int fsnum, int inum, int trunc, int flg, case TypeInodeFile: BUG_ON(fsnum); /* FIXME should be more careful */ - iput(inode); + lafs_iput_fs(inode); inode = lafs_iget_fs(fs, inum, bnum, SYNC); if (IS_ERR(inode)) { err = PTR_ERR(inode); @@ -238,13 +238,13 @@ roll_mini(struct fs *fs, int fsnum, int inum, int trunc, int flg, */ if (list_empty(&db->orphans)) { list_add(&db->orphans, &fs->pending_orphans); - igrab(inode); + lafs_igrab_fs(inode); getdref(db, MKREF(roll_orphan)); } putdref(db, MKREF(roll)); break; } - iput(inode); + lafs_iput_fs(inode); return err; } @@ -383,7 +383,7 @@ roll_block(struct fs *fs, int fsnum, int inum, int trunc, int flg, } if (blk) putdref(blk, MKREF(roll)); - iput(inode); + lafs_iput_fs(inode); dprintk("leaving with error %d\n", err); return err; } @@ -568,7 +568,7 @@ static int roll_forward(struct fs *fs) struct datablock, orphans); list_del_init(&db->orphans); - iput(db->my_inode); + lafs_iput_fs(db->my_inode); putdref(db, MKREF(roll_orphan)); } fs->rolled = 1; -- 2.39.5