提交 7acedc5b 编写于 作者: M Mikulas Patocka 提交者: Alasdair G Kergon

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: NMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
Cc: stable@kernel.org
上级 7c9e6c17
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册