[PATCH] nvme-multipath: fix lockdep warning on shutdown
Hannes Reinecke
hare at suse.de
Fri Jan 24 00:29:32 PST 2025
On 1/24/25 08:14, hare at kernel.org wrote:
> From: Hannes Reinecke <hare at kernel.org>
>
> During shutdown of multipath devices lockdep complained about a
> potential circular locking:
>
> WARNING: possible circular locking dependency detected
> (udev-worker)/2792 is trying to acquire lock:
> ffff8881012a4348 ((wq_completion)kblockd){+.+.}-{0:0}, at: touch_wq_lockdep_map+0
> x26/0x90
>
> but task is already holding lock:
> ffff88811e4b7cc8 (&disk->open_mutex){+.+.}-{4:4}, at: bdev_release+0x61/0x1a0
> which lock already depends on the new lock.
>
> the existing dependency chain (in reverse order) is:
> -> #2 (&disk->open_mutex){+.+.}-{4:4}:
> __mutex_lock+0xa5/0xe00
> nvme_partition_scan_work+0x31/0x60
> process_scheduled_works+0x37c/0x6f0
> -> #1 ((work_completion)(&head->partition_scan_work)){+.+.}-{0:0}:
> process_scheduled_works+0x348/0x6f0
> worker_thread+0x127/0x2a0
> -> #0 ((wq_completion)kblockd){+.+.}-{0:0}:
> __lock_acquire+0x11f9/0x1790
> lock_acquire+0x245/0x2d0
> touch_wq_lockdep_map+0x3b/0x90
> __flush_work+0x240/0x4b0
> nvme_mpath_remove_disk+0x2b/0x50
> nvme_free_ns_head+0x19/0x90
>
> So the problem is that nvme_mpath_remove_disk() is called with the
> disk->open_mutex held, hence calling flush_work on partition_scan_work
> (which also will try to lock disk->open_mutex) will deadlock.
> Fix this by checking for NVME_NSHEAD_DISK_LIVE before trying to lock
> disk->open_mutex.
>
> Fixes: 1f021341eef4 ("nvme-multipath: defer partition scanning")
>
> Signed-off-by: Hannes Reinecke <hare at kernel.org>
> ---
> block/blk-ioprio.c | 6 ++++-
> drivers/nvme/host/multipath.c | 2 ++
> drivers/nvme/target/core.c | 42 +++++++++++++++----------------
> drivers/nvme/target/io-cmd-bdev.c | 9 +++++++
> 4 files changed, 37 insertions(+), 22 deletions(-)
>
Nice analysis, but wrong patch.
Please ignore.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list