Make get_component_size() work with named array.
PATCH 1/1 Make get_component_size() work with named array.
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.
--- sysfs.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
sysfs.c +2 -8
@@ -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 ;
Signature · 1 line
2.11.0
Jes Sorensen
AppliedQuoted 8 lines · NeilBrown
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.
Quoted 8 lines
So change it to use
stat2devnm()which does the right thing with all types of array names.Reported-and-tested-by Robert LeBlanc <[email protected]>Signed-off-by NeilBrown <[email protected]>--- sysfs.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
Applied!
Thanks,
Jes