]> git.neil.brown.name Git - LaFS.git/commitdiff
lafs_refile: separate out consistency checking
authorNeilBrown <neilb@suse.de>
Tue, 14 Sep 2010 03:00:20 +0000 (13:00 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 14 Sep 2010 03:00:20 +0000 (13:00 +1000)
lafs_refile is too big and clumsy.  Time to tidy up.

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

diff --git a/index.c b/index.c
index 18adc7d45e4666aff18898428823b2727c6e6aba..991f9c8cd258bfd232f8ebc10d5c37646725c105 100644 (file)
--- 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;