From b63e75e5fabc78758431376391263a5d26e8836e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 13 Sep 2010 15:44:05 +1000 Subject: [PATCH] cluster_allocate - minor code rearrangement. extract common code and general clean up Signed-off-by: NeilBrown --- cluster.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cluster.c b/cluster.c index c45c451..107f1bc 100644 --- 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++; -- 2.39.5