aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Jain <Anand.Jain@oracle.com>2014-06-02 23:36:00 -0400
committerChris Mason <clm@fb.com>2014-06-28 16:48:42 -0400
commit99994cde9c59c2b8bb67d46d531b26cc73e39747 (patch)
tree5d676af068a4e365412f6fd615892dda91843b77
parent9b4eaf43f4b0207b5d1ca8b8d22df88ea9e142fe (diff)
btrfs: dev delete should remove sysfs entry
when we delete the device from the mounted btrfs, we would need its corresponding sysfs enty to be removed as well. Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/sysfs.c20
-rw-r--r--fs/btrfs/sysfs.h2
-rw-r--r--fs/btrfs/volumes.c4
3 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 1395efbffa2d..401677b11045 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -605,6 +605,26 @@ static void init_feature_attrs(void)
605 } 605 }
606} 606}
607 607
608int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
609 struct btrfs_device *one_device)
610{
611 struct hd_struct *disk;
612 struct kobject *disk_kobj;
613
614 if (!fs_info->device_dir_kobj)
615 return -EINVAL;
616
617 if (one_device) {
618 disk = one_device->bdev->bd_part;
619 disk_kobj = &part_to_dev(disk)->kobj;
620
621 sysfs_remove_link(fs_info->device_dir_kobj,
622 disk_kobj->name);
623 }
624
625 return 0;
626}
627
608static int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info) 628static int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info)
609{ 629{
610 int error = 0; 630 int error = 0;
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 9ab576318a84..529554e5f9de 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -66,4 +66,6 @@ char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
66extern const char * const btrfs_feature_set_names[3]; 66extern const char * const btrfs_feature_set_names[3];
67extern struct kobj_type space_info_ktype; 67extern struct kobj_type space_info_ktype;
68extern struct kobj_type btrfs_raid_ktype; 68extern struct kobj_type btrfs_raid_ktype;
69int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
70 struct btrfs_device *one_device);
69#endif /* _BTRFS_SYSFS_H_ */ 71#endif /* _BTRFS_SYSFS_H_ */
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c83b24251e53..be2c8e285afb 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -40,6 +40,7 @@
40#include "rcu-string.h" 40#include "rcu-string.h"
41#include "math.h" 41#include "math.h"
42#include "dev-replace.h" 42#include "dev-replace.h"
43#include "sysfs.h"
43 44
44static int init_first_rw_device(struct btrfs_trans_handle *trans, 45static int init_first_rw_device(struct btrfs_trans_handle *trans,
45 struct btrfs_root *root, 46 struct btrfs_root *root,
@@ -1680,6 +1681,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1680 if (device->bdev) 1681 if (device->bdev)
1681 device->fs_devices->open_devices--; 1682 device->fs_devices->open_devices--;
1682 1683
1684 /* remove sysfs entry */
1685 btrfs_kobj_rm_device(root->fs_info, device);
1686
1683 call_rcu(&device->rcu, free_device); 1687 call_rcu(&device->rcu, free_device);
1684 1688
1685 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; 1689 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1;