From: Josef Bacik <josef@toxicpanda.com>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC 3/4] btrfs: introduce dedicated helper to scrub simple-stripe based range
Date: Mon, 3 Jan 2022 11:33:25 -0500 [thread overview]
Message-ID: <YdMlVbcZ0EdjwqWr@localhost.localdomain> (raw)
In-Reply-To: <20211221023349.27696-4-wqu@suse.com>
On Tue, Dec 21, 2021 at 10:33:48AM +0800, Qu Wenruo wrote:
> The new entrance will iterate through each data stripe which belongs to
> the target device.
>
> And since inside each data stripe, RAID0 is just SINGLE, while RAID10 is
> just RAID1, we can reuse scrub_simple_mirror() to do the scrub properly.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/scrub.c | 60 +++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 57 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index ddd069bd2375..aff9db6fbc7e 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -3446,6 +3446,55 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,
> return ret;
> }
>
> +static int scrub_simple_stripe(struct scrub_ctx *sctx,
> + struct btrfs_root *extent_root,
> + struct btrfs_root *csum_root,
> + struct btrfs_block_group *bg,
> + struct map_lookup *map,
> + struct btrfs_device *device,
> + int stripe_index)
> +{
> + /* The increment of logical bytenr */
> + const u64 logical_increment = (map->num_stripes / map->sub_stripes) *
> + map->stripe_len;
> + /*
> + * Our starting logical bytenr needs to be calculated based on
> + * stripe_index.
> + *
> + * stripe_index / sub_stripes gives how many data stripes we need to
> + * skip.
> + */
> + const u64 orig_logical = (stripe_index / map->sub_stripes) *
> + map->stripe_len + bg->start;
> + const u64 orig_physical = map->stripes[stripe_index].physical;
> + /*
> + * For RAID0, it's fixed to 1.
> + * For RAID10, the mirror_num is always 0,1,0,1,...
> + */
> + const int mirror_num = stripe_index % map->sub_stripes + 1;
For me I don't like having big comment blocks in the variable declaration part,
it makes it hard to read.
Also we have this sort of map math in a variety of different places. If it's
complex enough that it needs a comment then I think it would be good to have
static inline helpers with the math required to get the information we want,
which comments that exist there. Probably not needed for every little peice of
math, but for the common ones we do all the time it would be good.
If it doesn't make sense for any of the above things I would prefer to see
something like
/*
* logical_increment - the the size to increment based on the stripe size.
* orig_logical - the actual logical bytenr based on the stripe we're scrubbing.
* <etc>
*/
static int scrub_simple_stripe()
I'm not 100% married to this, it's purely a aesthetic opinion. If I'm the
minority then that's ok, but the above doesn't look great to me. Thanks,
Josef
next prev parent reply other threads:[~2022-01-03 16:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 2:33 [PATCH RFC 0/4] btrfs: refactor scrub entrances for each profile Qu Wenruo
2021-12-21 2:33 ` [PATCH RFC 1/4] btrfs: introduce a helper to locate an extent item Qu Wenruo
2021-12-21 2:33 ` [PATCH RFC 2/4] btrfs: introduce dedicated helper to scrub simple-mirror based range Qu Wenruo
2021-12-21 2:33 ` [PATCH RFC 3/4] btrfs: introduce dedicated helper to scrub simple-stripe " Qu Wenruo
2022-01-03 16:33 ` Josef Bacik [this message]
2022-01-03 23:44 ` Qu Wenruo
2021-12-21 2:33 ` [PATCH RFC 4/4] btrfs: use scrub_simple_mirror() to handle RAID56 data stripe scrub Qu Wenruo
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=YdMlVbcZ0EdjwqWr@localhost.localdomain \
--to=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox