[patch 12/27] dm exception store: fix misordered writes

From: Greg KH
Date: Fri Oct 24 2008 - 00:43:47 EST


2.6.27-stable review patch. If anyone has any objections, please let us
know.

------------------
From: Mikulas Patocka <mpatocka@xxxxxxxxxx>

commit 7acedc5b98a2fcff64f00c21110aae7d3ac2f7df upstream

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@xxxxxxxxxx>
Signed-off-by: Alasdair G Kergon <agk@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/md/dm-exception-store.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -603,17 +603,22 @@ static void persistent_commit(struct exc
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);

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/