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">&lt;<a href="mailto:plrca2@gmail.com">plrca2@gmail.com</a>&gt;</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&#39;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-&gt;value-&gt;data,<br>
+                                      &amp;percent) == 0) {<br>
+                       if ((percent &lt; 0) || (percent &gt; 100)) {<br>
+                               gf_log (xl-&gt;name, GF_LOG_ERROR,<br>
+                               &quot;&#39;%d&#39; in &#39;option %s %s&#39; is out of &quot;<br>
+                               &quot;range [0 - 100]&quot;,<br>
+                               percent, pair-&gt;key,<br>
+                               pair-&gt;value-&gt;data);<br>
+                       } <br>
+                       ret = 0;<br>
+                       goto out;</blockquote><div><br>assume a user gives &quot;option min-free-disk 131072&quot; (with the intention of disk size in size_t), gf_string2percent returns 0, but the check to validate the range fails. but it won&#39;t pass the check for &#39;gf_string2bytesize in this case. So, even logging &#39;error&#39; in that case won&#39;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-&gt;value-&gt;data,<br>
+                                               &amp;input_size) == 0) {<br>
+<br>
+                              if ((opt-&gt;min == 0) &amp;&amp; (opt-&gt;max == 0)) {<br>
+                                       gf_log (xl-&gt;name, GF_LOG_DEBUG,<br>
+                                               &quot;no range check required for &quot;<br>
+                                               &quot;&#39;option %s %s&#39;&quot;,<br>
+                                               pair-&gt;key, pair-&gt;value-&gt;data);<br>
+                                       ret = 0;<br>
+                                       break;<br>
+                               }<br>
+                               if ((input_size &lt; opt-&gt;min) ||<br>
+                                   (input_size &gt; opt-&gt;max)) {<br>
+                                       gf_log (xl-&gt;name, GF_LOG_ERROR,<br>
+                                               &quot;&#39;%&quot;PRId64&quot;&#39; in &#39;option %s %s&#39; is &quot;<br>
+                                               &quot;out of range [%&quot;PRId64&quot; - %&quot;PRId64&quot;]&quot;,<br>
+                                               input_size, pair-&gt;key,<br>
+                                               pair-&gt;value-&gt;data,<br>
+                                               opt-&gt;min, opt-&gt;max);<br>
+                               }<br>
+                               ret = 0;<br>
+                               goto out;<br>
+                       } else {<br>
+                               // It&#39;s not a percent or size<br>
+                               gf_log (xl-&gt;name, GF_LOG_ERROR,<br>
+                               &quot;invalid number format \&quot;%s\&quot; &quot;<br>
+                               &quot;in \&quot;option %s\&quot;&quot;,<br>
+                               pair-&gt;value-&gt;data, pair-&gt;key);<br>
+<br>
+                       }<br>
+               }<br>
+       }<br>
+       break;<br>
 </blockquote></div><br>-- <br>Amar Tumballi<br><br>