]> git.neil.brown.name Git - LaFS.git/commitdiff
cluster_allocate - minor code rearrangement.
authorNeilBrown <neilb@suse.de>
Mon, 13 Sep 2010 05:44:05 +0000 (15:44 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 13 Sep 2010 05:44:05 +0000 (15:44 +1000)
extract common code and general clean up

Signed-off-by: NeilBrown <neilb@suse.de>
cluster.c

index c45c451b30eaeaabbe4c94ecac8fc7a3d3ee9b5e..107f1bcf2f58d987064e965e942e6ddbfb38c10e 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -689,26 +689,19 @@ int lafs_cluster_allocate(struct block *b, int cnum)
                 */
                LAFS_BUG(!test_bit(B_Valid, &b2->flags), b2);
 
+               if (!test_and_set_bit(B_UnincCredit, &b2->flags))
+                       if (!test_and_clear_bit(B_ICredit, &b2->flags))
+                               credits--;
+
                if (cnum == 0) {
                        if (!test_bit(B_Dirty, &b2->flags))
                                /* need some credits... */
                                if (!test_and_set_bit(B_Credit, &b2->flags))
                                        credits--;
-                       if (!test_bit(B_UnincCredit, &b2->flags))
-                               if (!test_and_set_bit(B_ICredit, &b2->flags))
-                                       credits--;
-
                        lafs_dirty_dblock(dblk(b2));
                } else {
-                       /* FIXME this code should be in clean.c
-                        * it is copied from lafs_dirty_dblock() */
-                       LAFS_BUG(!test_bit(B_Valid, &b2->flags), b2);
                        if (!test_and_set_bit(B_Realloc, &b2->flags))
                                credits--;
-
-                       if (!test_and_set_bit(B_UnincCredit, &b2->flags))
-                               if (!test_and_clear_bit(B_ICredit, &b2->flags))
-                                       credits--;
                }
                LAFS_BUG(credits < 0, b2);
                lafs_space_return(fs, credits);
@@ -731,7 +724,6 @@ int lafs_cluster_allocate(struct block *b, int cnum)
                        LAFS_BUG(1, b);
                lafs_iounlock_block(b);
                lafs_allocated_block(fs, b, 0);
-               /* FIXME this is common code - make a function?? */
                if (cnum) {
                        if (test_and_clear_bit(B_Realloc, &b->flags))
                                credits++;