From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Laveesh Bansal <laveeshb@laveeshbansal.com>
Cc: Jens Axboe <axboe@kernel.dk>, Nilay Shroff <nilay@linux.ibm.com>,
Ming Lei <tom.leiming@gmail.com>, Christoph Hellwig <hch@lst.de>,
Yu Kuai <yukuai@fygo.io>, Reindl Harald <h.reindl@thelounge.net>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: only serialize elevator switches of the same queue
Date: Sun, 25 Oct 2026 21:23:23 +0900 [thread overview]
Message-ID: <at3xNpJLZ1PeGKUA@shinmob> (raw)
In-Reply-To: <20261023201704.20577-1-laveeshb@laveeshbansal.com>
On Oct 23, 2026 / 13:17, Laveesh Bansal wrote:
> Since commit 4ff58d6bc9dd ("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
> commit ce8ee8583ed8 ("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. That is what breaks the udev rules that set the scheduler 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, so use a new mutex for that instead. It is held across
> elevator_change(), and only the sysfs store takes it. The other callers
> of elevator_change() run before the queue is registered, after its sysfs
> files are gone, or with the lock held for write, so they cannot race
> with the store.
>
> nr_hw_queues updates, nr_requests writes and disk removal still take the
> lock for write, so a scheduler write can still get -EBUSY while one of
> those holds or waits for it, as before 4ff58d6bc9dd.
>
> Fixes: 4ff58d6bc9dd ("block: serialize elevator changes for the same queue using a writer lock")
> Cc: stable@vger.kernel.org # v7.2+
> Reported-by: Reindl Harald <h.reindl@thelounge.net>
> Closes: https://lore.kernel.org/r/077dd42e-cbc9-4c23-a5ef-3d20e4fc7757@thelounge.net
> Assisted-by: LLM
> Signed-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
FYI, this patch looks similar as the RFC patch that I created before [*]. It
adds another mutex in similar manner as this patch.
[*] https://lore.kernel.org/linux-block/aiqaXfTqCLMu2DwF@fedora/
I ran whole blktests applying this patch on top of the kernel v7.3. I observed
no regression, then looks good from testing point of view. In case this patch
gets applied,
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
prev parent reply other threads:[~2026-10-25 12:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 20:17 Laveesh Bansal
2026-10-25 12:23 ` Shin'ichiro Kawasaki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=at3xNpJLZ1PeGKUA@shinmob \
--to=shinichiro.kawasaki@wdc.com \
--cc=axboe@kernel.dk \
--cc=h.reindl@thelounge.net \
--cc=hch@lst.de \
--cc=laveeshb@laveeshbansal.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--cc=tom.leiming@gmail.com \
--cc=yukuai@fygo.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®