]> git.neil.brown.name Git - LaFS.git/commitdiff
Return ref on sb as well as ino from lafs_iget_fs
authorNeilBrown <neilb@suse.de>
Sun, 3 Oct 2010 09:04:27 +0000 (20:04 +1100)
committerNeilBrown <neilb@suse.de>
Sun, 10 Oct 2010 23:33:56 +0000 (10:33 +1100)
As the sb might not be mounted, we need to hold a reference.

Signed-off-by: NeilBrown <neilb@suse.de>
clean.c
inode.c
lafs.h
orphan.c
roll.c

diff --git a/clean.c b/clean.c
index ed37560837096a96465f4a0942cd420eb5192644..8a608be5432de7750d721c609758d2084673eddb 100644 (file)
--- 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 679371d2871faf489c5b27e7766cf49915d8eb8f..15d5276c9478f19a00e75d07c831658b94a97ace 100644 (file)
--- 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 8dfae2bca4e73357e7ea1bdb70a6c1280a47b5a8..397330e8659f6f7c6a3ad0ab5a8fb21af58442cb 100644 (file)
--- 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
index 0ba1f3539d475f3b72caa770755405e5e190904c..9e93676dabe1ce763602449bedecacbd557c35e1 100644 (file)
--- 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 a4dea4b778fa1c97951dd2ef837b517495ea874b..b28e5e3d1df77a3dd31e35f36f3389cbb9c8a4ef 100644 (file)
--- 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;