From cd45daffd1f7b53aac0835b23e97f814ec3f10dc Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Mon, 21 Jul 2008 12:00:32 +0100 Subject: dm snapshot: track snapshot reads Whenever a snapshot read gets mapped through to the origin, track it in a per-snapshot hash table indexed by chunk number, using memory allocated from a new per-snapshot mempool. We need to track these reads to avoid race conditions which will be fixed by patches that follow. Signed-off-by: Mikulas Patocka Signed-off-by: Alasdair G Kergon --- drivers/md/dm-snap.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/md/dm-snap.h') diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h index 24f9fb73b98..70dc961f40d 100644 --- a/drivers/md/dm-snap.h +++ b/drivers/md/dm-snap.h @@ -130,6 +130,10 @@ struct exception_store { void *context; }; +#define DM_TRACKED_CHUNK_HASH_SIZE 16 +#define DM_TRACKED_CHUNK_HASH(x) ((unsigned long)(x) & \ + (DM_TRACKED_CHUNK_HASH_SIZE - 1)) + struct dm_snapshot { struct rw_semaphore lock; struct dm_target *ti; @@ -174,6 +178,11 @@ struct dm_snapshot { /* Queue of snapshot writes for ksnapd to flush */ struct bio_list queued_bios; struct work_struct queued_bios_work; + + /* Chunks with outstanding reads */ + mempool_t *tracked_chunk_pool; + spinlock_t tracked_chunk_lock; + struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE]; }; /* -- cgit v1.2.3 From 92e868122edf08b9fc06b112e7e0c80ab94c1f93 Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Mon, 21 Jul 2008 12:00:35 +0100 Subject: dm snapshot: use per device mempools Change snapshot per-module mempool to per-device mempool. Per-module mempools could cause a deadlock if multiple snapshot devices are stacked above each other. Signed-off-by: Mikulas Patocka Signed-off-by: Alasdair G Kergon --- drivers/md/dm-snap.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/md/dm-snap.h') diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h index 70dc961f40d..292c15609ae 100644 --- a/drivers/md/dm-snap.h +++ b/drivers/md/dm-snap.h @@ -161,6 +161,8 @@ struct dm_snapshot { /* The last percentage we notified */ int last_percent; + mempool_t *pending_pool; + struct exception_table pending; struct exception_table complete; -- cgit v1.2.3