linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Fix RAID metadata check
@ 2016-09-22  7:02 Mariusz Dabrowski
  2016-09-22 15:35 ` Jes Sorensen
  0 siblings, 1 reply; 2+ messages in thread
From: Mariusz Dabrowski @ 2016-09-22  7:02 UTC (permalink / raw)
  To: linux-raid
  Cc: Jes.Sorensen, tomasz.majchrzak, aleksey.obitotskiy,
	pawel.baldysiak, artur.paszkiewicz, maksymilian.kunt,
	Mariusz Dabrowski

mdadm recognizes devices with partition table as part of an RAID array
and invalid warning message is displayed. After this fix proper warning
messages are being displayed for MBR/GPT disks and devices with RAID
metadata.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
---
 util.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/util.c b/util.c
index 8b52242..a238a21 100644
--- a/util.c
+++ b/util.c
@@ -710,17 +710,22 @@ int check_raid(int fd, char *name)
 
 	if (!st)
 		return 0;
-	st->ss->load_super(st, fd, name);
-	/* Looks like a raid array .. */
-	pr_err("%s appears to be part of a raid array:\n",
-		name);
-	st->ss->getinfo_super(st, &info, NULL);
-	st->ss->free_super(st);
-	crtime = info.array.ctime;
-	level = map_num(pers, info.array.level);
-	if (!level) level = "-unknown-";
-	cont_err("level=%s devices=%d ctime=%s",
-		 level, info.array.raid_disks, ctime(&crtime));
+	if (st->ss->add_to_super != NULL) {
+		st->ss->load_super(st, fd, name);
+		/* Looks like a raid array .. */
+		pr_err("%s appears to be part of a raid array:\n", name);
+		st->ss->getinfo_super(st, &info, NULL);
+		st->ss->free_super(st);
+		crtime = info.array.ctime;
+		level = map_num(pers, info.array.level);
+		if (!level)
+			level = "-unknown-";
+		cont_err("level=%s devices=%d ctime=%s",
+			level, info.array.raid_disks, ctime(&crtime));
+	} else {
+		/* Looks like GPT or MBR */
+		pr_err("partition table exists on %s\n", name);
+	}
 	return 1;
 }
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Fix RAID metadata check
  2016-09-22  7:02 [PATCH v2] Fix RAID metadata check Mariusz Dabrowski
@ 2016-09-22 15:35 ` Jes Sorensen
  0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2016-09-22 15:35 UTC (permalink / raw)
  To: Mariusz Dabrowski
  Cc: linux-raid, tomasz.majchrzak, aleksey.obitotskiy, pawel.baldysiak,
	artur.paszkiewicz, maksymilian.kunt

Mariusz Dabrowski <mariusz.dabrowski@intel.com> writes:
> mdadm recognizes devices with partition table as part of an RAID array
> and invalid warning message is displayed. After this fix proper warning
> messages are being displayed for MBR/GPT disks and devices with RAID
> metadata.
>
> Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
> ---
>  util.c | 27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)

Looks good, applied!

Thanks,
Jes

> diff --git a/util.c b/util.c
> index 8b52242..a238a21 100644
> --- a/util.c
> +++ b/util.c
> @@ -710,17 +710,22 @@ int check_raid(int fd, char *name)
>  
>  	if (!st)
>  		return 0;
> -	st->ss->load_super(st, fd, name);
> -	/* Looks like a raid array .. */
> -	pr_err("%s appears to be part of a raid array:\n",
> -		name);
> -	st->ss->getinfo_super(st, &info, NULL);
> -	st->ss->free_super(st);
> -	crtime = info.array.ctime;
> -	level = map_num(pers, info.array.level);
> -	if (!level) level = "-unknown-";
> -	cont_err("level=%s devices=%d ctime=%s",
> -		 level, info.array.raid_disks, ctime(&crtime));
> +	if (st->ss->add_to_super != NULL) {
> +		st->ss->load_super(st, fd, name);
> +		/* Looks like a raid array .. */
> +		pr_err("%s appears to be part of a raid array:\n", name);
> +		st->ss->getinfo_super(st, &info, NULL);
> +		st->ss->free_super(st);
> +		crtime = info.array.ctime;
> +		level = map_num(pers, info.array.level);
> +		if (!level)
> +			level = "-unknown-";
> +		cont_err("level=%s devices=%d ctime=%s",
> +			level, info.array.raid_disks, ctime(&crtime));
> +	} else {
> +		/* Looks like GPT or MBR */
> +		pr_err("partition table exists on %s\n", name);
> +	}
>  	return 1;
>  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-22 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22  7:02 [PATCH v2] Fix RAID metadata check Mariusz Dabrowski
2016-09-22 15: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).