]>
Commit | Line | Data |
---|---|---|
32367cb5 N |
1 | /* |
2 | * mdadm - manage Linux "md" devices aka RAID arrays. | |
3 | * | |
4 | * Copyright (C) 2011 Neil Brown <neilb@suse.de> | |
5 | * | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 | * | |
21 | * Author: Neil Brown | |
22 | * Email: <neilb@suse.de> | |
23 | */ | |
24 | ||
25 | #include "mdadm.h" | |
26 | ||
32367cb5 N |
27 | /* name/number mappings */ |
28 | ||
29 | mapping_t r5layout[] = { | |
30 | { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC}, | |
31 | { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC}, | |
32 | { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC}, | |
33 | { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC}, | |
34 | ||
35 | { "default", ALGORITHM_LEFT_SYMMETRIC}, | |
36 | { "la", ALGORITHM_LEFT_ASYMMETRIC}, | |
37 | { "ra", ALGORITHM_RIGHT_ASYMMETRIC}, | |
38 | { "ls", ALGORITHM_LEFT_SYMMETRIC}, | |
39 | { "rs", ALGORITHM_RIGHT_SYMMETRIC}, | |
40 | ||
41 | { "parity-first", ALGORITHM_PARITY_0}, | |
42 | { "parity-last", ALGORITHM_PARITY_N}, | |
43 | { "ddf-zero-restart", ALGORITHM_RIGHT_ASYMMETRIC}, | |
44 | { "ddf-N-restart", ALGORITHM_LEFT_ASYMMETRIC}, | |
45 | { "ddf-N-continue", ALGORITHM_LEFT_SYMMETRIC}, | |
46 | ||
47 | { NULL, 0} | |
48 | }; | |
49 | mapping_t r6layout[] = { | |
50 | { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC}, | |
51 | { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC}, | |
52 | { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC}, | |
53 | { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC}, | |
54 | ||
55 | { "default", ALGORITHM_LEFT_SYMMETRIC}, | |
56 | { "la", ALGORITHM_LEFT_ASYMMETRIC}, | |
57 | { "ra", ALGORITHM_RIGHT_ASYMMETRIC}, | |
58 | { "ls", ALGORITHM_LEFT_SYMMETRIC}, | |
59 | { "rs", ALGORITHM_RIGHT_SYMMETRIC}, | |
60 | ||
61 | { "parity-first", ALGORITHM_PARITY_0}, | |
62 | { "parity-last", ALGORITHM_PARITY_N}, | |
63 | { "ddf-zero-restart", ALGORITHM_ROTATING_ZERO_RESTART}, | |
64 | { "ddf-N-restart", ALGORITHM_ROTATING_N_RESTART}, | |
65 | { "ddf-N-continue", ALGORITHM_ROTATING_N_CONTINUE}, | |
66 | ||
67 | { "left-asymmetric-6", ALGORITHM_LEFT_ASYMMETRIC_6}, | |
68 | { "right-asymmetric-6", ALGORITHM_RIGHT_ASYMMETRIC_6}, | |
69 | { "left-symmetric-6", ALGORITHM_LEFT_SYMMETRIC_6}, | |
70 | { "right-symmetric-6", ALGORITHM_RIGHT_SYMMETRIC_6}, | |
71 | { "parity-first-6", ALGORITHM_PARITY_0_6}, | |
72 | ||
73 | { NULL, 0} | |
74 | }; | |
75 | ||
76 | mapping_t pers[] = { | |
77 | { "linear", LEVEL_LINEAR}, | |
78 | { "raid0", 0}, | |
79 | { "0", 0}, | |
80 | { "stripe", 0}, | |
81 | { "raid1", 1}, | |
82 | { "1", 1}, | |
83 | { "mirror", 1}, | |
84 | { "raid4", 4}, | |
85 | { "4", 4}, | |
86 | { "raid5", 5}, | |
87 | { "5", 5}, | |
88 | { "multipath", LEVEL_MULTIPATH}, | |
89 | { "mp", LEVEL_MULTIPATH}, | |
90 | { "raid6", 6}, | |
91 | { "6", 6}, | |
92 | { "raid10", 10}, | |
93 | { "10", 10}, | |
94 | { "faulty", LEVEL_FAULTY}, | |
95 | { "container", LEVEL_CONTAINER}, | |
96 | { NULL, 0} | |
97 | }; | |
98 | ||
32367cb5 N |
99 | mapping_t modes[] = { |
100 | { "assemble", ASSEMBLE}, | |
101 | { "build", BUILD}, | |
102 | { "create", CREATE}, | |
103 | { "manage", MANAGE}, | |
104 | { "misc", MISC}, | |
105 | { "monitor", MONITOR}, | |
106 | { "grow", GROW}, | |
107 | { "incremental", INCREMENTAL}, | |
108 | { "auto-detect", AUTODETECT}, | |
109 | }; | |
110 | ||
111 | mapping_t faultylayout[] = { | |
112 | { "write-transient", WriteTransient }, | |
113 | { "wt", WriteTransient }, | |
114 | { "read-transient", ReadTransient }, | |
115 | { "rt", ReadTransient }, | |
116 | { "write-persistent", WritePersistent }, | |
117 | { "wp", WritePersistent }, | |
118 | { "read-persistent", ReadPersistent }, | |
119 | { "rp", ReadPersistent }, | |
120 | { "write-all", WriteAll }, | |
121 | { "wa", WriteAll }, | |
122 | { "read-fixable", ReadFixable }, | |
123 | { "rf", ReadFixable }, | |
124 | ||
125 | { "clear", ClearErrors}, | |
126 | { "flush", ClearFaults}, | |
127 | { "none", ClearErrors}, | |
128 | { "default", ClearErrors}, | |
129 | { NULL, 0} | |
130 | }; | |
131 | ||
132 | char *map_num(mapping_t *map, int num) | |
133 | { | |
134 | while (map->name) { | |
135 | if (map->num == num) | |
136 | return map->name; | |
137 | map++; | |
138 | } | |
139 | return NULL; | |
140 | } | |
141 | ||
142 | int map_name(mapping_t *map, char *name) | |
143 | { | |
144 | while (map->name) { | |
145 | if (strcmp(map->name, name)==0) | |
146 | return map->num; | |
147 | map++; | |
148 | } | |
149 | return UnSet; | |
150 | } |