* [PATCH] mdadm: fix --grow with --add for linear
@ 2024-12-27 6:07 Yu Kuai
2024-12-31 8:49 ` Mariusz Tkaczyk
0 siblings, 1 reply; 4+ messages in thread
From: Yu Kuai @ 2024-12-27 6:07 UTC (permalink / raw)
To: mtkaczyk, song; +Cc: linux-raid, yukuai3, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
For the case mdadm --grow with --add, the s.btype should not be
initialized yet, hence BitmapUnknown should be checked instead of
BitmapNone.
Noted that this behaviour should only support by md-linear, which is
removed from kernel, howerver, it turns out md-linear is used widely
in home NAS and we're planning to reintroduce it soon.
Fixes: 581ba1341017 ("mdadm: remove bitmap file support")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
mdadm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mdadm.c b/mdadm.c
index 7d3b656b..1fd4dcba 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1625,7 +1625,7 @@ int main(int argc, char *argv[])
if (devs_found > 1 && s.raiddisks == 0 && s.level == UnSet) {
/* must be '-a'. */
if (s.size > 0 || s.chunk ||
- s.layout_str || s.btype != BitmapNone) {
+ s.layout_str || s.btype != BitmapUnknown) {
pr_err("--add cannot be used with other geometry changes in --grow mode\n");
rv = 1;
break;
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] mdadm: fix --grow with --add for linear
2024-12-27 6:07 [PATCH] mdadm: fix --grow with --add for linear Yu Kuai
@ 2024-12-31 8:49 ` Mariusz Tkaczyk
2025-01-26 8:22 ` Yu Kuai
0 siblings, 1 reply; 4+ messages in thread
From: Mariusz Tkaczyk @ 2024-12-31 8:49 UTC (permalink / raw)
To: Yu Kuai; +Cc: song, linux-raid, yukuai3, yangerkun
On Fri, 27 Dec 2024 14:07:02 +0800
Yu Kuai <yukuai1@huaweicloud.com> wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> For the case mdadm --grow with --add, the s.btype should not be
> initialized yet, hence BitmapUnknown should be checked instead of
> BitmapNone.
Hi Kuai,
For commit extra clarity it would be nice to include command you are
executing.
What if someone will do (not tested):
#mdadm --grow /dev/md0 --add /dev/sdx --bitmap=none
I think that it is perfectly valid, now it may work but I expect your
change to broke it.
I would say we need:
bool is_bitmap_set(struct shape *s) {
if (s.layout)
return true;
if (s.btype == BitmapNone || s.btype != BitmapUnknown)
return false;
return true;
}
And respect both cases. Setting property to default should never be a
mistake.
Has it some sense? If no, I miss some explanation in commit message (or
better comment).
>
> Noted that this behaviour should only support by md-linear, which is
> removed from kernel, howerver, it turns out md-linear is used widely
> in home NAS and we're planning to reintroduce it soon.
Wow. We get a lesson.
For the code, LGTM.
Thanks,
Mariusz
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mdadm: fix --grow with --add for linear
2024-12-31 8:49 ` Mariusz Tkaczyk
@ 2025-01-26 8:22 ` Yu Kuai
2025-01-27 9:35 ` Mariusz Tkaczyk
0 siblings, 1 reply; 4+ messages in thread
From: Yu Kuai @ 2025-01-26 8:22 UTC (permalink / raw)
To: Mariusz Tkaczyk, Yu Kuai; +Cc: song, linux-raid, yangerkun, yukuai (C)
在 2024/12/31 16:49, Mariusz Tkaczyk 写道:
> On Fri, 27 Dec 2024 14:07:02 +0800
> Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> For the case mdadm --grow with --add, the s.btype should not be
>> initialized yet, hence BitmapUnknown should be checked instead of
>> BitmapNone.
>
> Hi Kuai,
>
> For commit extra clarity it would be nice to include command you are
> executing.
>
> What if someone will do (not tested):
> #mdadm --grow /dev/md0 --add /dev/sdx --bitmap=none
>
> I think that it is perfectly valid, now it may work but I expect your
> change to broke it.
Hi,
Sorry for the late reply, I forgot about this patch somehow :(
Changes from commit 581ba1341017:
@@ -1634,7 +1625,7 @@ int main(int argc, char *argv[])
if (devs_found > 1 && s.raiddisks == 0 && s.level ==
UnSet) {
/* must be '-a'. */
if (s.size > 0 || s.chunk ||
- s.layout_str || s.bitmap_file) {
+ s.layout_str || s.btype != BitmapNone) {
pr_err("--add cannot be used with other
geometry changes in --grow mode\n");
rv = 1;
break;
Hence before the commit, bitmap=none is not valid in this case as well,
because s.bitmap_file will set to "none" in this case.
Thanks,
Kuai
>
> I would say we need:
>
> bool is_bitmap_set(struct shape *s) {
> if (s.layout)
> return true;
> if (s.btype == BitmapNone || s.btype != BitmapUnknown)
> return false;
>
> return true;
> }
>
> And respect both cases. Setting property to default should never be a
> mistake.
>
> Has it some sense? If no, I miss some explanation in commit message (or
> better comment).
>
>>
>> Noted that this behaviour should only support by md-linear, which is
>> removed from kernel, howerver, it turns out md-linear is used widely
>> in home NAS and we're planning to reintroduce it soon.
>
> Wow. We get a lesson.
>
> For the code, LGTM.
>
> Thanks,
> Mariusz
>
> .
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mdadm: fix --grow with --add for linear
2025-01-26 8:22 ` Yu Kuai
@ 2025-01-27 9:35 ` Mariusz Tkaczyk
0 siblings, 0 replies; 4+ messages in thread
From: Mariusz Tkaczyk @ 2025-01-27 9:35 UTC (permalink / raw)
To: Yu Kuai; +Cc: song, linux-raid, yangerkun, yukuai (C)
On Sun, 26 Jan 2025 16:22:58 +0800
Yu Kuai <yukuai1@huaweicloud.com> wrote:
> 在 2024/12/31 16:49, Mariusz Tkaczyk 写道:
> > On Fri, 27 Dec 2024 14:07:02 +0800
> > Yu Kuai <yukuai1@huaweicloud.com> wrote:
> >
> >> From: Yu Kuai <yukuai3@huawei.com>
> >>
> >> For the case mdadm --grow with --add, the s.btype should not be
> >> initialized yet, hence BitmapUnknown should be checked instead of
> >> BitmapNone.
> >
> > Hi Kuai,
> >
> > For commit extra clarity it would be nice to include command you are
> > executing.
> >
> > What if someone will do (not tested):
> > #mdadm --grow /dev/md0 --add /dev/sdx --bitmap=none
> >
> > I think that it is perfectly valid, now it may work but I expect
> > your change to broke it.
>
> Hi,
>
> Sorry for the late reply, I forgot about this patch somehow :(
>
> Changes from commit 581ba1341017:
>
> @@ -1634,7 +1625,7 @@ int main(int argc, char *argv[])
> if (devs_found > 1 && s.raiddisks == 0 && s.level ==
> UnSet) {
> /* must be '-a'. */
> if (s.size > 0 || s.chunk ||
> - s.layout_str || s.bitmap_file) {
> + s.layout_str || s.btype != BitmapNone) {
> pr_err("--add cannot be used with
> other geometry changes in --grow mode\n");
> rv = 1;
> break;
>
>
> Hence before the commit, bitmap=none is not valid in this case as
> well, because s.bitmap_file will set to "none" in this case.
>
> Thanks,
> Kuai
>
OK, ack from my side then.
If there will be no more comments we can merge it. I opened
PR to test it:
https://github.com/md-raid-utilities/mdadm/pull/145
Thanks,
Mariusz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-27 9:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-27 6:07 [PATCH] mdadm: fix --grow with --add for linear Yu Kuai
2024-12-31 8:49 ` Mariusz Tkaczyk
2025-01-26 8:22 ` Yu Kuai
2025-01-27 9:35 ` Mariusz Tkaczyk
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).