Patchwork [BUG:1508] cluster/dht: fixes to handle 'fix.layout' attribute properly.

login
register
Submitter Amar Tumballi
Date 2010-09-02 12:06:49
Message ID <20100902120649.GA2638@gluster.com>
Download mbox | patch
Permalink /patch/4485/
State Accepted
Headers show

Comments

Amar Tumballi - 2010-09-02 12:06:49
Signed-off-by: Amar Tumballi <amar@gluster.com>
---
 xlators/cluster/dht/src/dht-common.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

Patch

diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index b938921..3b4fe36 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -1652,6 +1652,8 @@  dht_getxattr (call_frame_t *frame, xlator_t *this,
         dht_layout_t *layout        = NULL;
         int           op_errno      = -1;
         int           ret           = 0;
+        int           flag          = 0;
+        int           i             = 0;
 
         VALIDATE_OR_GOTO (frame, err);
         VALIDATE_OR_GOTO (this, err);
@@ -1717,7 +1719,13 @@  dht_getxattr (call_frame_t *frame, xlator_t *this,
                 goto err;
         }
         if (key && (strcmp (key, GF_XATTR_FIX_LAYOUT_KEY) == 0)) {
-                if (layout->cnt < conf->subvolume_cnt) {
+                for (i = 0; i < layout->cnt; i++) {
+                        if (layout->list[i].start == layout->list[i].stop) {
+                                flag = 1;
+                                break;
+                        }
+                }
+                if ((layout->cnt < conf->subvolume_cnt) || flag) {
                         gf_log (this->name, GF_LOG_INFO,
                                 "expanding layout of %s from %d to %d",
                                 loc->path, layout->cnt, conf->subvolume_cnt);
@@ -1736,8 +1744,7 @@  dht_getxattr (call_frame_t *frame, xlator_t *this,
                                         "Out of memory");
                                 goto err;
                         }
-                        local->layout = layout = dht_layout_new (this,
-                                                                 conf->subvolume_cnt);
+                        local->layout = layout;
 
                         dht_selfheal_new_directory (frame, dht_fix_layout_cbk,
                                                     layout);