From: Stefan Behrens <sbehrens@giantdisaster.de>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <chris.mason@fusionio.com>
Subject: Re: [PATCH 2/4] Btrfs: add btrfs_alloc_device and switch to it
Date: Fri, 23 Aug 2013 09:35:03 +0200 [thread overview]
Message-ID: <521710A7.3050401@giantdisaster.de> (raw)
In-Reply-To: <1376307184-7175-3-git-send-email-idryomov@gmail.com>
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@gmail.com>
> ---
> 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.
next prev parent reply other threads:[~2013-08-23 7:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-12 11:33 [PATCH 0/4] btrfs_device fixes Ilya Dryomov
2013-08-12 11:33 ` [PATCH 1/4] Btrfs: find_next_devid: root -> fs_info Ilya Dryomov
2013-08-12 11:33 ` [PATCH 2/4] Btrfs: add btrfs_alloc_device and switch to it Ilya Dryomov
2013-08-23 7:35 ` Stefan Behrens [this message]
2013-08-23 8:57 ` Ilya Dryomov
2013-08-12 11:33 ` [PATCH 3/4] Btrfs: add alloc_fs_devices " Ilya Dryomov
2013-08-12 11:33 ` [PATCH 4/4] Btrfs: rollback btrfs_device fields on umount Ilya Dryomov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=521710A7.3050401@giantdisaster.de \
--to=sbehrens@giantdisaster.de \
--cc=chris.mason@fusionio.com \
--cc=idryomov@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).