]> git.neil.brown.name Git - LaFS.git/commitdiff
orphan: replace some pointless tests with BUGs.
authorNeilBrown <neilb@suse.de>
Sat, 2 Oct 2010 06:56:55 +0000 (16:56 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 10 Oct 2010 23:33:55 +0000 (10:33 +1100)
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 <neilb@suse.de>
orphan.c

index c9dd687306cd5308fc07b8d18a47121df62b046f..7dbb720fb71c0af6e74fa8d94c99e7e969f3b9fb 100644 (file)
--- 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));
        }
 }
-
-                       
-