File: | libglusterfs/src/options.c |
Location: | line 587, column 21 |
Description: | Access to field 'min' results in a dereference of a null pointer (loaded from variable 'opt') |
1 | /* | |||
2 | Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | #ifndef _CONFIG_H | |||
12 | #define _CONFIG_H | |||
13 | #include "config.h" | |||
14 | #endif | |||
15 | ||||
16 | #include <fnmatch.h> | |||
17 | ||||
18 | #include "xlator.h" | |||
19 | #include "defaults.h" | |||
20 | ||||
21 | #define GF_OPTION_LIST_EMPTY(_opt)(_opt->value[0] == ((void*)0)) (_opt->value[0] == NULL((void*)0)) | |||
22 | ||||
23 | ||||
24 | static int | |||
25 | xlator_option_validate_path (xlator_t *xl, const char *key, const char *value, | |||
26 | volume_option_t *opt, char **op_errstr) | |||
27 | { | |||
28 | int ret = -1; | |||
29 | char errstr[256]; | |||
30 | ||||
31 | if (strstr (value, "../")) { | |||
32 | snprintf (errstr, 256, | |||
33 | "invalid path given '%s'", | |||
34 | value); | |||
35 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 35, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
36 | goto out; | |||
37 | } | |||
38 | ||||
39 | /* Make sure the given path is valid */ | |||
40 | if (value[0] != '/') { | |||
41 | snprintf (errstr, 256, | |||
42 | "option %s %s: '%s' is not an " | |||
43 | "absolute path name", | |||
44 | key, value, value); | |||
45 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 45, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
46 | goto out; | |||
47 | } | |||
48 | ||||
49 | ret = 0; | |||
50 | out: | |||
51 | if (ret && op_errstr) | |||
52 | *op_errstr = gf_strdup (errstr); | |||
53 | return ret; | |||
54 | } | |||
55 | ||||
56 | static int | |||
57 | xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, | |||
58 | volume_option_t *opt, char **op_errstr) | |||
59 | { | |||
60 | long long inputll = 0; | |||
61 | int ret = -1; | |||
62 | char errstr[256]; | |||
63 | ||||
64 | /* Check the range */ | |||
65 | if (gf_string2longlong (value, &inputll) != 0) { | |||
66 | snprintf (errstr, 256, | |||
67 | "invalid number format \"%s\" in option \"%s\"", | |||
68 | value, key); | |||
69 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 69, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
70 | goto out; | |||
71 | } | |||
72 | ||||
73 | if ((opt->min == 0) && (opt->max == 0) && | |||
74 | (opt->validate == GF_OPT_VALIDATE_BOTH)) { | |||
75 | gf_log (xl->name, GF_LOG_TRACE,do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 77, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0) | |||
76 | "no range check required for 'option %s %s'",do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 77, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0) | |||
77 | key, value)do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 77, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0); | |||
78 | ret = 0; | |||
79 | goto out; | |||
80 | } | |||
81 | ||||
82 | if ((opt->validate == GF_OPT_VALIDATE_MIN)) { | |||
83 | if (inputll < opt->min) { | |||
84 | snprintf (errstr, 256, | |||
85 | "'%lld' in 'option %s %s' is smaller than " | |||
86 | "minimum value '%.0f'", inputll, key, | |||
87 | value, opt->min); | |||
88 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 88, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
89 | goto out; | |||
90 | } | |||
91 | } else if ((opt->validate == GF_OPT_VALIDATE_MAX)) { | |||
92 | if ((inputll > opt->max)) { | |||
93 | snprintf (errstr, 256, | |||
94 | "'%lld' in 'option %s %s' is greater than " | |||
95 | "maximum value '%.0f'", inputll, key, | |||
96 | value, opt->max); | |||
97 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 97, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
98 | goto out; | |||
99 | } | |||
100 | } else if ((inputll < opt->min) || (inputll > opt->max)) { | |||
101 | snprintf (errstr, 256, | |||
102 | "'%lld' in 'option %s %s' is out of range " | |||
103 | "[%.0f - %.0f]", | |||
104 | inputll, key, value, opt->min, opt->max); | |||
105 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 105, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
106 | goto out; | |||
107 | } | |||
108 | ||||
109 | ret = 0; | |||
110 | out: | |||
111 | if (ret && op_errstr) | |||
112 | *op_errstr = gf_strdup (errstr); | |||
113 | return ret; | |||
114 | } | |||
115 | ||||
116 | ||||
117 | static int | |||
118 | xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value, | |||
119 | volume_option_t *opt, char **op_errstr) | |||
120 | { | |||
121 | uint64_t size = 0; | |||
122 | int ret = 0; | |||
123 | char errstr[256]; | |||
124 | ||||
125 | /* Check the range */ | |||
126 | if (gf_string2bytesize (value, &size) != 0) { | |||
127 | snprintf (errstr, 256, | |||
128 | "invalid number format \"%s\" in option \"%s\"", | |||
129 | value, key); | |||
130 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 130, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
131 | ret = -1; | |||
132 | goto out; | |||
133 | } | |||
134 | ||||
135 | if ((opt->min == 0) && (opt->max == 0)) { | |||
136 | gf_log (xl->name, GF_LOG_TRACE,do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 138, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0) | |||
137 | "no range check required for 'option %s %s'",do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 138, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0) | |||
138 | key, value)do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 138, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0); | |||
139 | goto out; | |||
140 | } | |||
141 | ||||
142 | if ((size < opt->min) || (size > opt->max)) { | |||
143 | if ((strncmp (key, "cache-size", 10) == 0) && | |||
144 | (size > opt->max)) { | |||
145 | snprintf (errstr, 256, "Cache size %"PRId64"ll" "d"" is out of " | |||
146 | "range [%.0f - %.0f]", | |||
147 | size, opt->min, opt->max); | |||
148 | gf_log (xl->name, GF_LOG_WARNING, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 148, GF_LOG_WARNING, "%s" , errstr); } while (0); | |||
149 | } else { | |||
150 | snprintf (errstr, 256, | |||
151 | "'%"PRId64"ll" "d""' in 'option %s %s' " | |||
152 | "is out of range [%.0f - %.0f]", | |||
153 | size, key, value, opt->min, opt->max); | |||
154 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 154, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
155 | ret = -1; | |||
156 | } | |||
157 | } | |||
158 | ||||
159 | out: | |||
160 | if (ret && op_errstr) | |||
161 | *op_errstr = gf_strdup (errstr); | |||
162 | return ret; | |||
163 | } | |||
164 | ||||
165 | ||||
166 | static int | |||
167 | xlator_option_validate_bool (xlator_t *xl, const char *key, const char *value, | |||
168 | volume_option_t *opt, char **op_errstr) | |||
169 | { | |||
170 | int ret = -1; | |||
171 | char errstr[256]; | |||
172 | gf_boolean_t bool; | |||
173 | ||||
174 | ||||
175 | /* Check if the value is one of | |||
176 | '0|1|on|off|no|yes|true|false|enable|disable' */ | |||
177 | ||||
178 | if (gf_string2boolean (value, &bool) != 0) { | |||
179 | snprintf (errstr, 256, | |||
180 | "option %s %s: '%s' is not a valid boolean value", | |||
181 | key, value, value); | |||
182 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 182, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
183 | goto out; | |||
184 | } | |||
185 | ||||
186 | ret = 0; | |||
187 | out: | |||
188 | if (ret && op_errstr) | |||
189 | *op_errstr = gf_strdup (errstr); | |||
190 | return ret; | |||
191 | } | |||
192 | ||||
193 | ||||
194 | static int | |||
195 | xlator_option_validate_xlator (xlator_t *xl, const char *key, const char *value, | |||
196 | volume_option_t *opt, char **op_errstr) | |||
197 | { | |||
198 | int ret = -1; | |||
199 | char errstr[256]; | |||
200 | xlator_t *xlopt = NULL((void*)0); | |||
201 | ||||
202 | ||||
203 | /* Check if the value is one of the xlators */ | |||
204 | xlopt = xl; | |||
205 | while (xlopt->prev) | |||
206 | xlopt = xlopt->prev; | |||
207 | ||||
208 | while (xlopt) { | |||
209 | if (strcmp (value, xlopt->name) == 0) { | |||
210 | ret = 0; | |||
211 | break; | |||
212 | } | |||
213 | xlopt = xlopt->next; | |||
214 | } | |||
215 | ||||
216 | if (!xlopt) { | |||
217 | snprintf (errstr, 256, | |||
218 | "option %s %s: '%s' is not a valid volume name", | |||
219 | key, value, value); | |||
220 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 220, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
221 | goto out; | |||
222 | } | |||
223 | ||||
224 | ret = 0; | |||
225 | out: | |||
226 | if (ret && op_errstr) | |||
227 | *op_errstr = gf_strdup (errstr); | |||
228 | return ret; | |||
229 | } | |||
230 | ||||
231 | void | |||
232 | set_error_str (char *errstr, size_t len, volume_option_t *opt, const char *key, | |||
233 | const char *value) | |||
234 | { | |||
235 | int i = 0; | |||
236 | char given_array[4096] = {0,}; | |||
237 | ||||
238 | for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE64) && opt->value[i];) { | |||
239 | strcat (given_array, opt->value[i]); | |||
240 | if (((++i) < ZR_OPTION_MAX_ARRAY_SIZE64) && | |||
241 | (opt->value[i])) | |||
242 | strcat (given_array, ", "); | |||
243 | else | |||
244 | strcat (given_array, "."); | |||
245 | } | |||
246 | snprintf (errstr, len, "option %s %s: '%s' is not valid " | |||
247 | "(possible options are %s)", key, value, value, given_array); | |||
248 | return; | |||
249 | } | |||
250 | ||||
251 | int | |||
252 | is_all_whitespaces (const char *value) | |||
253 | { | |||
254 | int i = 0; | |||
255 | size_t len = 0; | |||
256 | ||||
257 | if (value == NULL((void*)0)) | |||
258 | return -1; | |||
259 | ||||
260 | len = strlen (value); | |||
261 | ||||
262 | for (i = 0; i < len; i++) { | |||
263 | if (value[i] == ' ') | |||
264 | continue; | |||
265 | else | |||
266 | return 0; | |||
267 | } | |||
268 | ||||
269 | return 1; | |||
270 | } | |||
271 | ||||
272 | static int | |||
273 | xlator_option_validate_str (xlator_t *xl, const char *key, const char *value, | |||
274 | volume_option_t *opt, char **op_errstr) | |||
275 | { | |||
276 | int ret = -1; | |||
277 | int i = 0; | |||
278 | char errstr[4096] = {0,}; | |||
279 | ||||
280 | /* Check if the '*str' is valid */ | |||
281 | if (GF_OPTION_LIST_EMPTY(opt)(opt->value[0] == ((void*)0))) { | |||
282 | ret = 0; | |||
283 | goto out; | |||
284 | } | |||
285 | ||||
286 | if (is_all_whitespaces (value) == 1) | |||
287 | goto out; | |||
288 | ||||
289 | for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE64) && opt->value[i]; i++) { | |||
290 | #ifdef GF_DARWIN_HOST_OS | |||
291 | if (fnmatch (opt->value[i], value, 0) == 0) { | |||
292 | ret = 0; | |||
293 | break; | |||
294 | } | |||
295 | #else | |||
296 | if (fnmatch (opt->value[i], value, FNM_EXTMATCH(1 << 5)) == 0) { | |||
297 | ret = 0; | |||
298 | break; | |||
299 | } | |||
300 | #endif | |||
301 | } | |||
302 | ||||
303 | if ((i == ZR_OPTION_MAX_ARRAY_SIZE64) || (!opt->value[i])) | |||
304 | goto out; | |||
305 | /* enter here only if | |||
306 | * 1. reached end of opt->value array and haven't | |||
307 | * validated input | |||
308 | * OR | |||
309 | * 2. valid input list is less than | |||
310 | * ZR_OPTION_MAX_ARRAY_SIZE and input has not | |||
311 | * matched all possible input values. | |||
312 | */ | |||
313 | ||||
314 | ret = 0; | |||
315 | ||||
316 | out: | |||
317 | if (ret) { | |||
318 | set_error_str (errstr, sizeof (errstr), opt, key, value); | |||
319 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 319, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
320 | if (op_errstr) | |||
321 | *op_errstr = gf_strdup (errstr); | |||
322 | } | |||
323 | return ret; | |||
324 | } | |||
325 | ||||
326 | ||||
327 | static int | |||
328 | xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value, | |||
329 | volume_option_t *opt, char **op_errstr) | |||
330 | { | |||
331 | double percent = 0; | |||
332 | int ret = -1; | |||
333 | char errstr[256]; | |||
334 | ||||
335 | /* Check if the value is valid percentage */ | |||
336 | if (gf_string2percent (value, &percent) != 0) { | |||
337 | snprintf (errstr, 256, | |||
338 | "invalid percent format \"%s\" in \"option %s\"", | |||
339 | value, key); | |||
340 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 340, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
341 | goto out; | |||
342 | } | |||
343 | ||||
344 | if ((percent < 0.0) || (percent > 100.0)) { | |||
345 | snprintf (errstr, 256, | |||
346 | "'%lf' in 'option %s %s' is out of range [0 - 100]", | |||
347 | percent, key, value); | |||
348 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 348, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
349 | goto out; | |||
350 | } | |||
351 | ||||
352 | ret = 0; | |||
353 | out: | |||
354 | if (ret && op_errstr) | |||
355 | *op_errstr = gf_strdup (errstr); | |||
356 | return ret; | |||
357 | } | |||
358 | ||||
359 | static int | |||
360 | xlator_option_validate_percent_or_sizet (xlator_t *xl, const char *key, | |||
361 | const char *value, | |||
362 | volume_option_t *opt, char **op_errstr) | |||
363 | { | |||
364 | int ret = -1; | |||
365 | char errstr[256]; | |||
366 | uint64_t size = 0; | |||
367 | gf_boolean_t is_percent = _gf_false; | |||
368 | ||||
369 | if (gf_string2percent_or_bytesize (value, &size, &is_percent) == 0) { | |||
370 | if (is_percent) { | |||
371 | ret = 0; | |||
372 | goto out; | |||
373 | } | |||
374 | /* Check the range */ | |||
375 | if ((opt->min == 0) && (opt->max == 0)) { | |||
376 | gf_log (xl->name, GF_LOG_TRACE,do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 379, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0) | |||
377 | "no range check required for "do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 379, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0) | |||
378 | "'option %s %s'",do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 379, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0) | |||
379 | key, value)do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 379, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0); | |||
380 | ret = 0; | |||
381 | goto out; | |||
382 | } | |||
383 | if ((size < opt->min) || (size > opt->max)) { | |||
384 | snprintf (errstr, 256, | |||
385 | "'%"PRId64"ll" "d""' in 'option %s %s'" | |||
386 | " is out of range [%.0f - %.0f]", | |||
387 | size, key, value, opt->min, opt->max); | |||
388 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 388, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
389 | goto out; | |||
390 | } | |||
391 | ret = 0; | |||
392 | goto out; | |||
393 | } | |||
394 | ||||
395 | /* If control reaches here, invalid argument */ | |||
396 | ||||
397 | snprintf (errstr, 256, | |||
398 | "invalid number format \"%s\" in \"option %s\"", | |||
399 | value, key); | |||
400 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 400, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
401 | ||||
402 | ||||
403 | out: | |||
404 | if (ret && op_errstr) | |||
405 | *op_errstr = gf_strdup (errstr); | |||
406 | return ret; | |||
407 | } | |||
408 | ||||
409 | ||||
410 | static int | |||
411 | xlator_option_validate_time (xlator_t *xl, const char *key, const char *value, | |||
412 | volume_option_t *opt, char **op_errstr) | |||
413 | { | |||
414 | int ret = -1; | |||
415 | char errstr[256]; | |||
416 | uint32_t input_time = 0; | |||
417 | ||||
418 | /* Check if the value is valid time */ | |||
419 | if (gf_string2time (value, &input_time) != 0) { | |||
420 | snprintf (errstr, 256, | |||
421 | "invalid time format \"%s\" in " | |||
422 | "\"option %s\"", | |||
423 | value, key); | |||
424 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 424, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
425 | goto out; | |||
426 | } | |||
427 | ||||
428 | if ((opt->min == 0) && (opt->max == 0)) { | |||
429 | gf_log (xl->name, GF_LOG_TRACE,do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 432, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0) | |||
430 | "no range check required for "do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 432, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0) | |||
431 | "'option %s %s'",do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 432, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0) | |||
432 | key, value)do { do { if (0) printf ("no range check required for " "'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 432, GF_LOG_TRACE, "no range check required for " "'option %s %s'", key, value); } while (0); | |||
433 | ret = 0; | |||
434 | goto out; | |||
435 | } | |||
436 | ||||
437 | if ((input_time < opt->min) || (input_time > opt->max)) { | |||
438 | snprintf (errstr, 256, | |||
439 | "'%"PRIu32"u""' in 'option %s %s' is " | |||
440 | "out of range [%.0f - %.0f]", | |||
441 | input_time, key, value, | |||
442 | opt->min, opt->max); | |||
443 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 443, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
444 | goto out; | |||
445 | } | |||
446 | ||||
447 | ret = 0; | |||
448 | out: | |||
449 | if (ret && op_errstr) | |||
450 | *op_errstr = gf_strdup (errstr); | |||
451 | return ret; | |||
452 | } | |||
453 | ||||
454 | ||||
455 | static int | |||
456 | xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, | |||
457 | volume_option_t *opt, char **op_errstr) | |||
458 | { | |||
459 | double input = 0.0; | |||
460 | int ret = -1; | |||
461 | char errstr[256]; | |||
462 | ||||
463 | /* Check the range */ | |||
464 | if (gf_string2double (value, &input) != 0) { | |||
465 | snprintf (errstr, 256, | |||
466 | "invalid number format \"%s\" in option \"%s\"", | |||
467 | value, key); | |||
468 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 468, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
469 | goto out; | |||
470 | } | |||
471 | ||||
472 | if ((opt->min == 0) && (opt->max == 0) && | |||
473 | (opt->validate == GF_OPT_VALIDATE_BOTH)) { | |||
474 | gf_log (xl->name, GF_LOG_TRACE,do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 476, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0) | |||
475 | "no range check required for 'option %s %s'",do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 476, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0) | |||
476 | key, value)do { do { if (0) printf ("no range check required for 'option %s %s'" , key, value); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 476, GF_LOG_TRACE, "no range check required for 'option %s %s'" , key, value); } while (0); | |||
477 | ret = 0; | |||
478 | goto out; | |||
479 | } | |||
480 | ||||
481 | if ((opt->validate == GF_OPT_VALIDATE_MIN)) { | |||
482 | if (input < opt->min) { | |||
483 | snprintf (errstr, 256, | |||
484 | "'%f' in 'option %s %s' is smaller than " | |||
485 | "minimum value '%f'", input, key, | |||
486 | value, opt->min); | |||
487 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 487, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
488 | goto out; | |||
489 | } | |||
490 | } else if ((opt->validate == GF_OPT_VALIDATE_MAX)) { | |||
491 | if ((input > opt->max)) { | |||
492 | snprintf (errstr, 256, | |||
493 | "'%f' in 'option %s %s' is greater than " | |||
494 | "maximum value '%f'", input, key, | |||
495 | value, opt->max); | |||
496 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 496, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
497 | goto out; | |||
498 | } | |||
499 | } else if ((input < opt->min) || (input > opt->max)) { | |||
500 | snprintf (errstr, 256, | |||
501 | "'%f' in 'option %s %s' is out of range " | |||
502 | "[%f - %f]", | |||
503 | input, key, value, opt->min, opt->max); | |||
504 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 504, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
505 | goto out; | |||
506 | } | |||
507 | ||||
508 | ret = 0; | |||
509 | out: | |||
510 | if (ret && op_errstr) | |||
511 | *op_errstr = gf_strdup (errstr); | |||
512 | return ret; | |||
513 | } | |||
514 | ||||
515 | ||||
516 | static int | |||
517 | xlator_option_validate_addr (xlator_t *xl, const char *key, const char *value, | |||
518 | volume_option_t *opt, char **op_errstr) | |||
519 | { | |||
520 | int ret = -1; | |||
521 | char errstr[256]; | |||
522 | ||||
523 | if (!valid_internet_address ((char *)value, _gf_false)) { | |||
524 | snprintf (errstr, 256, | |||
525 | "option %s %s: '%s' is not a valid internet-address," | |||
526 | " it does not conform to standards.", | |||
527 | key, value, value); | |||
528 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 528, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
529 | if (op_errstr) | |||
530 | *op_errstr = gf_strdup (errstr); | |||
531 | } | |||
532 | ||||
533 | ret = 0; | |||
534 | ||||
535 | return ret; | |||
536 | } | |||
537 | ||||
538 | static int | |||
539 | xlator_option_validate_addr_list (xlator_t *xl, const char *key, | |||
540 | const char *value, volume_option_t *opt, | |||
541 | char **op_errstr) | |||
542 | { | |||
543 | int ret = -1; | |||
544 | char *dup_val = NULL((void*)0); | |||
545 | char *addr_tok = NULL((void*)0); | |||
546 | char *save_ptr = NULL((void*)0); | |||
547 | char errstr[4096] = {0,}; | |||
548 | ||||
549 | dup_val = gf_strdup (value); | |||
550 | if (!dup_val) | |||
551 | goto out; | |||
552 | ||||
553 | addr_tok = strtok_r (dup_val, ",", &save_ptr); | |||
554 | if (addr_tok == NULL((void*)0)) | |||
555 | goto out; | |||
556 | while (addr_tok) { | |||
557 | if (!valid_internet_address (addr_tok, _gf_true)) | |||
558 | goto out; | |||
559 | ||||
560 | addr_tok = strtok_r (NULL((void*)0), ",", &save_ptr); | |||
561 | } | |||
562 | ret = 0; | |||
563 | ||||
564 | out: | |||
565 | if (ret) { | |||
566 | snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not " | |||
567 | "a valid internet-address-list", key, value, value); | |||
568 | gf_log (xl->name, GF_LOG_ERROR, "%s", errstr)do { do { if (0) printf ("%s", errstr); } while (0); _gf_log ( xl->name, "options.c", __FUNCTION__, 568, GF_LOG_ERROR, "%s" , errstr); } while (0); | |||
569 | if (op_errstr) | |||
570 | *op_errstr = gf_strdup (errstr); | |||
571 | } | |||
572 | GF_FREE (dup_val)__gf_free (dup_val); | |||
573 | ||||
574 | return ret; | |||
575 | } | |||
576 | ||||
577 | /*XXX: the rules to validate are as per block-size required for stripe xlator */ | |||
578 | static int | |||
579 | gf_validate_size (const char *sizestr, volume_option_t *opt) | |||
580 | { | |||
581 | uint64_t value = 0; | |||
582 | int ret = 0; | |||
583 | ||||
584 | GF_ASSERT (opt)do { if (!(opt)) { do { do { if (0) printf ("Assertion failed: " "opt"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 584, GF_LOG_ERROR, "Assertion failed: " "opt"); } while (0) ; } } while (0); | |||
585 | ||||
586 | if (gf_string2bytesize (sizestr, &value) != 0 || | |||
587 | value < opt->min || | |||
| ||||
588 | value % 512) { | |||
589 | ret = -1; | |||
590 | goto out; | |||
591 | } | |||
592 | ||||
593 | out: | |||
594 | gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ((*__glusterfs_this_location())->name, "options.c", __FUNCTION__ , 594, GF_LOG_DEBUG, "Returning %d", ret); } while (0); | |||
595 | return ret; | |||
596 | } | |||
597 | ||||
598 | static int | |||
599 | gf_validate_number (const char *numstr, volume_option_t *opt) | |||
600 | { | |||
601 | int32_t value; | |||
602 | return gf_string2int32 (numstr, &value); | |||
603 | } | |||
604 | ||||
605 | /* Parses the string to be of the form <key1>:<value1>,<key2>:<value2>... * | |||
606 | * takes two optional validaters key_validator and value_validator */ | |||
607 | static int | |||
608 | validate_list_elements (const char *string, volume_option_t *opt, | |||
609 | int (key_validator)( const char *), | |||
610 | int (value_validator)( const char *, volume_option_t *)) | |||
611 | { | |||
612 | ||||
613 | char *dup_string = NULL((void*)0); | |||
614 | char *str_sav = NULL((void*)0); | |||
615 | char *substr_sav = NULL((void*)0); | |||
616 | char *str_ptr = NULL((void*)0); | |||
617 | char *key = NULL((void*)0); | |||
618 | char *value = NULL((void*)0); | |||
619 | int ret = 0; | |||
620 | ||||
621 | GF_ASSERT (string)do { if (!(string)) { do { do { if (0) printf ("Assertion failed: " "string"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 621, GF_LOG_ERROR, "Assertion failed: " "string"); } while ( 0); } } while (0); | |||
622 | ||||
623 | dup_string = gf_strdup (string); | |||
624 | if (NULL((void*)0) == dup_string) | |||
625 | goto out; | |||
626 | ||||
627 | str_ptr = strtok_r (dup_string, ",", &str_sav); | |||
628 | if (str_ptr == NULL((void*)0)) { | |||
629 | ret = -1; | |||
630 | goto out; | |||
631 | } | |||
632 | while (str_ptr) { | |||
633 | ||||
634 | key = strtok_r (str_ptr, ":", &substr_sav); | |||
635 | if (!key || | |||
636 | (key_validator && key_validator(key))) { | |||
637 | ret = -1; | |||
638 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("invalid list '%s', key '%s' not valid." , string, key); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "options.c", __FUNCTION__, 640, GF_LOG_WARNING, "invalid list '%s', key '%s' not valid.", string, key); } while (0) | |||
639 | "invalid list '%s', key '%s' not valid.",do { do { if (0) printf ("invalid list '%s', key '%s' not valid." , string, key); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "options.c", __FUNCTION__, 640, GF_LOG_WARNING, "invalid list '%s', key '%s' not valid.", string, key); } while (0) | |||
640 | string, key)do { do { if (0) printf ("invalid list '%s', key '%s' not valid." , string, key); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "options.c", __FUNCTION__, 640, GF_LOG_WARNING, "invalid list '%s', key '%s' not valid.", string, key); } while (0); | |||
641 | goto out; | |||
642 | } | |||
643 | ||||
644 | value = strtok_r (NULL((void*)0), ":", &substr_sav); | |||
645 | if (!value || | |||
646 | (value_validator && value_validator(value, opt))) { | |||
647 | ret = -1; | |||
648 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("invalid list '%s', value '%s' not valid." , string, key); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "options.c", __FUNCTION__, 650, GF_LOG_WARNING, "invalid list '%s', value '%s' not valid.", string, key); } while (0) | |||
649 | "invalid list '%s', value '%s' not valid.",do { do { if (0) printf ("invalid list '%s', value '%s' not valid." , string, key); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "options.c", __FUNCTION__, 650, GF_LOG_WARNING, "invalid list '%s', value '%s' not valid.", string, key); } while (0) | |||
650 | string, key)do { do { if (0) printf ("invalid list '%s', value '%s' not valid." , string, key); } while (0); _gf_log ((*__glusterfs_this_location ())->name, "options.c", __FUNCTION__, 650, GF_LOG_WARNING, "invalid list '%s', value '%s' not valid.", string, key); } while (0); | |||
651 | goto out; | |||
652 | } | |||
653 | ||||
654 | str_ptr = strtok_r (NULL((void*)0), ",", &str_sav); | |||
655 | substr_sav = NULL((void*)0); | |||
656 | } | |||
657 | ||||
658 | out: | |||
659 | GF_FREE (dup_string)__gf_free (dup_string); | |||
660 | gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ((*__glusterfs_this_location())->name, "options.c", __FUNCTION__ , 660, GF_LOG_DEBUG, "Returning %d", ret); } while (0); | |||
661 | return ret; | |||
662 | } | |||
663 | ||||
664 | static int | |||
665 | xlator_option_validate_priority_list (xlator_t *xl, const char *key, | |||
666 | const char *value, volume_option_t *opt, | |||
667 | char **op_errstr) | |||
668 | { | |||
669 | int ret =0; | |||
670 | char errstr[1024] = {0, }; | |||
671 | ||||
672 | GF_ASSERT (value)do { if (!(value)) { do { do { if (0) printf ("Assertion failed: " "value"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 672, GF_LOG_ERROR, "Assertion failed: " "value"); } while ( 0); } } while (0); | |||
673 | ||||
674 | ret = validate_list_elements (value, opt, NULL((void*)0), &gf_validate_number); | |||
675 | if (ret) { | |||
676 | snprintf (errstr, 1024, | |||
677 | "option %s %s: '%s' is not a valid " | |||
678 | "priority-list", key, value, value); | |||
679 | *op_errstr = gf_strdup (errstr); | |||
680 | } | |||
681 | ||||
682 | return ret; | |||
683 | } | |||
684 | ||||
685 | static int | |||
686 | xlator_option_validate_size_list (xlator_t *xl, const char *key, | |||
687 | const char *value, volume_option_t *opt, | |||
688 | char **op_errstr) | |||
689 | { | |||
690 | ||||
691 | int ret = 0; | |||
692 | char errstr[1024] = {0, }; | |||
693 | ||||
694 | GF_ASSERT (value)do { if (!(value)) { do { do { if (0) printf ("Assertion failed: " "value"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 694, GF_LOG_ERROR, "Assertion failed: " "value"); } while ( 0); } } while (0); | |||
695 | ||||
696 | ret = gf_validate_size (value, opt); | |||
| ||||
697 | if (ret) | |||
698 | ret = validate_list_elements (value, opt, NULL((void*)0), &gf_validate_size); | |||
699 | ||||
700 | if (ret) { | |||
701 | snprintf (errstr, 1024, | |||
702 | "option %s %s: '%s' is not a valid " | |||
703 | "size-list", key, value, value); | |||
704 | *op_errstr = gf_strdup (errstr); | |||
705 | } | |||
706 | ||||
707 | return ret; | |||
708 | ||||
709 | } | |||
710 | ||||
711 | static int | |||
712 | xlator_option_validate_any (xlator_t *xl, const char *key, const char *value, | |||
713 | volume_option_t *opt, char **op_errstr) | |||
714 | { | |||
715 | return 0; | |||
716 | } | |||
717 | ||||
718 | typedef int (xlator_option_validator_t) (xlator_t *xl, const char *key, | |||
719 | const char *value, | |||
720 | volume_option_t *opt, char **operrstr); | |||
721 | ||||
722 | int | |||
723 | xlator_option_validate (xlator_t *xl, char *key, char *value, | |||
724 | volume_option_t *opt, char **op_errstr) | |||
725 | { | |||
726 | int ret = -1; | |||
727 | xlator_option_validator_t *validate; | |||
728 | xlator_option_validator_t *validators[] = { | |||
729 | [GF_OPTION_TYPE_PATH] = xlator_option_validate_path, | |||
730 | [GF_OPTION_TYPE_INT] = xlator_option_validate_int, | |||
731 | [GF_OPTION_TYPE_SIZET] = xlator_option_validate_sizet, | |||
732 | [GF_OPTION_TYPE_BOOL] = xlator_option_validate_bool, | |||
733 | [GF_OPTION_TYPE_XLATOR] = xlator_option_validate_xlator, | |||
734 | [GF_OPTION_TYPE_STR] = xlator_option_validate_str, | |||
735 | [GF_OPTION_TYPE_PERCENT] = xlator_option_validate_percent, | |||
736 | [GF_OPTION_TYPE_PERCENT_OR_SIZET] = | |||
737 | xlator_option_validate_percent_or_sizet, | |||
738 | [GF_OPTION_TYPE_TIME] = xlator_option_validate_time, | |||
739 | [GF_OPTION_TYPE_DOUBLE] = xlator_option_validate_double, | |||
740 | [GF_OPTION_TYPE_INTERNET_ADDRESS] = xlator_option_validate_addr, | |||
741 | [GF_OPTION_TYPE_INTERNET_ADDRESS_LIST] = | |||
742 | xlator_option_validate_addr_list, | |||
743 | [GF_OPTION_TYPE_PRIORITY_LIST] = | |||
744 | xlator_option_validate_priority_list, | |||
745 | [GF_OPTION_TYPE_SIZE_LIST] = xlator_option_validate_size_list, | |||
746 | [GF_OPTION_TYPE_ANY] = xlator_option_validate_any, | |||
747 | [GF_OPTION_TYPE_MAX] = NULL((void*)0), | |||
748 | }; | |||
749 | ||||
750 | if (opt->type < 0 || opt->type >= GF_OPTION_TYPE_MAX) { | |||
751 | gf_log (xl->name, GF_LOG_ERROR,do { do { if (0) printf ("unknown option type '%d'", opt-> type); } while (0); _gf_log (xl->name, "options.c", __FUNCTION__ , 752, GF_LOG_ERROR, "unknown option type '%d'", opt->type ); } while (0) | |||
752 | "unknown option type '%d'", opt->type)do { do { if (0) printf ("unknown option type '%d'", opt-> type); } while (0); _gf_log (xl->name, "options.c", __FUNCTION__ , 752, GF_LOG_ERROR, "unknown option type '%d'", opt->type ); } while (0); | |||
753 | goto out; | |||
754 | } | |||
755 | ||||
756 | validate = validators[opt->type]; | |||
757 | ||||
758 | ret = validate (xl, key, value, opt, op_errstr); | |||
759 | out: | |||
760 | return ret; | |||
761 | } | |||
762 | ||||
763 | ||||
764 | static volume_option_t * | |||
765 | xlator_volume_option_get_list (volume_opt_list_t *vol_list, const char *key) | |||
766 | { | |||
767 | volume_option_t *opt = NULL((void*)0); | |||
768 | volume_opt_list_t *opt_list = NULL((void*)0); | |||
769 | volume_option_t *found = NULL((void*)0); | |||
770 | int index = 0; | |||
771 | int i = 0; | |||
772 | char *cmp_key = NULL((void*)0); | |||
773 | ||||
774 | if (!vol_list->given_opt) { | |||
775 | opt_list = list_entry (vol_list->list.next, volume_opt_list_t,((volume_opt_list_t *)((char *)(vol_list->list.next)-(unsigned long)(&((volume_opt_list_t *)0)->list))) | |||
776 | list)((volume_opt_list_t *)((char *)(vol_list->list.next)-(unsigned long)(&((volume_opt_list_t *)0)->list))); | |||
777 | opt = opt_list->given_opt; | |||
778 | } else | |||
779 | opt = vol_list->given_opt; | |||
780 | ||||
781 | for (index = 0; opt[index].key[0]; index++) { | |||
782 | for (i = 0; i < ZR_VOLUME_MAX_NUM_KEY4; i++) { | |||
783 | cmp_key = opt[index].key[i]; | |||
784 | if (!cmp_key) | |||
785 | break; | |||
786 | if (fnmatch (cmp_key, key, FNM_NOESCAPE(1 << 1)) == 0) { | |||
787 | found = &opt[index]; | |||
788 | goto out; | |||
789 | } | |||
790 | } | |||
791 | } | |||
792 | out: | |||
793 | return found; | |||
794 | } | |||
795 | ||||
796 | ||||
797 | volume_option_t * | |||
798 | xlator_volume_option_get (xlator_t *xl, const char *key) | |||
799 | { | |||
800 | volume_opt_list_t *vol_list = NULL((void*)0); | |||
801 | volume_option_t *found = NULL((void*)0); | |||
802 | ||||
803 | list_for_each_entry (vol_list, &xl->volume_options, list)for (vol_list = ((typeof(*vol_list) *)((char *)((&xl-> volume_options)->next)-(unsigned long)(&((typeof(*vol_list ) *)0)->list))); &vol_list->list != (&xl->volume_options ); vol_list = ((typeof(*vol_list) *)((char *)(vol_list->list .next)-(unsigned long)(&((typeof(*vol_list) *)0)->list )))) { | |||
804 | found = xlator_volume_option_get_list (vol_list, key); | |||
805 | if (found) | |||
806 | break; | |||
807 | } | |||
808 | ||||
809 | return found; | |||
810 | } | |||
811 | ||||
812 | ||||
813 | static int | |||
814 | xl_opt_validate (dict_t *dict, char *key, data_t *value, void *data) | |||
815 | { | |||
816 | xlator_t *xl = NULL((void*)0); | |||
817 | volume_opt_list_t *vol_opt = NULL((void*)0); | |||
818 | volume_option_t *opt = NULL((void*)0); | |||
819 | int ret = 0; | |||
820 | char *errstr = NULL((void*)0); | |||
821 | ||||
822 | struct { | |||
823 | xlator_t *this; | |||
824 | volume_opt_list_t *vol_opt; | |||
825 | char *errstr; | |||
826 | } *stub; | |||
827 | ||||
828 | stub = data; | |||
829 | xl = stub->this; | |||
830 | vol_opt = stub->vol_opt; | |||
831 | ||||
832 | opt = xlator_volume_option_get_list (vol_opt, key); | |||
833 | if (!opt) | |||
834 | return 0; | |||
835 | ||||
836 | ret = xlator_option_validate (xl, key, value->data, opt, &errstr); | |||
837 | if (ret) | |||
838 | gf_log (xl->name, GF_LOG_WARNING, "validate of %s returned %d",do { do { if (0) printf ("validate of %s returned %d", key, ret ); } while (0); _gf_log (xl->name, "options.c", __FUNCTION__ , 839, GF_LOG_WARNING, "validate of %s returned %d", key, ret ); } while (0) | |||
839 | key, ret)do { do { if (0) printf ("validate of %s returned %d", key, ret ); } while (0); _gf_log (xl->name, "options.c", __FUNCTION__ , 839, GF_LOG_WARNING, "validate of %s returned %d", key, ret ); } while (0); | |||
840 | ||||
841 | if (errstr) | |||
842 | /* possible small leak of previously set stub->errstr */ | |||
843 | stub->errstr = errstr; | |||
844 | ||||
845 | if (fnmatch (opt->key[0], key, FNM_NOESCAPE(1 << 1)) != 0) { | |||
846 | gf_log (xl->name, GF_LOG_WARNING, "option '%s' is deprecated, "do { do { if (0) printf ("option '%s' is deprecated, " "preferred is '%s', continuing with correction" , key, opt->key[0]); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 848, GF_LOG_WARNING, "option '%s' is deprecated, " "preferred is '%s', continuing with correction", key, opt-> key[0]); } while (0) | |||
847 | "preferred is '%s', continuing with correction",do { do { if (0) printf ("option '%s' is deprecated, " "preferred is '%s', continuing with correction" , key, opt->key[0]); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 848, GF_LOG_WARNING, "option '%s' is deprecated, " "preferred is '%s', continuing with correction", key, opt-> key[0]); } while (0) | |||
848 | key, opt->key[0])do { do { if (0) printf ("option '%s' is deprecated, " "preferred is '%s', continuing with correction" , key, opt->key[0]); } while (0); _gf_log (xl->name, "options.c" , __FUNCTION__, 848, GF_LOG_WARNING, "option '%s' is deprecated, " "preferred is '%s', continuing with correction", key, opt-> key[0]); } while (0); | |||
849 | dict_set (dict, opt->key[0], value); | |||
850 | dict_del (dict, key); | |||
851 | } | |||
852 | return 0; | |||
853 | } | |||
854 | ||||
855 | ||||
856 | int | |||
857 | xlator_options_validate_list (xlator_t *xl, dict_t *options, | |||
858 | volume_opt_list_t *vol_opt, char **op_errstr) | |||
859 | { | |||
860 | int ret = 0; | |||
861 | struct { | |||
862 | xlator_t *this; | |||
863 | volume_opt_list_t *vol_opt; | |||
864 | char *errstr; | |||
865 | } stub; | |||
866 | ||||
867 | stub.this = xl; | |||
868 | stub.vol_opt = vol_opt; | |||
869 | stub.errstr = NULL((void*)0); | |||
870 | ||||
871 | dict_foreach (options, xl_opt_validate, &stub); | |||
872 | if (stub.errstr) { | |||
873 | ret = -1; | |||
874 | if (op_errstr) | |||
875 | *op_errstr = stub.errstr; | |||
876 | } | |||
877 | ||||
878 | return ret; | |||
879 | } | |||
880 | ||||
881 | ||||
882 | int | |||
883 | xlator_options_validate (xlator_t *xl, dict_t *options, char **op_errstr) | |||
884 | { | |||
885 | int ret = 0; | |||
886 | volume_opt_list_t *vol_opt = NULL((void*)0); | |||
887 | ||||
888 | ||||
889 | if (!xl) { | |||
890 | gf_log (THIS->name, GF_LOG_DEBUG, "'this' not a valid ptr")do { do { if (0) printf ("'this' not a valid ptr"); } while ( 0); _gf_log ((*__glusterfs_this_location())->name, "options.c" , __FUNCTION__, 890, GF_LOG_DEBUG, "'this' not a valid ptr"); } while (0); | |||
891 | ret = -1; | |||
892 | goto out; | |||
893 | } | |||
894 | ||||
895 | if (list_empty (&xl->volume_options)) | |||
896 | goto out; | |||
897 | ||||
898 | list_for_each_entry (vol_opt, &xl->volume_options, list)for (vol_opt = ((typeof(*vol_opt) *)((char *)((&xl->volume_options )->next)-(unsigned long)(&((typeof(*vol_opt) *)0)-> list))); &vol_opt->list != (&xl->volume_options ); vol_opt = ((typeof(*vol_opt) *)((char *)(vol_opt->list. next)-(unsigned long)(&((typeof(*vol_opt) *)0)->list)) )) { | |||
899 | ret = xlator_options_validate_list (xl, options, vol_opt, | |||
900 | op_errstr); | |||
901 | } | |||
902 | out: | |||
903 | return ret; | |||
904 | } | |||
905 | ||||
906 | ||||
907 | int | |||
908 | xlator_validate_rec (xlator_t *xlator, char **op_errstr) | |||
909 | { | |||
910 | int ret = -1; | |||
911 | xlator_list_t *trav = NULL((void*)0); | |||
912 | xlator_t *old_THIS = NULL((void*)0); | |||
913 | ||||
914 | GF_VALIDATE_OR_GOTO ("xlator", xlator, out)do { if (!xlator) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "xlator"); } while (0); _gf_log_callingfn ("xlator", "options.c", __FUNCTION__, 914, GF_LOG_ERROR, "invalid argument: " "xlator"); } while (0); goto out; } } while (0); | |||
915 | ||||
916 | trav = xlator->children; | |||
917 | ||||
918 | while (trav) { | |||
919 | if (xlator_validate_rec (trav->xlator, op_errstr)) { | |||
920 | gf_log ("xlator", GF_LOG_WARNING, "validate_rec failed")do { do { if (0) printf ("validate_rec failed"); } while (0); _gf_log ("xlator", "options.c", __FUNCTION__, 920, GF_LOG_WARNING , "validate_rec failed"); } while (0); | |||
921 | goto out; | |||
922 | } | |||
923 | ||||
924 | trav = trav->next; | |||
925 | } | |||
926 | ||||
927 | if (xlator_dynload (xlator)) | |||
928 | gf_log (xlator->name, GF_LOG_DEBUG, "Did not load the symbols")do { do { if (0) printf ("Did not load the symbols"); } while (0); _gf_log (xlator->name, "options.c", __FUNCTION__, 928 , GF_LOG_DEBUG, "Did not load the symbols"); } while (0); | |||
929 | ||||
930 | old_THIS = THIS(*__glusterfs_this_location()); | |||
931 | THIS(*__glusterfs_this_location()) = xlator; | |||
932 | ||||
933 | /* Need this here, as this graph has not yet called init() */ | |||
934 | if (!xlator->mem_acct.num_types) { | |||
935 | if (!xlator->mem_acct_init) | |||
936 | xlator->mem_acct_init = default_mem_acct_init; | |||
937 | xlator->mem_acct_init (xlator); | |||
938 | } | |||
939 | ||||
940 | ret = xlator_options_validate (xlator, xlator->options, op_errstr); | |||
941 | THIS(*__glusterfs_this_location()) = old_THIS; | |||
942 | ||||
943 | if (ret) { | |||
944 | gf_log (xlator->name, GF_LOG_INFO, "%s", *op_errstr)do { do { if (0) printf ("%s", *op_errstr); } while (0); _gf_log (xlator->name, "options.c", __FUNCTION__, 944, GF_LOG_INFO , "%s", *op_errstr); } while (0); | |||
945 | goto out; | |||
946 | } | |||
947 | ||||
948 | gf_log (xlator->name, GF_LOG_DEBUG, "Validated options")do { do { if (0) printf ("Validated options"); } while (0); _gf_log (xlator->name, "options.c", __FUNCTION__, 948, GF_LOG_DEBUG , "Validated options"); } while (0); | |||
949 | ||||
950 | ret = 0; | |||
951 | out: | |||
952 | return ret; | |||
953 | } | |||
954 | ||||
955 | ||||
956 | int | |||
957 | graph_reconf_validateopt (glusterfs_graph_t *graph, char **op_errstr) | |||
958 | { | |||
959 | xlator_t *xlator = NULL((void*)0); | |||
960 | int ret = -1; | |||
961 | ||||
962 | GF_ASSERT (graph)do { if (!(graph)) { do { do { if (0) printf ("Assertion failed: " "graph"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 962, GF_LOG_ERROR, "Assertion failed: " "graph"); } while ( 0); } } while (0); | |||
963 | ||||
964 | xlator = graph->first; | |||
965 | ||||
966 | ret = xlator_validate_rec (xlator, op_errstr); | |||
967 | ||||
968 | return ret; | |||
969 | } | |||
970 | ||||
971 | ||||
972 | static int | |||
973 | xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl) | |||
974 | { | |||
975 | xlator_list_t *trav1 = NULL((void*)0); | |||
976 | xlator_list_t *trav2 = NULL((void*)0); | |||
977 | int32_t ret = -1; | |||
978 | xlator_t *old_THIS = NULL((void*)0); | |||
979 | ||||
980 | GF_VALIDATE_OR_GOTO ("xlator", old_xl, out)do { if (!old_xl) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "old_xl"); } while (0); _gf_log_callingfn ("xlator", "options.c", __FUNCTION__, 980, GF_LOG_ERROR, "invalid argument: " "old_xl"); } while (0); goto out; } } while (0); | |||
981 | GF_VALIDATE_OR_GOTO ("xlator", new_xl, out)do { if (!new_xl) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "new_xl"); } while (0); _gf_log_callingfn ("xlator", "options.c", __FUNCTION__, 981, GF_LOG_ERROR, "invalid argument: " "new_xl"); } while (0); goto out; } } while (0); | |||
982 | ||||
983 | trav1 = old_xl->children; | |||
984 | trav2 = new_xl->children; | |||
985 | ||||
986 | while (trav1 && trav2) { | |||
987 | ret = xlator_reconfigure_rec (trav1->xlator, trav2->xlator); | |||
988 | if (ret) | |||
989 | goto out; | |||
990 | ||||
991 | gf_log (trav1->xlator->name, GF_LOG_DEBUG, "reconfigured")do { do { if (0) printf ("reconfigured"); } while (0); _gf_log (trav1->xlator->name, "options.c", __FUNCTION__, 991, GF_LOG_DEBUG , "reconfigured"); } while (0); | |||
992 | ||||
993 | trav1 = trav1->next; | |||
994 | trav2 = trav2->next; | |||
995 | } | |||
996 | ||||
997 | if (old_xl->reconfigure) { | |||
998 | old_THIS = THIS(*__glusterfs_this_location()); | |||
999 | THIS(*__glusterfs_this_location()) = old_xl; | |||
1000 | ||||
1001 | ret = old_xl->reconfigure (old_xl, new_xl->options); | |||
1002 | ||||
1003 | THIS(*__glusterfs_this_location()) = old_THIS; | |||
1004 | ||||
1005 | if (ret) | |||
1006 | goto out; | |||
1007 | } else { | |||
1008 | gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found")do { do { if (0) printf ("No reconfigure() found"); } while ( 0); _gf_log (old_xl->name, "options.c", __FUNCTION__, 1008 , GF_LOG_DEBUG, "No reconfigure() found"); } while (0); | |||
1009 | } | |||
1010 | ||||
1011 | ret = 0; | |||
1012 | out: | |||
1013 | return ret; | |||
1014 | } | |||
1015 | ||||
1016 | ||||
1017 | int | |||
1018 | xlator_tree_reconfigure (xlator_t *old_xl, xlator_t *new_xl) | |||
1019 | { | |||
1020 | xlator_t *new_top = NULL((void*)0); | |||
1021 | xlator_t *old_top = NULL((void*)0); | |||
1022 | ||||
1023 | GF_ASSERT (old_xl)do { if (!(old_xl)) { do { do { if (0) printf ("Assertion failed: " "old_xl"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 1023, GF_LOG_ERROR, "Assertion failed: " "old_xl"); } while (0); } } while (0); | |||
1024 | GF_ASSERT (new_xl)do { if (!(new_xl)) { do { do { if (0) printf ("Assertion failed: " "new_xl"); } while (0); _gf_log_callingfn ("", "options.c", __FUNCTION__ , 1024, GF_LOG_ERROR, "Assertion failed: " "new_xl"); } while (0); } } while (0); | |||
1025 | ||||
1026 | old_top = old_xl; | |||
1027 | new_top = new_xl; | |||
1028 | ||||
1029 | return xlator_reconfigure_rec (old_top, new_top); | |||
1030 | } | |||
1031 | ||||
1032 | ||||
1033 | int | |||
1034 | xlator_option_info_list (volume_opt_list_t *list, char *key, | |||
1035 | char **def_val, char **descr) | |||
1036 | { | |||
1037 | int ret = -1; | |||
1038 | volume_option_t *opt = NULL((void*)0); | |||
1039 | ||||
1040 | ||||
1041 | opt = xlator_volume_option_get_list (list, key); | |||
1042 | if (!opt) | |||
1043 | goto out; | |||
1044 | ||||
1045 | if (def_val) | |||
1046 | *def_val = opt->default_value; | |||
1047 | if (descr) | |||
1048 | *descr = opt->description; | |||
1049 | ||||
1050 | ret = 0; | |||
1051 | out: | |||
1052 | return ret; | |||
1053 | } | |||
1054 | ||||
1055 | ||||
1056 | static int | |||
1057 | pass (char *in, char **out) | |||
1058 | { | |||
1059 | *out = in; | |||
1060 | return 0; | |||
1061 | } | |||
1062 | ||||
1063 | ||||
1064 | static int | |||
1065 | xl_by_name (char *in, xlator_t **out) | |||
1066 | { | |||
1067 | xlator_t *xl = NULL((void*)0); | |||
1068 | ||||
1069 | xl = xlator_search_by_name (THIS(*__glusterfs_this_location()), in); | |||
1070 | ||||
1071 | if (!xl) | |||
1072 | return -1; | |||
1073 | *out = xl; | |||
1074 | return 0; | |||
1075 | } | |||
1076 | ||||
1077 | ||||
1078 | static int | |||
1079 | pc_or_size (char *in, double *out) | |||
1080 | { | |||
1081 | double pc = 0; | |||
1082 | int ret = 0; | |||
1083 | uint64_t size = 0; | |||
1084 | ||||
1085 | if (gf_string2percent (in, &pc) == 0) { | |||
1086 | if (pc > 100.0) { | |||
1087 | ret = gf_string2bytesize (in, &size); | |||
1088 | if (!ret) | |||
1089 | *out = size; | |||
1090 | } else { | |||
1091 | *out = pc; | |||
1092 | } | |||
1093 | } else { | |||
1094 | ret = gf_string2bytesize (in, &size); | |||
1095 | if (!ret) | |||
1096 | *out = size; | |||
1097 | } | |||
1098 | return ret; | |||
1099 | } | |||
1100 | ||||
1101 | ||||
1102 | DEFINE_INIT_OPT(char *, str, pass)int xlator_option_init_str (xlator_t *this, dict_t *options, char *key, char * *val_p) { int ret = 0; volume_option_t *opt = ( (void*)0); char *def_value = ((void*)0); char *set_value = (( void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void *)0); opt = xlator_volume_option_get (this, key); if (!opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1102 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1102, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (char *)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1102, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1102, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = pass (value , val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value, opt , ((void*)0)); return ret; }; | |||
1103 | DEFINE_INIT_OPT(uint64_t, uint64, gf_string2uint64)int xlator_option_init_uint64 (xlator_t *this, dict_t *options , char *key, uint64_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1103, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1103 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (uint64_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1103, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1103, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2uint64 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1104 | DEFINE_INIT_OPT(int64_t, int64, gf_string2int64)int xlator_option_init_int64 (xlator_t *this, dict_t *options , char *key, int64_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1104, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1104 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (int64_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1104, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1104, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2int64 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1105 | DEFINE_INIT_OPT(uint32_t, uint32, gf_string2uint32)int xlator_option_init_uint32 (xlator_t *this, dict_t *options , char *key, uint32_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1105, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1105 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (uint32_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1105, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1105, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2uint32 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1106 | DEFINE_INIT_OPT(int32_t, int32, gf_string2int32)int xlator_option_init_int32 (xlator_t *this, dict_t *options , char *key, int32_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1106, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1106 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (int32_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1106, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1106, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2int32 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1107 | DEFINE_INIT_OPT(uint64_t, size, gf_string2bytesize)int xlator_option_init_size (xlator_t *this, dict_t *options, char *key, uint64_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1107, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1107 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (uint64_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1107, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1107, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2bytesize (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1108 | DEFINE_INIT_OPT(double, percent, gf_string2percent)int xlator_option_init_percent (xlator_t *this, dict_t *options , char *key, double *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1108 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1108, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (double)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1108, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1108, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2percent (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1109 | DEFINE_INIT_OPT(double, percent_or_size, pc_or_size)int xlator_option_init_percent_or_size (xlator_t *this, dict_t *options, char *key, double *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1109, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1109 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (double)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1109, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1109, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = pc_or_size ( value, val_p); (*__glusterfs_this_location()) = old_THIS; if ( ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1110 | DEFINE_INIT_OPT(gf_boolean_t, bool, gf_string2boolean)int xlator_option_init_bool (xlator_t *this, dict_t *options, char *key, gf_boolean_t *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1110, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1110 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (gf_boolean_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1110, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1110, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2boolean (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1111 | DEFINE_INIT_OPT(xlator_t *, xlator, xl_by_name)int xlator_option_init_xlator (xlator_t *this, dict_t *options , char *key, xlator_t * *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1111, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1111 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (xlator_t *)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1111, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1111, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = xl_by_name ( value, val_p); (*__glusterfs_this_location()) = old_THIS; if ( ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1112 | DEFINE_INIT_OPT(char *, path, pass)int xlator_option_init_path (xlator_t *this, dict_t *options, char *key, char * *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1112 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1112, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (char *)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1112, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1112, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = pass (value , val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value, opt , ((void*)0)); return ret; }; | |||
1113 | DEFINE_INIT_OPT(double, double, gf_string2double)int xlator_option_init_double (xlator_t *this, dict_t *options , char *key, double *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1113 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1113, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (double)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1113, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1113, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2double (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1114 | ||||
1115 | ||||
1116 | ||||
1117 | DEFINE_RECONF_OPT(char *, str, pass)int xlator_option_reconf_str (xlator_t *this, dict_t *options , char *key, char * *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1117 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1117, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (char *)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1117, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1117, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = pass (value , val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value, opt , ((void*)0)); return ret; }; | |||
1118 | DEFINE_RECONF_OPT(uint64_t, uint64, gf_string2uint64)int xlator_option_reconf_uint64 (xlator_t *this, dict_t *options , char *key, uint64_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1118, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1118 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (uint64_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1118, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1118, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2uint64 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1119 | DEFINE_RECONF_OPT(int64_t, int64, gf_string2int64)int xlator_option_reconf_int64 (xlator_t *this, dict_t *options , char *key, int64_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1119, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1119 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (int64_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1119, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1119, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2int64 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1120 | DEFINE_RECONF_OPT(uint32_t, uint32, gf_string2uint32)int xlator_option_reconf_uint32 (xlator_t *this, dict_t *options , char *key, uint32_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1120, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1120 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (uint32_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1120, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1120, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2uint32 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1121 | DEFINE_RECONF_OPT(int32_t, int32, gf_string2int32)int xlator_option_reconf_int32 (xlator_t *this, dict_t *options , char *key, int32_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1121, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1121 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (int32_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1121, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1121, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2int32 (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1122 | DEFINE_RECONF_OPT(uint64_t, size, gf_string2bytesize)int xlator_option_reconf_size (xlator_t *this, dict_t *options , char *key, uint64_t *val_p) { int ret = 0; volume_option_t * opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1122, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1122 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (uint64_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1122, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1122, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2bytesize (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1123 | DEFINE_RECONF_OPT(double, percent, gf_string2percent)int xlator_option_reconf_percent (xlator_t *this, dict_t *options , char *key, double *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1123 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1123, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (double)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1123, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1123, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2percent (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1124 | DEFINE_RECONF_OPT(double, percent_or_size, pc_or_size)int xlator_option_reconf_percent_or_size (xlator_t *this, dict_t *options, char *key, double *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1124, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1124 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (double)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1124, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1124, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = pc_or_size ( value, val_p); (*__glusterfs_this_location()) = old_THIS; if ( ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1125 | DEFINE_RECONF_OPT(gf_boolean_t, bool, gf_string2boolean)int xlator_option_reconf_bool (xlator_t *this, dict_t *options , char *key, gf_boolean_t *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1125, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1125 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (gf_boolean_t)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1125, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1125, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2boolean (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1126 | DEFINE_RECONF_OPT(xlator_t *, xlator, xl_by_name)int xlator_option_reconf_xlator (xlator_t *this, dict_t *options , char *key, xlator_t * *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ((void*)0); opt = xlator_volume_option_get (this, key); if ( !opt) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1126, GF_LOG_WARNING, "unknown option: %s", key); } while ( 0); ret = -1; return ret; } def_value = opt->default_value ; ret = dict_get_str (options, key, &set_value); if (def_value ) value = def_value; if (set_value) value = set_value; if (!value ) { do { do { if (0) printf ("option %s not set", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1126 , GF_LOG_TRACE, "option %s not set", key); } while (0); *val_p = (xlator_t *)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value ); } while (0); _gf_log (this->name, "options.c", __FUNCTION__ , 1126, GF_LOG_TRACE, "option %s using default value %s", key , value); } while (0); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1126, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = xl_by_name ( value, val_p); (*__glusterfs_this_location()) = old_THIS; if ( ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; | |||
1127 | DEFINE_RECONF_OPT(char *, path, pass)int xlator_option_reconf_path (xlator_t *this, dict_t *options , char *key, char * *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1127 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1127, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (char *)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1127, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1127, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = pass (value , val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value, opt , ((void*)0)); return ret; }; | |||
1128 | DEFINE_RECONF_OPT(double, double, gf_string2double)int xlator_option_reconf_double (xlator_t *this, dict_t *options , char *key, double *val_p) { int ret = 0; volume_option_t *opt = ((void*)0); char *def_value = ((void*)0); char *set_value = ((void*)0); char *value = ((void*)0); xlator_t *old_THIS = ( (void*)0); opt = xlator_volume_option_get (this, key); if (!opt ) { do { do { if (0) printf ("unknown option: %s", key); } while (0); _gf_log (this->name, "options.c", __FUNCTION__, 1128 , GF_LOG_WARNING, "unknown option: %s", key); } while (0); ret = -1; return ret; } def_value = opt->default_value; ret = dict_get_str (options, key, &set_value); if (def_value) value = def_value; if (set_value) value = set_value; if (!value) { do { do { if (0) printf ("option %s not set", key); } while ( 0); _gf_log (this->name, "options.c", __FUNCTION__, 1128, GF_LOG_TRACE , "option %s not set", key); } while (0); *val_p = (double)0; return 0; } if (value == def_value) { do { do { if (0) printf ("option %s using default value %s", key, value); } while (0 ); _gf_log (this->name, "options.c", __FUNCTION__, 1128, GF_LOG_TRACE , "option %s using default value %s", key, value); } while (0 ); } else { do { do { if (0) printf ("option %s using set value %s" , key, value); } while (0); _gf_log (this->name, "options.c" , __FUNCTION__, 1128, GF_LOG_DEBUG, "option %s using set value %s" , key, value); } while (0); } old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = this; ret = gf_string2double (value, val_p); (*__glusterfs_this_location()) = old_THIS; if (ret) return ret; ret = xlator_option_validate (this, key, value , opt, ((void*)0)); return ret; }; |