From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] Btrfs: scrub raid56 stripes in the right way
Date: Fri, 28 Mar 2014 20:00:47 +0800 [thread overview]
Message-ID: <5335646F.7090604@cn.fujitsu.com> (raw)
In-Reply-To: <1395655091-5318-2-git-send-email-wangsl.fnst@cn.fujitsu.com>
Oops, this patch is not working right, please ignore this one,
i will send a v2.
Thanks,
Wang
On 03/24/2014 05:58 PM, Wang Shilong wrote:
> Steps to reproduce:
> # mkfs.btrfs -f /dev/sda[8-11] -m raid5 -d raid5
> # mount /dev/sda8 /mnt
> # btrfs scrub start -BR /mnt
> # echo $? <--unverified errors make return value be 3
>
> This is because we don't setup right mapping between physical
> and logical address for raid56, which makes checksum mismatch.
> But we will find everthing is fine later when rechecking using
> btrfs_map_block().
>
> This patch fixed the problem by settuping right mappings and
> we only verify data stripes' checksums.
>
> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
> ---
> fs/btrfs/scrub.c | 33 +++++++++++++++++++++++++--------
> 1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index db21a13..4182b44a 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2267,16 +2267,12 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
> u64 extent_logical;
> u64 extent_physical;
> u64 extent_len;
> + u64 stripe_nr;
> + u64 tmp;
> + int stripe_index;
> struct btrfs_device *extent_dev;
> int extent_mirror_num;
> - int stop_loop;
> -
> - if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
> - BTRFS_BLOCK_GROUP_RAID6)) {
> - if (num >= nr_data_stripes(map)) {
> - return 0;
> - }
> - }
> + int stop_loop = 0;
>
> nstripes = length;
> offset = 0;
> @@ -2296,6 +2292,14 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
> } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
> increment = map->stripe_len;
> mirror_num = num % map->num_stripes + 1;
> + } else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
> + BTRFS_BLOCK_GROUP_RAID6)) {
> + if (num < nr_data_stripes(map))
> + offset = num * map->stripe_len;
> + else
> + offset = (nr_data_stripes(map) - 1) * map->stripe_len;
> + increment = map->stripe_len * nr_data_stripes(map);
> + mirror_num = 1;
> } else {
> increment = map->stripe_len;
> mirror_num = 1;
> @@ -2361,6 +2365,18 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
> logic_end = logical + increment * nstripes;
> ret = 0;
> while (logical < logic_end) {
> + /* skip parity */
> + if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
> + BTRFS_BLOCK_GROUP_RAID6)) {
> + stripe_nr = logical - base;
> + do_div(stripe_nr, map->stripe_len);
> +
> + stripe_index = do_div(stripe_nr, nr_data_stripes(map));
> + tmp = stripe_nr + stripe_index;
> + stripe_index = do_div(tmp, map->num_stripes);
> + if (stripe_index != num)
> + goto skip;
> + }
> /*
> * canceled?
> */
> @@ -2521,6 +2537,7 @@ next:
> path->slots[0]++;
> }
> btrfs_release_path(path);
> +skip:
> logical += increment;
> physical += map->stripe_len;
> spin_lock(&sctx->stat_lock);
next prev parent reply other threads:[~2014-03-28 12:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 9:58 [PATCH 1/2] Btrfs: don't compress for a small write Wang Shilong
2014-03-24 9:58 ` [PATCH 2/2] Btrfs: scrub raid56 stripes in the right way Wang Shilong
2014-03-28 12:00 ` Wang Shilong [this message]
2014-03-26 18:10 ` [PATCH 1/2] Btrfs: don't compress for a small write David Sterba
2014-03-27 3:06 ` Wang Shilong
2014-03-31 12:31 ` Chris Mason
2014-03-31 12:53 ` Shilong Wang
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=5335646F.7090604@cn.fujitsu.com \
--to=wangsl.fnst@cn.fujitsu.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 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.