* [PATCH V2 1/1] mdadm/super1: Add MD_FEATURE_RAID0_LAYOUT for all raid0 after kernel v5.4
@ 2023-10-17 3:51 Xiao Ni
2023-10-17 7:36 ` Mariusz Tkaczyk
0 siblings, 1 reply; 3+ messages in thread
From: Xiao Ni @ 2023-10-17 3:51 UTC (permalink / raw)
To: jes; +Cc: mariusz.tkaczyk, colyli, neilb, linux-raid
After and include kernel v5.4, it adds one feature bit MD_FEATURE_RAID0_LAYOUT.
It must need to specify a layout for raid0 with more than one zone. But for
raid0 with one zone, in fact it also has a defalut layout.
Now for raid0 with one zone, *unknown* layout can be seen when running mdadm -D
command. It's the reason that mdadm doesn't set MD_FEATURE_RAID0_LAYOUT for
raid0 with one zone. Then in kernel space, super_1_validate sets mddev->layout
to -1 because of no MD_FEATURE_RAID0_LAYOUT. In fact, in raid0 io path, it
uses the default layout. So in fact after/include kernel v5.4, all raid0 device
have layout.
Fixes: 329dfc28debb ('Create: add support for RAID0 layouts.')
Signed-off-by: Xiao Ni <xni@redhat.com>
---
super1.c | 21 ++-------------------
1 file changed, 2 insertions(+), 19 deletions(-)
diff --git a/super1.c b/super1.c
index 856b02082662..653a2ea6c0e4 100644
--- a/super1.c
+++ b/super1.c
@@ -1978,26 +1978,10 @@ static int write_init_super1(struct supertype *st)
unsigned long long sb_offset;
unsigned long long data_offset;
long bm_offset;
- int raid0_need_layout = 0;
- for (di = st->info; di; di = di->next) {
+ for (di = st->info; di; di = di->next)
if (di->disk.state & (1 << MD_DISK_JOURNAL))
sb->feature_map |= __cpu_to_le32(MD_FEATURE_JOURNAL);
- if (sb->level == 0 && sb->layout != 0) {
- struct devinfo *di2 = st->info;
- unsigned long long s1, s2;
- s1 = di->dev_size;
- if (di->data_offset != INVALID_SECTORS)
- s1 -= di->data_offset;
- s1 /= __le32_to_cpu(sb->chunksize);
- s2 = di2->dev_size;
- if (di2->data_offset != INVALID_SECTORS)
- s2 -= di2->data_offset;
- s2 /= __le32_to_cpu(sb->chunksize);
- if (s1 != s2)
- raid0_need_layout = 1;
- }
- }
for (di = st->info; di; di = di->next) {
if (di->disk.state & (1 << MD_DISK_FAULTY))
@@ -2139,8 +2123,7 @@ static int write_init_super1(struct supertype *st)
sb->bblog_offset = 0;
}
- /* RAID0 needs a layout if devices aren't all the same size */
- if (raid0_need_layout)
+ if (sb->level == 0 && sb->layout && get_linux_version() >= 5004000)
sb->feature_map |= __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT);
sb->sb_csum = calc_sb_1_csum(sb);
--
2.32.0 (Apple Git-132)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2 1/1] mdadm/super1: Add MD_FEATURE_RAID0_LAYOUT for all raid0 after kernel v5.4
2023-10-17 3:51 [PATCH V2 1/1] mdadm/super1: Add MD_FEATURE_RAID0_LAYOUT for all raid0 after kernel v5.4 Xiao Ni
@ 2023-10-17 7:36 ` Mariusz Tkaczyk
2023-10-17 12:04 ` Xiao Ni
0 siblings, 1 reply; 3+ messages in thread
From: Mariusz Tkaczyk @ 2023-10-17 7:36 UTC (permalink / raw)
To: Xiao Ni; +Cc: jes, colyli, neilb, linux-raid
On Tue, 17 Oct 2023 11:51:42 +0800
Xiao Ni <xni@redhat.com> wrote:
> After and include kernel v5.4, it adds one feature bit
> MD_FEATURE_RAID0_LAYOUT. It must need to specify a layout for raid0 with more
> than one zone. But for raid0 with one zone, in fact it also has a defalut
> layout.
>
> Now for raid0 with one zone, *unknown* layout can be seen when running mdadm
> -D command. It's the reason that mdadm doesn't set MD_FEATURE_RAID0_LAYOUT for
> raid0 with one zone. Then in kernel space, super_1_validate sets mddev->layout
> to -1 because of no MD_FEATURE_RAID0_LAYOUT. In fact, in raid0 io path, it
> uses the default layout. So in fact after/include kernel v5.4, all raid0
> device have layout.
>
> Fixes: 329dfc28debb ('Create: add support for RAID0 layouts.')
> Signed-off-by: Xiao Ni <xni@redhat.com>
> ---
> super1.c | 21 ++-------------------
> 1 file changed, 2 insertions(+), 19 deletions(-)
>
> diff --git a/super1.c b/super1.c
> index 856b02082662..653a2ea6c0e4 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -1978,26 +1978,10 @@ static int write_init_super1(struct supertype *st)
> unsigned long long sb_offset;
> unsigned long long data_offset;
> long bm_offset;
> - int raid0_need_layout = 0;
>
> - for (di = st->info; di; di = di->next) {
> + for (di = st->info; di; di = di->next)
> if (di->disk.state & (1 << MD_DISK_JOURNAL))
> sb->feature_map |= __cpu_to_le32(MD_FEATURE_JOURNAL);
> - if (sb->level == 0 && sb->layout != 0) {
> - struct devinfo *di2 = st->info;
> - unsigned long long s1, s2;
> - s1 = di->dev_size;
> - if (di->data_offset != INVALID_SECTORS)
> - s1 -= di->data_offset;
> - s1 /= __le32_to_cpu(sb->chunksize);
> - s2 = di2->dev_size;
> - if (di2->data_offset != INVALID_SECTORS)
> - s2 -= di2->data_offset;
> - s2 /= __le32_to_cpu(sb->chunksize);
> - if (s1 != s2)
> - raid0_need_layout = 1;
> - }
> - }
We need to keep this code. Neil made MD_FEATURE_RAID0_LAYOUT always added for
device with various sizes. You are extending it not replacing.
I understand that now it sets MD_FEATURE_RAID0_LAYOUT if it detects
member devices with various sizes. Kernel version is irrelevant so I suspect
that if someone creates zoned raid0 array, it fails to start array if
MD_FEATURE_RAID0_LAYOUT is not supported by the MD driver. User must
acknowledge that by layout=dangerous (it means no layout I think).
We don't want remove this. It prevents users from data corruption.
Your change is to start always setting MD_FEATURE_RAID0_LAYOUT if it seems to be
safe i.e. kernel is >=5.4 but it does not invalidate the raid0_need_layout
routine from the reason raised above.
Please correct me if I missed something or if I'm wrong. I did not tested it.
I trust that you made necessary testing and can provide real-life input here.
Thanks,
Mariusz
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2 1/1] mdadm/super1: Add MD_FEATURE_RAID0_LAYOUT for all raid0 after kernel v5.4
2023-10-17 7:36 ` Mariusz Tkaczyk
@ 2023-10-17 12:04 ` Xiao Ni
0 siblings, 0 replies; 3+ messages in thread
From: Xiao Ni @ 2023-10-17 12:04 UTC (permalink / raw)
To: Mariusz Tkaczyk; +Cc: jes, colyli, neilb, linux-raid
On Tue, Oct 17, 2023 at 3:36 PM Mariusz Tkaczyk
<mariusz.tkaczyk@linux.intel.com> wrote:
>
> On Tue, 17 Oct 2023 11:51:42 +0800
> Xiao Ni <xni@redhat.com> wrote:
>
> > After and include kernel v5.4, it adds one feature bit
> > MD_FEATURE_RAID0_LAYOUT. It must need to specify a layout for raid0 with more
> > than one zone. But for raid0 with one zone, in fact it also has a defalut
> > layout.
> >
> > Now for raid0 with one zone, *unknown* layout can be seen when running mdadm
> > -D command. It's the reason that mdadm doesn't set MD_FEATURE_RAID0_LAYOUT for
> > raid0 with one zone. Then in kernel space, super_1_validate sets mddev->layout
> > to -1 because of no MD_FEATURE_RAID0_LAYOUT. In fact, in raid0 io path, it
> > uses the default layout. So in fact after/include kernel v5.4, all raid0
> > device have layout.
> >
> > Fixes: 329dfc28debb ('Create: add support for RAID0 layouts.')
> > Signed-off-by: Xiao Ni <xni@redhat.com>
> > ---
> > super1.c | 21 ++-------------------
> > 1 file changed, 2 insertions(+), 19 deletions(-)
> >
> > diff --git a/super1.c b/super1.c
> > index 856b02082662..653a2ea6c0e4 100644
> > --- a/super1.c
> > +++ b/super1.c
> > @@ -1978,26 +1978,10 @@ static int write_init_super1(struct supertype *st)
> > unsigned long long sb_offset;
> > unsigned long long data_offset;
> > long bm_offset;
> > - int raid0_need_layout = 0;
> >
> > - for (di = st->info; di; di = di->next) {
> > + for (di = st->info; di; di = di->next)
> > if (di->disk.state & (1 << MD_DISK_JOURNAL))
> > sb->feature_map |= __cpu_to_le32(MD_FEATURE_JOURNAL);
> > - if (sb->level == 0 && sb->layout != 0) {
> > - struct devinfo *di2 = st->info;
> > - unsigned long long s1, s2;
> > - s1 = di->dev_size;
> > - if (di->data_offset != INVALID_SECTORS)
> > - s1 -= di->data_offset;
> > - s1 /= __le32_to_cpu(sb->chunksize);
> > - s2 = di2->dev_size;
> > - if (di2->data_offset != INVALID_SECTORS)
> > - s2 -= di2->data_offset;
> > - s2 /= __le32_to_cpu(sb->chunksize);
> > - if (s1 != s2)
> > - raid0_need_layout = 1;
> > - }
> > - }
>
> We need to keep this code. Neil made MD_FEATURE_RAID0_LAYOUT always added for
> device with various sizes. You are extending it not replacing.
>
> I understand that now it sets MD_FEATURE_RAID0_LAYOUT if it detects
> member devices with various sizes. Kernel version is irrelevant so I suspect
> that if someone creates zoned raid0 array, it fails to start array if
> MD_FEATURE_RAID0_LAYOUT is not supported by the MD driver. User must
> acknowledge that by layout=dangerous (it means no layout I think).
>
> We don't want remove this. It prevents users from data corruption.
>
> Your change is to start always setting MD_FEATURE_RAID0_LAYOUT if it seems to be
> safe i.e. kernel is >=5.4 but it does not invalidate the raid0_need_layout
> routine from the reason raised above.
>
> Please correct me if I missed something or if I'm wrong. I did not tested it.
> I trust that you made necessary testing and can provide real-life input here.
>
> Thanks,
> Mariusz
>
Hi Mariusz
Thanks. I'll add the check <5.4 situation
Best Regards
Xiao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-17 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17 3:51 [PATCH V2 1/1] mdadm/super1: Add MD_FEATURE_RAID0_LAYOUT for all raid0 after kernel v5.4 Xiao Ni
2023-10-17 7:36 ` Mariusz Tkaczyk
2023-10-17 12:04 ` Xiao Ni
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.