Skip to content

Commit 87fa3bb

Browse files
Liu Bomasoncl
authored andcommitted
Btrfs: fix regression of btrfs device replace
Commit 49c6f73( btrfs: dev replace should replace the sysfs entry) added the missing sysfs entry in the process of device replace, but didn't take missing devices into account, so now we have BUG: unable to handle kernel NULL pointer dereference at 0000000000000088 IP: [<ffffffffa0268551>] btrfs_kobj_rm_device+0x21/0x40 [btrfs] ... To reproduce it, 1. mkfs.btrfs -f disk1 disk2 2. mkfs.ext4 disk1 3. mount disk2 /mnt -odegraded 4. btrfs replace start -B 1 disk3 /mnt -------------------------- This fixes the problem. Reported-by: Chris Murphy <[email protected]> Signed-off-by: Liu Bo <[email protected]> Reviewed-by: Satoru Takeuchi <[email protected]> Tested-by: Satoru Takeuchi <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 9566997 commit 87fa3bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ int btrfs_kobj_rm_device(struct btrfs_fs_info *fs_info,
614614
if (!fs_info->device_dir_kobj)
615615
return -EINVAL;
616616

617-
if (one_device) {
617+
if (one_device && one_device->bdev) {
618618
disk = one_device->bdev->bd_part;
619619
disk_kobj = &part_to_dev(disk)->kobj;
620620

0 commit comments

Comments
 (0)