d1681e
From 85d0f78a989304cfe4ee74840f22bacf6685a659 Mon Sep 17 00:00:00 2001
d1681e
From: Sunny Kumar <sunkumar@redhat.com>
d1681e
Date: Tue, 2 Jan 2018 12:25:33 +0530
d1681e
Subject: [PATCH 118/128] snapshot : after brick reset/replace snapshot
d1681e
 creation fails
d1681e
d1681e
Problem : after brick reset/replace snapshot creation fails
d1681e
d1681e
Solution : During brick reset/replace when we validate and aggrigate
d1681e
           dictionary data from another node it was rewriting
d1681e
           'mount_dir' value to NULL which is critical for snapshot
d1681e
           creation.
d1681e
d1681e
Upstream patch : https://review.gluster.org/c/19049/
d1681e
d1681e
>BUG: 1512451
d1681e
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
d1681e
d1681e
Change-Id: Iabefbfcef7d8ac4cbd2a241e821c0e51492c093e
d1681e
BUG: 1507394
d1681e
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/126712
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
---
d1681e
 xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 30 +++++++++++++++-------
d1681e
 xlators/mgmt/glusterd/src/glusterd-reset-brick.c   | 27 ++++++++++++-------
d1681e
 xlators/mgmt/glusterd/src/glusterd-utils.c         |  9 -------
d1681e
 3 files changed, 39 insertions(+), 27 deletions(-)
d1681e
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
d1681e
index 0e28608..b11adf1 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
d1681e
@@ -309,16 +309,28 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
d1681e
                 /* A bricks mount dir is required only by snapshots which were
d1681e
                  * introduced in gluster-3.6.0
d1681e
                  */
d1681e
-                ret = glusterd_get_brick_mount_dir (dst_brickinfo->path,
d1681e
-                                                    dst_brickinfo->hostname,
d1681e
-                                                    dst_brickinfo->mount_dir);
d1681e
-                if (ret) {
d1681e
-                        gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
-                                GD_MSG_BRICK_MOUNTDIR_GET_FAIL,
d1681e
-                                "Failed to get brick mount_dir");
d1681e
-                        goto out;
d1681e
-                }
d1681e
 
d1681e
+                if (!(gf_uuid_compare (dst_brickinfo->uuid, MY_UUID))) {
d1681e
+                        ret = glusterd_get_brick_mount_dir
d1681e
+                                        (dst_brickinfo->path,
d1681e
+                                         dst_brickinfo->hostname,
d1681e
+                                         dst_brickinfo->mount_dir);
d1681e
+                        if (ret) {
d1681e
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                        GD_MSG_BRICK_MOUNTDIR_GET_FAIL,
d1681e
+                                        "Failed to get brick mount_dir");
d1681e
+                                goto out;
d1681e
+                        }
d1681e
+                        ret = dict_set_dynstr_with_alloc
d1681e
+                                        (rsp_dict, "brick1.mount_dir",
d1681e
+                                         dst_brickinfo->mount_dir);
d1681e
+                        if (ret) {
d1681e
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                        GD_MSG_DICT_SET_FAILED,
d1681e
+                                        "Failed to set brick.mount_dir");
d1681e
+                                goto out;
d1681e
+                        }
d1681e
+                }
d1681e
 
d1681e
                 ret = dict_set_int32 (rsp_dict, "brick_count", 1);
d1681e
                 if (ret) {
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-reset-brick.c b/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
d1681e
index 10ee6f4..c1de043 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
d1681e
@@ -197,15 +197,24 @@ glusterd_reset_brick_prevalidate (dict_t *dict, char **op_errstr,
d1681e
 
d1681e
         }
d1681e
 
d1681e
-        ret = glusterd_get_brick_mount_dir
d1681e
-                        (dst_brickinfo->path,
d1681e
-                         dst_brickinfo->hostname,
d1681e
-                         dst_brickinfo->mount_dir);
d1681e
-        if (ret) {
d1681e
-                gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
-                        GD_MSG_BRICK_MOUNTDIR_GET_FAIL,
d1681e
-                        "Failed to get brick mount_dir.");
d1681e
-                goto out;
d1681e
+        if (!(gf_uuid_compare (dst_brickinfo->uuid, MY_UUID))) {
d1681e
+                ret = glusterd_get_brick_mount_dir (dst_brickinfo->path,
d1681e
+                                                    dst_brickinfo->hostname,
d1681e
+                                                    dst_brickinfo->mount_dir);
d1681e
+                if (ret) {
d1681e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                GD_MSG_BRICK_MOUNTDIR_GET_FAIL,
d1681e
+                                "Failed to get brick mount_dir");
d1681e
+                        goto out;
d1681e
+                }
d1681e
+                ret = dict_set_dynstr_with_alloc (rsp_dict, "brick1.mount_dir",
d1681e
+                                                  dst_brickinfo->mount_dir);
d1681e
+                if (ret) {
d1681e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                GD_MSG_DICT_SET_FAILED,
d1681e
+                                "Failed to set brick.mount_dir");
d1681e
+                        goto out;
d1681e
+                }
d1681e
         }
d1681e
 
d1681e
         ret = dict_set_int32 (rsp_dict, "brick_count", 1);
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
index 4b53898..1b2cc43 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
@@ -13696,15 +13696,6 @@ glusterd_brick_op_prerequisites (dict_t *dict,
d1681e
                                         (*src_brickinfo)->port);
d1681e
                         }
d1681e
                 }
d1681e
-                /* setting mount_dir */
d1681e
-                ret = dict_set_dynstr_with_alloc (rsp_dict, "brick1.mount_dir",
d1681e
-                                                  (*src_brickinfo)->mount_dir);
d1681e
-                if (ret) {
d1681e
-                        gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
-                                GD_MSG_DICT_SET_FAILED,
d1681e
-                                "Failed to set brick1.mount_dir");
d1681e
-                        goto out;
d1681e
-                }
d1681e
 
d1681e
                 v = *volinfo;
d1681e
                 b = *src_brickinfo;
d1681e
-- 
d1681e
1.8.3.1
d1681e