On Mon, 12 Aug 2013 14:33:02 +0300, Ilya Dryomov wrote:
> Currently btrfs_device is allocated ad-hoc in a few different places,
> and as a result not all fields are initialized properly. In particular,
> readahead state is only initialized in device_list_add (at scan time),
> and not in btrfs_init_new_device (when the new device is added with
> 'btrfs dev add'). Fix this by adding an allocation helper and switch
> everybody but __btrfs_close_devices to it. (__btrfs_close_devices is
> dealt with in a later commit.)
>
> Signed-off-by: Ilya Dryomov <idryomov@xxxxxxxxx>
> ---
> fs/btrfs/volumes.c | 150 ++++++++++++++++++++++++++++++++--------------------
> fs/btrfs/volumes.h | 3 ++
> 2 files changed, 96 insertions(+), 57 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index ae1bcb0..fe52704 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
[...]
> @@ -2142,9 +2133,9 @@ int btrfs_init_dev_replace_tgtdev(struct btrfs_root *root, char *device_path,
> }
> }
>
> - device = kzalloc(sizeof(*device), GFP_NOFS);
> - if (!device) {
> - ret = -ENOMEM;
> + device = btrfs_alloc_device(NULL, BTRFS_DEV_REPLACE_DEVID, NULL);
> + if (IS_ERR(device)) {
> + ret = PTR_ERR(device);
BTRFS_DEV_REPLACE_DEVID is not a "const u64 *devid".
> +struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
> + const u64 *devid,
> + const u8 *uuid)
> +{
> + struct btrfs_device *dev;
> + u64 tmp;
> +
> + if (!devid && !fs_info) {
> + WARN_ON(1);
> + return ERR_PTR(-EINVAL);
> + }
This WARN_ON(1) is triggered with the device replace procedure because
BTRFS_DEV_REPLACE_DEVID is zero.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html