From 6463c5d2d18402528ba398fe455b3ae2b815f9c8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 2 Oct 2010 16:56:55 +1000 Subject: [PATCH] orphan: replace some pointless tests with BUGs. All orphan file blocks always have a reference and are Valid, so lots of testing is not needed. Also, make sure this really is true when reading the orphan file at mount time. Signed-off-by: NeilBrown --- orphan.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/orphan.c b/orphan.c index c9dd687..7dbb720 100644 --- a/orphan.c +++ b/orphan.c @@ -359,19 +359,17 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b, struct inode *ino) /* need to swap in the last entry */ struct inode *bino; struct datablock *bbl; + + /* All blocks in the orphan file a referenced either by + * an orphan or by a reservation, so this must succeed. + */ ob2 = lafs_get_block(fs->orphans, (om->nextfree-1) >> shift, NULL, GFP_KERNEL, MKREF(orphan_move)); - if (!ob2) { - /* Oh dear, we cannot effect the swap - sad */ - printk("OUCH 1\n"); - goto out_unlock; - } - if (lafs_read_block_async(ob2) != 0) { - putdref(ob2, MKREF(orphan_move)); - printk("OUCH 2\n"); - goto out_unlock; - } - BUG_ON(!test_bit(B_PinPending, &ob2->b.flags)); + LAFS_BUG(ob2 == NULL, &b->b); + + LAFS_BUG(!test_bit(B_Valid, &ob2->b.flags), &ob2->b); + LAFS_BUG(!test_bit(B_PinPending, &ob2->b.flags), &ob2->b); + if (lafs_pin_dblock(ob2, ReleaseSpace) < 0) { putdref(ob2, MKREF(orphan_move)); goto out_unlock; @@ -384,22 +382,16 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b, struct inode *ino) lastor[lastent].type = 0; unmap_dblock_2(ob2, lastor); + /* The block, being an orphan, must exist */ bino = lafs_iget_fs(fs, le32_to_cpu(last.filesys), le32_to_cpu(last.inum), ASYNC); - if (bino) - bbl = lafs_get_block(bino, - le32_to_cpu(last.addr), - NULL, GFP_KERNEL, MKREF(orphan_blk)); - else - bbl = NULL; + LAFS_BUG(!bino, &b->b); + bbl = lafs_get_block(bino, + le32_to_cpu(last.addr), + NULL, GFP_KERNEL, MKREF(orphan_blk)); + LAFS_BUG(!bbl, &b->b); - if (!bbl) { - putdref(ob2, MKREF(orphan_move)); - iput(bino); - BUG(); - goto out_unlock; - } dprintk("Q %d %d\n", bbl->orphan_slot, om->nextfree); LAFS_BUG(bbl->orphan_slot != om->nextfree-1, &bbl->b); @@ -708,6 +700,7 @@ void lafs_add_orphans(struct fs *fs, struct inode *ino, int count) if (!IS_ERR(ob)) { if (!test_and_set_bit(B_Orphan, &ob->b.flags)) { getdref(ob, MKREF(orphan_flag)); + getdref(db, MKREF(orphan)); ob->orphan_slot = bslot + slot; lafs_add_orphan(fs, ob); } @@ -716,8 +709,6 @@ void lafs_add_orphans(struct fs *fs, struct inode *ino, int count) iput(oino); } unmap_dblock(db, or); + putdref(db, MKREF(add_orphans)); } } - - - -- 2.39.5