Count exceptions in progress. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 9 +++++++++ 1 file changed, 9 insertions(+) Index: linux-2.6.31-fast-new-2/drivers/md/dm-snap.c =================================================================== --- linux-2.6.31-fast-new-2.orig/drivers/md/dm-snap.c 2009-10-16 21:52:43.000000000 +0200 +++ linux-2.6.31-fast-new-2/drivers/md/dm-snap.c 2009-10-16 21:52:48.000000000 +0200 @@ -97,8 +97,12 @@ struct dm_snapshot { mempool_t *pending_pool; + /* The number of pending exceptions allocated from the mempool */ atomic_t pending_exceptions_count; + /* The number of entries in "pending" table */ + int pending_exceptions_submitted; + struct dm_exception_table pending; struct dm_exception_table complete; @@ -932,6 +936,7 @@ static int snapshot_ctr(struct dm_target s->active = 0; s->suspended = 0; atomic_set(&s->pending_exceptions_count, 0); + s->pending_exceptions_submitted = 0; s->handover = 0; s->handover_snap = NULL; s->merge_running = 0; @@ -1142,6 +1147,7 @@ static void snapshot_dtr(struct dm_targe smp_mb(); #ifdef CONFIG_DM_DEBUG + BUG_ON(s->pending_exceptions_submitted); for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++) BUG_ON(!hlist_empty(&s->tracked_chunk_hash[i])); #endif @@ -1291,6 +1297,8 @@ static void pending_complete(struct dm_s dm_insert_exception(&s->complete, e); out: + BUG_ON(s->pending_exceptions_submitted <= 0); + s->pending_exceptions_submitted--; dm_remove_exception(&pe->e); snapshot_bios = bio_list_get(&pe->snapshot_bios); origin_bios = bio_list_get(&pe->origin_bios); @@ -1401,6 +1409,7 @@ __find_pending_exception(struct dm_snaps } dm_insert_exception(&s->pending, &pe->e); + s->pending_exceptions_submitted++; return pe; }