generate "change" uevent for loop device
Recent udev versions probe loop devices for filesystems meaning that the /dev/disk hierarchy may contain useful entries such as $ ls -l /dev/disk/by-label/Fedora-12-x86_64-Live lrwxrwxrwx 1 root root 11 Mar 11 13:41 /dev/disk/by-label/Fedora-12-x86_64-Live -> ../../loop0 Unfortunately, no "change" uevent is generated when the loop device is detached so the symlink persists. Additionally, no "change" uevent is guaranteed to be generated when attaching an fd or changing capacity. For example, user space could open the loop device O_RDONLY (in fact, recent util-linux-ng does this) so udev's OPTIONS+="watch" machinery may not trigger the "change" uevent. This patch ensures that the "change" uevent is generated in all of these cases. As a result, the /dev/disk hierarchy works as expected for loop devices. Signed-off-by: David Zeuthen <davidz@redhat.com> Acked-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Родитель
6245838fe4
Коммит
c3473c6354
|
@ -835,6 +835,8 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
|
|||
|
||||
set_capacity(lo->lo_disk, size);
|
||||
bd_set_size(bdev, size << 9);
|
||||
/* let user-space know about the new size */
|
||||
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
|
||||
|
||||
set_blocksize(bdev, lo_blocksize);
|
||||
|
||||
|
@ -858,6 +860,7 @@ out_clr:
|
|||
set_capacity(lo->lo_disk, 0);
|
||||
invalidate_bdev(bdev);
|
||||
bd_set_size(bdev, 0);
|
||||
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
|
||||
mapping_set_gfp_mask(mapping, lo->old_gfp_mask);
|
||||
lo->lo_state = Lo_unbound;
|
||||
out_putf:
|
||||
|
@ -944,8 +947,11 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
|
|||
if (bdev)
|
||||
invalidate_bdev(bdev);
|
||||
set_capacity(lo->lo_disk, 0);
|
||||
if (bdev)
|
||||
if (bdev) {
|
||||
bd_set_size(bdev, 0);
|
||||
/* let user-space know about this change */
|
||||
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
|
||||
}
|
||||
mapping_set_gfp_mask(filp->f_mapping, gfp);
|
||||
lo->lo_state = Lo_unbound;
|
||||
/* This is safe: open() is still holding a reference. */
|
||||
|
@ -1189,6 +1195,8 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev)
|
|||
sz <<= 9;
|
||||
mutex_lock(&bdev->bd_mutex);
|
||||
bd_set_size(bdev, sz);
|
||||
/* let user-space know about the new size */
|
||||
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
|
||||
mutex_unlock(&bdev->bd_mutex);
|
||||
|
||||
out:
|
||||
|
|
Загрузка…
Ссылка в новой задаче