[RFC PATCH v1 02/17] dm thin: avoid bio_set_dev under pool lock
Yu Kuai <[email protected]> Sun, 5 Jul 2026 03:51:09 +0800
| Newsgroups | org.kernel.vger.linux-bcache,dev.linux.lists.dm-devel,org.infradead.lists.linux-nvme,org.kernel.vger.cgroups,org.kernel.vger.linux-block |
|---|---|
| Message-ID | <[email protected]> |
From: Yu Kuai <[email protected]> bio_set_dev() is about to become explicitly sleepable because it can associate the bio with a blkg for the destination queue. pool_map() calls bio_set_dev() while holding pool->lock with interrupts disabled, which would be invalid once bio_set_dev() may sleep. The lock is not needed in this map path. The pool target is a singleton mapping and pool_map() only reads pt->data_dev, which is a target-private device reference acquired during construction and released during target destruction. It does not inspect or modify pool state protected by pool->lock. Remove the lock so the remap stays in the normal sleepable DM map context while the data device pointer remains stable for the table lifetime. Signed-off-by: Yu Kuai <[email protected]> --- 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; } -- 2.51.0