From: NeilBrown Date: Sun, 9 Aug 2009 05:50:54 +0000 (+1000) Subject: Don't insist on having UnincCredits for all Index blocks. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=9f4afd00f60f0d74a54f68afadc7d2589475ac69;p=LaFS.git Don't insist on having UnincCredits for all Index blocks. When an Index block has room for new addresses, it does not need to have an UnincCredit because we know it will not split before more credits are available. --- diff --git a/block.c b/block.c index cfe8da3..1919e92 100644 --- a/block.c +++ b/block.c @@ -655,9 +655,17 @@ lafs_dirty_iblock(struct indexblock *b) } } - 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; } diff --git a/index.c b/index.c index f492b32..3d4da4c 100644 --- a/index.c +++ b/index.c @@ -1781,14 +1781,18 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys) 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); diff --git a/modify.c b/modify.c index 27a682e..81958a8 100644 --- a/modify.c +++ b/modify.c @@ -1660,9 +1660,12 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib) * 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)); @@ -1671,9 +1674,12 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib) /* 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)); @@ -1683,6 +1689,12 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib) } 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));