Skip to content

Commit

Permalink
dm exception store: fix misordered writes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Oct 21, 2008
1 parent 7c9e6c1 commit 7acedc5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/md/dm-exception-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,18 +610,23 @@ static void persistent_commit(struct exception_store *store,
(ps->current_committed != ps->exceptions_per_area))
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);
Expand Down

0 comments on commit 7acedc5

Please sign in to comment.