]> git.neil.brown.name Git - LaFS.git/commitdiff
Keep track of 'seq' number in cleaner
authorNeilBrown <neilb@suse.de>
Sat, 14 Aug 2010 08:17:48 +0000 (18:17 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 14 Aug 2010 08:17:48 +0000 (18:17 +1000)
When reading cluster-heads, track the seq number, both for validation
and, later, for optimisation.

Signed-off-by: NeilBrown <neilb@suse.de>
clean.c
state.h

diff --git a/clean.c b/clean.c
index 7c6b6dd3991e0aa95dfaf727ed2bc406cf114e3c..8df9ce239bdbf6ea0e209072635e7691b110e20f 100644 (file)
--- a/clean.c
+++ b/clean.c
@@ -173,7 +173,15 @@ static int try_clean(struct fs *fs, struct toclean *tc)
                        goto bad_header;
                if (memcmp(tc->ch->uuid, fs->state->uuid, 16) != 0)
                        goto bad_header;
-               /* FIXME should I check 'seq' as well? */
+               if (tc->seq == 0)
+                       tc->seq = le64_to_cpu(tc->ch->seq);
+               else {
+                       tc->seq++;
+                       if (tc->seq != le64_to_cpu(tc->ch->seq)) {
+                               printk("Bad seq number\n");
+                               goto bad_header;
+                       }
+               }
                tc->gh = tc->ch->groups;
                tc->desc = tc->gh->u.desc;
                if (lafs_calc_cluster_csum(tc->ch) != tc->ch->checksum) {
@@ -546,6 +554,7 @@ unsigned long lafs_do_clean(struct fs *fs)
                        tc->gh = NULL;
                        tc->desc = NULL;
                        tc->ac.state = 1;
+                       tc->seq = 0;
                        INIT_LIST_HEAD(&tc->cleaning);
                        fs->cleaner.active = 1;
                }
diff --git a/state.h b/state.h
index e155644942872ff76afad6fbba6171b2f21c974a..a82418a666f6bcbf719ca1f55176030ab15b9e43 100644 (file)
--- a/state.h
+++ b/state.h
@@ -126,6 +126,7 @@ struct fs {
                        u16 dev;
                        u32 seg;
                        u64 haddr;      /* Address of this write-cluster-header */
+                       u64 seq;        /* seq of most recent header loaded */
                        struct cluster_head *ch;
                        struct group_head *gh; /* current group head */
                        struct descriptor *desc;