Skip to contentSkip to conversation

ddf: use 64bit 'size', not 32bit 'info->size' for create.

PATCH In review NeilBrown 2 participants 2 messages Mar 10, 2016 MD RAID

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 ddf: use 64bit 'size', not 32bit 'info->size' for create.

The 'size' field of mdu_disk_info_t is 32bit and should not be used except for legacy ioctls. super-ddf got this wrong :-(

This change makes it possible to create ddf arrays which used more than 2TB of each device.

---
 super-ddf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
super-ddf.c +2 -2
index faaf0a7ca9e0..0e00d17dd169 100644
@@ -2688,10 +2688,10 @@ static int init_super_ddf_bvd(struct supertype *st,
 		free(vcl);
 		return 0;
 	}
-	vc->blocks = cpu_to_be64(info->size * 2);
+	vc->blocks = cpu_to_be64(size * 2);
 	vc->array_blocks = cpu_to_be64(
 		calc_array_size(info->level, info->raid_disks, info->layout,
-				info->chunk_size, info->size*2));
+				info->chunk_size, size*2));
 	memset(vc->pad1, 0xff, 8);
 	vc->spare_refs[0] = cpu_to_be32(0xffffffff);
 	vc->spare_refs[1] = cpu_to_be32(0xffffffff);
Signature · 1 line
2.7.2
#1 lore raw
Quoted 19 lines · NeilBrown

The 'size' field of mdu_disk_info_t is 32bit and should not be used except for legacy ioctls. super-ddf got this wrong :-(

This change makes it possible to create ddf arrays which used more than 2TB of each device.

---
 super-ddf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
super-ddf.c +0 -0
index faaf0a7ca9e0..0e00d17dd169 100644
@@ -2688,10 +2688,10 @@ static int init_super_ddf_bvd(struct supertype *st,
 		free(vcl);
 		return 0;

super-ddf.c static int init_super_ddf_bvd(struct supertype *st, · line 2697

Quoted 10 lines
super-ddf.c +2 -2
 	}
-	vc->blocks = cpu_to_be64(info->size * 2);
+	vc->blocks = cpu_to_be64(size * 2);
 	vc->array_blocks = cpu_to_be64(
 		calc_array_size(info->level, info->raid_disks, info->layout,
-				info->chunk_size, info->size*2));
+				info->chunk_size, size*2));
 	memset(vc->pad1, 0xff, 8);
 	vc->spare_refs[0] = cpu_to_be32(0xffffffff);
 	vc->spare_refs[1] = cpu_to_be32(0xffffffff);

Thanks for the fix! I applied it with a small mod, adding the missing spaces in the last line:

super-ddf.c

Quoted 1 line
super-ddf.c +1 -0
+				info->chunk_size, size * 2));

Cheers,
Jes