From 806782ea5fb9ab12b132f41cf1f9516c01a11768 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 14 Sep 2010 13:00:20 +1000 Subject: [PATCH] lafs_refile: separate out consistency checking lafs_refile is too big and clumsy. Time to tidy up. Signed-off-by: NeilBrown --- index.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/index.c b/index.c index 18adc7d..991f9c8 100644 --- a/index.c +++ b/index.c @@ -752,18 +752,14 @@ int lafs_is_leaf(struct block *b, int ph) return 1; } -void lafs_refile(struct block *b, int dec) -{ - struct block *next = NULL, *next_parent = NULL; - struct fs *fs = NULL; - u64 physref = 0; - - if (!b) - return; - -/* sanity tests. - * 1/ make sure pincnt is right +/* + * This for debugging and is racy and is probably only safe on UP */ +static void check_consistency(struct block *b) +{ + /* sanity tests. + * 1/ make sure pincnt is right + */ if (test_bit(B_Index, &b->flags)) { int c[2]; struct block *cb; @@ -825,8 +821,18 @@ void lafs_refile(struct block *b, int dec) LAFS_BUG(1, &ib->b); } } +} + +void lafs_refile(struct block *b, int dec) +{ + struct block *next = NULL, *next_parent = NULL; + struct fs *fs = NULL; + u64 physref = 0; + + if (!b) + return; -/* End of sanity tests. Now for real code */ + check_consistency(b); /* To (mostly) avoid recursion, we have a loop which may * walk up to the parent. @@ -849,8 +855,6 @@ void lafs_refile(struct block *b, int dec) !test_bit(B_OnFree, &b->flags)) /* If B_IOLock, then it might be on the cluster * list, but not the LRU. - * FIXME can this race with writepage/lafs_cluster_allocate - * which sets B_IOLock before removing from lru ?? */ onlru = 1; -- 2.39.5