loop: Fix teardown
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 0 repliesNew
- v12 patches 3 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | block: Add post_release() operationblock/ include/ rust/ | +12 | 0 replies | |
| 2/2 | loop: Perform __loop_clr_fd() after disk->open_mutex is droppeddrivers/ | +44 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] loop: Fix teardown
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(-)