ASSERT(list_empty(&src_device->resized_list));
tgt_device->commit_total_bytes = src_device->commit_total_bytes;
tgt_device->commit_bytes_used = src_device->bytes_used;
- if (fs_info->sb->s_bdev == src_device->bdev)
+ if (fs_info->sb->s_bdev &&
+ (fs_info->sb->s_bdev == src_device->bdev))
fs_info->sb->s_bdev = tgt_device->bdev;
if (fs_info->fs_devices->latest_bdev == src_device->bdev)
fs_info->fs_devices->latest_bdev = tgt_device->bdev;
next_device = list_entry(root->fs_info->fs_devices->devices.next,
struct btrfs_device, dev_list);
- if (device->bdev == root->fs_info->sb->s_bdev)
+ if (root->fs_info->sb->s_bdev &&
+ (root->fs_info->sb->s_bdev == device->bdev))
root->fs_info->sb->s_bdev = next_device->bdev;
if (device->bdev == root->fs_info->fs_devices->latest_bdev)
root->fs_info->fs_devices->latest_bdev = next_device->bdev;
next_device = list_entry(fs_info->fs_devices->devices.next,
struct btrfs_device, dev_list);
- if (tgtdev->bdev == fs_info->sb->s_bdev)
+ if (fs_info->sb->s_bdev &&
+ (tgtdev->bdev == fs_info->sb->s_bdev))
fs_info->sb->s_bdev = next_device->bdev;
if (tgtdev->bdev == fs_info->fs_devices->latest_bdev)
fs_info->fs_devices->latest_bdev = next_device->bdev;