Skip to content

Commit 5e3283e

Browse files
jthornbersnitm
authored andcommitted
dm thin: irqsave must always be used with the pool->lock spinlock
Commit c140e1c ("dm thin: use per thin device deferred bio lists") incorrectly stopped disabling irqs when taking the pool's spinlock. Irqs must be disabled when taking the pool's spinlock otherwise a thread could spin_lock(), then get interrupted to service thin_endio() in interrupt context, which would then deadlock in spin_lock_irqsave(). Signed-off-by: Joe Thornber <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 0596661 commit 5e3283e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/md/dm-thin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
31013101
struct thin_c *tc;
31023102
struct dm_dev *pool_dev, *origin_dev;
31033103
struct mapped_device *pool_md;
3104+
unsigned long flags;
31043105

31053106
mutex_lock(&dm_thin_pool_table.mutex);
31063107

@@ -3191,9 +3192,9 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
31913192

31923193
mutex_unlock(&dm_thin_pool_table.mutex);
31933194

3194-
spin_lock(&tc->pool->lock);
3195+
spin_lock_irqsave(&tc->pool->lock, flags);
31953196
list_add_tail_rcu(&tc->list, &tc->pool->active_thins);
3196-
spin_unlock(&tc->pool->lock);
3197+
spin_unlock_irqrestore(&tc->pool->lock, flags);
31973198
/*
31983199
* This synchronize_rcu() call is needed here otherwise we risk a
31993200
* wake_worker() call finding no bios to process (because the newly

0 commit comments

Comments
 (0)