diff options
author | David Sterba <dsterba@suse.com> | 2018-11-06 16:49:57 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-11-06 16:49:57 +0100 |
commit | b0ed122617a67a50fadc54dc867df6b3c4d9e184 (patch) | |
tree | de9e6ee30d518a217b9479df4079c679aaed0089 /fs/btrfs | |
parent | 3e92948109ab653f6a9648e958b5702aa6a9efa7 (diff) | |
parent | cb6358164b7b60ce0bc650a450ed2e5a88b17d4c (diff) | |
download | linux-next-b0ed122617a67a50fadc54dc867df6b3c4d9e184.tar.gz |
Merge branch 'ext/anand/harden-dev-rename' into for-next-next-v4.20-20181106
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/volumes.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1e7f99d4b1cf..0fb123bb53e2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -850,6 +850,29 @@ static noinline struct btrfs_device *device_list_add(const char *path, return ERR_PTR(-EEXIST); } + /* + * we are going to replace the device path, make sure its the + * same device if the device mounted + */ + if (device->bdev) { + struct block_device *path_bdev; + + path_bdev = lookup_bdev(path); + if (IS_ERR(path_bdev)) { + mutex_unlock(&fs_devices->device_list_mutex); + return ERR_CAST(path_bdev); + } + + if (device->bdev != path_bdev) { + bdput(path_bdev); + mutex_unlock(&fs_devices->device_list_mutex); + return ERR_PTR(-EEXIST); + } + bdput(path_bdev); + pr_info("BTRFS: device fsid:devid %pU:%llu old path:%s new path:%s\n", + disk_super->fsid, devid, rcu_str_deref(device->name), path); + } + name = rcu_string_strdup(path, GFP_NOFS); if (!name) { mutex_unlock(&fs_devices->device_list_mutex); |