]> git.neil.brown.name Git - LaFS.git/commitdiff
LAFS_BUG add new debug macro that prints block information.
authorNeilBrown <neilb@suse.de>
Sun, 16 Aug 2009 06:39:21 +0000 (16:39 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 16 Aug 2009 06:39:21 +0000 (16:39 +1000)
15 files changed:
block.c
checkpoint.c
clean.c
cluster.c
dir.c
file.c
index.c
inode.c
io.c
lafs.h
modify.c
orphan.c
roll.c
segments.c
snapshot.c

diff --git a/block.c b/block.c
index 7dec0fc4b680de8bb3332613cb9cc2e1584cccaf..9a387d08588c424bef45181a94c4dc47322b3a06 100644 (file)
--- a/block.c
+++ b/block.c
@@ -154,7 +154,7 @@ lafs_get_block(struct inode *ino, unsigned long index, struct page *p,
                unlock_page(p);
                page_cache_release(p);
        }
-       BUG_ON(b->b.inode != ino);
+       LAFS_BUG(b->b.inode != ino, &b->b);
        return b;
 }
 
@@ -195,15 +195,18 @@ void lafs_invalidate_page(struct page *page, unsigned long offset)
                        else if (b_start >= offset) {
                                /* Just remove block from mapping */
                                lafs_iolock_block(&b[i].b);
-                               BUG_ON(test_bit(B_Dirty, &b[i].b.flags));
-                               BUG_ON(test_bit(B_Realloc, &b[i].b.flags));
+                               LAFS_BUG(test_bit(B_Dirty, &b[i].b.flags),
+                                        &b[i].b);
+                               LAFS_BUG(test_bit(B_Realloc, &b[i].b.flags),
+                                        &b[i].b);
                                clear_bit(B_Valid, &b[i].b.flags);
                                lafs_iounlock_block(&b[i].b, 0);
                        }
                        b_start += sb->s_blocksize;
                        start += sb->s_blocksize;
