From b40942d7826c002fc6e700a4af1863a60b17629d Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 14 Aug 2010 18:17:48 +1000 Subject: [PATCH] Keep track of 'seq' number in cleaner When reading cluster-heads, track the seq number, both for validation and, later, for optimisation. Signed-off-by: NeilBrown --- clean.c | 11 ++++++++++- state.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clean.c b/clean.c index 7c6b6dd..8df9ce2 100644 --- 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 e155644..a82418a 100644 --- 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; -- 2.39.5