Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2037427pja; Thu, 26 Mar 2020 08:43:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsfYr1/n4Hdks+vH+87AyN5Aq8W+MZd0iYxXHpb5DQO3TT7MaLtr/0Lmt79/s6TZmKZh4hg X-Received: by 2002:a9d:67d7:: with SMTP id c23mr7193285otn.280.1585237406909; Thu, 26 Mar 2020 08:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585237406; cv=none; d=google.com; s=arc-20160816; b=FxUmC8SsjDpjhUlvag7I+nUk2Z9IGB8KfAqKhil5AOvCVK3naNnK63tx3C0uxEw3D0 /l5mPVqoh5bSSHZvyYbkN/EJUxdwsky4jAbz4/jNVbCTXkxz9XwdPiXDU5ra2KtzeEpJ 3AC5LN3nzaqeB5cFPQLvGZFuCM9Z0tO4cBD8kl7ilHTRTCKiB3oAY7mgKbS5QMp3Ojb6 K+zwlDZfL/RBTHlR4d3LcPSlAzdWJKod+OkhTIzeTVKvDzpPWNXiwc1xdkUnclJ3CmEF XcDmkmgicGKPRqjP893C32CdsV2afRHnf29zh/xwjiuI0IDlXYXUeTY3/i1SQ89fLlgE ScDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=4Rhgc12JFsMtKIyNi6i/tNVpQycGEAdzKCaEdKdCY1c=; b=bJvL9a9jUTtfKxUaE5YzHjTKBhmFCl6fMqIOqzsxJ39WflxEGq0IoIWs3KgeYYdEec T0Ms03ngiq/2vZLPefd0GnROqcjoMD6v/GziCeWD5Nvb94dzj49UdWwkjx30GIQCaxge jxEbtuTaeEkUvmpnMY3C0IDTs4Z5q5IH7f9/mp4iYENA/ESD53BUiaMNiy7p9JpxmBID 4nGFODSt/o7aRqXqg4ca3NetQq0h+iyj7rnjM810E4R52EePvlCSI0qasDAR0r6Imj/0 Zzz8ZmH6LOnXGosK7kBwNq0MyS5wiXWgk1wZzLNvu04Aj849KEUPCvmoTx0VwmM5qsPj N3Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hl67uVF2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x64si1169600oig.34.2020.03.26.08.43.13; Thu, 26 Mar 2020 08:43:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hl67uVF2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728593AbgCZPjH (ORCPT + 99 others); Thu, 26 Mar 2020 11:39:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45244 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgCZPjH (ORCPT ); Thu, 26 Mar 2020 11:39:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=4Rhgc12JFsMtKIyNi6i/tNVpQycGEAdzKCaEdKdCY1c=; b=hl67uVF2FcEI0atatFBaSMyqLb o9r800pgWA+iabo3TAoBBmsfysRN/L8vsCIbcivB2IsSkEROq2xRWk6Hs9abnXfiSk0MnLkjMZliM ZEjx1ZEtsYIadI/EzFQhOJK7yZB8l7cLQV/cVo8yjUMt+NMNA5iD8HEJpdw/GK915SUHiqjFHaXPJ OrtPFrJplNu8gAVf4PkFJRqTdaeb5ABnQn6v89KBDggMtYJ5HbEM+AWWigha6i6cGgS+X0fmL7SM6 YKckZOeA+AS5rP22i5iWdD2NLKBXKipQ45Nikr1U8PnB3X4CjKITFgnWiRBcfo0E5j3/xwEfQoqCY zGU/HzDg==; Received: from [2601:1c0:6280:3f0::19c2] by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHUb3-0002U8-Eb; Thu, 26 Mar 2020 15:39:05 +0000 Subject: Re: [PATCH] md/raid0: add config parameters to specify zone layout To: Jason Baron , songliubraving@fb.com Cc: agk@redhat.com, snitzer@redhat.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Guoqing Jiang , NeilBrown References: <1585236500-12015-1-git-send-email-jbaron@akamai.com> From: Randy Dunlap Message-ID: Date: Thu, 26 Mar 2020 08:39:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <1585236500-12015-1-git-send-email-jbaron@akamai.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/26/20 8:28 AM, Jason Baron wrote: > Let's add some CONFIG_* options to directly configure the raid0 layout > if you know in advance how your raid0 array was created. This can be > simpler than having to manage module or kernel command-line parameters. > > If the raid0 array was created by a pre-3.14 kernel, use > RAID0_ORIG_LAYOUT. If the raid0 array was created by a 3.14 or newer > kernel then select RAID0_ALT_MULTIZONE_LAYOUT. Otherwise, the default > setting is RAID0_LAYOUT_NONE, in which case the current behavior of > needing to specify a module parameter raid0.default_layout=1|2 is > preserved. > > Cc: Guoqing Jiang > Cc: NeilBrown > Cc: Song Liu > Signed-off-by: Jason Baron > --- > drivers/md/Kconfig | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/md/raid0.c | 7 +++++++ > 2 files changed, 62 insertions(+) > > diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig > index d6d5ab2..c0c6d82 100644 > --- a/drivers/md/Kconfig > +++ b/drivers/md/Kconfig > @@ -79,6 +79,61 @@ config MD_RAID0 > > If unsure, say Y. > > +choice > + prompt "RAID0 Layout" > + default RAID0_LAYOUT_NONE > + depends on MD_RAID0 > + help > + A change was made in Linux 3.14 that unintentinally changed the unintentionally > + the layout for RAID0. This can result in data corruption if a pre-3.14 > + and a 3.14 or later kernel both wrote to the array. However, if the > + devices in the array are all of the same size then the layout would > + have been unaffected by this change, and there is no risk of data > + corruption from this issue. > + > + Unfortunately, the layout can not be determined by the kernel. If the > + array has only been written to by a 3.14 or later kernel its safe to it's > + set RAID0_ALT_MULTIZONE_LAYOUT. If its only been written to by a it has > + pre-3.14 kernel its safe to select RAID0_ORIG_LAYOUT. If its been it's If it has been > + written by both then select RAID0_LAYOUT_NONE, which will not > + configure the array. The array can then be examined for corruption. > + > + For new arrays you may choose either layout version. Neither version > + is inherently better than the other. > + > + Alternatively, these parameters can also be specified via the module > + parameter raid0.default_layout=. N=2 selects the 'new' or multizone > + layout, while N=1 selects the 'old' layout or original layout. If > + unset the array will not be configured. > + > + The layout can also be written directly to the raid0 array via the > + mdadm command, which can be auto-detected by the kernel. See: > + > + > +config RAID0_ORIG_LAYOUT > + bool "raid0 layout for arrays only written to by a pre-3.14 kernel" > + help > + If the raid0 array was only created and written to by a pre-3.14 kernel. > + > +config RAID0_ALT_MULTIZONE_LAYOUT > + bool "raid0 layout for arrays only written to be a 3.14 or newer kernel" by > + help > + If the raid0 array was only created and written to by a 3.14 or later > + kernel. > + > +config RAID0_LAYOUT_NONE > + bool "raid0 layout must be specified via a module parameter" > + help > + If a raid0 array was written to by both a pre-3.14 and a 3.14 or > + later kernel, you may have data corruption. This option will not > + auto configure the array and thus you can examine the array offline > + to determine the best way to proceed. With RAID0_LAYOUT_NONE > + set, the choice for raid0 layout can be set via a module parameter > + raid0.default_layout=. Or the layout can be written directly > + to the raid0 array via the mdadm command. > + > +endchoice > + > config MD_RAID1 > tristate "RAID-1 (mirroring) mode" > depends on BLK_DEV_MD > diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c > index 322386f..576eaa6 100644 > --- a/drivers/md/raid0.c > +++ b/drivers/md/raid0.c > @@ -19,7 +19,14 @@ > #include "raid0.h" > #include "raid5.h" > > +#if defined(CONFIG_RAID0_ORIG_LAYOUT) > +static int default_layout = RAID0_ORIG_LAYOUT; > +#elif defined(CONFIG_RAID0_ALT_MULTIZONE_LAYOUT) > +static int default_layout = RAID0_ALT_MULTIZONE_LAYOUT; > +#else > static int default_layout = 0; > +#endif > + > module_param(default_layout, int, 0644); > > #define UNSUPPORTED_MDDEV_FLAGS \ > -- ~Randy Reported-by: Randy Dunlap