From: Bart Van Assche <bvanassche@acm.org>
To: Tao Cui <cui.tao@linux.dev>, axboe@kernel.dk, hch@lst.de
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Tao Cui <cuitao@kylinos.cn>
Subject: Re: [PATCH] loop: defer the queue limits clear to a workqueue
Date: Fri, 28 Aug 2026 09:34:43 -0700 [thread overview]
Message-ID: <638dd174-99ba-43d9-b379-5ade06982259@acm.org> (raw)
In-Reply-To: <20260828072004.273519-1-cui.tao@linux.dev>
On 8/28/26 12:20 AM, Tao Cui wrote:
> loop_clear_limits() calls queue_limits_commit_update() directly from
> the loop workqueue that processes the request. That does a
> non-atomic struct assignment to q->limits without freezing the queue,
> which races with lockless readers of q->limits on other CPUs - bio
> splitting reads max_hw_sectors, the discard path reads
> max_hw_discard_sectors - and can let them observe torn values. The
> trigger is a discard or write-zeroes request on a loop device whose
> backing file does not support the corresponding fallocate operation.
>
> The code already has an XXX comment saying this should move to a
> workqueue. Do that: schedule a work item on the system workqueue,
> where it is safe to freeze the queue and update the limits using
> queue_limits_commit_update_frozen(). Accumulate pending modes in
> lo->clear_limits_mode so that failures between scheduling and
> execution of the work item are not lost, and cancel the work item
> before the device is freed. If the device is reconfigured to a
> backing file that does support the operation in that window, the
> stale clear takes effect and discard is disabled until the next
> reconfiguration.
Please help with reviewing this patch, which seems more complete to me
than this patch:
https://lore.kernel.org/linux-block/c2ab2547-63b3-48cf-87c1-fc53219e360a@I-love.SAKURA.ne.jp/
Thanks,
Bart.
next prev parent reply other threads:[~2026-08-28 16:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 7:20 [PATCH] loop: defer the queue limits clear to a workqueue Tao Cui
2026-08-28 16:34 ` Bart Van Assche [this message]
2026-08-31 13:34 ` Tao Cui
2026-08-31 16:25 ` Bart Van Assche
2026-09-01 13:14 ` Tao Cui
2026-09-01 17:29 ` Bart Van Assche
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=638dd174-99ba-43d9-b379-5ade06982259@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=cui.tao@linux.dev \
--cc=cuitao@kylinos.cn \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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