Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp505429ybz; Fri, 24 Apr 2020 21:34:33 -0700 (PDT) X-Google-Smtp-Source: APiQypKIVj8keK3FcfckfaM3IUz6UVw41jQ59dwYVdPFDFzraCspQkvxREsOZ91/XQKrqPZIEWWW X-Received: by 2002:a05:6402:2208:: with SMTP id cq8mr10728903edb.293.1587789273039; Fri, 24 Apr 2020 21:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587789273; cv=none; d=google.com; s=arc-20160816; b=YsHx0qNsvBF2jwYNUS0yRVfjgDUR6CVmN4bDs17/2MK5Fc+vfDEh6MgdpILFW/AeIF CstxYNxxzX3InMJxSPdNbc1YM6bcsvGPTllsU0XncOp8vZaesaFw3WIsr44CF+IPHiY9 PAaK5xw7aOBeO4KpsQ1VeI0Up6K/BKBzawieDaXCmd9HpgswRsZyIH/wzCAga/1BvzCQ nmQea/0EHIWjTs/qQ6w1d50OAvoninlThgTDzJFJE4wLvghAl59GXWPOYbRZoihq6HOw z+SbgAibBCyMNAFEWF9kJs5CuqdKqT44lNQZlHxHZNYjJl1BKkAjHfFfY107OzLUYIZr H0ww== 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:subject:autocrypt:from:references:cc:to; bh=cLxi9lTohASf8Pmda6hjijGCps7ZYGa/EpFpYKysEqQ=; b=khcOn4IVLvE225/DwBVjWjrAe/nOuj3Dps3iTY9qItO/rcat5owvHU8bnIYFAC0nsQ hU3sxd145Rb6sdavC5mHQ7b6rrwgBbsl6RaaFhA8htiQ/2sJhaqnAjcvQlJ1A0zS82JK YO06WHcUVpzb8E0aw0s3yFKyXKM+KFs4GhB4sPrMfrm7k2guv/IhrhFWDFO07hiB8jTY s9PJLFiO7gJvSMIYNhY37VkVxZfDlCn1OZc8MDjW8bYB3/F9ihE5MAHUpYOS1WC6RpKB atJD8AyTv9MBBhzQHtkrtYAiH9aco/XomzBbfg5kZ0BSvyRrmt1t1SgxeReU+P2+rzxP ln9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si4515835ejn.415.2020.04.24.21.34.09; Fri, 24 Apr 2020 21:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbgDYEcE (ORCPT + 99 others); Sat, 25 Apr 2020 00:32:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:36816 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgDYEcD (ORCPT ); Sat, 25 Apr 2020 00:32:03 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 51B8CAE0F; Sat, 25 Apr 2020 04:31:59 +0000 (UTC) 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: Coly Li Autocrypt: addr=colyli@suse.de; keydata= mQINBFYX6S8BEAC9VSamb2aiMTQREFXK4K/W7nGnAinca7MRuFUD4JqWMJ9FakNRd/E0v30F qvZ2YWpidPjaIxHwu3u9tmLKqS+2vnP0k7PRHXBYbtZEMpy3kCzseNfdr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6j5FL/T5SGCN6PrQxzkHk2t9+PwFAlxHziAFCRj7 5/EACgkQxzkHk2t9+PxgfA//cH5R1DvpJPwraTAl24SUcG9EWe+NXyqveApe05nk15zEuxxd e4zFEjo+xYZilSveLqYHrm/amvQhsQ6JLU+8N60DZHVcXbw1Eb8CEjM5oXdbcJpXh1/1BEwl 4phsQMkxOTns51bGDhTQkv4lsZKvNByB9NiiMkT43EOx14rjkhHw3rnqoI7ogu8OO7XWfKcL CbchjJ8t3c2XK1MUe056yPpNAT2XPNF2EEBPG2Y2F4vLgEbPv1EtpGUS1+JvmK3APxjXUl5z 6xrxCQDWM5AAtGfM/IswVjbZYSJYyH4BQKrShzMb0rWUjkpXvvjsjt8rEXpZEYJgX9jvCoxt oqjCKiVLpwje9WkEe9O9VxljmPvxAhVqJjX62S+TGp93iD+mvpCoHo3+CcvyRcilz+Ko8lfO hS9tYT0HDUiDLvpUyH1AR2xW9RGDevGfwGTpF0K6cLouqyZNdhlmNciX48tFUGjakRFsxRmX K0Jx4CEZubakJe+894sX6pvNFiI7qUUdB882i5GR3v9ijVPhaMr8oGuJ3kvwBIA8lvRBGVGn 9xvzkQ8Prpbqh30I4NMp8MjFdkwCN6znBKPHdjNTwE5PRZH0S9J0o67IEIvHfH0eAWAsgpTz +jwc7VKH7vkvgscUhq/v1/PEWCAqh9UHy7R/jiUxwzw/288OpgO+i+2l11Y= Subject: Re: [PATCH] md/raid0: add config parameters to specify zone layout Message-ID: <0b7aad8b-f0b7-24c6-ad19-99c6202a3036@suse.de> Date: Sat, 25 Apr 2020 12:31:55 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/26 23:28, 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. > Hi Jason, If the people who compiling the kernel is not the end users, the communication gap has potential risk to make users to use a different layout for existing raid0 array after a kernel upgrade. If this patch goes into upstream, it is very probably such risky situation may happen. The purpose of adding default_layout is to let *end user* to be aware of they layout when they use difference sizes component disks to assemble the raid0 array, and make decision which layout algorithm should be used. Such situation cannot be decided in kernel compiling time. > 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. > The difficulty is for a given md raid0 array, there is no clue whether it is built on pre-3.14 kernel or not. If the kernel is not configured and built by end user, we have risk that wrong algorithm will be applied to unmatched layout. Thanks. Coly Li > 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 > + 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 > + set RAID0_ALT_MULTIZONE_LAYOUT. If its only been written to by a > + pre-3.14 kernel its safe to select RAID0_ORIG_LAYOUT. If its 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" > + 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 \ >