Skip to content

Commit c50747a

Browse files
bvanasschegregkh
authored andcommitted
blk-zoned: Fix a lockdep complaint about recursive locking
commit 198f36f upstream. If preparing a write bio fails then blk_zone_wplug_bio_work() calls bio_endio() with zwplug->lock held. If a device mapper driver is stacked on top of the zoned block device then this results in nested locking of zwplug->lock. The resulting lockdep complaint is a false positive because this is nested locking and not recursive locking. Suppress this false positive by calling blk_zone_wplug_bio_io_error() without holding zwplug->lock. This is safe because no code in blk_zone_wplug_bio_io_error() depends on zwplug->lock being held. This patch suppresses the following lockdep complaint: WARNING: possible recursive locking detected -------------------------------------------- kworker/3:0H/46 is trying to acquire lock: ffffff882968b830 (&zwplug->lock){-...}-{2:2}, at: blk_zone_write_plug_bio_endio+0x64/0x1f0 but task is already holding lock: ffffff88315bc230 (&zwplug->lock){-...}-{2:2}, at: blk_zone_wplug_bio_work+0x8c/0x48c other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&zwplug->lock); lock(&zwplug->lock); *** DEADLOCK *** May be due to missing lock nesting notation 3 locks held by kworker/3:0H/46: #0: ffffff8809486758 ((wq_completion)sdd_zwplugs){+.+.}-{0:0}, at: process_one_work+0x1bc/0x65c #1: ffffffc085de3d70 ((work_completion)(&zwplug->bio_work)){+.+.}-{0:0}, at: process_one_work+0x1e4/0x65c #2: ffffff88315bc230 (&zwplug->lock){-...}-{2:2}, at: blk_zone_wplug_bio_work+0x8c/0x48c stack backtrace: CPU: 3 UID: 0 PID: 46 Comm: kworker/3:0H Tainted: G W OE 6.12.38-android16-5-maybe-dirty-4k #1 8b362b6f76e3645a58cd27d86982bce10d150025 Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE Hardware name: Spacecraft board based on MALIBU (DT) Workqueue: sdd_zwplugs blk_zone_wplug_bio_work Call trace: dump_backtrace+0xfc/0x17c show_stack+0x18/0x28 dump_stack_lvl+0x40/0xa0 dump_stack+0x18/0x24 print_deadlock_bug+0x38c/0x398 __lock_acquire+0x13e8/0x2e1c lock_acquire+0x134/0x2b4 _raw_spin_lock_irqsave+0x5c/0x80 blk_zone_write_plug_bio_endio+0x64/0x1f0 bio_endio+0x9c/0x240 __dm_io_complete+0x214/0x260 clone_endio+0xe8/0x214 bio_endio+0x218/0x240 blk_zone_wplug_bio_work+0x204/0x48c process_one_work+0x26c/0x65c worker_thread+0x33c/0x498 kthread+0x110/0x134 ret_from_fork+0x10/0x20 Cc: [email protected] Cc: Damien Le Moal <[email protected]> Cc: Christoph Hellwig <[email protected]> Fixes: dd291d7 ("block: Introduce zone write plugging") Signed-off-by: Bart Van Assche <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 07b367f commit c50747a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

block/blk-zoned.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,28 +1281,29 @@ static void blk_zone_wplug_bio_work(struct work_struct *work)
12811281
struct block_device *bdev;
12821282
unsigned long flags;
12831283
struct bio *bio;
1284+
bool prepared;
12841285

12851286
/*
12861287
* Submit the next plugged BIO. If we do not have any, clear
12871288
* the plugged flag.
12881289
*/
1289-
spin_lock_irqsave(&zwplug->lock, flags);
1290-
12911290
again:
1291+
spin_lock_irqsave(&zwplug->lock, flags);
12921292
bio = bio_list_pop(&zwplug->bio_list);
12931293
if (!bio) {
12941294
zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED;
12951295
spin_unlock_irqrestore(&zwplug->lock, flags);
12961296
goto put_zwplug;
12971297
}
12981298

1299-
if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
1299+
prepared = blk_zone_wplug_prepare_bio(zwplug, bio);
1300+
spin_unlock_irqrestore(&zwplug->lock, flags);
1301+
1302+
if (!prepared) {
13001303
blk_zone_wplug_bio_io_error(zwplug, bio);
13011304
goto again;
13021305
}
13031306

1304-
spin_unlock_irqrestore(&zwplug->lock, flags);
1305-
13061307
bdev = bio->bi_bdev;
13071308

13081309
/*

0 commit comments

Comments
 (0)