linux-stable/drivers/block
Alyssa Ross b106f0f7af loop: LOOP_CONFIGURE: send uevents for partitions
[ Upstream commit bb430b6942 ]

LOOP_CONFIGURE is, as far as I understand it, supposed to be a way to
combine LOOP_SET_FD and LOOP_SET_STATUS64 into a single syscall.  When
using LOOP_SET_FD+LOOP_SET_STATUS64, a single uevent would be sent for
each partition found on the loop device after the second ioctl(), but
when using LOOP_CONFIGURE, no such uevent was being sent.

In the old setup, uevents are disabled for LOOP_SET_FD, but not for
LOOP_SET_STATUS64.  This makes sense, as it prevents uevents being
sent for a partially configured device during LOOP_SET_FD - they're
only sent at the end of LOOP_SET_STATUS64.  But for LOOP_CONFIGURE,
uevents were disabled for the entire operation, so that final
notification was never issued.  To fix this, reduce the critical
section to exclude the loop_reread_partitions() call, which causes
the uevents to be issued, to after uevents are re-enabled, matching
the behaviour of the LOOP_SET_FD+LOOP_SET_STATUS64 combination.

I noticed this because Busybox's losetup program recently changed from
using LOOP_SET_FD+LOOP_SET_STATUS64 to LOOP_CONFIGURE, and this broke
my setup, for which I want a notification from the kernel any time a
new partition becomes available.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
[hch: reduced the critical section]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Fixes: 3448914e8c ("loop: Add LOOP_CONFIGURE ioctl")
Link: https://lore.kernel.org/r/20230320125430.55367-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-06 12:12:37 +02:00
..
aoe driver core: make struct class.devnode() take a const * 2022-11-24 17:12:27 +01:00
drbd block-2023-01-06 2023-01-06 13:12:42 -08:00
mtip32xx block: move from strlcpy with unused retval to strscpy 2022-09-21 19:45:04 -06:00
null_blk block: null_blk: Fix handling of fake timeout request 2023-03-22 13:37:50 +01:00
paride block: Change the type of req_op() and bio_op() into enum req_op 2022-07-14 12:14:30 -06:00
rnbd block/rnbd-clt: fix wrong max ID in ida_alloc_max 2023-01-17 08:33:36 -07:00
xen-blkback xen: make remove callback of xen driver void returned 2022-12-15 16:06:10 +01:00
zram block: count 'ios' and 'sectors' when io is done for bio-based device 2023-03-22 13:37:50 +01:00
amiflop.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
ataflop.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
brd.c brd: use radix_tree_maybe_preload instead of radix_tree_preload 2023-03-10 09:29:57 +01:00
floppy.c floppy: Fix memory leak in do_floppy_init() 2022-12-04 18:03:41 +04:00
Kconfig Revert "pktcdvd: remove driver." 2023-01-04 14:44:13 -07:00
loop.c loop: LOOP_CONFIGURE: send uevents for partitions 2023-04-06 12:12:37 +02:00
Makefile Revert "pktcdvd: remove driver." 2023-01-04 14:44:13 -07:00
n64cart.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
nbd.c Treewide: Stop corrupting socket's task_frag 2022-12-19 17:28:49 -08:00
pktcdvd.c pktcdvd: check for NULL returna fter calling bio_split_to_limits() 2023-01-16 08:51:05 -07:00
ps3disk.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
ps3vram.c block: handle bio_split_to_limits() NULL return 2023-01-04 09:05:23 -07:00
rbd.c rbd: avoid use-after-free in do_rbd_add() when rbd_dev_create() fails 2023-03-10 09:29:47 +01:00
rbd_types.h libceph, rbd: replace zero-length array with flexible-array 2020-06-01 13:22:53 +02:00
sunvdc.c block: sunvdc: add check for mdesc_grab() returning NULL 2023-03-22 13:37:50 +01:00
swim.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
swim3.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00
swim_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ublk_drv.c block/io_uring: pass in issue_flags for uring_cmd task_work handling 2023-03-30 12:51:34 +02:00
virtio_blk.c virtio_blk: Fix signedness bug in virtblk_prep_rq() 2022-12-28 05:28:11 -05:00
xen-blkfront.c xen: branch for v6.2-rc4 2023-01-12 17:02:20 -06:00
z2ram.c block: remove blk_cleanup_disk 2022-06-28 06:33:15 -06:00