* [Patch v5] super1: fix sb->max_dev when adding a new disk in linear array
@ 2017-05-25 9:28 Lidong Zhong
2017-05-25 21:51 ` NeilBrown
2017-05-26 18:35 ` Jes Sorensen
0 siblings, 2 replies; 3+ messages in thread
From: Lidong Zhong @ 2017-05-25 9:28 UTC (permalink / raw)
To: linux-raid, neilb; +Cc: colyli, Jes.Sorensen
The value of sb->max_dev will always be increased by 1 when adding
a new disk in linear array. It causes an inconsistence between each
disk in the array and the "Array State" value of "mdadm --examine DISK"
is wrong. For example, when adding the first new disk into linear array
it will be:
Array State : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
('A' == active, '.' == missing, 'R' == replacing)
Adding the second disk into linear array it will be
Array State : .AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
('A' == active, '.' == missing, 'R' == replacing)
Signed-off-by: Lidong Zhong <lzhong@suse.com>
---
super1.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/super1.c b/super1.c
index 2fcb814..86ec850 100644
--- a/super1.c
+++ b/super1.c
@@ -1267,8 +1267,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
break;
sb->dev_number = __cpu_to_le32(i);
info->disk.number = i;
- if (max >= __le32_to_cpu(sb->max_dev))
+ if (i >= max) {
sb->max_dev = __cpu_to_le32(max+1);
+ }
random_uuid(sb->device_uuid);
@@ -1293,7 +1294,11 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
}
}
} else if (strcmp(update, "linear-grow-update") == 0) {
+ int max = __le32_to_cpu(sb->max_dev);
sb->raid_disks = __cpu_to_le32(info->array.raid_disks);
+ if (info->array.raid_disks > max) {
+ sb->max_dev = __cpu_to_le32(max+1);
+ }
sb->dev_roles[info->disk.number] =
__cpu_to_le16(info->disk.raid_disk);
} else if (strcmp(update, "resync") == 0) {
--
2.12.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Patch v5] super1: fix sb->max_dev when adding a new disk in linear array
2017-05-25 9:28 [Patch v5] super1: fix sb->max_dev when adding a new disk in linear array Lidong Zhong
@ 2017-05-25 21:51 ` NeilBrown
2017-05-26 18:35 ` Jes Sorensen
1 sibling, 0 replies; 3+ messages in thread
From: NeilBrown @ 2017-05-25 21:51 UTC (permalink / raw)
To: Lidong Zhong, linux-raid; +Cc: colyli, Jes.Sorensen
[-- Attachment #1: Type: text/plain, Size: 1840 bytes --]
On Thu, May 25 2017, Lidong Zhong wrote:
> The value of sb->max_dev will always be increased by 1 when adding
> a new disk in linear array. It causes an inconsistence between each
> disk in the array and the "Array State" value of "mdadm --examine DISK"
> is wrong. For example, when adding the first new disk into linear array
> it will be:
>
> Array State : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> ('A' == active, '.' == missing, 'R' == replacing)
>
> Adding the second disk into linear array it will be
>
> Array State : .AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> ('A' == active, '.' == missing, 'R' == replacing)
>
> Signed-off-by: Lidong Zhong <lzhong@suse.com>
Reviewed-by: NeilBrown <neilb@suse.com>
Thanks,
NeilBrown
> ---
> super1.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/super1.c b/super1.c
> index 2fcb814..86ec850 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -1267,8 +1267,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
> break;
> sb->dev_number = __cpu_to_le32(i);
> info->disk.number = i;
> - if (max >= __le32_to_cpu(sb->max_dev))
> + if (i >= max) {
> sb->max_dev = __cpu_to_le32(max+1);
> + }
>
> random_uuid(sb->device_uuid);
>
> @@ -1293,7 +1294,11 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
> }
> }
> } else if (strcmp(update, "linear-grow-update") == 0) {
> + int max = __le32_to_cpu(sb->max_dev);
> sb->raid_disks = __cpu_to_le32(info->array.raid_disks);
> + if (info->array.raid_disks > max) {
> + sb->max_dev = __cpu_to_le32(max+1);
> + }
> sb->dev_roles[info->disk.number] =
> __cpu_to_le16(info->disk.raid_disk);
> } else if (strcmp(update, "resync") == 0) {
> --
> 2.12.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Patch v5] super1: fix sb->max_dev when adding a new disk in linear array
2017-05-25 9:28 [Patch v5] super1: fix sb->max_dev when adding a new disk in linear array Lidong Zhong
2017-05-25 21:51 ` NeilBrown
@ 2017-05-26 18:35 ` Jes Sorensen
1 sibling, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2017-05-26 18:35 UTC (permalink / raw)
To: Lidong Zhong, linux-raid, neilb; +Cc: colyli
On 05/25/2017 05:28 AM, Lidong Zhong wrote:
> The value of sb->max_dev will always be increased by 1 when adding
> a new disk in linear array. It causes an inconsistence between each
> disk in the array and the "Array State" value of "mdadm --examine DISK"
> is wrong. For example, when adding the first new disk into linear array
> it will be:
>
> Array State : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> ('A' == active, '.' == missing, 'R' == replacing)
>
> Adding the second disk into linear array it will be
>
> Array State : .AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> ('A' == active, '.' == missing, 'R' == replacing)
>
> Signed-off-by: Lidong Zhong <lzhong@suse.com>
> ---
> super1.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied!
Thanks,
Jes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-26 18:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-25 9:28 [Patch v5] super1: fix sb->max_dev when adding a new disk in linear array Lidong Zhong
2017-05-25 21:51 ` NeilBrown
2017-05-26 18:35 ` Jes Sorensen
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).