Linux block layer
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: Bart Van Assche <bvanassche@acm.org>,
	axboe@kernel.dk, hch@lst.de,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: cui.tao@linux.dev, cuitao@kylinos.cn,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: Re: [PATCH v7] loop: defer the queue limits clear to a workqueue
Date: Thu, 26 Nov 2026 10:09:22 +0800	[thread overview]
Message-ID: <a4f6abfa-0415-4b8b-bc5a-fb05c02ff7ac@linux.dev> (raw)
In-Reply-To: <f8d3056d-2950-428c-b5f3-c41b5fa10eb2@acm.org>

Hello, Bart,

在 2026/11/25 00:56, Bart Van Assche 写道:
> On 11/24/26 12:10 AM, Tao Cui wrote:
>> For v8, my plan is to stop deciding whether to quiet a request at
>> queue_rq() time and instead quiet repeated failures at the point of
>> failure. The verdicts remain recorded for the lifetime of the backing
>> file and are cleared only on rebind or unbind. loop_clear_limits()
>> reports whether a verdict is new, and repeated failures mark only
>> their own request quiet. That guarantees the first failure for each
>> mode is reported, regardless of how dispatch and queue freezing
>> interleave.
>>
>> [ ... ]
>>
>> Does this approach look reasonable to you? If so, I'll send the
>> already tested patch as v8.
> 
> That approach sounds reasonable to me. If the verdicts are kept for the
> lifetime of the backing file, I think the following simplifications are
> possible:
> - The clear_limits_pending member variable is no longer needed. The
>   work function can read the mask with the unsupported modes without
>   resetting it.
> - lo_fallocate() can return -EOPNOTSUPP without calling
>   file->f_op->fallocate() if the mode is already known to be
>   unsupported.
> 
Thanks.  v8 follows with all of this addressed.

Both are in: the work item reads the mask without resetting it, and
lo_fallocate() skips the fallocate probe when the mode is already
known to be unsupported.

> Tracking the verdicts per mode also fixes the following issue in v7:
> clear_limits_pending is not per mode, so a failed discard suppresses
> the error message for the first write-zeroes failure.
> 
Right.  The verdicts are per mode and stay recorded for the lifetime
of the backing file, so a failed discard no longer suppresses the
first write-zeroes report.
> A few more comments about v7 that also apply to v8:
> - loop_clear_limits() calls schedule_work() after clear_limits_lock has
>   been unlocked. Can a request that passed the lo->lo_backing_file
>   check queue the work item after cancel_work_sync() has been called
>   by __loop_clr_fd() or loop_remove()? Since lo_free_disk() no longer
>   cancels the work item, I think that would result in a use-after-free.
>   How about calling schedule_work() while holding clear_limits_lock and
>   resetting the state before calling cancel_work_sync() in
>   __loop_clr_fd()?
v8 does exactly that: schedule_work() now happens while
clear_limits_lock is held, and __loop_clr_fd() resets the verdicts
before calling cancel_work_sync().  A verdict that passes the
backing-file check queues the work item before the lock is released,
so the reset is ordered after any pending schedule and
cancel_work_sync() cannot miss it.  loop_remove() needs no
reordering: after __loop_clr_fd() has reset the verdicts no further
schedule can happen, so its cancel stays as the backstop it already
was.

> - The code that resets clear_limits_mode occurs three times. Please
>   introduce a helper function. Is the reset in
>   loop_assign_backing_file() needed since __loop_clr_fd() already
>   resets the state and since loop_clear_limits() ignores failures for
>   a backing file that is no longer current?
I dropped the reset in loop_assign_backing_file() instead of moving
it: since d4fabede1da0 ("loop: remove support for swapping loop fds")
its only caller is loop_configure(), which requires an unbound device,
so the verdicts are always zero there.  That leaves __loop_clr_fd()
as the only reset site, so there is no helper to add anymore.

> - The work function freezes the queue and commits the queue limits even
>   if no mode has been recorded. Please return early in that case.
> - The changelog for v7 is missing. Please include a "Changes since v7"
>   and a "Changes since v6" section in v8.
> 
Both done: the work item returns early when the verdicts are already
reset, and the changelog has both "Changes since v6" and "Changes
since v7" sections.

Re-tested after these changes: a concurrency sweep at 2, 4, 8, 16 and
32 threads logs exactly one error per run, whereas v7 starts reporting
duplicate errors at eight threads.  Sixty rounds of mkfs-kill/unbind
stress also completed without warnings.

Thanks,
Tao.

> Thanks,
> 
> Bart.


      reply	other threads:[~2026-11-26  2:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  3:12 [PATCH v7] loop: defer the queue limits clear to a workqueue Tao Cui
2026-11-24  8:10 ` Tao Cui
2026-11-24 16:56   ` Bart Van Assche
2026-11-26  2:09     ` Tao Cui [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=a4f6abfa-0415-4b8b-bc5a-fb05c02ff7ac@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=cuitao@kylinos.cn \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=shinichiro.kawasaki@wdc.com \
    /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