aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2012-12-06 14:25:48 -0500
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:21 -0500
commitb8b8ff590f99678616f9ea85f5088542d1cfc0be (patch)
treeef60815d6542627f3b60b914b5528cdb0ae5c244 /fs
parentac6a2b36f9fcfbe4865550afb6d333dec6b57578 (diff)
btrfs: Notify udev when removing device
Currently udev does not know about the device being removed from the file system. This may result in the situation where we're unable to mount the file system by UUID or by LABEL because the by-uuid and by-label links may still point to the device which is no longer part of the btrfs file system and hence does not have any btrfs super block. It can be easily reproduced by the following: mkfs.btrfs -L bugfs /dev/loop[0-6] mount /dev/loop0 /mnt/test btrfs device delete /dev/loop0 /mnt/test umount /mnt/test mount LABEL=bugfs /mnt/test <---- this fails then see: ls -l /dev/disk/by-label/bugfs which will still point to the /dev/loop0 We did not noticed this before because libblkid would send the udev event for us when it notice that the link does not fit the reality, however it does not do that anymore and completely relies on udev information. Fix this by sending the KOBJ_CHANGE event to the bdev kobject after successful device removal. Note that this does not affect device addition, because we will open the device prior the addition from userspace and udev will notice that and reread the device afterwards. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/volumes.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0b1b7e22e7ea..886f4ba0f71d 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -72,6 +72,19 @@ static void free_fs_devices(struct btrfs_fs_devices *fs_devices)
72 kfree(fs_devices); 72 kfree(fs_devices);
73} 73}
74 74
75static void btrfs_kobject_uevent(struct block_device *bdev,
76 enum kobject_action action)
77{
78 int ret;
79
80 ret = kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, action);
81 if (ret)
82 pr_warn("Sending event '%d' to kobject: '%s' (%p): failed\n",
83 action,
84 kobject_name(&disk_to_dev(bdev->bd_disk)->kobj),
85 &disk_to_dev(bdev->bd_disk)->kobj);
86}
87
75void btrfs_cleanup_fs_uuids(void) 88void btrfs_cleanup_fs_uuids(void)
76{ 89{
77 struct btrfs_fs_devices *fs_devices; 90 struct btrfs_fs_devices *fs_devices;
@@ -1542,6 +1555,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1542 1555
1543 ret = 0; 1556 ret = 0;
1544 1557
1558 /* Notify udev that device has changed */
1559 btrfs_kobject_uevent(bdev, KOBJ_CHANGE);
1560
1545error_brelse: 1561error_brelse:
1546 brelse(bh); 1562 brelse(bh);
1547 if (bdev) 1563 if (bdev)