]> git.ipfire.org Git - thirdparty/mdadm.git/blame - maps.c
platform-intel - cache 'intel_devices' for a few seconds.
[thirdparty/mdadm.git] / maps.c
CommitLineData
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
27
28/* name/number mappings */
29
30mapping_t r5layout[] = {
31 { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
32 { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC},
33 { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC},
34 { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC},
35
36 { "default", ALGORITHM_LEFT_SYMMETRIC},
37 { "la", ALGORITHM_LEFT_ASYMMETRIC},
38 { "ra", ALGORITHM_RIGHT_ASYMMETRIC},
39 { "ls", ALGORITHM_LEFT_SYMMETRIC},
40 { "rs", ALGORITHM_RIGHT_SYMMETRIC},
41
42 { "parity-first", ALGORITHM_PARITY_0},
43 { "parity-last", ALGORITHM_PARITY_N},
44 { "ddf-zero-restart", ALGORITHM_RIGHT_ASYMMETRIC},
45 { "ddf-N-restart", ALGORITHM_LEFT_ASYMMETRIC},
46 { "ddf-N-continue", ALGORITHM_LEFT_SYMMETRIC},
47
48 { NULL, 0}
49};
50mapping_t r6layout[] = {
51 { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
52 { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC},
53 { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC},
54 { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC},
55
56 { "default", ALGORITHM_LEFT_SYMMETRIC},
57 { "la", ALGORITHM_LEFT_ASYMMETRIC},
58 { "ra", ALGORITHM_RIGHT_ASYMMETRIC},
59 { "ls", ALGORITHM_LEFT_SYMMETRIC},
60 { "rs", ALGORITHM_RIGHT_SYMMETRIC},
61
62 { "parity-first", ALGORITHM_PARITY_0},
63 { "parity-last", ALGORITHM_PARITY_N},
64 { "ddf-zero-restart", ALGORITHM_ROTATING_ZERO_RESTART},
65 { "ddf-N-restart", ALGORITHM_ROTATING_N_RESTART},
66 { "ddf-N-continue", ALGORITHM_ROTATING_N_CONTINUE},
67
68 { "left-asymmetric-6", ALGORITHM_LEFT_ASYMMETRIC_6},
69 { "right-asymmetric-6", ALGORITHM_RIGHT_ASYMMETRIC_6},
70 { "left-symmetric-6", ALGORITHM_LEFT_SYMMETRIC_6},
71 { "right-symmetric-6", ALGORITHM_RIGHT_SYMMETRIC_6},
72 { "parity-first-6", ALGORITHM_PARITY_0_6},
73
74 { NULL, 0}
75};
76
77mapping_t pers[] = {
78 { "linear", LEVEL_LINEAR},
79 { "raid0", 0},
80 { "0", 0},
81 { "stripe", 0},
82 { "raid1", 1},
83 { "1", 1},
84 { "mirror", 1},
85 { "raid4", 4},
86 { "4", 4},
87 { "raid5", 5},
88 { "5", 5},
89 { "multipath", LEVEL_MULTIPATH},
90 { "mp", LEVEL_MULTIPATH},
91 { "raid6", 6},
92 { "6", 6},
93 { "raid10", 10},
94 { "10", 10},
95 { "faulty", LEVEL_FAULTY},
96 { "container", LEVEL_CONTAINER},
97 { NULL, 0}
98};
99
100
101mapping_t modes[] = {
102 { "assemble", ASSEMBLE},
103 { "build", BUILD},
104 { "create", CREATE},
105 { "manage", MANAGE},
106 { "misc", MISC},
107 { "monitor", MONITOR},
108 { "grow", GROW},
109 { "incremental", INCREMENTAL},
110 { "auto-detect", AUTODETECT},
111};
112
113mapping_t faultylayout[] = {
114 { "write-transient", WriteTransient },
115 { "wt", WriteTransient },
116 { "read-transient", ReadTransient },
117 { "rt", ReadTransient },
118 { "write-persistent", WritePersistent },
119 { "wp", WritePersistent },
120 { "read-persistent", ReadPersistent },
121 { "rp", ReadPersistent },
122 { "write-all", WriteAll },
123 { "wa", WriteAll },
124 { "read-fixable", ReadFixable },
125 { "rf", ReadFixable },
126
127 { "clear", ClearErrors},
128 { "flush", ClearFaults},
129 { "none", ClearErrors},
130 { "default", ClearErrors},
131 { NULL, 0}
132};
133
134char *map_num(mapping_t *map, int num)
135{
136 while (map->name) {
137 if (map->num == num)
138 return map->name;
139 map++;
140 }
141 return NULL;
142}
143
144int map_name(mapping_t *map, char *name)
145{
146 while (map->name) {
147 if (strcmp(map->name, name)==0)
148 return map->num;
149 map++;
150 }
151 return UnSet;
152}
153