From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Nilay Shroff <nilay@linux.ibm.com>,
Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH v2 0/2] loop: Fix teardown
Date: Thu, 17 Sep 2026 14:20:24 -0700 [thread overview]
Message-ID: <cover.1789679858.git.bvanassche@acm.org> (raw)
Hi Jens,
This series fixes loop driver teardown. When tearing down an autoclear loop
device, the loop driver must drain in-flight I/O and flush workqueues to
prevent NULL pointer dereferences in lo_rw_aio() and related I/O paths.
The .release() block device callback is invoked while holding
disk->open_mutex. Freezing the request queue or draining workqueues under
disk->open_mutex causes lock inversion and circular locking dependencies
(e.g., when worker threads or I/O completion paths also acquire open_mutex
or interact with request queue synchronization).
This patch series resolves the lock inversion by:
1. Adding a .post_release() block device operation that is called
synchronously from bdev_release() immediately after disk->open_mutex
is released.
2. Migrating __loop_clr_fd() to .post_release(), allowing loop device
teardown and queue freezing to happen outside of disk->open_mutex.
This series is inspired by Tetsuo's loop driver patch series.
Please consider applying this patch series.
Thanks,
Bart.
Bart Van Assche (1):
loop: Perform __loop_clr_fd() after disk->open_mutex is dropped
Tetsuo Handa (1):
block: Add post_release() operation
block/bdev.c | 3 ++
drivers/block/loop.c | 60 +++++++++++++++++++++++---------
include/linux/blkdev.h | 8 +++++
rust/kernel/block/mq/gen_disk.rs | 1 +
4 files changed, 56 insertions(+), 16 deletions(-)
next reply other threads:[~2026-09-17 21:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 21:20 Bart Van Assche [this message]
2026-09-17 21:20 ` [PATCH v2 1/2] block: Add post_release() operation Bart Van Assche
2026-09-17 21:20 ` [PATCH v2 2/2] loop: Perform __loop_clr_fd() after disk->open_mutex is dropped 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=cover.1789679858.git.bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--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.