Track in-progress writes on the merging snapshot device and delay merging the chunk until all writes to that chunk finish. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) Index: linux-2.6.26-devel/drivers/md/dm-snap.c =================================================================== --- linux-2.6.26-devel.orig/drivers/md/dm-snap.c 2008-07-14 20:23:54.000000000 +0200 +++ linux-2.6.26-devel/drivers/md/dm-snap.c 2008-07-14 20:23:58.000000000 +0200 @@ -610,7 +610,8 @@ static void snapshot_merge_process(struc s->merge_write_interlock_n = 1; up_write(&s->lock); - /* !!! FIXME: wait until writes to this chunk drain */ + while (__chunk_is_tracked(s, old_chunk)) + yield(); dm_kcopyd_copy(s->kcopyd_client, &src, 1, &dest, 0, merge_callback, s); return; @@ -1299,7 +1300,11 @@ static int snapshot_merge_map(struct dm_ r = DM_MAPIO_SUBMITTED; goto out_unlock; } + remap_exception(s, e, bio, chunk); + + if (bio_rw(bio) == WRITE) + map_context->ptr = track_chunk(s, chunk); goto out_unlock; }