Centos-kernel-stream-9/drivers/block
Ming Lei 2fe5143e05 loop: use kiocb helpers to fix lockdep warning
JIRA: https://issues.redhat.com/browse/RHEL-104374

commit c4706c5058a7bd7d7c20f3b24a8f523ecad44e83
Author: Ming Lei <ming.lei@redhat.com>
Date:   Wed Jul 16 19:48:08 2025 +0800

    loop: use kiocb helpers to fix lockdep warning

    The lockdep tool can report a circular lock dependency warning in the loop
    driver's AIO read/write path:

    ```
    [ 6540.587728] kworker/u96:5/72779 is trying to acquire lock:
    [ 6540.593856] ff110001b5968440 (sb_writers#9){.+.+}-{0:0}, at: loop_process_work+0x11a/0xf70 [loop]
    [ 6540.603786]
    [ 6540.603786] but task is already holding lock:
    [ 6540.610291] ff110001b5968440 (sb_writers#9){.+.+}-{0:0}, at: loop_process_work+0x11a/0xf70 [loop]
    [ 6540.620210]
    [ 6540.620210] other info that might help us debug this:
    [ 6540.627499]  Possible unsafe locking scenario:
    [ 6540.627499]
    [ 6540.634110]        CPU0
    [ 6540.636841]        ----
    [ 6540.639574]   lock(sb_writers#9);
    [ 6540.643281]   lock(sb_writers#9);
    [ 6540.646988]
    [ 6540.646988]  *** DEADLOCK ***
    ```

    This patch fixes the issue by using the AIO-specific helpers
    `kiocb_start_write()` and `kiocb_end_write()`. These functions are
    designed to be used with a `kiocb` and manage write sequencing
    correctly for asynchronous I/O without introducing the problematic
    lock dependency.

    The `kiocb` is already part of the `loop_cmd` struct, so this change
    also simplifies the completion function `lo_rw_aio_do_completion()` by
    using the `iocb` from the `cmd` struct directly, instead of retrieving
    the loop device from the request queue.

    Fixes: 39d86db34e41 ("loop: add file_start_write() and file_end_write()")
    Cc: Changhui Zhong <czhong@redhat.com>
    Signed-off-by: Ming Lei <ming.lei@redhat.com>
    Link: https://lore.kernel.org/r/20250716114808.3159657-1-ming.lei@redhat.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Ming Lei <ming.lei@redhat.com>
2025-08-04 22:42:15 +08:00
..
aoe block: force noio scope in blk_mq_freeze_queue 2025-03-14 16:48:44 +08:00
drbd drbd: Remove unused conn_lowest_minor 2024-11-28 17:45:24 +08:00
mtip32xx block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00
null_blk block: change blk_mq_add_to_batch() third argument type to bool 2025-03-17 12:58:37 +08:00
paride
rnbd block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00
rsxx block: rsxx: switch to new queue limit API 2024-09-27 11:53:55 +08:00
xen-blkback
zram zram: fix potential UAF of zram table 2025-02-14 16:31:26 +08:00
Kconfig
Makefile
amiflop.c block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00
ataflop.c block: force noio scope in blk_mq_freeze_queue 2025-03-14 16:48:44 +08:00
brd.c brd: decrease the number of allocated pages which discarded 2025-03-14 16:48:28 +08:00
floppy.c block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00
loop.c loop: use kiocb helpers to fix lockdep warning 2025-08-04 22:42:15 +08:00
n64cart.c
nbd.c block: force noio scope in blk_mq_freeze_queue 2025-03-14 16:48:44 +08:00
pktcdvd.c pktcdvd: remove unnecessary debugfs_create_dir() error check 2024-11-28 17:34:11 +08:00
ps3disk.c ps3disk: Do not use dev->bounce_size before it is set 2025-03-14 16:48:37 +08:00
ps3vram.c
rbd.c block: force noio scope in blk_mq_freeze_queue 2025-03-14 16:48:44 +08:00
rbd_types.h
sunvdc.c drivers/block/sunvdc.c: update the correct AIP call 2025-03-14 16:48:44 +08:00
swim.c block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00
swim3.c block: force noio scope in blk_mq_freeze_queue 2025-03-14 16:48:44 +08:00
swim_asm.S
virtio_blk.c block: change blk_mq_add_to_batch() third argument type to bool 2025-03-17 12:58:37 +08:00
xen-blkfront.c block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00
z2ram.c block: remove BLK_MQ_F_SHOULD_MERGE 2025-03-14 16:48:35 +08:00