From: NeilBrown Date: Sun, 1 Aug 2010 03:38:06 +0000 (+1000) Subject: Use lafs_iget_fs rather than multiple get_blocks in orphan lookup. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=7046cf01e29ee6753587b76eef04e170fbbfb4c0;p=LaFS.git Use lafs_iget_fs rather than multiple get_blocks in orphan lookup. 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 --- diff --git a/orphan.c b/orphan.c index cf30e13..ed009e7 100644 --- 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);