[dm-devel] [PATCH] dm snapshot: fix data corruption
Mikulas Patocka
mpatocka at redhat.com
Mon Mar 3 22:19:22 UTC 2014
The patch 55494bf2947dccdf2d98b62374fea7365dfead84 broke snapshots. When
loading the list of exceptions, the old code read exception areas one by
one into ps->area and inserted the exceptions into the hash table. The
patch 55494bf2 changed it so that dm-bufio with prefetch is used to load
exceptions. It loads the exceptions correctly, but leaves ps->area
uninitialized. When a new exception is allocated, it is stored in this
uninitialized ps->area location and full ps->area is written to the disk.
This causes metadata corruption.
This patch fixes the bug by copying the last area that was read via
dm-bufio into ps->area.
Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
---
drivers/md/dm-snap-persistent.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-3.14-rc5/drivers/md/dm-snap-persistent.c
===================================================================
--- linux-3.14-rc5.orig/drivers/md/dm-snap-persistent.c 2014-03-03 22:42:32.000000000 +0100
+++ linux-3.14-rc5/drivers/md/dm-snap-persistent.c 2014-03-03 22:45:45.000000000 +0100
@@ -546,6 +546,9 @@ static int read_exceptions(struct pstore
r = insert_exceptions(ps, area, callback, callback_context,
&full);
+ if (!full)
+ memcpy(ps->area, area, ps->store->chunk_size << SECTOR_SHIFT);
+
dm_bufio_release(bp);
dm_bufio_forget(client, chunk);
More information about the dm-devel
mailing list