unlock_page(p);
page_cache_release(p);
}
- BUG_ON(b->b.inode != ino);
+ LAFS_BUG(b->b.inode != ino, &b->b);
return b;
}
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) {
*/
|| 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.
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));
} 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);
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;
/*
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??
*/
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);
}
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))
* (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
{
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);
* 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;
* 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.
}
}
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 &&
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);
}
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))
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);
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;
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 */
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
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);
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++;
/* 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))
} 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--;
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);
/* 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);
* 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;
{
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);
/* 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);
* 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 */
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);
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);
* 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);
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;
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 */
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);
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
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) &&
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)
}
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);
}
}
}
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);
}
}
* 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;
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);
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),
/* 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++;
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",
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__);
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;
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))) {
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));
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))
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);
}
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
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 {
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.
}
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.
}
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;
}
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;
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);
/* 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);
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);
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;
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);
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);
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 {
}
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);
}
ucnt++;
i = 0;
ncnt = 0;
- BUG_ON(ucnt == 0);
+ LAFS_BUG(ucnt == 0, uninc);
uaddr = uninc->fileaddr;
blk = uninc;
}
}
temp_credits = 0;
- BUG_ON(ncnt);
+ LAFS_BUG(ncnt, uninc);
return credits;
}
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);
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);
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) {
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.
* 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;
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;
(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;
}
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;
(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;
}
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;
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 */
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;
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 */
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
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;
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;
* 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 */
/* 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);
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;
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);
* 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;
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;
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;
/* ?? 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)
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)