This patch includes two smaller things:<br> 1. support to define an option of type PERCENT_OR_SIZET, (modification in libglusterfs/src/*)<br><br> 2. support in alu to provide min-free-disk option with type PERCENT_OR_SIZET <br>
<br><br>Review replies inline:<br><br><div class="gmail_quote">On Wed, Apr 22, 2009 at 4:10 PM, Paul Rawson <span dir="ltr"><<a href="mailto:plrca2@gmail.com">plrca2@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sorry, I think gmail is screwing up the formatting. Let me know if<br>
this still isn't right.</blockquote><div><br>formatting is fine now.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">+ case GF_OPTION_TYPE_PERCENTORSIZET:<br>
+ {<br>
+ uint32_t percent = 0;<br>
+ uint32_t input_size = 0;<br>
+<br>
+ /* Check if the value is valid percentage */<br>
+ if (gf_string2percent (pair->value->data,<br>
+ &percent) == 0) {<br>
+ if ((percent < 0) || (percent > 100)) {<br>
+ gf_log (xl->name, GF_LOG_ERROR,<br>
+ "'%d' in 'option %s %s' is out of "<br>
+ "range [0 - 100]",<br>
+ percent, pair->key,<br>
+ pair->value->data);<br>
+ } <br>
+ ret = 0;<br>
+ goto out;</blockquote><div><br>assume a user gives "option min-free-disk 131072" (with the intention of disk size in size_t), gf_string2percent returns 0, but the check to validate the range fails. but it won't pass the check for 'gf_string2bytesize in this case. So, even logging 'error' in that case won't be valid.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
+ } else {<br>
+ /* Check the range */<br>
+ if (gf_string2bytesize (pair->value->data,<br>
+ &input_size) == 0) {<br>
+<br>
+ if ((opt->min == 0) && (opt->max == 0)) {<br>
+ gf_log (xl->name, GF_LOG_DEBUG,<br>
+ "no range check required for "<br>
+ "'option %s %s'",<br>
+ pair->key, pair->value->data);<br>
+ ret = 0;<br>
+ break;<br>
+ }<br>
+ if ((input_size < opt->min) ||<br>
+ (input_size > opt->max)) {<br>
+ gf_log (xl->name, GF_LOG_ERROR,<br>
+ "'%"PRId64"' in 'option %s %s' is "<br>
+ "out of range [%"PRId64" - %"PRId64"]",<br>
+ input_size, pair->key,<br>
+ pair->value->data,<br>
+ opt->min, opt->max);<br>
+ }<br>
+ ret = 0;<br>
+ goto out;<br>
+ } else {<br>
+ // It's not a percent or size<br>
+ gf_log (xl->name, GF_LOG_ERROR,<br>
+ "invalid number format \"%s\" "<br>
+ "in \"option %s\"",<br>
+ pair->value->data, pair->key);<br>
+<br>
+ }<br>
+ }<br>
+ }<br>
+ break;<br>
</blockquote></div><br>-- <br>Amar Tumballi<br><br>