]> git.neil.brown.name Git - LaFS.git/commitdiff
Only increment pending_nxt when we finish a cluster
authorNeilBrown <neilb@suse.de>
Fri, 9 Jul 2010 10:39:45 +0000 (20:39 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 9 Jul 2010 21:32:01 +0000 (07:32 +1000)
cluster_reset is called when we reset a cluster, but also
when we reposition to the start of a new segment - which should be
the same cluster.
pending_nxt should only be changed in the first of those cases.

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

index 96b9afa7bc2c89182b58f1ba3c0320083cb9233d..9e32b2dd20e9246ae9634c48d8884408b80bddd0 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -381,7 +381,6 @@ static void cluster_reset(struct fs *fs, struct wc *wc)
        int blocksize = fs->prime_sb->s_blocksize;
        if (wc->seg.dev < 0) {
                wc->remaining = 0;
-               wc->chead = NULL;
                wc->chead_size = 0;
                return;
        }
@@ -389,11 +388,8 @@ static void cluster_reset(struct fs *fs, struct wc *wc)
        wc->chead_blocks = 1;
        wc->remaining--;
        wc->cluster_space = blocksize - sizeof(struct cluster_head);
-       wc->chead_size = sizeof(struct cluster_head);
-
-       wc->pending_next = (wc->pending_next+1) % 4;
        wc->chead = page_address(wc->page[wc->pending_next]);
-       
+       wc->chead_size = sizeof(struct cluster_head);
 }
 
 static void close_segment(struct fs *fs, int cnum)
@@ -1390,6 +1386,7 @@ static void cluster_flush(struct fs *fs, int cnum)
        }
        dprintk("D %d\n", wake);
 
+       wc->pending_next = (wc->pending_next+1) % 4;
        /* now re-initialise the cluster information */
        cluster_reset(fs, wc);
 
@@ -1544,6 +1541,8 @@ int lafs_cluster_init(struct fs *fs, int cnum, u64 addr, u64 prev, u64 seq)
        INIT_LIST_HEAD(&wc->clhead);
 
        for (i = 0; i < 4 ; i++) {
+               wc->pending_vfy_type[i] = VerifyNull;
+               atomic_set(&wc->pending_cnt[i], 0);
                wc->page[i] = alloc_page(GFP_KERNEL);
                if (!wc->page[i])
                        break;
@@ -1555,7 +1554,7 @@ int lafs_cluster_init(struct fs *fs, int cnum, u64 addr, u64 prev, u64 seq)
                }
                return -ENOMEM;
        }
-       wc->pending_next = -1;
+       wc->pending_next = 0;
        wc->cluster_seq = seq;
        wc->prev_addr = prev;