From: NeilBrown Date: Thu, 3 Sep 2009 05:28:20 +0000 (+1000) Subject: Don't add Credits to Dirty blocks. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=ad395cacb3904958bccb25dcf79c68b93a611a82;p=LaFS.git Don't add Credits to Dirty blocks. 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. --- diff --git a/modify.c b/modify.c index 373b025..712174b 100644 --- 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 ||