linux-stable/block
Bart Van Assche 6ed86bb11d blk-zoned: Fix a lockdep complaint about recursive locking
commit 198f36f902 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: stable@vger.kernel.org
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Fixes: dd291d77cc ("block: Introduce zone write plugging")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20250825182720.1697203-1-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-04 16:55:46 +02:00
..
partitions
badblocks.c
bdev.c xfs: New code for 6.16 2025-05-26 12:56:01 -07:00
bfq-cgroup.c
bfq-iosched.c block: move elevator queue allocation logic into blk_mq_init_sched 2025-08-28 16:34:50 +02:00
bfq-iosched.h lib/sbitmap: convert shallow_depth from one word to the whole sbitmap 2025-08-20 18:41:31 +02:00
bfq-wf2q.c
bio-integrity-auto.c
bio-integrity.c block: drop direction param from bio_integrity_copy_user() 2025-06-03 12:45:45 -06:00
bio.c for-6.16/block-20250523 2025-05-26 11:39:36 -07:00
blk-cgroup-fc-appid.c
blk-cgroup-rwstat.c
blk-cgroup-rwstat.h
blk-cgroup.c cgroup: Changes for v6.16 2025-05-27 20:59:53 -07:00
blk-cgroup.h
blk-core.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
blk-crypto-fallback.c
blk-crypto-internal.h
blk-crypto-profile.c
blk-crypto-sysfs.c
blk-crypto.c
blk-flush.c
blk-ia-ranges.c
blk-integrity.c block: flip iter directions in blk_rq_integrity_map_user() 2025-06-03 17:24:59 -06:00
blk-ioc.c
blk-iocost.c
blk-iolatency.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
blk-ioprio.c
blk-ioprio.h
blk-lib.c
blk-map.c
blk-merge.c block: use plug request list tail for one-shot backmerge attempt 2025-06-11 08:48:46 -06:00
blk-mq-cpumap.c
blk-mq-debugfs.c block: avoid cpu_hotplug_lock depedency on freeze_lock 2025-08-28 16:34:50 +02:00
blk-mq-debugfs.h
blk-mq-dma.c blk-mq: add a copyright notice to blk-mq-dma.c 2025-05-16 08:43:41 -06:00
blk-mq-sched.c block: fix potential deadlock while running nr_hw_queue update 2025-08-28 16:34:50 +02:00
blk-mq-sched.h block: fix potential deadlock while running nr_hw_queue update 2025-08-28 16:34:50 +02:00
blk-mq-sysfs.c
blk-mq-tag.c
blk-mq.c blk-mq: fix lockdep warning in __blk_mq_update_nr_hw_queues 2025-08-28 16:34:50 +02:00
blk-mq.h
blk-pm.c
blk-pm.h
blk-rq-qos.c block: avoid cpu_hotplug_lock depedency on freeze_lock 2025-08-28 16:34:50 +02:00
blk-rq-qos.h block: validate QoS before calling __rq_qos_done_bio() 2025-09-04 16:55:39 +02:00
blk-settings.c block: avoid possible overflow for chunk_sectors check in blk_stack_limits() 2025-08-20 18:41:32 +02:00
blk-stat.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
blk-stat.h
blk-sysfs.c block: restore default wbt enablement 2025-08-28 16:34:25 +02:00
blk-throttle.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
blk-throttle.h blk-throttle: Prevents the bps restricted io from entering the bps queue again 2025-05-13 12:08:27 -06:00
blk-timeout.c
blk-wbt.c for-6.16/block-20250523 2025-05-26 11:39:36 -07:00
blk-wbt.h
blk-zoned.c blk-zoned: Fix a lockdep complaint about recursive locking 2025-09-04 16:55:46 +02:00
blk.h block: fix potential deadlock while running nr_hw_queue update 2025-08-28 16:34:50 +02:00
bsg-lib.c
bsg.c
disk-events.c
early-lookup.c
elevator.c block: fix potential deadlock while running nr_hw_queue update 2025-08-28 16:34:50 +02:00
elevator.h block: fix lockdep warning caused by lock dependency in elv_iosched_store 2025-08-28 16:34:50 +02:00
fops.c
genhd.c block: fix kobject double initialization in add_disk 2025-08-20 18:41:33 +02:00
holder.c
ioctl.c
ioprio.c
Kconfig block: Remove obsolete configs BLK_MQ_{PCI,VIRTIO} 2025-05-14 05:43:56 -06:00
Kconfig.iosched
kyber-iosched.c block: move elevator queue allocation logic into blk_mq_init_sched 2025-08-28 16:34:50 +02:00
Makefile blk-mq: move the DMA mapping code to a separate file 2025-05-16 08:43:41 -06:00
mq-deadline.c block: move elevator queue allocation logic into blk_mq_init_sched 2025-08-28 16:34:50 +02:00
opal_proto.h
sed-opal.c
t10-pi.c