mdadm: minor fixes
cover mdadm: minor fixes
There are some building errors and regression bug.
The PR is at https://github.com/md-raid-utilities/mdadm/pull/178
Xiao Ni (3):
mdadm: use standard libc nftw
mdadm: fix building errors
mdadm: add attribute nonstring for signature
lib.c | 22 ---------------------- platform-intel.h | 2 +- super-ddf.c | 9 +++++---- super-intel.c | 3 ++- 4 files changed, 8 insertions(+), 28 deletions(-)
Signature · 1 line
2.32.0 (Apple Git-132)
PATCH 1/3 mdadm: use standard libc nftw
commit bd648e3bec3d ("mdadm: Remove klibc and uclibc support") removes macro HAVE_NFTW/HAVE_FTW and uses libc header ftw.h. But it leaves the codes in lib.c which let mdadm command call nftw defined in lib.c. It needs to remove these codes.
The bug can be reproduced by:
mdadm -CR /dev/md0 --level raid5 --metadata=1.1 --chunk=32 --raid-disks 3 --size 10000 /dev/loop1 /dev/loop2 /dev/loop3
mdadm /dev/md0 --grow --chunk=64
mdadm: /dev/md0: cannot open component -unknown-
--- lib.c | 22 ---------------------- 1 file changed, 22 deletions(-)
lib.c +0 -22
@@ -245,28 +245,6 @@ int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)return 0 ; } -#ifndef HAVE_NFTW -#ifdef HAVE_FTW -int add_dev_1 (const char *name,const struct stat *stb,int flag) -{ -return add_dev (name, stb, flag,NULL ); -} -int nftw (const char *path, -int (*han)(const char *name,const struct stat *stb, -int flag,struct FTW *s),int nopenfd,int flags) -{ -return ftw (path, add_dev_1, nopenfd); -} -#else -int nftw (const char *path, -int (*han)(const char *name,const struct stat *stb, -int flag,struct FTW *s),int nopenfd,int flags) -{ -return 0 ; -} -#endif /* HAVE_FTW */ -#endif /* HAVE_NFTW */ -/* * Find a block device with the right major/minor number. * If we find multiple names, choose the shortest.
Signature · 1 line
2.32.0 (Apple Git-132)
PATCH 2/3 mdadm: fix building errors
In reply to Xiao NiSome building errors are found in ppc64le platform:
format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=]
--- super-ddf.c | 9 +++++---- super-intel.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-)
super-ddf.c +5 -4
@@ -1606,9 +1606,9 @@ static void examine_vd(int n, struct ddf_super *sb, char *guid) map_num(ddf_sec_level, vc->srl) ?: "-unknown-"); }printf (" Device Size[%d] : %llu\n" , n, -be64_to_cpu (vc->blocks)/2 ); + (unsigned long long )(be64_to_cpu (vc->blocks)/2 ));printf (" Array Size[%d] : %llu\n" , n, -be64_to_cpu (vc->array_blocks)/2 ); + (unsigned long long )(be64_to_cpu (vc->array_blocks)/2 )); } }
@@ -1665,7 +1665,7 @@ static void examine_pds(struct ddf_super *sb)printf (" %3d %08x " , i,be32_to_cpu (pd->refnum));printf ("%8lluK " , -be64_to_cpu (pd->config_size)>>1 ); + (unsigned long long )be64_to_cpu (pd->config_size)>>1 );for (dl = sb->dlist; dl ; dl = dl->next) {if (be32_eq (dl->disk.refnum, pd->refnum)) {char *dv =map_dev (dl->major, dl->minor,0 );
@@ -2901,7 +2901,8 @@ static unsigned int find_unused_pde(const struct ddf_super *ddf)static void _set_config_size (struct phys_disk_entry *pde,const struct dl *dl) {__u64 cfs, t; - cfs =min (dl->size -32 *1024 *2ULL ,be64_to_cpu (dl->primary_lba)); + cfs =min ((unsigned long long )dl->size -32 *1024 *2ULL , + (unsigned long long )(be64_to_cpu (dl->primary_lba))); t =be64_to_cpu (dl->secondary_lba);if (t != ~(__u64 )0 ) cfs =min (cfs, t);
super-intel.c +2 -1
@@ -2325,7 +2325,8 @@ static void export_examine_super_imsm(struct supertype *st)printf ("MD_LEVEL=container\n" );printf ("MD_UUID=%s\n" , nbuf+5 );printf ("MD_DEVICES=%u\n" , mpb->num_disks); -printf ("MD_CREATION_TIME=%llu\n" ,__le64_to_cpu (mpb->creation_time)); +printf ("MD_CREATION_TIME=%llu\n" , + (unsigned long long )__le64_to_cpu (mpb->creation_time)); } static void detail_super_imsm(struct supertype *st, char *homehost,
Signature · 1 line
2.32.0 (Apple Git-132)
Re: [PATCH 2/3] mdadm: fix building errors
Dear Xiao,
Thank you for your patch. Could you make the summary/title more specific? Something like Cast …?
Am 07.05.25 um 14:20 schrieb Xiao Ni:
Quoted 3 lines
Some building errors are found in ppc64le platform:
format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=]
I’d put pasted things in one line.
Also, please state how you fixed this.
Quoted 23 lines
Signed-off-by Xiao Ni <[email protected]>--- super-ddf.c | 9 +++++---- super-intel.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-)super-ddf.c +2
-2@@ -1606,9 +1606,9 @@ static void examine_vd(int n, struct ddf_super *sb, char *guid) map_num(ddf_sec_level, vc->srl) ?: "-unknown-"); }printf (" Device Size[%d] : %llu\n" , n, -be64_to_cpu (vc->blocks)/2 ); + (unsigned long long )(be64_to_cpu (vc->blocks)/2 ));printf (" Array Size[%d] : %llu\n" , n, -be64_to_cpu (vc->array_blocks)/2 ); + (unsigned long long )(be64_to_cpu (vc->array_blocks)/2 )); } }
super-ddf.c static void examine_pds(struct ddf_super *sb) · line 1668
Quoted 5 lines
super-ddf.c +1
-1@@ -1665,7 +1665,7 @@ static void examine_pds(struct ddf_super *sb)printf (" %3d %08x " , i,be32_to_cpu (pd->refnum));printf ("%8lluK " , -be64_to_cpu (pd->config_size)>>1 ); + (unsigned long long )be64_to_cpu (pd->config_size)>>1 );
Keep the alignement from before?
Quoted 18 lines
super-ddf.c +2
-1for (dl = sb->dlist; dl ; dl = dl->next) {if (be32_eq (dl->disk.refnum, pd->refnum)) {char *dv =map_dev (dl->major, dl->minor,0 );@@ -2901,7 +2901,8 @@ static unsigned int find_unused_pde(const struct ddf_super *ddf)static void _set_config_size (struct phys_disk_entry *pde,const struct dl *dl) {__u64 cfs, t; - cfs =min (dl->size -32 *1024 *2ULL ,be64_to_cpu (dl->primary_lba)); + cfs =min ((unsigned long long )dl->size -32 *1024 *2ULL , + (unsigned long long )(be64_to_cpu (dl->primary_lba))); t =be64_to_cpu (dl->secondary_lba);if (t != ~(__u64 )0 ) cfs =min (cfs, t);super-intel.c +0
-0
super-intel.c static void export_examine_super_imsm(struct supertype *st) · line 2332
Quoted 9 lines
super-intel.c +2
-1@@ -2325,7 +2325,8 @@ static void export_examine_super_imsm(struct supertype *st)printf ("MD_LEVEL=container\n" );printf ("MD_UUID=%s\n" , nbuf+5 );printf ("MD_DEVICES=%u\n" , mpb->num_disks); -printf ("MD_CREATION_TIME=%llu\n" ,__le64_to_cpu (mpb->creation_time)); +printf ("MD_CREATION_TIME=%llu\n" , + (unsigned long long )__le64_to_cpu (mpb->creation_time)); } static void detail_super_imsm(struct supertype *st, char *homehost,
Can’t this be fixed in the header?
Kind regards,
Paul
Re: [PATCH 2/3] mdadm: fix building errors
Quoted 6 lines · Paul Menzel
Dear Xiao,
Thank you for your patch. Could you make the summary/title more specific? Something like Cast …?
How about 'Cast be64_to_cpu to unsigned long long'? Or any good suggestion?
Quoted 8 lines
Am 07.05.25 um 14:20 schrieb Xiao Ni:
Quoted 3 lines
Some building errors are found in ppc64le platform:
format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=]I’d put pasted things in one line.
There is a 75 character number limit for each line in commit.
Quoted 2 lines
Also, please state how you fixed this.
Ok, but it's easy to see from the patch. It just do a cast with (unsigned long long)
Quoted 23 lines
Quoted 23 lines
Signed-off-by Xiao Ni <[email protected]>--- super-ddf.c | 9 +++++---- super-intel.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-)super-ddf.c +2
-2@@ -1606,9 +1606,9 @@ static void examine_vd(int n, struct ddf_super *sb, char *guid) map_num(ddf_sec_level, vc->srl) ?: "-unknown-"); }printf (" Device Size[%d] : %llu\n" , n, -be64_to_cpu (vc->blocks)/2 ); + (unsigned long long )(be64_to_cpu (vc->blocks)/2 ));printf (" Array Size[%d] : %llu\n" , n, -be64_to_cpu (vc->array_blocks)/2 ); + (unsigned long long )(be64_to_cpu (vc->array_blocks)/2 )); } }
Quoted 8 lines
super-ddf.c static void examine_pds(struct ddf_super *sb) · line 1668
Quoted 6 lines
super-ddf.c +1
-1@@ -1665,7 +1665,7 @@ static void examine_pds(struct ddf_super *sb)printf (" %3d %08x " , i,be32_to_cpu (pd->refnum));printf ("%8lluK " , -be64_to_cpu (pd->config_size)>>1 ); + (unsigned long long )be64_to_cpu (pd->config_size)>>1 );Keep the alignement from before?
We usually use tab rather than spaces. So it's better to use tab here. But I don't want to fix all the alignments problem.
Quoted 27 lines
Quoted 27 lines
super-ddf.c +2
-1for (dl = sb->dlist; dl ; dl = dl->next) {if (be32_eq (dl->disk.refnum, pd->refnum)) {char *dv =map_dev (dl->major, dl->minor,0 );@@ -2901,7 +2901,8 @@ static unsigned int find_unused_pde(const struct ddf_super *ddf)static void _set_config_size (struct phys_disk_entry *pde,const struct dl *dl) {__u64 cfs, t; - cfs =min (dl->size -32 *1024 *2ULL ,be64_to_cpu (dl->primary_lba)); + cfs =min ((unsigned long long )dl->size -32 *1024 *2ULL , + (unsigned long long )(be64_to_cpu (dl->primary_lba))); t =be64_to_cpu (dl->secondary_lba);if (t != ~(__u64 )0 ) cfs =min (cfs, t);super-intel.c +2
-1@@ -2325,7 +2325,8 @@ static void export_examine_super_imsm(struct supertype *st)printf ("MD_LEVEL=container\n" );printf ("MD_UUID=%s\n" , nbuf+5 );printf ("MD_DEVICES=%u\n" , mpb->num_disks); -printf ("MD_CREATION_TIME=%llu\n" ,__le64_to_cpu (mpb->creation_time)); +printf ("MD_CREATION_TIME=%llu\n" , + (unsigned long long )__le64_to_cpu (mpb->creation_time)); }
Quoted 3 lines
super-intel.c static void export_examine_super_imsm(struct supertype *st) · line 2332
Quoted 1 line
super-intel.c +0
-0static void detail_super_imsm(struct supertype *st, char *homehost,Can’t this be fixed in the header?
I don't follow you here.
Best Regards
Xiao
Quoted 6 lines
Kind regards,
Paul
PATCH 3/3 mdadm: add attribute nonstring for signature
In reply to Xiao NiIt reports building error in f42:
error: initializer-string for array of ‘unsigned char’ truncates NULL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
--- platform-intel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
platform-intel.h +1 -1
@@ -24,7 +24,7 @@/* The IMSM Capability (IMSM AHCI and ISCU OROM/EFI variable) Version Table definition */ struct imsm_orom { -__u8 signature[4 ]; +__u8 signature[4 ] __attribute__((nonstring));#define IMSM_OROM_SIGNATURE "$VER"#define IMSM_NVME_OROM_COMPAT_SIGNATURE "$NVM"#define IMSM_VMD_OROM_COMPAT_SIGNATURE "$VMD"
Signature · 1 line
2.32.0 (Apple Git-132)