Status: ok Provide support for new RAID-10 module ... which is still under development Signed-off-by: Neil Brown ### Diffstat output ./Create.c | 13 +++++++++++++ ./Detail.c | 6 ++++++ ./Examine.c | 6 ++++++ ./ReadMe.c | 6 ++++-- ./mdadm.c | 19 ++++++++++++++++++- ./util.c | 2 ++ 6 files changed, 49 insertions(+), 3 deletions(-) diff ./Create.c~current~ ./Create.c --- ./Create.c~current~ 2004-08-02 11:19:59.000000000 +1000 +++ ./Create.c 2004-06-25 11:25:22.000000000 +1000 @@ -111,6 +111,18 @@ int Create(char *mddev, int mdfd, return 1; } + if (level == 10) { + /* check layout */ + if (layout == UnSet) { + fprintf(stderr, Name ": layout must be set for raid10\n"); + return 1; + } + if ((layout&255) * ((layout>>8)&255) > raiddisks) { + fprintf(stderr, Name ": that layout requires at least %d devices\n", + (layout&255) * ((layout>>8)&255)); + return 1; + } + } /* now set some defaults */ if (layout == UnSet) switch(level) { @@ -129,6 +141,7 @@ int Create(char *mddev, int mdfd, switch(level) { case 4: case 5: + case 10: case 6: case 0: case -1: /* linear */ diff ./Detail.c~current~ ./Detail.c --- ./Detail.c~current~ 2004-08-02 11:19:59.000000000 +1000 +++ ./Detail.c 2004-06-25 11:21:35.000000000 +1000 @@ -174,10 +174,16 @@ int Detail(char *dev, int brief, int tes c = map_num(r5layout, array.layout); printf(" Layout : %s\n", c?c:"-unknown-"); } + if (array.level == 10) { + printf(" Layout : near=%d, far=%d\n", + array.layout&255, (array.layout>>8)&255); + } switch (array.level) { case 0: case 4: case 5: + case 10: + case 6: printf(" Chunk Size : %dK\n\n", array.chunk_size/1024); break; case -1: diff ./Examine.c~current~ ./Examine.c --- ./Examine.c~current~ 2004-08-02 11:19:59.000000000 +1000 +++ ./Examine.c 2004-06-25 11:20:15.000000000 +1000 @@ -179,10 +179,16 @@ int Examine(mddev_dev_t devlist, int bri c = map_num(r5layout, super.layout); printf(" Layout : %s\n", c?c:"-unknown-"); } + if (super.level == 10) { + printf(" Layout : near=%d, far=%d\n", + super.layout&255, (super.layout>>8)&255); + } switch(super.level) { case 0: case 4: case 5: + case 6: + case 10: printf(" Chunk Size : %dK\n", super.chunk_size/1024); break; case -1: diff ./ReadMe.c~current~ ./ReadMe.c --- ./ReadMe.c~current~ 2004-08-02 11:19:59.000000000 +1000 +++ ./ReadMe.c 2004-06-25 11:06:35.000000000 +1000 @@ -216,7 +216,7 @@ char OptionHelp[] = " --layout= : same as --parity\n" " --raid-devices= -n : number of active devices in array\n" " --spare-devices= -x: number of spares (eXtras) devices in initial array\n" -" --size= -z : Size (in K) of each drive in RAID1/4/5/6 - optional\n" +" --size= -z : Size (in K) of each drive in RAID1/4/5/6/10 - optional\n" " --force -f : Honour devices as listed on command line. Don't\n" " : insert a missing drive for RAID5.\n" " --auto(=p) -a : Automatically allocate new (partitioned) md array if needed.\n" @@ -284,7 +284,7 @@ char Help_create[] = " --layout= : same as --parity\n" " --raid-devices= -n : number of active devices in array\n" " --spare-devices= -x: number of spares (eXtras) devices in initial array\n" -" --size= -z : Size (in K) of each drive in RAID1/4/5/6 - optional\n" +" --size= -z : Size (in K) of each drive in RAID1/4/5/6/10 - optional\n" " --force -f : Honour devices as listed on command line. Don't\n" " : insert a missing drive for RAID5.\n" " --run -R : insist of running the array even if not all\n" @@ -508,6 +508,8 @@ mapping_t pers[] = { { "mp", -4}, { "raid6", 6}, { "6", 6}, + { "raid10", 10}, + { "10", 10}, { NULL, 0} }; diff ./mdadm.c~current~ ./mdadm.c --- ./mdadm.c~current~ 2004-08-02 11:19:59.000000000 +1000 +++ ./mdadm.c 2004-06-25 11:23:35.000000000 +1000 @@ -235,6 +235,8 @@ int main(int argc, char *argv[]) int daemonise = 0; int oneshot = 0; + int copies; + int mdfd = -1; ident.uuid_set=0; @@ -445,7 +447,7 @@ int main(int argc, char *argv[]) continue; case O(CREATE,'p'): /* raid5 layout */ - if (layout >= 0) { + if (layout != UnSet) { fprintf(stderr,Name ": layout may only be sent once. " "Second value was %s\n", optarg); exit(2); @@ -468,6 +470,21 @@ int main(int argc, char *argv[]) exit(2); } break; + + case 10: + /* 'f' or 'n' followed by a number <= raid_disks */ + if ((optarg[0] != 'n' && optarg[0] != 'f') || + (copies = strtoul(optarg+1, &cp, 10)) < 1 || + copies > 200 || + *cp) { + fprintf(stderr, Name ": layout for raid10 must be 'nNN' or 'fNN' where NN is a number, not %s\n", optarg); + exit(2); + } + if (optarg[0] == 'n') + layout = 256 + copies; + else + layout = 1 + (copies<<8); + break; } continue; diff ./util.c~current~ ./util.c --- ./util.c~current~ 2004-08-02 11:19:59.000000000 +1000 +++ ./util.c 2004-06-25 11:17:38.000000000 +1000 @@ -121,6 +121,8 @@ int get_linux_version() int enough(int level, int raid_disks, int avail_disks) { switch (level) { + case 10: return 1; /* a lie, but it is hard to tell */ + case -4: return avail_disks>= 1; case -1: