Skip to content

Commit bb430b6

Browse files
alyssaisaxboe
authored andcommitted
loop: LOOP_CONFIGURE: send uevents for partitions
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 <[email protected]> [hch: reduced the critical section] Signed-off-by: Christoph Hellwig <[email protected]> Fixes: 3448914 ("loop: Add LOOP_CONFIGURE ioctl") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent f915da0 commit bb430b6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/block/loop.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
10101010
/* This is safe, since we have a reference from open(). */
10111011
__module_get(THIS_MODULE);
10121012

1013-
/* suppress uevents while reconfiguring the device */
1014-
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 1);
1015-
10161013
/*
10171014
* If we don't hold exclusive handle for the device, upgrade to it
10181015
* here to avoid changing device under exclusive owner.
@@ -1067,6 +1064,9 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
10671064
}
10681065
}
10691066

1067+
/* suppress uevents while reconfiguring the device */
1068+
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 1);
1069+
10701070
disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
10711071
set_disk_ro(lo->lo_disk, (lo->lo_flags & LO_FLAGS_READ_ONLY) != 0);
10721072

@@ -1109,17 +1109,17 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
11091109
if (partscan)
11101110
clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
11111111

1112+
/* enable and uncork uevent now that we are done */
1113+
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
1114+
11121115
loop_global_unlock(lo, is_loop);
11131116
if (partscan)
11141117
loop_reread_partitions(lo);
1118+
11151119
if (!(mode & FMODE_EXCL))
11161120
bd_abort_claiming(bdev, loop_configure);
11171121

1118-
error = 0;
1119-
done:
1120-
/* enable and uncork uevent now that we are done */
1121-
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
1122-
return error;
1122+
return 0;
11231123

11241124
out_unlock:
11251125
loop_global_unlock(lo, is_loop);
@@ -1130,7 +1130,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
11301130
fput(file);
11311131
/* This is safe: open() is still holding a reference. */
11321132
module_put(THIS_MODULE);
1133-
goto done;
1133+
return error;
11341134
}
11351135

11361136
static void __loop_clr_fd(struct loop_device *lo, bool release)

0 commit comments

Comments
 (0)