[PATCH 2/2] block: set QUEUE_FLAG_NO_ELV_SWITCH under the read lock in del_gendisk()
Nilay Shroff
nilay at linux.ibm.com
Mon Nov 2 21:53:59 PST 2026
On 11/2/26 11:44 AM, Qiliang Yuan wrote:
> del_gendisk() takes the tag set's update_nr_hwq_lock for write to set
> QUEUE_FLAG_NO_ELV_SWITCH, then for read around __del_gendisk(). The
> write lock was there to wait for elevator switches from sysfs, which
> held the lock for read when the flag was added.
>
> When several disks of one tag set are deleted at once, as nvme does for
> the namespaces of a controller, each write lock waits for the other
> disks to get through __del_gendisk() under the read lock, and the
> deletions run one after another.
>
> Elevator switches from sysfs have taken update_nr_hwq_lock for write
> since commit 4ff58d6bc9dd4 ("block: serialize elevator changes for the
> same queue using a writer lock"), as updates of nr_hw_queues do. Set the
> flag under the read lock instead, which still waits for both and keeps
> them out.
Currently, there's a patch[1] in-review to change update_nr_hwq_lock from
write to read while switching elevator.
So the proposal in this patch may not work out if the changes in patch[1]
are accepted. I understand your proposed patchset but I'd recommend wait a
bit till we settle with the patch[1].
[1] https://lore.kernel.org/all/20261031044141.5569-1-laveeshb@laveeshbansal.com/
Thanks,
--Nilay
More information about the Linux-nvme
mailing list