]> git.neil.brown.name Git - LaFS.git/commitdiff
Don't add Credits to Dirty blocks.
authorNeilBrown <neilb@suse.de>
Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 3 Sep 2009 05:28:20 +0000 (15:28 +1000)
If the Credit has moved to Dirty, we don't need to add
another one during prealloc.
Doing so means that prealloc can fail on a block which is
already adequately allocated.

modify.c

index 373b02513f3749f12d0e4e247f4ddd8d9437179b..712174b59d34320c9bb03427131071490d19fee9 100644 (file)
--- a/modify.c
+++ b/modify.c
@@ -1783,15 +1783,18 @@ int __must_check lafs_prealloc(struct block *blk, int why)
        b = blk;
 
        while (b) {
-               if (credits <= 0)
-                       need += !test_bit(B_Credit, &b->flags);
-               else if (!test_and_set_bit(B_Credit, &b->flags))
-                       credits--;
-               if (credits <= 0)
-                       need += !test_bit(B_ICredit, &b->flags);
-               else if (!test_and_set_bit(B_ICredit, &b->flags))
-                       credits--;
-
+               if (!test_bit(B_Dirty, &b->flags)) {
+                       if (credits <= 0)
+                               need += !test_bit(B_Credit, &b->flags);
+                       else if (!test_and_set_bit(B_Credit, &b->flags))
+                               credits--;
+               }
+               if (!test_bit(B_UnincCredit, &b->flags)) {
+                       if (credits <= 0)
+                               need += !test_bit(B_ICredit, &b->flags);
+                       else if (!test_and_set_bit(B_ICredit, &b->flags))
+                               credits--;
+               }
                if (test_bit(B_Index, &b->flags) ||
                    LAFSI(b->inode)->type == TypeOrphanList ||
                    LAFSI(b->inode)->type == TypeQuota ||