]> git.neil.brown.name Git - LaFS.git/commitdiff
lafs_wait_block fixes
authorNeilBrown <neilb@suse.de>
Thu, 3 Sep 2009 05:46:38 +0000 (15:46 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 3 Sep 2009 05:46:38 +0000 (15:46 +1000)
If the block is already Valid, there is no need to wait for
it to be unlocked.
This avoids extra async blocks lying around.

checkpoint.c
io.c

index 264f6dc4d84c3144bb7104f2ae56b3bcde49131e..57212f8ae61be9e53d32507feed9eb67259ca1eb 100644 (file)
@@ -369,6 +369,9 @@ static void do_checkpoint(void *data)
        while ((b = lafs_get_flushable(fs, oldphase)) != NULL) {
                int unlock = 1;
                dprintk("Checkpoint Block %s\n", strblk(b));
+               /* FIXME I should check for Async children and
+                * de-async them.
+                */
 
                if (!test_bit(B_Pinned, &b->flags))
                        /* Haven't refiled since we cleared that */ ;
diff --git a/io.c b/io.c
index d2a08eda68e43d57e611ac49da408f726b4e7281..6534e03b61e4d758badc7b87b05469719704dd99 100644 (file)
--- a/io.c
+++ b/io.c
@@ -313,11 +313,13 @@ void lafs_iocheck_writeback(struct datablock *db, int unlock)
 int __must_check
 lafs_wait_block(struct block *b)
 {
-       if (test_bit(B_IOLock, &b->flags)) {
+       if (test_bit(B_IOLock, &b->flags) &&
+           !test_bit(B_Valid, &b->flags)) {
                DEFINE_WAIT(wq);
                for (;;) {
                        prepare_to_wait(&block_wait, &wq, TASK_UNINTERRUPTIBLE);
-                       if (test_bit(B_IOLock, &b->flags))
+                       if (test_bit(B_IOLock, &b->flags) &&
+                           !test_bit(B_Valid, &b->flags))
                                schedule();
                        else
                                break;
@@ -334,7 +336,8 @@ lafs_wait_block_async(struct block *b)
                if (!test_and_set_bit(B_Async, &b->flags))
                        getref(b, MKREF(async));
        }
-       if (!test_bit(B_IOLock, &b->flags)) {
+       if (!test_bit(B_IOLock, &b->flags) ||
+           test_bit(B_Valid, &b->flags)) {
                if (test_and_clear_bit(B_Async, &b->flags))
                        putref(b, MKREF(async));
                if (test_bit(B_Valid, &b->flags))