Skip to content

Commit e7bc001

Browse files
t-8chaxboe
authored andcommitted
loop: properly send KOBJ_CHANGED uevent for disk device
The original commit message and the wording "uncork" in the code comment indicate that it is expected that the suppressed event instances are automatically sent after unsuppressing. This is not the case, instead they are discarded. In effect this means that no "changed" events are emitted on the device itself by default. While each discovered partition does trigger a changed event on the device, devices without partitions don't have any event emitted. This makes udev miss the device creation and prompted workarounds in userspace. See the linked util-linux/losetup bug. Explicitly emit the events and drop the confusingly worded comments. Link: util-linux/util-linux#2434 Fixes: 498ef5c ("loop: suppress uevents while reconfiguring the device") Cc: stable@vger.kernel.org Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Link: https://lore.kernel.org/r/20250415-loop-uevent-changed-v2-1-0c4e6a923b2a@linutronix.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1fdb818 commit e7bc001

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/block/loop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
667667

668668
error = 0;
669669
done:
670-
/* enable and uncork uevent now that we are done */
671670
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
671+
kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE);
672672
return error;
673673

674674
out_err:
@@ -1129,8 +1129,8 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
11291129
if (partscan)
11301130
clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
11311131

1132-
/* enable and uncork uevent now that we are done */
11331132
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
1133+
kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE);
11341134

11351135
loop_global_unlock(lo, is_loop);
11361136
if (partscan)

0 commit comments

Comments
 (0)