Move code to function for code reuse. Signed-off-by: Adam Kwolek <adam.kwolek@xxxxxxxxx> --- mdadm.h | 1 + util.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mdadm.h b/mdadm.h index 8f3e786..4bbf660 100644 --- a/mdadm.h +++ b/mdadm.h @@ -1165,6 +1165,7 @@ extern unsigned long long get_component_size(int fd); extern void remove_partitions(int fd); extern int test_partition(int fd); extern int test_partition_from_id(dev_t id); +extern int get_data_disks(int level, int layout, int raid_disks); extern unsigned long long calc_array_size(int level, int raid_disks, int layout, int chunksize, unsigned long long devsize); extern int flush_metadata_updates(struct supertype *st); diff --git a/util.c b/util.c index 0ea7e0d..50c98c1 100644 --- a/util.c +++ b/util.c @@ -703,6 +703,12 @@ void print_r10_layout(int layout) unsigned long long calc_array_size(int level, int raid_disks, int layout, int chunksize, unsigned long long devsize) { + devsize &= ~(unsigned long long)((chunksize>>9)-1); + return get_data_disks(level, layout, raid_disks) * devsize; +} + +int get_data_disks(int level, int layout, int raid_disks) +{ int data_disks = 0; switch (level) { case 0: data_disks = raid_disks; break; @@ -713,8 +719,8 @@ unsigned long long calc_array_size(int level, int raid_disks, int layout, case 10: data_disks = raid_disks / (layout & 255) / ((layout>>8)&255); break; } - devsize &= ~(unsigned long long)((chunksize>>9)-1); - return data_disks * devsize; + + return data_disks; } #if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html