Patch is logically fine. Avati, you can push it, once you check it compiles without errors.<br><br>Regards,<br>Amar<br><br><div class="gmail_quote">On Mon, Apr 27, 2009 at 10:53 AM, 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;">Ok, this one should be good. I&#39;ve removed the changes to alu since<br>
that seems to be depreciated.<br>
-Paul<br>
<br>
---<br>
 libglusterfs/src/xlator.c               |   84 +++++++++++++++++++++++++++++++<br>
 libglusterfs/src/xlator.h               |    1 +<br>
 xlators/cluster/dht/src/dht-common.h    |    3 +-<br>
 xlators/cluster/dht/src/dht-diskusage.c |   47 +++++++++++++----<br>
 xlators/cluster/dht/src/dht.c           |   50 ++++++++++++-------<br>
 xlators/cluster/dht/src/nufa.c          |   36 ++++++++++----<br>
 6 files changed, 180 insertions(+), 41 deletions(-)<br>
<br>
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c<br>
index 6af2c8e..bf6252a 100644<br>
--- a/libglusterfs/src/xlator.c<br>
+++ b/libglusterfs/src/xlator.c<br>
@@ -431,6 +431,90 @@ _volume_option_value_validate (xlator_t *xl,<br>
                ret = 0;<br>
        }<br>
        break;<br>
+       case GF_OPTION_TYPE_PERCENTORSIZET:<br>
+       {<br>
+               uint32_t percent = 0;<br>
+               uint64_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 &gt; 100) {<br>
+                               gf_log (xl-&gt;name, GF_LOG_DEBUG,<br>
+                                       &quot;value given was greater than 100, &quot;<br>
+                                       &quot;assuming this is actually a size&quot;);<br>
+                               if (gf_string2bytesize (pair-&gt;value-&gt;data,<br>
+                                                       &amp;input_size) == 0) {<br>
+                                       /* Check the range */<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>
+                                               // It is a size<br>
+                                               ret = 0;<br>
+                                                       goto out;<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>
+                                       // It is a size<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>
+                       // It is a percent<br>
+                       ret = 0;<br>
+                       goto out;<br>
+               } else {<br>
+                               if (gf_string2bytesize (pair-&gt;value-&gt;data,<br>
+                                               &amp;input_size) == 0) {<br>
+                               /* Check the range */<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>
+                                       // It is a size<br>
+                                       ret = 0;<br>
+                                       goto out;<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>
+                       } 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>
+                       //It is a size<br>
+                        ret = 0;<br>
+                       goto out;<br>
+               }<br>
+<br>
+       }<br>
+       break;<br>
        case GF_OPTION_TYPE_TIME:<br>
        {<br>
                uint32_t input_time = 0;<br>
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h<br>
index 654e334..bba074e 100644<br>
--- a/libglusterfs/src/xlator.h<br>
+++ b/libglusterfs/src/xlator.h<br>
@@ -807,6 +807,7 @@ typedef enum {<br>
        GF_OPTION_TYPE_INT,<br>
        GF_OPTION_TYPE_SIZET,<br>
        GF_OPTION_TYPE_PERCENT,<br>
+        GF_OPTION_TYPE_PERCENTORSIZET,<br>
        GF_OPTION_TYPE_BOOL,<br>
        GF_OPTION_TYPE_XLATOR,<br>
        GF_OPTION_TYPE_PATH,<br>
diff --git a/xlators/cluster/dht/src/dht-common.h<br>
b/xlators/cluster/dht/src/dht-common.h<br>
index 63a8bb2..1c2b6f4 100644<br>
--- a/xlators/cluster/dht/src/dht-common.h<br>
+++ b/xlators/cluster/dht/src/dht-common.h<br>
@@ -117,7 +117,8 @@ struct dht_conf {<br>
        gf_boolean_t   search_unhashed;<br>
        int            gen;<br>
         dht_du_t      *du_stats;<br>
-        uint32_t       min_free_disk;<br>
+        uint64_t       min_free_disk;<br>
+        char           disk_unit;<br>
         int32_t        refresh_interval;<br>
         gf_boolean_t   unhashed_sticky_bit;<br>
        struct timeval last_stat_fetch;<br>
diff --git a/xlators/cluster/dht/src/dht-diskusage.c<br>
b/xlators/cluster/dht/src/dht-diskusage.c<br>
index 5e3dc23..7edf4d0 100644<br>
--- a/xlators/cluster/dht/src/dht-diskusage.c<br>
+++ b/xlators/cluster/dht/src/dht-diskusage.c<br>
@@ -43,6 +43,7 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie,<br>
xlator_t *this,<br>
        int            this_call_cnt = 0;<br>
         int            i = 0;<br>
         double         percent = 0;<br>
+        uint64_t       bytes = 0;<br>
<br>
        local = frame-&gt;local;<br>
         conf = this-&gt;private;<br>
@@ -56,8 +57,15 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie,<br>
xlator_t *this,<br>
         LOCK (&amp;conf-&gt;subvolume_lock);<br>
         {<br>
                 for (i = 0; i &lt; conf-&gt;subvolume_cnt; i++)<br>
-                        if (prev-&gt;this == conf-&gt;subvolumes[i])<br>
+                        if (prev-&gt;this == conf-&gt;subvolumes[i]){<br>
                                 conf-&gt;du_stats[i].avail_percent = percent;<br>
+                               conf-&gt;du_stats[i].avail_space = bytes;<br>
+                               gf_log (this-&gt;name, GF_LOG_DEBUG,<br>
+                                       &quot;avail_percent on %d is: %f, &quot;<br>
+                                       &quot;and avail_space on %d is: %llu&quot;,<br>
+                                       i, conf-&gt;du_stats[i].avail_percent,<br>
+                                       i, conf-&gt;du_stats[i].avail_space);<br>
+                       }<br>
         }<br>
         UNLOCK (&amp;conf-&gt;subvolume_lock);<br>
<br>
@@ -174,15 +182,24 @@ dht_is_subvol_filled (xlator_t *this, xlator_t *subvol)<br>
<br>
         conf = this-&gt;private;<br>
<br>
-        /* Check for values above 90% free disk */<br>
+        /* Check for values above specified percent or free disk */<br>
         LOCK (&amp;conf-&gt;subvolume_lock);<br>
         {<br>
                 for (i = 0; i &lt; conf-&gt;subvolume_cnt; i++) {<br>
-                        if ((subvol == conf-&gt;subvolumes[i]) &amp;&amp;<br>
-                            (conf-&gt;du_stats[i].avail_percent &lt;<br>
-                             conf-&gt;min_free_disk)) {<br>
-                                subvol_filled = 1;<br>
-                                break;<br>
+                        if (subvol == conf-&gt;subvolumes[i]) {<br>
+                               if (conf-&gt;disk_unit == &#39;p&#39;) {<br>
+                                       if (conf-&gt;du_stats[i].avail_percent &lt;<br>
+                                            conf-&gt;min_free_disk) {<br>
+                                               subvol_filled = 1;<br>
+                                               break;<br>
+                                       }<br>
+                               } else {<br>
+                                       if (conf-&gt;du_stats[i].avail_space &lt;<br>
+                                           conf-&gt;min_free_disk) {<br>
+                                               subvol_filled = 1;<br>
+                                               break;<br>
+                                       }<br>
+                               }<br>
                         }<br>
                 }<br>
         }<br>
@@ -190,7 +207,7 @@ dht_is_subvol_filled (xlator_t *this, xlator_t *subvol)<br>
<br>
         if (subvol_filled) {<br>
                 if (!(conf-&gt;du_stats[i].log++ % GF_UNIVERSAL_ANSWER)) {<br>
-                        gf_log (this-&gt;name, GF_LOG_CRITICAL,<br>
+                        gf_log (this-&gt;name, GF_LOG_WARNING,<br>
                                 &quot;disk space on subvolume &#39;%s&#39; is getting &quot;<br>
                                 &quot;full (%.2f %%), consider adding more nodes&quot;,<br>
                                 subvol-&gt;name,<br>
@@ -205,7 +222,7 @@ xlator_t *<br>
 dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol)<br>
 {<br>
         int         i = 0;<br>
-        double      max_avail = 0;<br>
+        uint64_t    max_avail = 0;<br>
         xlator_t   *avail_subvol = NULL;<br>
        dht_conf_t *conf = NULL;<br>
<br>
@@ -215,10 +232,16 @@ dht_free_disk_available_subvol (xlator_t *this,<br>
xlator_t *subvol)<br>
         LOCK (&amp;conf-&gt;subvolume_lock);<br>
         {<br>
                 for (i = 0; i &lt; conf-&gt;subvolume_cnt; i++) {<br>
-                        if (conf-&gt;du_stats[i].avail_percent &gt; max_avail) {<br>
-                                max_avail  = conf-&gt;du_stats[i].avail_percent;<br>
+                       if (conf-&gt;disk_unit == &#39;p&#39;) {<br>
+                               if (conf-&gt;du_stats[i].avail_percent &gt; max_avail) {<br>
+                                       max_avail  = conf-&gt;du_stats[i].avail_percent;<br>
+                               }<br>
                                 avail_subvol = conf-&gt;subvolumes[i];<br>
-                        }<br>
+                       } else {<br>
+                               if (conf-&gt;du_stats[i].avail_space &gt; max_avail) {<br>
+                                       max_avail = conf-&gt;du_stats[i].avail_space;<br>
+                               }<br>
+                       }<br>
                 }<br>
         }<br>
         UNLOCK (&amp;conf-&gt;subvolume_lock);<br>
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c<br>
index 4dac730..4658e59 100644<br>
--- a/xlators/cluster/dht/src/dht.c<br>
+++ b/xlators/cluster/dht/src/dht.c<br>
@@ -81,9 +81,10 @@ int<br>
 init (xlator_t *this)<br>
 {<br>
         dht_conf_t    *conf = NULL;<br>
-       char          *lookup_unhashed_str = NULL;<br>
+       char          *temp_str = NULL;<br>
         int            ret = -1;<br>
         int            i = 0;<br>
+        uint32_t       temp_free_disk = 0;<br>
<br>
        if (!this-&gt;children) {<br>
                gf_log (this-&gt;name, GF_LOG_ERROR,<br>
@@ -106,27 +107,40 @@ init (xlator_t *this)<br>
        conf-&gt;search_unhashed = 0;<br>
<br>
        if (dict_get_str (this-&gt;options, &quot;lookup-unhashed&quot;,<br>
-                         &amp;lookup_unhashed_str) == 0) {<br>
-               gf_string2boolean (lookup_unhashed_str,<br>
+                         &amp;temp_str) == 0) {<br>
+               gf_string2boolean (temp_str,<br>
                                   &amp;conf-&gt;search_unhashed);<br>
        }<br>
<br>
-       conf-&gt;unhashed_sticky_bit = 0;<br>
+        conf-&gt;unhashed_sticky_bit = 0;<br>
<br>
-       if (dict_get_str (this-&gt;options, &quot;unhashed-sticky-bit&quot;,<br>
-                         &amp;lookup_unhashed_str) == 0) {<br>
-               gf_string2boolean (lookup_unhashed_str,<br>
-                                  &amp;conf-&gt;unhashed_sticky_bit);<br>
+        if (dict_get_str (this-&gt;options, &quot;unhashed-sticky-bit&quot;,<br>
+                                   &amp;temp_str) == 0) {<br>
+                gf_string2boolean (temp_str,<br>
+                                   &amp;conf-&gt;unhashed_sticky_bit);<br>
        }<br>
<br>
         conf-&gt;min_free_disk = 10;<br>
-<br>
-       if (dict_get_str (this-&gt;options, &quot;min-free-disk&quot;,<br>
-                         &amp;lookup_unhashed_str) == 0) {<br>
-               gf_string2percent (lookup_unhashed_str,<br>
-                                  &amp;conf-&gt;min_free_disk);<br>
-       }<br>
-<br>
+        conf-&gt;disk_unit = &#39;p&#39;;<br>
+<br>
+        if (dict_get_str (this-&gt;options, &quot;min-free-disk&quot;,<br>
+                          &amp;temp_str) == 0) {<br>
+                if (gf_string2percent (temp_str,<br>
+                                       &amp;temp_free_disk) == 0) {<br>
+                        if (temp_free_disk &gt; 100) {<br>
+                                gf_string2bytesize (temp_str,<br>
+                                                        &amp;conf-&gt;min_free_disk);<br>
+                                conf-&gt;disk_unit = &#39;b&#39;;<br>
+                        } else {<br>
+                                conf-&gt;min_free_disk = (uint64_t)temp_free_disk;<br>
+                               conf-&gt;disk_unit = &#39;p&#39;;<br>
+                        }<br>
+                } else {<br>
+                        gf_string2bytesize (temp_str,<br>
+                                                &amp;conf-&gt;min_free_disk);<br>
+                        conf-&gt;disk_unit = &#39;b&#39;;<br>
+                }<br>
+        }<br>
<br>
         ret = dht_init_subvolumes (this, conf);<br>
         if (ret == -1) {<br>
@@ -242,11 +256,11 @@ struct xlator_cbks cbks = {<br>
<br>
<br>
 struct volume_options options[] = {<br>
+        { .key  = {&quot;min-free-disk&quot;},<br>
+          .type = GF_OPTION_TYPE_PERCENTORSIZET<br>
+        },<br>
         { .key  = {&quot;lookup-unhashed&quot;},<br>
          .type = GF_OPTION_TYPE_BOOL<br>
        },<br>
-        { .key  = {&quot;min-free-disk&quot;},<br>
-          .type = GF_OPTION_TYPE_PERCENT<br>
-        },<br>
        { .key  = {NULL} },<br>
 };<br>
diff --git a/xlators/cluster/dht/src/nufa.c b/xlators/cluster/dht/src/nufa.c<br>
index 57ac6b0..128ff77 100644<br>
--- a/xlators/cluster/dht/src/nufa.c<br>
+++ b/xlators/cluster/dht/src/nufa.c<br>
@@ -527,10 +527,11 @@ init (xlator_t *this)<br>
        xlator_list_t *trav = NULL;<br>
        data_t        *data = NULL;<br>
        char          *local_volname = NULL;<br>
-       char          *lookup_unhashed_str = NULL;<br>
+       char          *temp_str = NULL;<br>
         int            ret = -1;<br>
         int            i = 0;<br>
        char           my_hostname[256];<br>
+       uint32_t       temp_free_disk = 0;<br>
<br>
        if (!this-&gt;children) {<br>
                gf_log (this-&gt;name, GF_LOG_ERROR,<br>
@@ -553,9 +554,9 @@ init (xlator_t *this)<br>
        conf-&gt;search_unhashed = 0;<br>
<br>
        if (dict_get_str (this-&gt;options, &quot;lookup-unhashed&quot;,<br>
-                         &amp;lookup_unhashed_str) == 0) {<br>
-               gf_string2boolean (lookup_unhashed_str,<br>
-                                  &amp;conf-&gt;search_unhashed);<br>
+                         &amp;temp_str) == 0) {<br>
+               gf_string2boolean (temp_str,<br>
+                                  &amp;conf-&gt;search_unhashed);<br>
        }<br>
<br>
         ret = dht_init_subvolumes (this, conf);<br>
@@ -607,11 +608,26 @@ init (xlator_t *this)<br>
        conf-&gt;local_volume = trav-&gt;xlator;<br>
<br>
         conf-&gt;min_free_disk = 10;<br>
-<br>
-       data = dict_get (this-&gt;options, &quot;min-free-disk&quot;);<br>
-       if (data) {<br>
-               gf_string2percent (data-&gt;data, &amp;conf-&gt;min_free_disk);<br>
-       }<br>
+        conf-&gt;disk_unit = &#39;p&#39;;<br>
+<br>
+        if (dict_get_str (this-&gt;options, &quot;min-free-disk&quot;,<br>
+                          &amp;temp_str) == 0) {<br>
+                if (gf_string2percent (temp_str,<br>
+                                       &amp;temp_free_disk) == 0) {<br>
+                        if (temp_free_disk &gt; 100) {<br>
+                                gf_string2bytesize (temp_str,<br>
+                                                        &amp;conf-&gt;min_free_disk);<br>
+                                conf-&gt;disk_unit = &#39;b&#39;;<br>
+                        } else {<br>
+                                conf-&gt;min_free_disk = (uint64_t)temp_free_disk;<br>
+                                conf-&gt;disk_unit = &#39;p&#39;;<br>
+                        }<br>
+                } else {<br>
+                        gf_string2bytesize (temp_str,<br>
+                                                &amp;conf-&gt;min_free_disk);<br>
+                        conf-&gt;disk_unit = &#39;b&#39;;<br>
+                }<br>
+        }<br>
<br>
         conf-&gt;du_stats = CALLOC (conf-&gt;subvolume_cnt, sizeof (dht_du_t));<br>
         if (!conf-&gt;du_stats) {<br>
@@ -720,7 +736,7 @@ struct volume_options options[] = {<br>
          .type = GF_OPTION_TYPE_BOOL<br>
        },<br>
         { .key  = {&quot;min-free-disk&quot;},<br>
-          .type = GF_OPTION_TYPE_PERCENT<br>
+          .type = GF_OPTION_TYPE_PERCENTORSIZET<br>
         },<br>
        { .key  = {NULL} },<br>
 };<br>
<font color="#888888">--<br>
1.6.0.6<br>
<br>
<br>
_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@nongnu.org">Gluster-devel@nongnu.org</a><br>
<a href="http://lists.nongnu.org/mailman/listinfo/gluster-devel" target="_blank">http://lists.nongnu.org/mailman/listinfo/gluster-devel</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Amar Tumballi<br><br>