From: Su Yue <l@damenly.su>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: Move missing device handling in a dedicate function
Date: Wed, 12 Jan 2022 11:28:49 +0800 [thread overview]
Message-ID: <k0f5hbov.fsf@damenly.su> (raw)
In-Reply-To: <20220111160026.1900599-1-nborisov@suse.com>
On Tue 11 Jan 2022 at 18:00, Nikolay Borisov <nborisov@suse.com>
wrote:
> This simplifies the code flow in read_one_chunk and makes error
> handling
> when handling missing devices a bit simipler by reducing it to a
> single
> check if something went wrong. No functional changes.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/volumes.c | 39 +++++++++++++++++++++++++--------------
> 1 file changed, 25 insertions(+), 14 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index b07d382d53a8..7518ac5c28dc 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7060,6 +7060,27 @@ static void warn_32bit_meta_chunk(struct
> btrfs_fs_info *fs_info,
> }
> #endif
>
> +static struct btrfs_device *handle_missing_device(struct
> btrfs_fs_info *fs_info,
> + u64 devid, u8
> *uuid)
> +{
> + struct btrfs_device *dev;
> +
> + if (!btrfs_test_opt(fs_info, DEGRADED)) {
> + btrfs_report_missing_device(fs_info, devid, uuid,
> true);
> + return ERR_PTR(-ENOENT);
> + }
> +
> + dev = add_missing_dev(fs_info->fs_devices, devid, uuid);
> + if (IS_ERR(dev)) {
> + btrfs_err(fs_info, "failed to init missing dev
> %llu: %ld",
> + devid, PTR_ERR(dev));
> + return dev;
> + }
> + btrfs_report_missing_device(fs_info, devid, uuid, false);
> +
> + return dev;
> +}
> +
> static int read_one_chunk(struct btrfs_key *key, struct
> extent_buffer *leaf,
> struct btrfs_chunk *chunk)
> {
> @@ -7147,28 +7168,18 @@ static int read_one_chunk(struct
> btrfs_key *key, struct extent_buffer *leaf,
> BTRFS_UUID_SIZE);
> args.uuid = uuid;
> map->stripes[i].dev =
> btrfs_find_device(fs_info->fs_devices, &args);
> - if (!map->stripes[i].dev &&
> - !btrfs_test_opt(fs_info, DEGRADED)) {
> - free_extent_map(em);
> - btrfs_report_missing_device(fs_info,
> devid, uuid, true);
> - return -ENOENT;
> - }
> if (!map->stripes[i].dev) {
> - map->stripes[i].dev =
> -
> add_missing_dev(fs_info->fs_devices, devid,
> - uuid);
> + map->stripes[i].dev =
> handle_missing_device(fs_info,
> +
> devid, uuid);
> if (IS_ERR(map->stripes[i].dev)) {
> free_extent_map(em);
> - btrfs_err(fs_info,
> - "failed to init missing
> dev %llu: %ld",
> - devid,
> PTR_ERR(map->stripes[i].dev));
> return
> PTR_ERR(map->stripes[i].dev);
> +
>
No need for the blank line, I think.
Reviewed-by: Su Yue <l@damenly.su>
--
Su
> }
> - btrfs_report_missing_device(fs_info,
> devid, uuid, false);
> }
> +
> set_bit(BTRFS_DEV_STATE_IN_FS_METADATA,
> &(map->stripes[i].dev->dev_state));
> -
> }
>
> write_lock(&map_tree->lock);
next prev parent reply other threads:[~2022-01-12 3:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 16:00 [PATCH] btrfs: Move missing device handling in a dedicate function Nikolay Borisov
2022-01-12 3:28 ` Su Yue [this message]
2022-01-12 15:40 ` David Sterba
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=k0f5hbov.fsf@damenly.su \
--to=l@damenly.su \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.