From: Liu Bo <bo.li.liu@oracle.com>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.cz
Subject: Re: [PATCH v3 2/5] btrfs: scrub: Fix RAID56 recovery race condition
Date: Wed, 29 Mar 2017 17:51:18 -0700 [thread overview]
Message-ID: <20170330005117.GB15452@lim.localdomain> (raw)
In-Reply-To: <20170329013322.1323-3-quwenruo@cn.fujitsu.com>
On Wed, Mar 29, 2017 at 09:33:19AM +0800, Qu Wenruo wrote:
[...]
>
> Reported-by: Goffredo Baroncelli <kreijack@libero.it>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> ---
> fs/btrfs/scrub.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index ab33b9a8aac2..f92d2512f4f3 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -1129,6 +1129,17 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
> have_csum = sblock_to_check->pagev[0]->have_csum;
> dev = sblock_to_check->pagev[0]->dev;
>
> + /*
> + * For RAID5/6 race can happen for different dev scrub thread.
> + * For data corruption, Parity and Data thread will both try
> + * to recovery the data.
> + * Race can lead to double added csum error, or even unrecoverable
> + * error.
> + */
> + ret = lock_full_stripe(fs_info, logical);
> + if (ret < 0)
> + return ret;
> +
Firstly, sctx->stat needs to be set with errors before returning errors.
Secondly, I think the critical section starts right before re-checking the
failed mirror, doesn't it? If so, we could get the benefit from
sblock_bad->page since the page->recover can tell if this is a raid56 profile so
that we may save a searching for block group.
> if (sctx->is_dev_replace && !is_metadata && !have_csum) {
> sblocks_for_recheck = NULL;
> goto nodatasum_case;
> @@ -1463,6 +1474,9 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
> kfree(sblocks_for_recheck);
> }
>
> + ret = unlock_full_stripe(fs_info, logical);
> + if (ret < 0)
> + return ret;
Seems that the callers of scrub_handle_errored_block doesn't care about @ret.
And could you please put a 'locked' flag after taking the lock succesfully?
Otherwise every raid profile has to check block group for raid flag.
Thanks,
-liubo
> return 0;
> }
>
> --
> 2.12.1
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-03-30 0:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 1:33 [PATCH v3 0/5] raid56: scrub related fixes Qu Wenruo
2017-03-29 1:33 ` [PATCH v3 1/5] btrfs: scrub: Introduce full stripe lock for RAID56 Qu Wenruo
2017-03-30 0:34 ` Liu Bo
2017-03-30 1:03 ` Qu Wenruo
2017-03-30 10:31 ` David Sterba
2017-03-31 2:03 ` Qu Wenruo
2017-03-31 17:26 ` David Sterba
2017-04-03 0:43 ` Qu Wenruo
2017-03-29 1:33 ` [PATCH v3 2/5] btrfs: scrub: Fix RAID56 recovery race condition Qu Wenruo
2017-03-30 0:51 ` Liu Bo [this message]
2017-03-30 3:24 ` Qu Wenruo
2017-03-29 1:33 ` [PATCH v3 3/5] btrfs: scrub: Don't append on-disk pages for raid56 scrub Qu Wenruo
2017-03-29 18:00 ` Liu Bo
2017-03-29 1:33 ` [PATCH v3 4/5] btrfs: Wait flighting bio before freeing target device for raid56 Qu Wenruo
2017-03-29 18:05 ` Liu Bo
2017-03-29 1:33 ` [PATCH v3 5/5] btrfs: Prevent scrub recheck from racing with dev replace Qu Wenruo
2017-03-29 18:08 ` Liu Bo
2017-03-30 16:52 ` [PATCH v3 0/5] raid56: scrub related fixes 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=20170330005117.GB15452@lim.localdomain \
--to=bo.li.liu@oracle.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).