[PATCH] dm thin: Remove unnecessary locking from pool_map()

Hao Zhang posted 1 patch 1 week, 6 days ago
drivers/md/dm-thin.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] dm thin: Remove unnecessary locking from pool_map()
Posted by Hao Zhang 1 week, 6 days ago
From: Hao Zhang <zhanghao1@kylinos.cn>

pool_map() takes pool->lock only while setting the bio's data device.

The pool target's data_dev is initialized when the target is
constructed and is not changed afterwards.  The device-mapper target
remains alive while its map callback is running, so pool->lock is not
needed to protect data_dev.

Remove the unnecessary locking.  This also avoids holding pool->lock
across bio_set_dev(), which may perform a blkcg lookup and acquire the
request queue's queue_lock.

Signed-off-by: Hao Zhang <zhanghao1@kylinos.cn>
---
 drivers/md/dm-thin.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 59392de7a477..358ed77ffb2b 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -3438,14 +3438,11 @@ static int pool_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 static int pool_map(struct dm_target *ti, struct bio *bio)
 {
 	struct pool_c *pt = ti->private;
-	struct pool *pool = pt->pool;
 
 	/*
 	 * As this is a singleton target, ti->begin is always zero.
 	 */
-	spin_lock_irq(&pool->lock);
 	bio_set_dev(bio, pt->data_dev->bdev);
-	spin_unlock_irq(&pool->lock);
 
 	return DM_MAPIO_REMAPPED;
 }

base-commit: 08df884136f1c1197bab2a27814404fd329d9aac
-- 
2.15.0