-                       BUG_ON(offset == 0 &&
-                              test_bit(B_IOLock, &b[i].b.flags));
+                       LAFS_BUG(offset == 0 &&
+                                test_bit(B_IOLock, &b[i].b.flags),
+                                &b[i].b);
                }
        }
        if (offset == 0) {
@@ -256,11 +259,8 @@ int lafs_release_page(struct page *page, gfp_t gfp_flags)
                     */
                    || test_bit(B_Uninc, &b[i].b.flags)
                        ) {
-                       printk(KERN_ERR "Cannot release %s\n", strblk(&b[i].b));
-                       if (!list_empty(&b[i].b.lru))
-                               printk(KERN_ERR "lru NOT empty\n");
                        spin_unlock(&mapping->private_lock);
-                       BUG();
+                       LAFS_BUG(1, &b[i].b);
                        /* This not really a bug, but bugs can lead
                         * here, and this is an unusual situation
                         * (currently) so we BUG here to be safe.
@@ -362,7 +362,8 @@ lafs_reserve_block(struct block *b, int alloc_type)
                b->physaddr = 0;
 
        if (test_bit(B_Index, &b->flags))
-               BUG_ON(b->parent == NULL && !test_bit(B_Root, &b->flags));
+               LAFS_BUG(b->parent == NULL && !test_bit(B_Root, &b->flags),
+                        b);
        else
                err = lafs_setparent(dblk(b));
 
@@ -440,7 +441,7 @@ lafs_pin_dblock(struct datablock *b)
        } else
                blk = getref(&b->b, MKREF(pindb));
 
-       BUG_ON(!test_phase_locked(fs));
+       LAFS_BUG(!test_phase_locked(fs), &b->b);
 
        lafs_phase_wait(blk);
 
@@ -465,7 +466,7 @@ lafs_pin_dblock(struct datablock *b)
 void
 lafs_dirty_dblock(struct datablock *b)
 {
-       BUG_ON(!test_bit(B_Valid, &b->b.flags));
+       LAFS_BUG(!test_bit(B_Valid, &b->b.flags), &b->b);
        if (test_bit(B_Pinned, &b->b.flags))
                b->b.inode->i_sb->s_dirt = 1;
        /*
@@ -476,13 +477,13 @@ lafs_dirty_dblock(struct datablock *b)
        if (!test_and_set_bit(B_Dirty, &b->b.flags)) {
                if (!test_and_clear_bit(B_Credit, &b->b.flags))
                        if (!test_and_clear_bit(B_NCredit, &b->b.flags))
-                               BUG(); // Credit should have been set.
+                               LAFS_BUG(1, &b->b); // Credit should have been set.
                __set_page_dirty_nobuffers(b->page);
        }
        if (!test_and_set_bit(B_UnincCredit, &b->b.flags))
                if (!test_and_clear_bit(B_ICredit, &b->b.flags))
                        if (!test_and_clear_bit(B_NICredit, &b->b.flags))
-                               BUG();  // ICredit should be set before we dirty
+                               LAFS_BUG(1, &b->b);     // ICredit should be set before we dirty
                                        // a block.
 
        // FIXME Do I need to do something with PinPending??
@@ -504,8 +505,8 @@ lafs_erase_dblock(struct datablock *b)
                 */
                spin_lock(&b->b.inode->i_data.private_lock);
                if (LAFSI(b->b.inode)->iblock) {
-                       BUG_ON(LAFSI(b->b.inode)->depth !=
-                              LAFSI(b->b.inode)->iblock->depth);
+                       LAFS_BUG(LAFSI(b->b.inode)->depth !=
+                                LAFSI(b->b.inode)->iblock->depth, &b->b);
                        lafs_clear_index(LAFSI(b->b.inode)->iblock);
                        clear_bit(B_PhysValid, &b->b.flags);
                }
@@ -515,7 +516,8 @@ lafs_erase_dblock(struct datablock *b)
 
        if (LAFSI(b->b.inode)->type == TypeInodeFile &&
            LAFSI(b->my_inode)->iblock)
-               BUG_ON(test_bit(B_Valid, &LAFSI(b->my_inode)->iblock->b.flags));
+               LAFS_BUG(test_bit(B_Valid, &LAFSI(b->my_inode)->iblock->b.flags),
+                        &b->b);
 
        clear_bit(B_Valid, &b->b.flags);
        if (test_and_clear_bit(B_Dirty, &b->b.flags))
@@ -533,7 +535,7 @@ lafs_erase_dblock(struct datablock *b)
                 * (i.e. an InoIdx block) still pinned, then it should be erased
                 * first.
                 */
-               BUG_ON(list_empty(&b->b.lru));
+               LAFS_BUG(list_empty(&b->b.lru), &b->b);
                list_del_init(&b->b.lru);
                if (!test_bit(B_Root, &b->b.flags))
                        atomic_dec(&b->b.parent->pincnt
@@ -569,7 +571,7 @@ lafs_erase_iblock(struct indexblock *b)
 {
        struct fs *fs = fs_from_inode(b->b.inode);
 
-       BUG_ON(!test_bit(B_IOLock, &b->b.flags));
+       LAFS_BUG(!test_bit(B_IOLock, &b->b.flags), &b->b);
        clear_bit(B_Valid, &b->b.flags);
        if (test_and_clear_bit(B_Dirty, &b->b.flags))
                lafs_space_return(fs, 1);
@@ -585,8 +587,8 @@ lafs_erase_iblock(struct indexblock *b)
                 * a _leaf list because we hold IOLock
                 */
                int onlist = 0;
-               BUG_ON(atomic_read(&b->pincnt[0]));
-               BUG_ON(atomic_read(&b->pincnt[1]));
+               LAFS_BUG(atomic_read(&b->pincnt[0]), &b->b);
+               LAFS_BUG(atomic_read(&b->pincnt[1]), &b->b);
                if (!list_empty(&b->b.lru)) {
                        list_del_init(&b->b.lru);
                        onlist = 1;
@@ -618,13 +620,12 @@ lafs_dirty_iblock(struct indexblock *b)
         * in the previous phase.
         */
 
-       BUG_ON(!test_bit(B_Valid, &b->b.flags));
-       BUG_ON(!test_bit(B_Pinned, &b->b.flags));
+       LAFS_BUG(!test_bit(B_Valid, &b->b.flags), &b->b);
+       LAFS_BUG(!test_bit(B_Pinned, &b->b.flags), &b->b);
        if (!test_and_set_bit(B_Dirty, &b->b.flags)) {
                if (!test_and_clear_bit(B_Credit, &b->b.flags)) {
-                       printk(KERN_ERR "Why have I no credits? %s\n",
-                              strblk(&b->b));
-                       BUG(); // Credit should have been set.
+                       printk(KERN_ERR "Why have I no credits?\n");
+                       LAFS_BUG(1, &b->b); // Credit should have been set.
                }
        }
 
index b6f9061c3c7eec88c5f3d0c92a7f489ae0bd8661..23dd2ca85dbe59163217bed89cb00d127cd325ef 100644 (file)
@@ -239,7 +239,7 @@ static int print_tree(struct block *b, int depth)
 
        if (test_bit(B_Index, &b->flags)) {
                list_for_each_entry(b, &ib->children, siblings) {
-                       BUG_ON(b->parent != ib);
+                       LAFS_BUG(b->parent != ib, b);
                        credits += print_tree(b, depth+2);
                }
        } else if (LAFSI(b->inode)->type == TypeInodeFile &&
@@ -247,7 +247,8 @@ static int print_tree(struct block *b, int depth)
                   LAFSI(dblk(b)->my_inode)->iblock &&
                   LAFSI(dblk(b)->my_inode)->iblock->b.parent
                ) {
-               BUG_ON(LAFSI(dblk(b)->my_inode)->iblock->b.parent != b->parent);
+               LAFS_BUG(LAFSI(dblk(b)->my_inode)->iblock->b.parent != b->parent,
+                        b);
                credits += print_tree(&LAFSI(dblk(b)->my_inode)->iblock->b,
                                      depth+1);
        }
diff --git a/clean.c b/clean.c
index a48f4a301f25d1e19358e953a663a9a7ed5f3cd4..37a6f00d0fc6811b76ad502e39db9b216c9df6f3 100644 (file)
--- a/clean.c
+++ b/clean.c
@@ -153,7 +153,7 @@ static int mark_cleaning(struct block *b)
        err = lafs_reserve_block(b, CleanSpace);
        if (err)
                return err;
-       BUG_ON(!test_bit(B_Valid, &b->flags));
+       LAFS_BUG(!test_bit(B_Valid, &b->flags), b);
        if (!test_bit(B_Realloc, &b->flags)) {
                if (lafs_space_alloc(fs_from_inode(b->inode), 1, CleanSpace) == 1)
                        if (test_and_set_bit(B_Realloc, &b->flags))
@@ -174,7 +174,7 @@ static int mark_cleaning(struct block *b)
 
        if (!test_and_set_bit(B_UnincCredit, &b->flags))
                if (!test_and_clear_bit(B_ICredit, &b->flags))
-                       BUG(); // ICredit should be set before we dirty a block.
+                       LAFS_BUG(1, b); // ICredit should be set before we dirty a block.
 
        lafs_refile(b, 0);
        lafs_refile(&b->parent->b, 0);
index 73bc3601b6e075a7173892a564b056b8b6f07b72..3c473fbdb220b349033c74196b75e3fe2eb52a96 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -464,18 +464,19 @@ static int flush_data_to_inode(struct block *b)
                lafs_dirty_dblock(lai->dblock);
        } else if (test_and_clear_bit(B_Realloc, &b->flags)) {
                int credits = 1;
-               BUG_ON(!test_bit(B_Valid, &lai->iblock->b.flags));
+               LAFS_BUG(!test_bit(B_Valid, &lai->iblock->b.flags),
+                        &lai->iblock->b);
                if (!test_and_set_bit(B_Realloc, &lai->iblock->b.flags))
                                credits--;
                if (!test_and_set_bit(B_UnincCredit, &lai->iblock->b.flags))
                        if (!test_and_clear_bit(B_ICredit,
                                                &lai->iblock->b.flags))
                                if (!test_and_clear_bit(B_UnincCredit, &b->flags))
-                                       BUG(); /* We needed an UnincCredit */
+                                       LAFS_BUG(1, b); /* We needed an UnincCredit */
                lafs_space_return(fs, credits);
        } else {
                printk("Wasn't dirty or realloc: %s\n", strblk(b));
-               BUG();
+               LAFS_BUG(1, b);
        }
        lai->depth = 0;
        lai->iblock->depth = 0;
@@ -519,16 +520,16 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
        int used;
 
 
-       BUG_ON(!test_bit(B_IOLock, &b->flags));
+       LAFS_BUG(!test_bit(B_IOLock, &b->flags), b);
        lai = LAFSI(b->inode);
 
        if (!test_bit(B_Valid, &b->flags)) {
                lafs_iounlock_block(b, B_IOLock);
                return wc->cluster_seq;
        }
-       BUG_ON(!fs->rolled);
-       BUG_ON(lai->flags & File_nonlogged &&
-              !test_bit(B_Index, &b->flags));
+       LAFS_BUG(!fs->rolled, b);
+       LAFS_BUG(lai->flags & File_nonlogged &&
+              !test_bit(B_Index, &b->flags), b);
 
        size = i_size_read(b->inode);
        if (!test_bit(B_Index, &b->flags) &&          /* it is a datablock */
@@ -575,7 +576,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                int credits = 0;
                /* FIXME should I inode_fillblock here?? */
 
-               BUG_ON(!test_bit(B_Pinned, &b->flags));
+               LAFS_BUG(!test_bit(B_Pinned, &b->flags), b);
                if (!test_bit(B_Pinned, &lai->dblock->b.flags)) {
                        /* index block pinned, data block not,
                         * carry the pinning across
@@ -584,7 +585,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                            b->parent)
                                lai->dblock->b.parent =
                                        getiref(b->parent, MKREF(child));
-                       BUG_ON(b->parent != lai->dblock->b.parent);
+                       LAFS_BUG(b->parent != lai->dblock->b.parent, b);
                        set_phase(&lai->dblock->b, test_bit(B_Phase1,
                                                            &b->flags));
                        lafs_refile(&lai->dblock->b, 0);
@@ -593,7 +594,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                if (cnum) {
                        if (test_and_clear_bit(B_Realloc, &b->flags))
                                credits++;
-                       BUG_ON(test_bit(B_Dirty, &b->flags));
+                       LAFS_BUG(test_bit(B_Dirty, &b->flags), b);
                } else {
                        if (test_and_clear_bit(B_Dirty, &b->flags))
                                credits++;
@@ -609,7 +610,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                /* We always erase the InoIdx block before the
                 * inode data block, so this cannot happen
                 */
-               BUG_ON(!test_bit(B_Valid, &b2->flags));
+               LAFS_BUG(!test_bit(B_Valid, &b2->flags), b2);
 
                if (cnum == 0) {
                        if (!test_bit(B_Dirty, &b2->flags))
@@ -624,7 +625,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                } else {
                        /* FIXME this code should be in clean.c
                         * it is copied from lafs_dirty_dblock() */
-                       BUG_ON(!test_bit(B_Valid, &b2->flags));
+                       LAFS_BUG(!test_bit(B_Valid, &b2->flags), b2);
                        if (!test_and_set_bit(B_Realloc, &b2->flags))
                                credits--;
 
@@ -632,7 +633,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                                if (!test_and_clear_bit(B_ICredit, &b2->flags))
                                        credits--;
                }
-               BUG_ON(credits < 0);
+               LAFS_BUG(credits < 0, b2);
                lafs_space_return(fs, credits);
                /* make sure 'dirty' status is registered */
                lafs_refile(b2, 0);
@@ -650,7 +651,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
        /* FIXME these are no longer needed */
        if (!test_bit(B_Valid, &b->flags))
                printk("Not Valid in allocate %s\n", strblk(b));
-       BUG_ON(!test_bit(B_Valid, &b->flags));
+       LAFS_BUG(!test_bit(B_Valid, &b->flags), b);
 
        mutex_lock(&wc->lock);
 
@@ -666,7 +667,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
                 * Must remove it from the leaf lru
                 */
                int onlru = 1;
-               BUG_ON(test_bit(B_OnFree, &b->flags));
+               LAFS_BUG(test_bit(B_OnFree, &b->flags), b);
                spin_lock(&fs->lock);
                if (list_empty(&b->lru))
                        onlru = 0;
diff --git a/dir.c b/dir.c
index 0667afe9cd47c90bf896dae9bb45ccc4db4c4032..090ee5629a09651da69d9f99e152bcaa5a2e861e 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -200,7 +200,7 @@ static void dir_add_orphan(struct datablock *b)
 {
        struct inode *dir = b->b.inode;
        /* i_mutex protects dirorphans */
-       BUG_ON(!mutex_is_locked(&dir->i_mutex));
+       LAFS_BUG(!mutex_is_locked(&dir->i_mutex), &b->b);
        if (list_empty(&b->orphans)) {
                getdref(b, MKREF(orphan));
                list_add(&b->orphans, &LAFSI(dir)->md.file.dirorphans);
diff --git a/file.c b/file.c
index 2b77c713307aff432bb7bf7ec111d4c9b6a2484d..10cc96b7173c1b5ce0a30525eada2e6a52c9588d 100644 (file)
--- a/file.c
+++ b/file.c
@@ -123,8 +123,7 @@ lafs_prepare_write(struct file *file, struct page *page,
                /* FIXME need PinPending or something to make sure
                 * credits don't disappear */
                err = lafs_reserve_block(&fb[i - first].b, NewSpace);
-               if (fb[i-first].b.parent == NULL)
-                       BUG();
+               LAFS_BUG(fb[i-first].b.parent == NULL, &fb[i-first].b);
        }
        if (err == -EAGAIN) {
                lafs_checkpoint_unlock_wait(fs);
diff --git a/index.c b/index.c
index f5418c74c0835b72f5e1303889b41808967a7b91..50cd7600ce483ca423cd9bfc34efff0e2da8960d 100644 (file)
--- a/index.c
+++ b/index.c
@@ -79,7 +79,7 @@ static int lafs_shrinker(int nr_to_scan, /*gfp_t*/unsigned int gfp_mask)
                         * the above 'if' also tested for 'Pinned', and that
                         * seems unnecessary, but I want to be sure. 
                         */
-                       BUG_ON(test_bit(B_Pinned, &ib->b.flags));
+                       LAFS_BUG(test_bit(B_Pinned, &ib->b.flags), &ib->b);
                        if (!hlist_unhashed(&ib->hash))
                                hlist_del(&ib->hash);
                        /* delete from inode->free_index */
@@ -120,7 +120,7 @@ void lafs_release_index(struct list_head *head)
                                                   struct indexblock,
                                                   b.siblings);
                list_del_init(&ib->b.siblings);
-               BUG_ON(!test_bit(B_OnFree, &ib->b.flags));
+               LAFS_BUG(!test_bit(B_OnFree, &ib->b.flags), &ib->b);
                if (!hlist_unhashed(&ib->hash))
                        hlist_del(&ib->hash);
                list_move(&ib->b.lru, &togo);
@@ -248,7 +248,7 @@ struct indexblock *getiref_locked(struct indexblock *ib, REFARG)
                ok = 1;
        if (spin_is_locked(&lafs_hash_lock))
                ok = 1;
-       BUG_ON(!ok);
+       LAFS_BUG(!ok, &ib->b);
 
        if (!test_bit(B_InoIdx, &ib->b.flags)) {
                getref_locked(&ib->b, REF);
@@ -259,7 +259,7 @@ struct indexblock *getiref_locked(struct indexblock *ib, REFARG)
                 * to the dblock
                 */
                db = getdref_locked(LAFSI(ib->b.inode)->dblock, MKREF(iblock));
-               BUG_ON(db == NULL);
+               LAFS_BUG(db == NULL, &ib->b);
        }
        add_ref(&ib->b, REF, __FILE__, __LINE__);
        __getref(&ib->b);
@@ -317,16 +317,16 @@ block_adopt(struct block *blk, struct indexblock *parent)
        struct address_space *as;
 
        if (parent == NULL) {
-               BUG_ON(!test_bit(B_Root, &blk->flags));
+               LAFS_BUG(!test_bit(B_Root, &blk->flags), blk);
                return;
        }
 
        if (blk->parent) {
-               BUG_ON(blk->parent != parent);
+               LAFS_BUG(blk->parent != parent, blk);
                return;
        }
 
-       BUG_ON(!(parent->b.flags & B_Valid));
+       LAFS_BUG(!(parent->b.flags & B_Valid), &parent->b);
 
        as = blk->inode->i_mapping;
 
@@ -338,9 +338,9 @@ block_adopt(struct block *blk, struct indexblock *parent)
                        printk("parent = %s\n", strblk(&parent->b));
                        lafs_dump_tree();
                }
-               BUG_ON(blk->parent != parent);
+               LAFS_BUG(blk->parent != parent, blk);
        } else {
-               BUG_ON(parent == iblk(blk));
+               LAFS_BUG(parent == iblk(blk), blk);
                blk->parent = parent;
                getiref(parent, MKREF(child));
                /* Remove from the per-inode free list */
@@ -376,9 +376,9 @@ void lafs_pin_block_ph(struct block *b, int ph)
        struct block *p;
        struct inode *ino;
 
-       BUG_ON(b->parent == NULL && !test_bit(B_Root, &b->flags));
+       LAFS_BUG(b->parent == NULL && !test_bit(B_Root, &b->flags), b);
        if (!test_bit(B_Realloc, &b->flags))
-               BUG_ON(!test_phase_locked(fs));
+               LAFS_BUG(!test_phase_locked(fs), b);
 
        ino = b->inode;
        spin_lock(&ino->i_mapping->private_lock);
@@ -453,12 +453,12 @@ void lafs_phase_flip(struct fs *fs, struct block *b)
 
        dprintk("FLIP %s\n", strblk(b));
 
-       BUG_ON(!test_bit(B_Pinned, &b->flags));
-       BUG_ON(!test_bit(B_Index, &b->flags));
-       BUG_ON(b->parent == NULL && !test_bit(B_Root, &b->flags));
-       BUG_ON(ib->uninc_table.pending_cnt);
-       BUG_ON(atomic_read(&ib->pincnt[oldphase]));
-       BUG_ON(!test_bit(B_IOLock, &b->flags));
+       LAFS_BUG(!test_bit(B_Pinned, &b->flags), b);
+       LAFS_BUG(!test_bit(B_Index, &b->flags), b);
+       LAFS_BUG(b->parent == NULL && !test_bit(B_Root, &b->flags), b);
+       LAFS_BUG(ib->uninc_table.pending_cnt, b);
+       LAFS_BUG(atomic_read(&ib->pincnt[oldphase]), b);
+       LAFS_BUG(!test_bit(B_IOLock, &b->flags), b);
 
        /* If this is the only reference, and pincnts are zero
         * and all relevant flags are clear, then don't flip
@@ -551,7 +551,7 @@ void lafs_phase_flip(struct fs *fs, struct block *b)
                        atomic_inc(&p->pincnt[1-oldphase]);
                        atomic_dec(&p->pincnt[oldphase]);
                } else
-                       BUG_ON(!test_bit(B_Root, &b->flags));
+                       LAFS_BUG(!test_bit(B_Root, &b->flags), b);
 
                /* move 'next' credits to 'here' */
                if (!test_bit(B_Credit, &b->flags) &&
@@ -586,7 +586,7 @@ void lafs_phase_flip(struct fs *fs, struct block *b)
                lafs_add_block_address(fs, b2);
                putref(b2, MKREF(uninc));
        }
-       BUG_ON(ib->uninc_next);
+       LAFS_BUG(ib->uninc_next, &ib->b);
 
        lafs_refile(b, 0);
        if (p)
@@ -680,9 +680,9 @@ void lafs_refile(struct block *b, int dec)
                }
                if (c[0] != atomic_read(&iblk(b)->pincnt[0]) ||
                    c[1] != atomic_read(&iblk(b)->pincnt[1])) {
-                       printk("%d %d %s\n", c[0], c[1], strblk(b));
+                       printk("%d %d\n", c[0], c[1]);
                        lafs_dump_tree();
-                       BUG();
+                       LAFS_BUG(1, b);
                }
        }
 
@@ -712,8 +712,8 @@ void lafs_refile(struct block *b, int dec)
                }
                if (c[0] != atomic_read(&ib->pincnt[0]) ||
                    c[1] != atomic_read(&ib->pincnt[1])) {
-                       printk("badcnt %d %d %s\n", c[0], c[1], strblk(&ib->b));
-                       BUG();
+                       printk("badcnt %d %d\n", c[0], c[1]);
+                       LAFS_BUG(1, &ib->b);
                }
        }
 
@@ -724,7 +724,7 @@ void lafs_refile(struct block *b, int dec)
  * The main reason for holding lafs_hash_lock is that it protects
  * ->lru - i.e. all the lists.
  */
-       BUG_ON(atomic_read(&b->refcnt) == 0);
+       LAFS_BUG(atomic_read(&b->refcnt) == 0, b);
        while (b) {
                int ph;
                int free_me = 0;
@@ -777,7 +777,7 @@ void lafs_refile(struct block *b, int dec)
                                if (!test_bit(B_Root, &b->flags)) {
                                        atomic_dec(&b->parent->pincnt[ph]);
                                        if (next_parent != &b->parent->b) {
-                                               BUG_ON(next_parent);
+                                               LAFS_BUG(next_parent, b);
                                                next_parent = &b->parent->b;
                                                atomic_inc(&next_parent
                                                           ->refcnt);
@@ -833,9 +833,9 @@ void lafs_refile(struct block *b, int dec)
                                if (next_parent == &b->parent->b) {
                                        if (atomic_dec_and_test(&next_parent
                                                                ->refcnt))
-                                               BUG();
+                                               LAFS_BUG(1, b);
                                } else {
-                                       BUG_ON(next_parent);
+                                       LAFS_BUG(next_parent, b);
                                        next_parent = &b->parent->b;
                                }
                                del_ref(next_parent, MKREF(child),
@@ -878,10 +878,10 @@ void lafs_refile(struct block *b, int dec)
                                        /* Could this be uninc - where
                                         * is refcnt */
                                        printk("Problem: %s\n", strblk(b));
-                               BUG_ON(b->parent != NULL);
+                               LAFS_BUG(b->parent != NULL, b);
                                /* put it on the lru */
                                if (!test_and_set_bit(B_OnFree, &b->flags)) {
-                                       BUG_ON(!list_empty(&b->lru));
+                                       LAFS_BUG(!list_empty(&b->lru), b);
                                        list_move(&b->lru, &freelist.lru);
                                }
                                freelist.freecnt++;
@@ -904,7 +904,7 @@ void lafs_refile(struct block *b, int dec)
                                        int mask = (1<<bits) - 1;
                                        int bnum = b->fileaddr & mask;
 
-                                       BUG_ON(next);
+                                       LAFS_BUG(next, next);
                                        if (bnum) {
                                                next = &db[-bnum].b;
                                                del_ref(next, "lafs_release_0",
@@ -920,9 +920,9 @@ void lafs_refile(struct block *b, int dec)
                                if (test_bit(B_InoIdx, &b->flags)) {
                                        spin_lock(&b->inode->i_mapping
                                                  ->private_lock);
-                                       BUG_ON(LAFSI(b->inode)->iblock
-                                              != iblk(b));
-                                       BUG_ON(next);
+                                       LAFS_BUG(LAFSI(b->inode)->iblock
+                                              != iblk(b), b);
+                                       LAFS_BUG(next, next);
                                        next = &LAFSI(b->inode)->dblock->b;
                                        del_ref(next, MKREF(iblock),
                                                __FILE__, __LINE__);
@@ -1032,7 +1032,7 @@ lafs_make_iblock(struct inode *ino, int adopt, int async, REFARG)
        new->b.physaddr = lai->dblock->b.physaddr;
        if (test_bit(B_PhysValid, &lai->dblock->b.flags))
                set_bit(B_PhysValid, &new->b.flags);
-       BUG_ON(!test_bit(B_Valid, &lai->dblock->b.flags));
+       LAFS_BUG(!test_bit(B_Valid, &lai->dblock->b.flags), &lai->dblock->b);
        set_bit(B_Valid, &new->b.flags);
        new->b.inode = ino;
        new->depth = lai->depth;
@@ -1578,9 +1578,9 @@ find_block(struct datablock *b, int adopt, int async)
        void *buf;
        int  offset;
 
-       if (test_bit(B_Pinned, &b->b.flags) &&
-           b->b.parent == NULL)
-               BUG();
+       LAFS_BUG(test_bit(B_Pinned, &b->b.flags) &&
+                b->b.parent == NULL,
+                &b->b);
 
        if (test_bit(B_PhysValid, &b->b.flags)
            && (!adopt || b->b.parent || test_bit(B_Root, &b->b.flags))) {
@@ -1701,7 +1701,7 @@ int lafs_add_block_address(struct fs *fs, struct block *blk)
                        return 1;
                spin_lock(&fs->lock);
                blk->chain = p->uninc;
-               BUG_ON(p->depth == 1);
+               LAFS_BUG(p->depth == 1, blk);
                p->uninc = blk;
                spin_unlock(&fs->lock);
                getref(blk, MKREF(uninc));
@@ -1742,8 +1742,8 @@ int lafs_add_block_address(struct fs *fs, struct block *blk)
                if (fs->rolled)
                        // FIXME I really need to dirty this p block
                        // in roll.c
-                       BUG_ON(!test_bit(B_Dirty, &p->b.flags) &&
-                              !test_bit(B_Realloc, &p->b.flags));
+                       LAFS_BUG(!test_bit(B_Dirty, &p->b.flags) &&
+                                !test_bit(B_Realloc, &p->b.flags), blk);
                p->uninc_table.pending_cnt++;
                if (test_and_clear_bit(B_UnincCredit,
                                       &blk->flags))
@@ -1794,21 +1794,21 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
                printk("something missing %s\n", strblk(blk));
        WARN_ON_ONCE(!test_bit(B_UnincCredit, &blk->flags) && phys &&
                     !test_bit(B_Index, &blk->flags));
-       BUG_ON(!test_bit(B_Dirty, &blk->flags) &&
-              !test_bit(B_Realloc, &blk->flags) &&
-              phys != 0);
-       BUG_ON(!test_bit(B_IOLock, &blk->flags));
+       LAFS_BUG(!test_bit(B_Dirty, &blk->flags) &&
+                !test_bit(B_Realloc, &blk->flags) &&
+                phys != 0, blk);
+       LAFS_BUG(!test_bit(B_IOLock, &blk->flags), blk);
 
        if (test_bit(B_Root, &blk->flags)) {
                int i;
                struct lafs_inode *lai;
 
-               BUG_ON(test_bit(B_Index, &blk->flags));
+               LAFS_BUG(test_bit(B_Index, &blk->flags), blk);
 
                for (i = 0; i < fs->maxsnapshot; i++)
                        if (fs->ss[i].root == blk->inode)
                                break;
-               BUG_ON(i == fs->maxsnapshot);
+               LAFS_BUG(i == fs->maxsnapshot, blk);
                blk->physaddr = phys; /* superblock doesn't get
                                         counted in summaries */
                set_bit(B_PhysValid, &blk->flags);
@@ -1841,8 +1841,7 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
        }
        p = blk->parent;
 
-       if (!p)
-               BUG();
+       LAFS_BUG(!p, blk);
 
        /* We need to work out if this block is in the current phase or
         * the next one.  This can only be an issue if a phase change
@@ -1853,13 +1852,13 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
        if (test_bit(B_Pinned, &blk->flags))
                ph = !!test_bit(B_Phase1, &blk->flags);
        else if (test_bit(B_Index, &blk->flags))
-               BUG(); /* Index blocks must always be pinned when dirty (*/
+               LAFS_BUG(1, blk); /* Index blocks must always be pinned when dirty (*/
        else if (p->uninc_table.pending_cnt) {
                /* attach data block into previous phase as incorporation of
                 * this phase is still to happen.
                 * This is needed for flush-if-cannot-preallocate to work.
                 */
-               BUG_ON(!test_bit(B_Pinned, &p->b.flags));
+               LAFS_BUG(!test_bit(B_Pinned, &p->b.flags), &p->b);
                ph = !!test_bit(B_Phase1, &p->b.flags);
                lafs_pin_block_ph(blk, ph);
        } else {
@@ -1916,7 +1915,7 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
                               strblk(&p->b));
                        printk("blk is %s\n", strblk(blk));
                }
-               BUG_ON(!test_bit(B_Valid, &p->b.flags));
+               LAFS_BUG(!test_bit(B_Valid, &p->b.flags), &p->b);
                if (!test_bit(B_Realloc, &p->b.flags)) {
                        /* I cannot use B_Credit to fill B_Realloc as that
                         * might still be needed for B_Dirty.
@@ -1932,7 +1931,7 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
                }
                if (!test_and_set_bit(B_UnincCredit, &p->b.flags))
                        if (!test_and_clear_bit(B_ICredit, &p->b.flags))
-                               BUG(); // ICredit should be set before
+                               LAFS_BUG(1, &p->b); // ICredit should be set before
                //we dirty a block.
 
        }
@@ -1943,8 +1942,8 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
 
                p = blk->parent;
 
-               BUG_ON(!p);
-               BUG_ON(!test_bit(B_Pinned, &p->b.flags));
+               LAFS_BUG(!p, blk);
+               LAFS_BUG(!test_bit(B_Pinned, &p->b.flags), blk);
                goto new_parent;
        }
 
diff --git a/inode.c b/inode.c
index 881be53b0e4ad803a520dacb3583813e35c6cc1e..66db77b2ab8c7791cd4eba1ae7aab020b3b0b35b 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -99,7 +99,7 @@ lafs_import_inode(struct inode *ino, struct datablock *b)
        ino->i_mode = S_IFREG;
        err = -EINVAL;
 
-       BUG_ON(ino->i_ino != b->b.fileaddr);
+       LAFS_BUG(ino->i_ino != b->b.fileaddr, &b->b);
        li->filesys = b->b.inode;
        li->cblocks = le32_to_cpu(lai->data_blocks);
        li->pblocks = li->ablocks = 0;
@@ -565,8 +565,8 @@ static int prune_some(void *data, u32 addr, u64 paddr, int len)
                        a->fileaddr = addr + i;
                        a->physaddr = paddr + i;
                        a->cnt = 1;
-               BUG_ON(!test_bit(B_Dirty, &ib->b.flags) &&
-                      !test_bit(B_Realloc, &ib->b.flags));
+               LAFS_BUG(!test_bit(B_Dirty, &ib->b.flags) &&
+                      !test_bit(B_Realloc, &ib->b.flags), &ib->b);
                        ib->uninc_table.pending_cnt++;
                } else {
                        spin_unlock(&fs->lock);
@@ -597,7 +597,7 @@ static int lafs_inode_handle_orphan(struct datablock *b)
                        /* Not an orphan any more */
                        lafs_orphan_release(fs, b);
                } else {
-                       BUG_ON(LAFSI(ino)->type != 0);
+                       LAFS_BUG(LAFSI(ino)->type != 0, &b->b);
                        lafs_orphan_release(fs, b);
                        lafs_iolock_block(&ib->b);
                        lafs_erase_iblock(ib);
@@ -784,8 +784,8 @@ static int lafs_inode_handle_orphan(struct datablock *b)
                lafs_walk_leaf_index(ib, prune, ib);
        else {
                /* This had better be already clear. */
-               BUG_ON(!test_bit(B_PhysValid, &ib->b.flags));
-               BUG_ON(ib->b.physaddr != 0);
+               LAFS_BUG(!test_bit(B_PhysValid, &ib->b.flags), &ib->b);
+               LAFS_BUG(ib->b.physaddr != 0, &ib->b);
        }
        lafs_clear_index(ib);
 
@@ -1328,13 +1328,13 @@ lafs_new_inode(struct fs *fs, struct inode *dir, int type, int inum, int mode,
        ino = lafs_iget(dir->i_sb, b->b.fileaddr, 0);
        if (IS_ERR(ino)) {
                lafs_cluster_update_abort(&ui);
-               BUG();
+               LAFS_BUG(1, &b->b);
        } else
                lafs_cluster_update_commit(&ui, b, 0,
                                           LAFSI(ino)->metadata_size);
        clear_bit(B_PinPending, &b->b.flags);
-       BUG_ON(LAFSI(ino)->dblock != b);
-       BUG_ON(b->my_inode != ino);
+       LAFS_BUG(LAFSI(ino)->dblock != b, &b->b);
+       LAFS_BUG(b->my_inode != ino, &b->b);
        lafs_checkpoint_unlock(fs);
 
        *inodbp = b;
diff --git a/io.c b/io.c
index bc51f15b9cfd36a16d99c2e1bf0b75c271482949..354f874c171fb4ae15c0e68c43cfba2d9932605d 100644 (file)
--- a/io.c
+++ b/io.c
@@ -358,11 +358,11 @@ lafs_load_block(struct block *b, int unlock)
                lafs_iounlock_block(b, unlock ? B_IOLock : 0);
                return 0;
        }
-       BUG_ON(test_bit(B_InoIdx, &b->flags));
+       LAFS_BUG(test_bit(B_InoIdx, &b->flags), b);
        if (test_bit(B_Index, &b->flags)) {
                struct indexblock *ib = iblk(b);
                if (b->physaddr == 0) {
-                       BUG();
+                       LAFS_BUG(1, b);
                        /* I think this is really an error FIXME */
                        memset(ib->data, 0, b->inode->i_sb->s_blocksize);
                        lafs_iounlock_block(b, unlock ? B_IOLock : 0);
@@ -380,7 +380,7 @@ lafs_load_block(struct block *b, int unlock)
                        void *baddr = map_dblock(db);
 
                        /* This case is handled in find_block */
-                       BUG_ON(lai->depth == 0 && b->fileaddr == 0);
+                       LAFS_BUG(lai->depth == 0 && b->fileaddr == 0, b);
 
                        memset(baddr, 0, (1<<b->inode->i_blkbits));
                        unmap_dblock(db, baddr);
diff --git a/lafs.h b/lafs.h
index 02f88e13c4b30120b9fcb3a412b628ee5f094e1e..653ca65ab0eacee1f6ff3d67e01e8c8d67b3164c 100644 (file)
--- a/lafs.h
+++ b/lafs.h
@@ -16,6 +16,8 @@
 extern int lafs_trace;
 #define dprintk(x...) do { if(lafs_trace)printk(x); }while(0)
 
+#define LAFS_BUG(cond, b) do { if (cond) { printk(KERN_ERR "%s:%d: %s\n", __FILE__,__LINE__,strblk(b));BUG();}}while(0)
+
 #ifdef DUMP
 extern struct fs *dfs;
 extern struct freelists {
@@ -356,7 +358,7 @@ static inline struct block *__getref(struct block *b)
 }
 static inline struct block *_getref(struct block *b)
 {
-       BUG_ON(b && atomic_read(&b->refcnt) == 0);
+       LAFS_BUG(b && atomic_read(&b->refcnt) == 0, b);
        return __getref(b);
 }
 
index bb9659784fff48c8170c2693d955c1c8ca97e120..c86df0f702edfa7d5816d70587d7d6ed40bc1bbd 100644 (file)
--- a/modify.c
+++ b/modify.c
@@ -241,7 +241,7 @@ static int incorporate_index(struct block *uninc, char *buf, int size)
                ucnt++;
        i = 0;
        ncnt = 0;
-       BUG_ON(ucnt == 0);
+       LAFS_BUG(ucnt == 0, uninc);
        uaddr = uninc->fileaddr;
        blk = uninc;
 
@@ -387,7 +387,7 @@ static int incorporate_index(struct block *uninc, char *buf, int size)
                }
        }
        temp_credits = 0;
-       BUG_ON(ncnt);
+       LAFS_BUG(ncnt, uninc);
        return credits;
 }
 
@@ -437,18 +437,18 @@ static void grow_index_tree(struct indexblock *ib, struct indexblock *new)
        unmap_iblock(new, ibuf);
        set_bit(B_Valid, &new->b.flags);
 
-       BUG_ON(LAFSI(new->b.inode)->iblock != ib);
+       LAFS_BUG(LAFSI(new->b.inode)->iblock != ib, &ib->b);
        LAFSI(new->b.inode)->iblock = new;
        list_add(&ib->b.siblings, &new->children);
        INIT_LIST_HEAD(&new->b.siblings);
 
        new->depth = ib->depth + 1;
        LAFSI(new->b.inode)->depth++;
-       BUG_ON(new->depth != LAFSI(new->b.inode)->depth);
+       LAFS_BUG(new->depth != LAFSI(new->b.inode)->depth, &ib->b);
        lafs_clear_index(new);
 
        /* Make sure pin count is correct */
-       BUG_ON(!test_bit(B_Pinned, &ib->b.flags));
+       LAFS_BUG(!test_bit(B_Pinned, &ib->b.flags), &ib->b);
        set_bit(B_Pinned, &new->b.flags);
        set_phase(&new->b, test_bit(B_Phase1, &ib->b.flags));
        atomic_set(&new->pincnt[!!test_bit(B_Phase1, &ib->b.flags)], 1);
@@ -974,8 +974,7 @@ void lafs_walk_leaf_index(struct indexblock *ib,
                break;
        default:
                printk("CURRENT=%d\n", current_layout);
-               printk("X: %s\n", strblk(&ib->b));
-               BUG(); // FIXME should be IO error ??
+               LAFS_BUG(1, &ib->b); // FIXME should be IO error ??
        }
        if (test_bit(B_InoIdx, &ib->b.flags))
                kunmap(LAFSI(ib->b.inode)->dblock->page);
@@ -1121,7 +1120,7 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib,
                            check_leaf, &leafinfo);
                break;
        default:
-               BUG(); // FIXME should be IO error ??
+               LAFS_BUG(1, &ib->b); // FIXME should be IO error ??
        }
 
        if (leafinfo.cnt == 0) {
@@ -1174,7 +1173,7 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib,
                unmap_iblock(ib, ibuf);
                return 1;
        }
-       BUG_ON(offset);
+       LAFS_BUG(offset, &ib->b);
 
        /* It didn't fit, and this is a regular index block, so
         * we need to do a horizontal split.
@@ -1246,8 +1245,8 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib,
                 * be at least one extent still in ui.
                 * So zero the buff and encode those extents as IBLK_EXTENT
                 */
-               BUG_ON(next < ib->b.fileaddr + (len-2)/6);
-               BUG_ON(ui->pending_cnt == 0);
+               LAFS_BUG(next < ib->b.fileaddr + (len-2)/6, &ib->b);
+               LAFS_BUG(ui->pending_cnt == 0, &ib->b);
                memset(ibuf, 0, len);
                sbuf = NULL;
                slen = 0;
@@ -1281,19 +1280,19 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib,
                memmove(sbuf, buf, slen);
                break;
        default:
-               BUG();
+               LAFS_BUG(1, &ib->b);
        }
        layout.data = ibuf;
        layout.size = len;
        next2 = walk_extent(next, &sbuf, slen, ui, add_extent, &layout);
-       BUG_ON(next2 != 0);
+       LAFS_BUG(next2 != 0, &ib->b);
        if (slen && layout.data > sbuf) {
                printk("slen=%d ld-sb=%d layout.data=%p sbuf=%p "
                       "buf=%p ibuf=%p len=%d\n",
                       slen, layout.data-sbuf, layout.data, sbuf,
                       buf, ibuf, len);
        }
-       BUG_ON(slen && layout.data > sbuf);
+       LAFS_BUG(slen && layout.data > sbuf, &ib->b);
        memset(layout.data, 0, layout.size);
 
        new->b.fileaddr = next;
@@ -1335,7 +1334,7 @@ BUG_ON(!test_bit(B_Dirty, &new->b.flags) &&
        (void)getiref(new->b.parent, MKREF(child));
        new->b.inode = ib->b.inode;
        lafs_hash_iblock(new);
-       BUG_ON(!test_bit(B_Pinned, &ib->b.flags));
+       LAFS_BUG(!test_bit(B_Pinned, &ib->b.flags), &ib->b);
        set_phase(&new->b, test_bit(B_Phase1, &ib->b.flags));
        return 2;
 }
@@ -1376,8 +1375,8 @@ static int do_incorporate_internal(struct fs *fs, struct indexblock *ib,
 
        current_layout = le16_to_cpu(*(u16 *)(ibuf+offset));
        buf = ibuf + offset + 2;
-       if (current_layout != IBLK_INDEX)
-               BUG();
+       LAFS_BUG(current_layout != IBLK_INDEX,
+                &ib->b);
 
        nbuf = map_iblock_2(new);
        layout.data = nbuf;
@@ -1486,7 +1485,7 @@ static int do_incorporate_internal(struct fs *fs, struct indexblock *ib,
        (void)getiref(new->b.parent, MKREF(child));
        new->b.inode = ib->b.inode;
        lafs_hash_iblock(new);
-       BUG_ON(!test_bit(B_Pinned, &ib->b.flags));
+       LAFS_BUG(!test_bit(B_Pinned, &ib->b.flags), &ib->b);
        set_phase(&new->b, test_bit(B_Phase1, &ib->b.flags));
        return 2;
 }
@@ -1507,13 +1506,13 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
        struct uninc uit;
        int blocksize = fs->prime_sb->s_blocksize;
 
-       BUG_ON(!test_bit(B_IOLock, &ib->b.flags));
+       LAFS_BUG(!test_bit(B_IOLock, &ib->b.flags), &ib->b);
 
        if (ib->depth <= 1) {
                /* take a copy of the uninc_table so we can work while
                 * more changes can be made
                 */
-               BUG_ON(ib->uninc);
+               LAFS_BUG(ib->uninc, &ib->b);
                spin_lock(&fs->lock);
                memcpy(&uit, &ib->uninc_table, sizeof(uit));
                ib->uninc_table.pending_cnt = 0;
@@ -1527,8 +1526,8 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
                if(!test_bit(B_Dirty, &ib->b.flags) &&
                   !test_bit(B_Realloc, &ib->b.flags))
                        printk("bad %s\n", strblk(&ib->b));
-               BUG_ON(!test_bit(B_Dirty, &ib->b.flags) &&
-                      !test_bit(B_Realloc, &ib->b.flags));
+               LAFS_BUG(!test_bit(B_Dirty, &ib->b.flags) &&
+                      !test_bit(B_Realloc, &ib->b.flags), &ib->b);
 
                /* OK, we genuinely have work to do. */
                /* find size and type of current block */
@@ -1578,7 +1577,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
                int cred;
                uit.credits = 0;
 
-               BUG_ON(ib->uninc_table.pending_cnt);
+               LAFS_BUG(ib->uninc_table.pending_cnt, &ib->b);
                spin_lock(&fs->lock);
                uninc = ib->uninc;
                ib->uninc = NULL;
@@ -1587,8 +1586,8 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
                if (uninc == NULL)
                        goto out;
 
-               BUG_ON(!test_bit(B_Dirty, &ib->b.flags) &&
-                      !test_bit(B_Realloc, &ib->b.flags));
+               LAFS_BUG(!test_bit(B_Dirty, &ib->b.flags) &&
+                      !test_bit(B_Realloc, &ib->b.flags), &ib->b);
 
                /* OK, we genuinely have work to do. */
                /* find size and type of current block */
@@ -1626,7 +1625,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
 
        if (ib->depth < 1)
                printk("small depth %s\n", strblk(&ib->b));
-       BUG_ON(ib->depth < 1);
+       LAFS_BUG(ib->depth < 1, &ib->b);
        if (ib->depth == 1)
                rv = do_incorporate_leaf(fs, ib, &uit, new);
        else
@@ -1730,8 +1729,8 @@ int __must_check lafs_prealloc(struct block *blk, int why)
        int need;
        int credits = 0;
 
-       BUG_ON(why != CleanSpace && !test_phase_locked(fs)
-              && !fs->checkpointing);
+       LAFS_BUG(why != CleanSpace && !test_phase_locked(fs)
+                && !fs->checkpointing, blk);
 
  retry:
        need = 0;
index a1889b44cadd042d3b57888a26e76321b5c9e156..03889b3e858464453bc6b7a33696b903156a687c 100644 (file)
--- a/orphan.c
+++ b/orphan.c
@@ -138,7 +138,7 @@ int lafs_orphan_pin(struct orphan_info *oi, struct datablock *b, int n)
        dprintk("slot=%d bnum=%d\n", slot, bnum);
        ob = lafs_get_block(fs->orphans, bnum, NULL, GFP_KERNEL, MKREF(orphan));
        /* that *must* succeed as we own a reference on the block already */
-       BUG_ON(ob == NULL);
+       LAFS_BUG(ob == NULL, &b->b);
 
        lafs_phase_wait(&ob->b);
        oi->ob = ob;
@@ -182,7 +182,8 @@ void lafs_orphan_commit(struct orphan_info *oi)
         * So there is not much to do here
         */
        if (oi->ob) {
-               BUG_ON(!test_bit(B_PinPending, &oi->ob->b.flags));
+               LAFS_BUG(!test_bit(B_PinPending, &oi->ob->b.flags),
+                        &oi->ob->b);
                lafs_dirty_dblock(oi->ob);
                if (atomic_dec_and_test(&oi->ob->pincnt))
                        /* FIXME this is racy */
@@ -271,7 +272,7 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b)
        /* We already own an 'orphan' reference on this block, so we
         * don't need this one
         */
-       BUG_ON(ob1 == NULL);
+       LAFS_BUG(ob1 == NULL, &b->b);
        putdref(ob1, MKREF(orphan_release));
 
        lafs_phase_wait(&ob1->b);
@@ -337,7 +338,7 @@ void lafs_orphan_release(struct fs *fs, struct datablock *b)
                        goto ouch;
                }
                dprintk("Q %d %d\n", bbl->orphan_slot, om->nextfree);
-               BUG_ON(bbl->orphan_slot != om->nextfree-1);
+               LAFS_BUG(bbl->orphan_slot != om->nextfree-1, &bbl->b);
 
                or = map_dblock(ob1);
                or[ent] = last;
diff --git a/roll.c b/roll.c
index 43c7699e02c579578e7dc1a19f02639d14318d30..87ec51e95ff026045ac01be1c82cb08f7137a5df 100644 (file)
--- a/roll.c
+++ b/roll.c
@@ -335,7 +335,7 @@ roll_block(struct fs *fs, int fsnum, int inum, int trunc, int flg,
                lafs_dirty_iblock(blk->b.parent);
                if (lafs_add_block_address(fs, &blk->b) == 0)
                        /* FIXME if the table becomes full, we have a problem... */
-                       BUG();
+                       LAFS_BUG(1, &blk->b);
                dprintk("Allocated block %lu to %llu\n",
                       (unsigned long)bnum, baddr);
                lafs_iounlock_block(&blk->b, 0);
@@ -345,7 +345,7 @@ roll_block(struct fs *fs, int fsnum, int inum, int trunc, int flg,
                 * the contents are now invalid.  If they are dirty,
                 * we have a real problem as those changes cannot be saved.
                 */
-               BUG_ON(test_bit(B_Dirty, &blk->b.flags));
+               LAFS_BUG(test_bit(B_Dirty, &blk->b.flags), &blk->b);
                clear_bit(B_Valid, &blk->b.flags);
 
                break;
index 65ff770e5b4253d8ab41bad622e831841d65cdcc..ace8c8ec8d9ec71eeecf08631ddc2e9dc5a42b35 100644 (file)
@@ -526,7 +526,7 @@ static int count_credits(struct block *b)
 
        if (test_bit(B_Index, &b->flags)) {
                list_for_each_entry(b, &ib->children, siblings) {
-                       BUG_ON(b->parent != ib);
+                       LAFS_BUG(b->parent != ib, b);
                        credits += count_credits(b);
                }
                credits += ib->uninc_table.credits;
@@ -535,7 +535,7 @@ static int count_credits(struct block *b)
                   LAFSI(dblk(b)->my_inode)->iblock &&
                   LAFSI(dblk(b)->my_inode)->iblock->b.parent
                ) {
-               BUG_ON(LAFSI(dblk(b)->my_inode)->iblock->b.parent != b->parent);
+               LAFS_BUG(LAFSI(dblk(b)->my_inode)->iblock->b.parent != b->parent, b);
                credits += count_credits(&LAFSI(dblk(b)->my_inode)->iblock->b);
        }
        return credits;
@@ -1067,7 +1067,7 @@ void lafs_free_get(struct fs *fs, unsigned int *dev, u32 *seg,
                        /* ?? what do I need to release etc */
                        /* Maybe this cannot fail because we own references
                         * to the two blocks !! */
-                       BUG();
+                       LAFS_BUG(1, &db->b);
                lafs_checkpoint_lock(fs);
                (void)lafs_reserve_block(&ssum->ssblk->b, CleanSpace);
                if (ssnum == 0)
index 409e58eb77280ba026a3ace3a56e507d6637b747..456069dd577850f266e268ffbd75d58a455181d8 100644 (file)
@@ -132,7 +132,7 @@ lafs_snap_get_sb(struct file_system_type *fstype,
                                   MKREF(snap));
                b->b.physaddr = fs->ss[s].root_addr;
                set_bit(B_PhysValid, &b->b.flags);
-               BUG_ON(test_bit(B_Valid, &b->b.flags));
+               LAFS_BUG(test_bit(B_Valid, &b->b.flags), &b->b);
                printk("ss root at %llu\n", b->b.physaddr);
                err = lafs_load_block(&b->b, 0);
                if (!err)