Patchwork [BUG:1985] mgmt/glusterd: resolve the bricks before comparing uuid

login
register
Submitter Pranith K
Date 2010-10-20 06:50:59
Message ID <20101020065059.GA9353@dev.gluster.com>
Download mbox | patch
Permalink /patch/5534/
State Accepted
Headers show

Comments

Pranith K - 2010-10-20 06:50:59
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
---
 xlators/mgmt/glusterd/src/glusterd-handler.c |   23 ++++++++++++++++-------
 xlators/mgmt/glusterd/src/glusterd-utils.c   |   12 +++++++++++-
 2 files changed, 27 insertions(+), 8 deletions(-)

Patch

diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 51704b3..9ef81a4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -624,15 +624,23 @@  glusterd_handle_cli_deprobe (rpcsvc_request_t *req)
                 goto out;
         }
 
-        ret = glusterd_all_volume_cond_check (glusterd_friend_brick_belongs,
-                                              -1, &uuid);
-        if (ret) {
-                op_errno = GF_DEPROBE_BRICK_EXIST;
-                goto out;
+        if (!uuid_is_null (uuid)) {
+                ret = glusterd_all_volume_cond_check (
+                                                glusterd_friend_brick_belongs,
+                                                -1, &uuid);
+                if (ret) {
+                        op_errno = GF_DEPROBE_BRICK_EXIST;
+                        goto out;
+                }
         }
 
-        ret = glusterd_deprobe_begin (req, cli_req.hostname,
-                                      cli_req.port, uuid);
+        if (!uuid_is_null (uuid)) {
+                ret = glusterd_deprobe_begin (req, cli_req.hostname,
+                                              cli_req.port, uuid);
+        } else {
+                ret = glusterd_deprobe_begin (req, cli_req.hostname,
+                                              cli_req.port, NULL);
+        }
 
         gf_cmd_log ("peer deprobe", "on host %s:%d %s", cli_req.hostname,
                     cli_req.port, (ret) ? "FAILED" : "SUCCESS");
@@ -641,6 +649,7 @@  out:
                 ret = glusterd_xfer_cli_deprobe_resp (req, ret, op_errno,
                                                       cli_req.hostname);
         }
+
         if (cli_req.hostname)
                 free (cli_req.hostname);//malloced by xdr
         return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index f6fa6f6..502a3bf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1604,6 +1604,7 @@  glusterd_import_friend_volume (dict_t *vols, int count)
 
                 strcpy (brickinfo->path, path);
                 strcpy (brickinfo->hostname, hostname);
+                glusterd_resolve_brick (brickinfo);
 
                 list_add_tail (&brickinfo->brick_list, &volinfo->bricks);
 
@@ -2021,13 +2022,22 @@  int
 glusterd_friend_brick_belongs (glusterd_volinfo_t *volinfo,
                                glusterd_brickinfo_t *brickinfo, void* uuid)
 {
+        int             ret = -1;
+
         GF_ASSERT (volinfo);
         GF_ASSERT (brickinfo);
         GF_ASSERT (uuid);
 
+        if (uuid_is_null (brickinfo->uuid)) {
+                ret = glusterd_resolve_brick (brickinfo);
+                if (ret) {
+                        GF_ASSERT (0);
+                        goto out;
+                }
+        }
         if (!uuid_compare (brickinfo->uuid, *((uuid_t *)uuid)))
                 return 0;
-
+out:
         return -1;
 }