summaryrefslogtreecommitdiff
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorGu Jinxiang <gujx@cn.fujitsu.com>2018-07-12 14:23:16 +0800
committerDavid Sterba <dsterba@suse.com>2018-08-06 13:12:48 +0200
commit36350e95a2b1feed6382fe38cc80f79ec35a1323 (patch)
tree251ce4ef0286301593c2ca0e16e04de144368697 /fs/btrfs/volumes.c
parentd64dcbd183abab251beb0fa0acd81a772a09887e (diff)
btrfs: return device pointer from btrfs_scan_one_device
Return device pointer (with the IS_ERR semantics) from btrfs_scan_one_device so we don't have to return in through pointer. And since btrfs_fs_devices can be obtained from btrfs_device, return that. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> [ fixed conflics after recent changes to btrfs_scan_one_device ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 459cc2a2a31c..fd9d4e056b37 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1213,15 +1213,14 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr,
* and we are not allowed to call set_blocksize during the scan. The superblock
* is read via pagecache
*/
-int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
- struct btrfs_fs_devices **fs_devices_ret)
+struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
+ void *holder)
{
struct btrfs_super_block *disk_super;
bool new_device_added = false;
- struct btrfs_device *device;
+ struct btrfs_device *device = NULL;
struct block_device *bdev;
struct page *page;
- int ret = 0;
u64 bytenr;
lockdep_assert_held(&uuid_mutex);
@@ -1237,18 +1236,15 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
bdev = blkdev_get_by_path(path, flags, holder);
if (IS_ERR(bdev))
- return PTR_ERR(bdev);
+ return ERR_CAST(bdev);
if (btrfs_read_disk_super(bdev, bytenr, &page, &disk_super)) {
- ret = -EINVAL;
+ device = ERR_PTR(-EINVAL);
goto error_bdev_put;
}
device = device_list_add(path, disk_super, &new_device_added);
- if (IS_ERR(device)) {
- ret = PTR_ERR(device);
- } else {
- *fs_devices_ret = device->fs_devices;
+ if (!IS_ERR(device)) {
if (new_device_added)
btrfs_free_stale_devices(path, device);
}
@@ -1258,7 +1254,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
error_bdev_put:
blkdev_put(bdev, flags);
- return ret;
+ return device;
}
static int contains_pending_extent(struct btrfs_transaction *transaction,