linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [mdadm PATCH] Make get_component_size() work with named array.
@ 2016-12-22  2:14 NeilBrown
  2016-12-22 17:19 ` Jes Sorensen
  0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2016-12-22  2:14 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Robert LeBlanc, linux-raid

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]


get_component_size() still assumes that all array are
 /sys/block/md%d or /sys/block/md_d%d
and so doesn't work with e.g. /sys/block/md_foo.

This cause "mdadm --detail" to report
   Used Dev Size : unknown
and causes problems when added spares and in other circumstances.

So change it to use stat2devnm() which does the right thing with all
types of array names.

Reported-and-tested-by: Robert LeBlanc <robert@leblancnet.us>
Signed-off-by: NeilBrown <neilb@suse.com>
---
 sysfs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/sysfs.c b/sysfs.c
index 84c7348526c9..b0657a04b3a3 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -400,14 +400,8 @@ unsigned long long get_component_size(int fd)
 	int n;
 	if (fstat(fd, &stb))
 		return 0;
-	if (major(stb.st_rdev) != (unsigned)get_mdp_major())
-		snprintf(fname, MAX_SYSFS_PATH_LEN,
-			"/sys/block/md%d/md/component_size",
-			(int)minor(stb.st_rdev));
-	else
-		snprintf(fname, MAX_SYSFS_PATH_LEN,
-			"/sys/block/md_d%d/md/component_size",
-			(int)minor(stb.st_rdev)>>MdpMinorShift);
+	snprintf(fname, MAX_SYSFS_PATH_LEN,
+		 "/sys/block/%s/md/component_size", stat2devnm(&stb));
 	fd = open(fname, O_RDONLY);
 	if (fd < 0)
 		return 0;
-- 
2.11.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [mdadm PATCH] Make get_component_size() work with named array.
  2016-12-22  2:14 [mdadm PATCH] Make get_component_size() work with named array NeilBrown
@ 2016-12-22 17:19 ` Jes Sorensen
  0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2016-12-22 17:19 UTC (permalink / raw)
  To: NeilBrown; +Cc: Robert LeBlanc, linux-raid

NeilBrown <neilb@suse.com> writes:
> get_component_size() still assumes that all array are
>  /sys/block/md%d or /sys/block/md_d%d
> and so doesn't work with e.g. /sys/block/md_foo.
>
> This cause "mdadm --detail" to report
>    Used Dev Size : unknown
> and causes problems when added spares and in other circumstances.
>
> So change it to use stat2devnm() which does the right thing with all
> types of array names.
>
> Reported-and-tested-by: Robert LeBlanc <robert@leblancnet.us>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  sysfs.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)

Applied!

Thanks,
Jes

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

end of thread, other threads:[~2016-12-22 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-22  2:14 [mdadm PATCH] Make get_component_size() work with named array NeilBrown
2016-12-22 17:19 ` 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).