mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
Since commit4ff58d6bc9("block: serialize elevator changes for the same queue using a writer lock"), a write to queue/scheduler fails with -EBUSY whenever something else holds set->update_nr_hwq_lock. That commit takes the lock for write, and it has to be a trylock because of commitce8ee8583e("block: use trylock to avoid lockdep circular dependency in sysfs"). The lock covers the whole tag set, so it is easy to hit. A scheduler write fails while another queue of the set is switching, or while a sibling disk of the same SCSI host or NVMe controller is added or removed. This matches the udev failures reported on 7.2. Go back to taking the lock for read. The write lock was there to keep two switches of one queue from overlapping in elevator_change_done(), which touches the elevator sysfs and debugfs entries outside of q->elevator_lock. Use QUEUE_FLAG_NO_ELV_SWITCH for that instead: a write sets it before elevator_change() and clears it afterwards, and a write that finds it set returns -EBUSY. Disk removal already sets the flag under the write lock, so no switch can start once it has run. Writes to the same queue, and writes that race with an nr_hw_queues update, an nr_requests write or disk removal, can still get -EBUSY, as with4ff58d6bc9. A write to a disk that is being removed now gets -EBUSY instead of -ENOENT. Fixes:4ff58d6bc9("block: serialize elevator changes for the same queue using a writer lock") Cc: [email protected] # v7.2+ Reported-by: Reindl Harald <[email protected]> Closes: https://lore.kernel.org/r/[email protected] Suggested-by: Nilay Shroff <[email protected]> Assisted-by: LLM Signed-off-by: Laveesh Bansal <[email protected]> Reviewed-by: Nilay Shroff <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jens Axboe <[email protected]>