summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2008-10-21 17:44:56 +0100
committerAlasdair G Kergon <agk@redhat.com>2008-10-21 17:44:56 +0100
commit7acedc5b98a2fcff64f00c21110aae7d3ac2f7df (patch)
treeed9eda05b30d3606f1ad16e368c313b40c616c3d /drivers/md
parent7c9e6c17325fab380fbe9c9787680ff7d4a51abd (diff)
downloadlinux-7acedc5b98a2fcff64f00c21110aae7d3ac2f7df.tar.gz
linux-7acedc5b98a2fcff64f00c21110aae7d3ac2f7df.tar.bz2
linux-7acedc5b98a2fcff64f00c21110aae7d3ac2f7df.zip
dm exception store: fix misordered writes
We must zero the next chunk on disk *before* writing out the current chunk, not after. Otherwise if the machine crashes at the wrong time, the "end of metadata" marker may be missing. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Cc: stable@kernel.org
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-exception-store.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index fe6cef8df203..6179bf70f98a 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -611,17 +611,22 @@ static void persistent_commit(struct exception_store *store,
return;
/*
+ * If we completely filled the current area, then wipe the next one.
+ */
+ if ((ps->current_committed == ps->exceptions_per_area) &&
+ zero_disk_area(ps, ps->current_area + 1))
+ ps->valid = 0;
+
+ /*
* Commit exceptions to disk.
*/
- if (area_io(ps, WRITE))
+ if (ps->valid && area_io(ps, WRITE))
ps->valid = 0;
/*
* Advance to the next area if this one is full.
*/
if (ps->current_committed == ps->exceptions_per_area) {
- if (zero_disk_area(ps, ps->current_area + 1))
- ps->valid = 0;
ps->current_committed = 0;
ps->current_area++;
zero_memory_area(ps);