From: NeilBrown <neilb@suse.de>
To: Or Sagi <ors@reduxio.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH] mdadm: fix --detail for cases where device count > max_devices/2
Date: Tue, 4 Nov 2014 09:33:11 +1100 [thread overview]
Message-ID: <20141104093311.2dabb44c@notabene.brown> (raw)
In-Reply-To: <CCCA52F1-B747-4762-8D07-12B543996470@reduxio.com>
[-- Attachment #1: Type: text/plain, Size: 2533 bytes --]
On Fri, 31 Oct 2014 11:10:33 +0200 Or Sagi <ors@reduxio.com> wrote:
> mdadm misreports (less devices then there are, and as a result decides the array is degraded) in cases where there are > max_devices/2 devices.
>
> This seems to fix it.
>
> ---
> Detail.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Detail.c b/Detail.c
> index c4fcad9..62e5867 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -72,7 +72,7 @@ int Detail(char *dev, struct context *c)
> int failed = 0;
> struct supertype *st;
> char *subarray = NULL;
> - int max_disks = MD_SB_DISKS; /* just a default */
> + int max_disks = MD_SB_DISKS * 2; /* just a default */
> struct mdinfo *info = NULL;
> struct mdinfo *sra;
> struct mdinfo *subdev;
> @@ -124,7 +124,7 @@ int Detail(char *dev, struct context *c)
> rv = 0;
>
> if (st)
> - max_disks = st->max_devs;
> + max_disks = st->max_devs * 2;
>
> if (subarray) {
> /* This is a subarray of some container.
Thanks for the report, but this patch is too simplistic.
Setting "max_disks" to twice the maximum is clearly wrong.
Then it should be called twice_max_disks.
The problem is that the 'disks' array has two entries for each 'raid_disk',
the primary disk and a possible replacement. So we need to check that all
references to the size of the array, or indices to it, are treated properly.
I think this patch should fix it. Can you test please?
Thanks,
NeilBrown
diff --git a/Detail.c b/Detail.c
index c4fcad9620ba..dd72eded995d 100644
--- a/Detail.c
+++ b/Detail.c
@@ -295,8 +295,8 @@ int Detail(char *dev, struct context *c)
goto out;
}
- disks = xmalloc(max_disks * sizeof(mdu_disk_info_t));
- for (d = 0; d < max_disks; d++) {
+ disks = xmalloc(max_disks * 2 * sizeof(mdu_disk_info_t));
+ for (d = 0; d < max_disks * 2; d++) {
disks[d].state = (1<<MD_DISK_REMOVED);
disks[d].major = disks[d].minor = 0;
disks[d].number = disks[d].raid_disk = d;
@@ -327,7 +327,7 @@ int Detail(char *dev, struct context *c)
else if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks
&& disks[disk.raid_disk*2+1].state == (1<<MD_DISK_REMOVED))
disks[disk.raid_disk*2+1] = disk;
- else if (next < max_disks)
+ else if (next < max_disks*2)
disks[next++] = disk;
}
@@ -602,7 +602,7 @@ This is pretty boring
}
free(info);
- for (d= 0; d < max_disks; d++) {
+ for (d= 0; d < max_disks * 2; d++) {
char *dv;
mdu_disk_info_t disk = disks[d];
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
prev parent reply other threads:[~2014-11-03 22:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-31 9:10 [PATCH] mdadm: fix --detail for cases where device count > max_devices/2 Or Sagi
2014-11-03 22:33 ` NeilBrown [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141104093311.2dabb44c@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=ors@reduxio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).