From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: NeilBrown <neilb@suse.de>, Coly Li <colyli@suse.de>,
Song Liu <songliubraving@fb.com>
Cc: NeilBrown <neilb@suse.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
linux-raid <linux-raid@vger.kernel.org>
Subject: Re: [PATCH] md/raid0: avoid RAID0 data corruption due to layout confusion.
Date: Mon, 9 Sep 2019 17:09:38 +0200 [thread overview]
Message-ID: <02a0d884-0a7a-63ed-2987-f5d07b93491b@cloud.ionos.com> (raw)
In-Reply-To: <87pnkaardl.fsf@notabene.neil.brown.name>
On 9/9/19 8:57 AM, NeilBrown wrote:
>
> If the drives in a RAID0 are not all the same size, the array is
> divided into zones.
> The first zone covers all drives, to the size of the smallest.
> The second zone covers all drives larger than the smallest, up to
> the size of the second smallest - etc.
>
> A change in Linux 3.14 unintentionally changed the layout for the
> second and subsequent zones. All the correct data is still stored, but
> each chunk may be assigned to a different device than in pre-3.14 kernels.
> This can lead to data corruption.
>
> It is not possible to determine what layout to use - it depends which
> kernel the data was written by.
> So we add a module parameter to allow the old (0) or new (1) layout to be
> specified, and refused to assemble an affected array if that parameter is
> not set.
>
> Fixes: 20d0189b1012 ("block: Introduce new bio_split()")
> cc: stable@vger.kernel.org (3.14+)
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>
> This and the next patch are my proposal for how to address
> this problem. I haven't actually tested .....
>
> NeilBrown
>
> drivers/md/raid0.c | 28 +++++++++++++++++++++++++++-
> drivers/md/raid0.h | 14 ++++++++++++++
> 2 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
> index bf5cf184a260..a8888c12308a 100644
> --- a/drivers/md/raid0.c
> +++ b/drivers/md/raid0.c
> @@ -19,6 +19,9 @@
> #include "raid0.h"
> #include "raid5.h"
>
> +static int default_layout = -1;
> +module_param(default_layout, int, 0644);
> +
> #define UNSUPPORTED_MDDEV_FLAGS \
> ((1L << MD_HAS_JOURNAL) | \
> (1L << MD_JOURNAL_CLEAN) | \
> @@ -139,6 +142,19 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
> }
> pr_debug("md/raid0:%s: FINAL %d zones\n",
> mdname(mddev), conf->nr_strip_zones);
> +
> + if (conf->nr_strip_zones == 1) {
> + conf->layout = RAID0_ORIG_LAYOUT;
> + } else if (default_layout == RAID0_ORIG_LAYOUT ||
> + default_layout == RAID0_ALT_MULTIZONE_LAYOUT) {
> + conf->layout = default_layout;
> + } else {
> + pr_err("md/raid0:%s: cannot assemble multi-zone RAID0 with default_layout setting\n",
> + mdname(mddev));
> + pr_err("md/raid0: please set raid.default_layout to 0 or 1\n");
Maybe "1 or 2" to align with the definition of below r0layout?
[snip]
> +enum r0layout {
> + RAID0_ORIG_LAYOUT = 1,
> + RAID0_ALT_MULTIZONE_LAYOUT = 2,
> +};
> struct r0conf {
> struct strip_zone *strip_zone;
> struct md_rdev **devlist; /* lists of rdevs, pointed to
> * by strip_zone->dev */
> int nr_strip_zones;
> + enum r0layout layout;
> };
>
> #endif
>
Thanks,
Guoqing
next prev parent reply other threads:[~2019-09-09 15:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 10:38 [RFC] How to handle an ugly md raid0 sector map bug ? Coly Li
2019-08-23 0:02 ` NeilBrown
2019-08-23 16:37 ` Song Liu
2019-08-23 17:03 ` Coly Li
2019-08-23 17:17 ` Song Liu
2019-08-23 17:47 ` Coly Li
2019-09-09 6:57 ` [PATCH] md/raid0: avoid RAID0 data corruption due to layout confusion NeilBrown
2019-09-09 6:58 ` [PATCH 2/2] md: add feature flag MD_FEATURE_RAID0_LAYOUT NeilBrown
2019-09-09 15:33 ` Guoqing Jiang
2019-09-09 23:26 ` NeilBrown
2019-09-09 14:56 ` [PATCH] md/raid0: avoid RAID0 data corruption due to layout confusion Song Liu
2019-09-09 23:33 ` NeilBrown
2019-09-10 15:45 ` Song Liu
2019-09-10 16:01 ` Guoqing Jiang
2019-09-10 23:08 ` NeilBrown
2019-09-11 9:56 ` Song Liu
2019-09-11 22:48 ` NeilBrown
2019-09-09 15:09 ` Guoqing Jiang [this message]
2019-09-09 23:34 ` NeilBrown
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=02a0d884-0a7a-63ed-2987-f5d07b93491b@cloud.ionos.com \
--to=guoqing.jiang@cloud.ionos.com \
--cc=colyli@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
--cc=neilb@suse.de \
--cc=songliubraving@fb.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).