}
}
- if (!test_and_set_bit(B_UnincCredit, &b->b.flags))
- if (!test_and_clear_bit(B_ICredit, &b->b.flags))
- BUG(); // ICredit should be set before we dirty a block.
+ /* Iblocks don't always have ICredits. If they have room
+ * for 3 new addresses, the ICredit is not essential. But
+ * it is preferred.
+ */
+ if (!test_bit(B_UnincCredit, &b->b.flags))
+ /* We would like a credit */
+ if (test_and_clear_bit(B_ICredit, &b->b.flags))
+ /* We have a credit */
+ if (test_and_set_bit(B_UnincCredit, &b->b.flags))
+ /* race - we didn't need it after all */
+ lafs_space_return(fs_from_inode(b->b.inode), 1);
b->b.inode->i_sb->s_dirt = 1;
}
dprintk("Allocated %s -> %llu\n", strblk(blk), phys);
/* FIXME if phys is 0, I shouldn't need uninc credit. Should
- * I not demand it? See comment in lafs_erase_dblock */
+ * I not demand it? See comment in lafs_erase_dblock.
+ * Also, Index block that are not near full do not need UnincCredits
+ * so don't warn about them
+ */
if (!test_bit(B_UnincCredit, &blk->flags) && phys)
printk("no uninc credit %s\n", strblk(blk));
if (!test_bit(B_Dirty, &blk->flags) &&
!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);
+ 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);
* new->uninc_table. 'new' has been linked in to the
* parent.
*/
- uit.credits -= 2;
+ uit.credits --;
set_bit(B_Credit, &new->b.flags);
- set_bit(B_ICredit, &new->b.flags);
+ if (uit.credits > 0) {
+ set_bit(B_ICredit, &new->b.flags);
+ uit.credits--;
+ }
lafs_dirty_iblock(new); // or Realloc?? FIXME
putiref(new, MKREF(inc));
/* new needs a B_Credit and a B_ICredit.
*/
- uit.credits -= 2;
+ uit.credits--;;
set_bit(B_Credit, &new->b.flags);
- set_bit(B_ICredit, &new->b.flags);
+ if (uit.credits > 0){
+ set_bit(B_ICredit, &new->b.flags);
+ uit.credits--;
+ }
lafs_dirty_iblock(new); // or Realloc?? FIXME
printk("Just Grew %s\n", strblk(&new->b));
}
out:
+ if (uit.credits > 0 && !test_and_set_bit(B_UnincCredit, &ib->b.flags))
+ uit.credits--;
+ if (uit.credits > 0 && !test_and_set_bit(B_ICredit, &ib->b.flags))
+ uit.credits--;
+ if (uit.credits > 0 && !test_and_set_bit(B_NICredit, &ib->b.flags))
+ uit.credits--;
if (uit.credits < 0) {
printk("Credits = %d, rv=%d\n", uit.credits, rv);
printk("ib = %s\n", strblk(&ib->b));