Re: [PATCH v3 2/2] nbd: drop stale partitions on NBD_CLEAR_SOCK

From: Bart Van Assche

Date: Thu Oct 22 2026 - 12:15:47 EST


On 10/22/26 6:31 AM, Daan De Meyer via B4 Relay wrote:
+ /*
+ * Drop the partitions of the disconnected device on the next open.
+ * They can exist even with max_part zero as they may have been added
+ * manually with BLKPG. Dropping them here is not possible as that
+ * needs open_mutex, which nbd_open() acquires under config_lock.
+ */

The lock order is reversed in this comment and also in the patch
description. The actual lock hierarchy is the reverse: bdev_open holds
disk->open_mutex when calling blkdev_get_whole -> nbd_open, so nbd_open
acquires config_lock under open_mutex (open_mutex -> nbd_index_mutex ->
config_lock), whereas nbd_clear_sock_ioctl is called with config_lock
held. The conclusion (cannot take open_mutex inside
nbd_clear_sock_ioctl) is still right.

Thanks,

Bart.