]> git.neil.brown.name Git - LaFS.git/commitdiff
Don't insist on having UnincCredits for all Index blocks.
authorNeilBrown <neilb@suse.de>
Sun, 9 Aug 2009 05:50:54 +0000 (15:50 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 9 Aug 2009 05:50:54 +0000 (15:50 +1000)
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.

block.c
index.c
modify.c

diff --git a/block.c b/block.c
index cfe8da3a5850fcd731978375de5d899a7f4175de..1919e9260d32012f37bf5dbe67f7cb45e8aa241d 100644 (file)
--- 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 f492b3239db5458cd4bdd1f7f63e4c79e77c0087..3d4da4cfbcb1f92b8d967f52fa7e4ec7ccc882c7 100644 (file)
--- 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);
index 27a682ed82450c6895249db9663302d9fd580889..81958a84c8b64cf665818807d15c8911781cbc31 100644 (file)
--- 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));