]> git.neil.brown.name Git - LaFS.git/commitdiff
Add lots of assertions.
authorNeilBrown <neilb@suse.de>
Fri, 25 Jun 2010 10:46:38 +0000 (20:46 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 27 Jun 2010 23:15:00 +0000 (09:15 +1000)
Add a number of assertions (BUG_ON) that have show to be valuable.

Signed-off-by: NeilBrown <neilb@suse.de>
cluster.c
index.c
inode.c
modify.c
segments.c
super.c

index ba2f7b7027ff4d164d766317762297e66e951ee2..9a10bacfdbc59bd27532da0dc8f462f779eb8e28 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -535,6 +535,8 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
        loff_t size;
        int used;
 
+       LAFS_BUG(test_bit(B_Index, &b->flags) &&
+                iblk(b)->uninc_table.pending_cnt > 0, b);
 
        LAFS_BUG(!test_bit(B_IOLock, &b->flags), b);
        lai = LAFSI(b->inode);
diff --git a/index.c b/index.c
index 6186db13cecc6aff8398b7335c40be1524b5af11..38aca36d67872ba6f243fd71bc3d450ef3d8894e 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1921,6 +1921,9 @@ int lafs_add_block_address(struct fs *fs, struct block *blk)
         * If this block threatens problems we incorporate first.
         */
 
+       LAFS_BUG(!test_bit(B_Dirty, &p->b.flags) &&
+                !test_bit(B_Realloc, &p->b.flags), blk);
+
        a = &p->uninc_table.pending_addr
                [p->uninc_table.pending_cnt-1];
        if (p->uninc_table.pending_cnt >= 1 &&
@@ -1976,8 +1979,8 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
            !test_bit(B_Realloc, &blk->flags) &&
            phys != 0)
                printk("something missing %s\n", strblk(blk));
-       WARN_ON_ONCE(!test_bit(B_UnincCredit, &blk->flags) && phys &&
-                    !test_bit(B_Index, &blk->flags));
+       LAFS_BUG(!test_bit(B_UnincCredit, &blk->flags) && phys &&
+                !test_bit(B_Index, &blk->flags), blk);
        LAFS_BUG(!test_bit(B_Dirty, &blk->flags) &&
                 !test_bit(B_Realloc, &blk->flags) &&
                 phys != 0, blk);
diff --git a/inode.c b/inode.c
index d40c27a816ec74525564b1208dbf4a71315934a8..99a7deb3583b0b9c4a8a0552c17c899a3406ff96 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -455,6 +455,7 @@ void lafs_inode_init(struct datablock *b, int type, int mode, struct inode *dir)
 
        unmap_dblock(b, lai);
        set_bit(B_Valid, &b->b.flags);
+       LAFS_BUG(!test_bit(B_Pinned, &b->b.flags), &b->b);
        lafs_dirty_dblock(b);
 }
 
@@ -563,6 +564,7 @@ static int prune_some(void *data, u32 addr, u64 paddr, int len)
                        a->fileaddr = addr + i;
                        a->physaddr = 0;
                        a->cnt = 1;
