Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: dev add should add its sysfs entry

we would need the device links to be created,
when device is added.

Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>

authored by

Anand Jain and committed by
Chris Mason
0d39376a 99994cde

+16 -3
+9 -3
fs/btrfs/sysfs.c
··· 625 625 return 0; 626 626 } 627 627 628 - static int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info) 628 + int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info, 629 + struct btrfs_device *one_device) 629 630 { 630 631 int error = 0; 631 632 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; 632 633 struct btrfs_device *dev; 633 634 634 - fs_info->device_dir_kobj = kobject_create_and_add("devices", 635 + if (!fs_info->device_dir_kobj) 636 + fs_info->device_dir_kobj = kobject_create_and_add("devices", 635 637 &fs_info->super_kobj); 638 + 636 639 if (!fs_info->device_dir_kobj) 637 640 return -ENOMEM; 638 641 ··· 644 641 struct kobject *disk_kobj; 645 642 646 643 if (!dev->bdev) 644 + continue; 645 + 646 + if (one_device && one_device != dev) 647 647 continue; 648 648 649 649 disk = dev->bdev->bd_part; ··· 692 686 if (error) 693 687 goto failure; 694 688 695 - error = btrfs_kobj_add_device(fs_info); 689 + error = btrfs_kobj_add_device(fs_info, NULL); 696 690 if (error) 697 691 goto failure; 698 692
+2
fs/btrfs/sysfs.h
··· 66 66 extern const char * const btrfs_feature_set_names[3]; 67 67 extern struct kobj_type space_info_ktype; 68 68 extern struct kobj_type btrfs_raid_ktype; 69 + int btrfs_kobj_add_device(struct btrfs_fs_info *fs_info, 70 + struct btrfs_device *one_device); 69 71 int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info, 70 72 struct btrfs_device *one_device); 71 73 #endif /* _BTRFS_SYSFS_H_ */
+5
fs/btrfs/volumes.c
··· 2147 2147 total_bytes = btrfs_super_num_devices(root->fs_info->super_copy); 2148 2148 btrfs_set_super_num_devices(root->fs_info->super_copy, 2149 2149 total_bytes + 1); 2150 + 2151 + /* add sysfs device entry */ 2152 + btrfs_kobj_add_device(root->fs_info, device); 2153 + 2150 2154 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); 2151 2155 2152 2156 if (seeding_dev) { ··· 2213 2209 unlock_chunks(root); 2214 2210 btrfs_end_transaction(trans, root); 2215 2211 rcu_string_free(device->name); 2212 + btrfs_kobj_rm_device(root->fs_info, device); 2216 2213 kfree(device); 2217 2214 error: 2218 2215 blkdev_put(bdev, FMODE_EXCL);