All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Tao Cui <cui.tao@linux.dev>
Cc: Bart Van Assche <bvanassche@acm.org>,
	axboe@kernel.dk, hch@lst.de,
	 Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	cuitao@kylinos.cn, linux-block@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] loop: defer the queue limits clear to a workqueue
Date: Mon, 5 Oct 2026 16:04:46 +0200	[thread overview]
Message-ID: <asOt_idu0XzUackX@shinmob> (raw)
In-Reply-To: <20260928093512.3153646-1-cui.tao@linux.dev>

On Sep 28, 2026 / 17:35, Tao Cui wrote:
> From: Tao Cui <cuitao@kylinos.cn>
> 
> 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 around the limits update.  The pending
> modes live under a new mutex, lo->clear_limits_lock.
> loop_change_fd() and __loop_clr_fd() cancel the work item before
> changing or dropping the backing file, and loop_assign_backing_file()
> resets the modes, so a stale clear cannot hit the new backing file.
> The work item is also cancelled before the device is freed.
> 
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>

FYI, blktests CI observed the failure of loop/011 test case with this patch:

  loop/011 (Make sure unsupported backing file fallocate does not fill dmesg with errors) [failed]
      runtime    ...  0.737s
      --- tests/loop/011.out	2026-10-05 09:59:42.755411625 +0000
      +++ /home/runner/blktests/results/nodev/loop/011.out.bad	2026-10-05 10:42:15.607566132 +0000
      @@ -1,3 +1,3 @@
       Running loop/011
      -Found 1 error(s) in dmesg
      +Found 2 error(s) in dmesg
       Test complete

      parent reply	other threads:[~2026-10-05 14:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  9:35 [PATCH v6] loop: defer the queue limits clear to a workqueue Tao Cui
2026-09-28 17:26 ` Bart Van Assche
2026-09-29  2:08   ` Tao Cui
2026-10-05 14:04 ` 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=asOt_idu0XzUackX@shinmob \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --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 \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.