--- drivers/md/dm-thin.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) Index: linux-3.0/drivers/md/dm-thin.c =================================================================== --- linux-3.0.orig/drivers/md/dm-thin.c +++ linux-3.0/drivers/md/dm-thin.c @@ -487,6 +487,8 @@ struct pool { mempool_t *endio_hook_pool; atomic_t ref_count; + + struct mutex big_lock; }; /* @@ -1126,14 +1128,18 @@ static void do_producer(struct work_stru { struct pool *pool = container_of(ws, struct pool, producer); + mutex_lock(&pool->big_lock); process_deferred_bios(pool); + mutex_unlock(&pool->big_lock); } static void do_consumer(struct work_struct *ws) { struct pool *pool = container_of(ws, struct pool, consumer); + mutex_lock(&pool->big_lock); process_prepared_mappings(pool); + mutex_unlock(&pool->big_lock); } static void defer_bio(struct thin_c *tc, struct bio *bio) @@ -1396,6 +1402,7 @@ static struct pool *pool_create(struct b } atomic_set(&pool->ref_count, 1); + mutex_init(&pool->big_lock); return pool; bad_endio_hook_pool: @@ -2123,9 +2130,17 @@ bad_pool_dev: static int thin_map(struct dm_target *ti, struct bio *bio, union map_info *map_context) { + int r; + struct thin_c *tc = ti->private; + struct pool *pool = tc->pool; + bio->bi_sector -= ti->begin; - return bio_map(ti, bio, map_context); + mutex_lock(&pool->big_lock); + r = bio_map(ti, bio, map_context); + mutex_unlock(&pool->big_lock); + + return r; } /*