+                       LAFS_BUG(!test_bit(B_Pinned, &ib->b.flags), &ib->b);
                        ib->uninc_table.pending_cnt++;
                } else {
                        spin_unlock(&ino->i_data.private_lock);
@@ -589,6 +591,18 @@ void lafs_inode_handle_orphan(struct datablock *b)
        if (!test_bit(I_Trunc, &LAFSI(ino)->iflags)) {
                if (test_bit(I_Deleting, &LAFSI(ino)->iflags)) {
                        LAFS_BUG(ino->i_nlink, &b->b);
+                       printk("Deleting inode %lu: %ld+%ld+%ld %ld+%ld\n",
+                              ino->i_ino,
+                              LAFSI(ino)->cblocks,
+                              LAFSI(ino)->pblocks,
+                              LAFSI(ino)->ablocks,
+                              LAFSI(ino)->ciblocks,
+                              LAFSI(ino)->piblocks);
+                       BUG_ON(LAFSI(ino)->cblocks +
+                              LAFSI(ino)->pblocks +
+                              LAFSI(ino)->ablocks +
+                              LAFSI(ino)->ciblocks +
+                              LAFSI(ino)->piblocks);
                        lafs_erase_dblock(b);
                        clear_bit(I_Deleting, &LAFSI(ino)->iflags);
                        lafs_orphan_release(fs, b);
@@ -625,6 +639,7 @@ void lafs_inode_handle_orphan(struct datablock *b)
 
                if (!test_bit(B_Pinned, &ib->b.flags)) {
                        /* must be finished */
+                       LAFS_BUG(test_bit(B_Dirty, &ib->b.flags), &ib->b);
                        clear_bit(I_Trunc, &LAFSI(ino)->iflags);
                        wake_up(&fs->trunc_wait);
                        putiref(ib, MKREF(inode_handle_orphan));
@@ -674,6 +689,10 @@ void lafs_inode_handle_orphan(struct datablock *b)
                 * Pinned children.
                 * Incorporating it should unpin it.
                 */
+               if (!list_empty(&ib2->children)) {
+                       lafs_print_tree(&ib2->b, 3);
+                       LAFS_BUG(1, &ib2->b);
+               }
                        
                /* lafs_iolock_written(&ib2->b); - without blocking */
                if (!lafs_iolock_block_async(&ib2->b)) {
index e14a12ccbd7eb1b38ec77db8de3b4c9c01385a9c..20a0574997d6314836026fc8f7cabe4f0be03636 100644 (file)
--- a/modify.c
+++ b/modify.c
@@ -426,6 +426,7 @@ static void grow_index_tree(struct indexblock *ib, struct indexblock *new)
        ibuf = map_iblock(new);
        memcpy(ib->data, ibuf + offset, blksize - offset);
        memset(ib->data + blksize - offset, 0, offset);
+       LAFS_BUG(ib->depth == 0, &ib->b);
        new->depth = ib->depth + 1;
        LAFSI(new->b.inode)->depth++;
        ((struct la_inode*)(ibuf))->depth = LAFSI(new->b.inode)->depth;
@@ -1603,7 +1604,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
        LAFS_BUG(!test_bit(B_Dirty, &ib->b.flags) &&
                 !test_bit(B_Realloc, &ib->b.flags), &ib->b);
 
-       LAFS_BUG(!test_bit(B_Valid, &ib->b.flags), &ib->b);
+       LAFS_BUG(!test_bit(B_Valid, &ib->b.flags) && ib->depth > 0, &ib->b);
 
        if (ib->depth <= 1) {
                /* take a copy of the uninc_table so we can work while
index 75b7011961cec832a903fe931df59e1609754679..c273d53b5d7fd8674ed29623fcd1c40154a6b78f 100644 (file)
@@ -655,7 +655,7 @@ int lafs_space_alloc(struct fs *fs, int credits, int why)
        }
 
        fs->allocated_blocks += credits;
-//     BUG_ON(fs->free_blocks < fs->allocated_blocks);
+       BUG_ON(fs->free_blocks < fs->allocated_blocks);
        spin_unlock(&fs->alloc_lock);
        return credits;
 }
diff --git a/super.c b/super.c
index ccb06dafa4a9393aaef5f3c7c77c59e5d009fa36..e674f25121e346bd6723dedcdea2604d937f044f 100644 (file)
--- a/super.c
+++ b/super.c
@@ -946,6 +946,8 @@ void lafs_destroy_inode(struct inode *inode)
 {
        struct datablock *db = NULL;
 
+       BUG_ON(!list_empty(&inode->i_sb_list));
+       // Cannot test i_list as dispose_list just does list_del
        if (LAFSI(inode)->dblock) {
                spin_lock(&inode->i_data.private_lock);
                if (LAFSI(inode)->dblock)