]> git.neil.brown.name Git - LaFS.git/commitdiff
Use lafs_iget_fs rather than multiple get_blocks in orphan lookup.
authorNeilBrown <neilb@suse.de>
Sun, 1 Aug 2010 03:38:06 +0000 (13:38 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 9 Aug 2010 02:01:43 +0000 (12:01 +1000)
When compacting the orphan table so so changing the orphan
slot for a block, use lafs_iget_fs to help find the orphan block.
This avoids allocating blocks if the inodes exist (which they
should).

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

index cf30e13695b989d75c09d442578716adf72cc99a..ed009e7b8c21dcd922ffd4eedbde77e67cf4f1ba 100644 (file)
--- a/orphan.c
+++ b/orphan.c
@@ -346,7 +346,8 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b, struct inode *ino)
 
        if (b->orphan_slot != om->nextfree-1) {
                /* need to swap in the last entry */
-               struct datablock *bfs, *bi, *bbl;
+               struct inode *bino;
+               struct datablock *bbl;
                ob2 = lafs_get_block(fs->orphans, (om->nextfree-1) >> shift,
                                     NULL, GFP_KERNEL, MKREF(orphan_move));
                if (!ob2) {
@@ -372,34 +373,19 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b, struct inode *ino)
                lastor[lastent].type = 0;
                unmap_dblock_2(ob2, lastor);
 
-               /* FIXME these should not create the block if it
-                * doesn't exist */
-               bfs = lafs_get_block(fs->ss[0].root, le32_to_cpu(last.filesys),
-                                    NULL, GFP_KERNEL, MKREF(orphan_fs));
-               if (bfs && bfs->my_inode)
-                       bi = lafs_get_block(bfs->my_inode,
-                                           le32_to_cpu(last.inum),
-                                           NULL, GFP_KERNEL, MKREF(orphan_ino));
-               else
-                       bi = NULL;
-               putdref(bfs, MKREF(orphan_fs));
-               if (bi && bi->my_inode)
-                       bbl = lafs_get_block(bi->my_inode,
+               bino = lafs_iget_fs(fs,
+                                   le32_to_cpu(last.filesys),
+                                   le32_to_cpu(last.inum));
+               if (bino)
+                       bbl = lafs_get_block(bino,
                                             le32_to_cpu(last.addr),
                                             NULL, GFP_KERNEL, MKREF(orphan_blk));
                else
                        bbl = NULL;
-               putdref(bi, MKREF(orphan_ino));
-               dprintk("O bfs=%p(%p) bi=%p bbl=%p lastent=%d "
-                       "fs=%d in=%d a=%d\n",
-                       bfs, bfs->my_inode, bi, bbl, lastent,
-                       le32_to_cpu(last.filesys),
-                       le32_to_cpu(last.inum),
-                       le32_to_cpu(last.addr)
-                       );
+
                if (!bbl) {
                        putdref(ob2, MKREF(orphan_move));
-                       printk("OUCH 3\n");
+                       iput(bino);
                        BUG();
                        goto out_unlock;
                }
@@ -411,6 +397,8 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b, struct inode *ino)
                unmap_dblock(ob1, or);
                bbl->orphan_slot = b->orphan_slot;
                putdref(bbl, MKREF(orphan_blk));
+               iput(bino);
+
                lafs_dirty_dblock(ob1);
                lafs_dirty_dblock(ob2);