From: NeilBrown Date: Fri, 25 Jun 2010 10:46:38 +0000 (+1000) Subject: Add lots of assertions. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=dbd6127deb91b4651e487f5c44452cde3c4e596a;p=LaFS.git Add lots of assertions. Add a number of assertions (BUG_ON) that have show to be valuable. Signed-off-by: NeilBrown --- diff --git a/cluster.c b/cluster.c index ba2f7b7..9a10bac 100644 --- 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 6186db1..38aca36 100644 --- 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 d40c27a..99a7deb 100644 --- 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)) { diff --git a/modify.c b/modify.c index e14a12c..20a0574 100644 --- 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 diff --git a/segments.c b/segments.c index 75b7011..c273d53 100644 --- a/segments.c +++ b/segments.c @@ -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 ccb06da..e674f25 100644 --- 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)