summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2016-04-14 18:24:10 +0800
committerDavid Sterba <dsterba@suse.com>2016-05-04 09:52:44 +0200
commit8ed01abe7da6af62f2089da9a4c1fe839dc638f5 (patch)
treedfa4f934f163c593995b20a897df8d5872948b71 /fs
parentb5255456c529155730c837f8cfcea47e8feb85ca (diff)
downloadlinux-8ed01abe7da6af62f2089da9a4c1fe839dc638f5.tar.bz2
btrfs: s_bdev is not null after missing replace
Yauhen reported in the ML that s_bdev is null at mount, and s_bdev gets updated to some device when missing device is replaced, as because bdev is null for missing device, things gets matched up. Fix this by checking if s_bdev is set. I didn't want to completely remove updating s_bdev because the future multi device support at vfs layer may need it. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reported-by: Yauhen Kharuzhy <yauhen.kharuzhy@zavadatar.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/dev-replace.c3
-rw-r--r--fs/btrfs/volumes.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 5aebedf12b5f..c93eec9ca433 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -569,7 +569,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
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;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e43b01e438b1..41bc384f3483 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1848,7 +1848,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path, u64 devid)
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;
@@ -1996,7 +1997,8 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
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;