|
@@ -2108,9 +2108,8 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev)
|
|
call_rcu(&tgtdev->rcu, free_device_rcu);
|
|
call_rcu(&tgtdev->rcu, free_device_rcu);
|
|
}
|
|
}
|
|
|
|
|
|
-static int btrfs_find_device_by_path(struct btrfs_fs_info *fs_info,
|
|
|
|
- const char *device_path,
|
|
|
|
- struct btrfs_device **device)
|
|
|
|
|
|
+static struct btrfs_device *btrfs_find_device_by_path(
|
|
|
|
+ struct btrfs_fs_info *fs_info, const char *device_path)
|
|
{
|
|
{
|
|
int ret = 0;
|
|
int ret = 0;
|
|
struct btrfs_super_block *disk_super;
|
|
struct btrfs_super_block *disk_super;
|
|
@@ -2118,21 +2117,21 @@ static int btrfs_find_device_by_path(struct btrfs_fs_info *fs_info,
|
|
u8 *dev_uuid;
|
|
u8 *dev_uuid;
|
|
struct block_device *bdev;
|
|
struct block_device *bdev;
|
|
struct buffer_head *bh;
|
|
struct buffer_head *bh;
|
|
|
|
+ struct btrfs_device *device;
|
|
|
|
|
|
- *device = NULL;
|
|
|
|
ret = btrfs_get_bdev_and_sb(device_path, FMODE_READ,
|
|
ret = btrfs_get_bdev_and_sb(device_path, FMODE_READ,
|
|
fs_info->bdev_holder, 0, &bdev, &bh);
|
|
fs_info->bdev_holder, 0, &bdev, &bh);
|
|
if (ret)
|
|
if (ret)
|
|
- return ret;
|
|
|
|
|
|
+ return ERR_PTR(ret);
|
|
disk_super = (struct btrfs_super_block *)bh->b_data;
|
|
disk_super = (struct btrfs_super_block *)bh->b_data;
|
|
devid = btrfs_stack_device_id(&disk_super->dev_item);
|
|
devid = btrfs_stack_device_id(&disk_super->dev_item);
|
|
dev_uuid = disk_super->dev_item.uuid;
|
|
dev_uuid = disk_super->dev_item.uuid;
|
|
- *device = btrfs_find_device(fs_info, devid, dev_uuid, disk_super->fsid);
|
|
|
|
|
|
+ device = btrfs_find_device(fs_info, devid, dev_uuid, disk_super->fsid);
|
|
brelse(bh);
|
|
brelse(bh);
|
|
- if (!*device)
|
|
|
|
- ret = -ENOENT;
|
|
|
|
|
|
+ if (!device)
|
|
|
|
+ device = ERR_PTR(-ENOENT);
|
|
blkdev_put(bdev, FMODE_READ);
|
|
blkdev_put(bdev, FMODE_READ);
|
|
- return ret;
|
|
|
|
|
|
+ return device;
|
|
}
|
|
}
|
|
|
|
|
|
int btrfs_find_device_missing_or_by_path(struct btrfs_fs_info *fs_info,
|
|
int btrfs_find_device_missing_or_by_path(struct btrfs_fs_info *fs_info,
|
|
@@ -2155,11 +2154,13 @@ int btrfs_find_device_missing_or_by_path(struct btrfs_fs_info *fs_info,
|
|
|
|
|
|
if (!*device)
|
|
if (!*device)
|
|
return BTRFS_ERROR_DEV_MISSING_NOT_FOUND;
|
|
return BTRFS_ERROR_DEV_MISSING_NOT_FOUND;
|
|
-
|
|
|
|
- return 0;
|
|
|
|
} else {
|
|
} else {
|
|
- return btrfs_find_device_by_path(fs_info, device_path, device);
|
|
|
|
|
|
+ *device = btrfs_find_device_by_path(fs_info, device_path);
|
|
|
|
+ if (IS_ERR(*device))
|
|
|
|
+ return PTR_ERR(*device);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|