14f8ab
From b0815b8a84a07d17a1215c55afc38888ee9fc37c Mon Sep 17 00:00:00 2001
14f8ab
From: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
Date: Mon, 24 Jun 2019 12:00:20 +0530
14f8ab
Subject: [PATCH 227/255] glusterd/svc: update pid of mux volumes from the shd
14f8ab
 process
14f8ab
14f8ab
For a normal volume, we are updating the pid from a the
14f8ab
process while we do a daemonization or at the end of the
14f8ab
init if it is no-daemon mode. Along with updating the pid
14f8ab
we also lock the file, to make sure that the process is
14f8ab
running fine.
14f8ab
14f8ab
With brick mux, we were updating the pidfile from gluterd
14f8ab
after an attach/detach request.
14f8ab
14f8ab
There are two problems with this approach.
14f8ab
1) We are not holding a pidlock for any file other than parent
14f8ab
   process.
14f8ab
2) There is a chance for possible race conditions with attach/detach.
14f8ab
   For example, shd start and a volume stop could race. Let's say
14f8ab
   we are starting an shd and it is attached to a volume.
14f8ab
   While we trying to link the pid file to the running process,
14f8ab
   this would have deleted by the thread that doing a volume stop.
14f8ab
14f8ab
> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22935/
14f8ab
14f8ab
>Change-Id: I29a00352102877ce09ea3f376ca52affceb5cf1a
14f8ab
>Updates: bz#1722541
14f8ab
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
14f8ab
Change-Id: I29a00352102877ce09ea3f376ca52affceb5cf1a
14f8ab
BUG: 1721802
14f8ab
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/175723
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
14f8ab
---
14f8ab
 glusterfsd/src/gf_attach.c                         |   2 +
14f8ab
 glusterfsd/src/glusterfsd-mgmt.c                   |  66 +++++++--
14f8ab
 libglusterfs/src/glusterfs/glusterfs.h             |   2 +-
14f8ab
 libglusterfs/src/glusterfs/libglusterfs-messages.h |   3 +-
14f8ab
 libglusterfs/src/graph.c                           | 154 ++++++++++++++++++++-
14f8ab
 rpc/xdr/src/glusterd1-xdr.x                        |   1 +
14f8ab
 xlators/mgmt/glusterd/src/glusterd-handler.c       |   2 +
14f8ab
 xlators/mgmt/glusterd/src/glusterd-handshake.c     |  42 +++++-
14f8ab
 xlators/mgmt/glusterd/src/glusterd-op-sm.c         |   4 +
14f8ab
 .../mgmt/glusterd/src/glusterd-shd-svc-helper.c    |  25 ++++
14f8ab
 .../mgmt/glusterd/src/glusterd-shd-svc-helper.h    |   3 +
14f8ab
 xlators/mgmt/glusterd/src/glusterd-shd-svc.c       |   8 +-
14f8ab
 xlators/mgmt/glusterd/src/glusterd-svc-helper.c    |  57 ++++----
14f8ab
 xlators/mgmt/glusterd/src/glusterd-syncop.c        |   2 +
14f8ab
 xlators/mgmt/glusterd/src/glusterd-utils.c         |   6 +-
14f8ab
 15 files changed, 325 insertions(+), 52 deletions(-)
14f8ab
14f8ab
diff --git a/glusterfsd/src/gf_attach.c b/glusterfsd/src/gf_attach.c
14f8ab
index 6293b9b..1bff854 100644
14f8ab
--- a/glusterfsd/src/gf_attach.c
14f8ab
+++ b/glusterfsd/src/gf_attach.c
14f8ab
@@ -65,6 +65,8 @@ send_brick_req(xlator_t *this, struct rpc_clnt *rpc, char *path, int op)
14f8ab
     brick_req.name = path;
14f8ab
     brick_req.input.input_val = NULL;
14f8ab
     brick_req.input.input_len = 0;
14f8ab
+    brick_req.dict.dict_val = NULL;
14f8ab
+    brick_req.dict.dict_len = 0;
14f8ab
 
14f8ab
     req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req);
14f8ab
     iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size);
14f8ab
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
14f8ab
index 1d2cd1a..f930e0a 100644
14f8ab
--- a/glusterfsd/src/glusterfsd-mgmt.c
14f8ab
+++ b/glusterfsd/src/glusterfsd-mgmt.c
14f8ab
@@ -50,13 +50,16 @@ int
14f8ab
 emancipate(glusterfs_ctx_t *ctx, int ret);
14f8ab
 int
14f8ab
 glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
14f8ab
-                                   char *volfile_id, char *checksum);
14f8ab
+                                   char *volfile_id, char *checksum,
14f8ab
+                                   dict_t *dict);
14f8ab
 int
14f8ab
 glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
14f8ab
-                                  gf_volfile_t *volfile_obj, char *checksum);
14f8ab
+                                  gf_volfile_t *volfile_obj, char *checksum,
14f8ab
+                                  dict_t *dict);
14f8ab
 int
14f8ab
 glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
14f8ab
-                                   char *volfile_id, char *checksum);
14f8ab
+                                   char *volfile_id, char *checksum,
14f8ab
+                                   dict_t *dict);
14f8ab
 int
14f8ab
 glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj);
14f8ab
 
14f8ab
@@ -75,7 +78,8 @@ mgmt_cbk_spec(struct rpc_clnt *rpc, void *mydata, void *data)
14f8ab
 }
14f8ab
 
14f8ab
 int
14f8ab
-mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id)
14f8ab
+mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id,
14f8ab
+                     dict_t *dict)
14f8ab
 {
14f8ab
     glusterfs_ctx_t *ctx = NULL;
14f8ab
     int ret = 0;
14f8ab
@@ -145,11 +149,11 @@ mgmt_process_volfile(const char *volfile, ssize_t size, char *volfile_id)
14f8ab
              * the volfile
14f8ab
              */
14f8ab
             ret = glusterfs_process_svc_attach_volfp(ctx, tmpfp, volfile_id,
14f8ab
-                                                     sha256_hash);
14f8ab
+                                                     sha256_hash, dict);
14f8ab
             goto unlock;
14f8ab
         }
14f8ab
         ret = glusterfs_mux_volfile_reconfigure(tmpfp, ctx, volfile_obj,
14f8ab
-                                                sha256_hash);
14f8ab
+                                                sha256_hash, dict);
14f8ab
         if (ret < 0) {
14f8ab
             gf_msg_debug("glusterfsd-mgmt", EINVAL, "Reconfigure failed !!");
14f8ab
         }
14f8ab
@@ -387,6 +391,8 @@ err:
14f8ab
         UNLOCK(&ctx->volfile_lock);
14f8ab
     if (xlator_req.input.input_val)
14f8ab
         free(xlator_req.input.input_val);
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
     free(xlator_req.name);
14f8ab
     xlator_req.name = NULL;
14f8ab
     return 0;
14f8ab
@@ -561,6 +567,8 @@ out:
14f8ab
 
14f8ab
     free(xlator_req.name);
14f8ab
     free(xlator_req.input.input_val);
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
     if (output)
14f8ab
         dict_unref(output);
14f8ab
     if (dict)
14f8ab
@@ -982,6 +990,8 @@ out:
14f8ab
     if (input)
14f8ab
         dict_unref(input);
14f8ab
     free(xlator_req.input.input_val); /*malloced by xdr*/
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
     if (output)
14f8ab
         dict_unref(output);
14f8ab
     free(xlator_req.name);
14f8ab
@@ -1062,6 +1072,8 @@ glusterfs_handle_attach(rpcsvc_request_t *req)
14f8ab
     out:
14f8ab
         UNLOCK(&ctx->volfile_lock);
14f8ab
     }
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
     free(xlator_req.input.input_val);
14f8ab
     free(xlator_req.name);
14f8ab
 
14f8ab
@@ -1077,6 +1089,7 @@ glusterfs_handle_svc_attach(rpcsvc_request_t *req)
14f8ab
     };
14f8ab
     xlator_t *this = NULL;
14f8ab
     glusterfs_ctx_t *ctx = NULL;
14f8ab
+    dict_t *dict = NULL;
14f8ab
 
14f8ab
     GF_ASSERT(req);
14f8ab
     this = THIS;
14f8ab
@@ -1091,20 +1104,41 @@ glusterfs_handle_svc_attach(rpcsvc_request_t *req)
14f8ab
         req->rpc_err = GARBAGE_ARGS;
14f8ab
         goto out;
14f8ab
     }
14f8ab
+
14f8ab
     gf_msg(THIS->name, GF_LOG_INFO, 0, glusterfsd_msg_41,
14f8ab
            "received attach "
14f8ab
            "request for volfile-id=%s",
14f8ab
            xlator_req.name);
14f8ab
+
14f8ab
+    dict = dict_new();
14f8ab
+    if (!dict) {
14f8ab
+        ret = -1;
14f8ab
+        errno = ENOMEM;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    ret = dict_unserialize(xlator_req.dict.dict_val, xlator_req.dict.dict_len,
14f8ab
+                           &dict);
14f8ab
+    if (ret) {
14f8ab
+        gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42,
14f8ab
+               "failed to unserialize xdata to dictionary");
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+    dict->extra_stdfree = xlator_req.dict.dict_val;
14f8ab
+
14f8ab
     ret = 0;
14f8ab
 
14f8ab
     if (ctx->active) {
14f8ab
         ret = mgmt_process_volfile(xlator_req.input.input_val,
14f8ab
-                                   xlator_req.input.input_len, xlator_req.name);
14f8ab
+                                   xlator_req.input.input_len, xlator_req.name,
14f8ab
+                                   dict);
14f8ab
     } else {
14f8ab
         gf_msg(this->name, GF_LOG_WARNING, EINVAL, glusterfsd_msg_42,
14f8ab
                "got attach for %s but no active graph", xlator_req.name);
14f8ab
     }
14f8ab
 out:
14f8ab
+    if (dict)
14f8ab
+        dict_unref(dict);
14f8ab
     if (xlator_req.input.input_val)
14f8ab
         free(xlator_req.input.input_val);
14f8ab
     if (xlator_req.name)
14f8ab
@@ -1241,6 +1275,8 @@ out:
14f8ab
     GF_FREE(filepath);
14f8ab
     if (xlator_req.input.input_val)
14f8ab
         free(xlator_req.input.input_val);
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
 
14f8ab
     return ret;
14f8ab
 }
14f8ab
@@ -1313,6 +1349,8 @@ out:
14f8ab
     if (dict)
14f8ab
         dict_unref(dict);
14f8ab
     free(xlator_req.input.input_val);  // malloced by xdr
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
     if (output)
14f8ab
         dict_unref(output);
14f8ab
     free(xlator_req.name);  // malloced by xdr
14f8ab
@@ -1461,6 +1499,8 @@ out:
14f8ab
     if (output)
14f8ab
         dict_unref(output);
14f8ab
     free(brick_req.input.input_val);
14f8ab
+    if (brick_req.dict.dict_val)
14f8ab
+        free(brick_req.dict.dict_val);
14f8ab
     free(brick_req.name);
14f8ab
     GF_FREE(xname);
14f8ab
     GF_FREE(msg);
14f8ab
@@ -1654,6 +1694,8 @@ out:
14f8ab
     if (dict)
14f8ab
         dict_unref(dict);
14f8ab
     free(node_req.input.input_val);
14f8ab
+    if (node_req.dict.dict_val)
14f8ab
+        free(node_req.dict.dict_val);
14f8ab
     GF_FREE(msg);
14f8ab
     GF_FREE(rsp.output.output_val);
14f8ab
     GF_FREE(node_name);
14f8ab
@@ -1757,6 +1799,8 @@ glusterfs_handle_nfs_profile(rpcsvc_request_t *req)
14f8ab
 
14f8ab
 out:
14f8ab
     free(nfs_req.input.input_val);
14f8ab
+    if (nfs_req.dict.dict_val)
14f8ab
+        free(nfs_req.dict.dict_val);
14f8ab
     if (dict)
14f8ab
         dict_unref(dict);
14f8ab
     if (output)
14f8ab
@@ -1835,6 +1879,8 @@ out:
14f8ab
     if (dict)
14f8ab
         dict_unref(dict);
14f8ab
     free(xlator_req.input.input_val);  // malloced by xdr
14f8ab
+    if (xlator_req.dict.dict_val)
14f8ab
+        free(xlator_req.dict.dict_val);
14f8ab
     if (output)
14f8ab
         dict_unref(output);
14f8ab
     free(xlator_req.name);  // malloced by xdr
14f8ab
@@ -1963,7 +2009,8 @@ out:
14f8ab
     if (dict)
14f8ab
         dict_unref(dict);
14f8ab
     free(brick_req.input.input_val);
14f8ab
-
14f8ab
+    if (brick_req.dict.dict_val)
14f8ab
+        free(brick_req.dict.dict_val);
14f8ab
     gf_log(THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
14f8ab
     return ret;
14f8ab
 }
14f8ab
@@ -2213,7 +2260,8 @@ volfile:
14f8ab
     size = rsp.op_ret;
14f8ab
     volfile_id = frame->local;
14f8ab
     if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name)) {
14f8ab
-        ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id);
14f8ab
+        ret = mgmt_process_volfile((const char *)rsp.spec, size, volfile_id,
14f8ab
+                                   dict);
14f8ab
         goto post_graph_mgmt;
14f8ab
     }
14f8ab
 
14f8ab
diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h
14f8ab
index 9ec2365..b6327b8 100644
14f8ab
--- a/libglusterfs/src/glusterfs/glusterfs.h
14f8ab
+++ b/libglusterfs/src/glusterfs/glusterfs.h
14f8ab
@@ -744,7 +744,7 @@ typedef struct {
14f8ab
     char vol_id[NAME_MAX + 1];
14f8ab
     struct list_head volfile_list;
14f8ab
     glusterfs_graph_t *graph;
14f8ab
-
14f8ab
+    FILE *pidfp;
14f8ab
 } gf_volfile_t;
14f8ab
 
14f8ab
 glusterfs_ctx_t *
14f8ab
diff --git a/libglusterfs/src/glusterfs/libglusterfs-messages.h b/libglusterfs/src/glusterfs/libglusterfs-messages.h
14f8ab
index ea2aa60..7e0eebb 100644
14f8ab
--- a/libglusterfs/src/glusterfs/libglusterfs-messages.h
14f8ab
+++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h
14f8ab
@@ -111,6 +111,7 @@ GLFS_MSGID(
14f8ab
     LG_MSG_PTHREAD_NAMING_FAILED, LG_MSG_SYSCALL_RETURNS_WRONG,
14f8ab
     LG_MSG_XXH64_TO_GFID_FAILED, LG_MSG_ASYNC_WARNING, LG_MSG_ASYNC_FAILURE,
14f8ab
     LG_MSG_GRAPH_CLEANUP_FAILED, LG_MSG_GRAPH_SETUP_FAILED,
14f8ab
-    LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED);
14f8ab
+    LG_MSG_GRAPH_DETACH_STARTED, LG_MSG_GRAPH_ATTACH_FAILED,
14f8ab
+    LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED);
14f8ab
 
14f8ab
 #endif /* !_LG_MESSAGES_H_ */
14f8ab
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
14f8ab
index 172dc61..05f76bf 100644
14f8ab
--- a/libglusterfs/src/graph.c
14f8ab
+++ b/libglusterfs/src/graph.c
14f8ab
@@ -1467,6 +1467,21 @@ out:
14f8ab
 }
14f8ab
 
14f8ab
 int
14f8ab
+glusterfs_svc_mux_pidfile_cleanup(gf_volfile_t *volfile_obj)
14f8ab
+{
14f8ab
+    if (!volfile_obj || !volfile_obj->pidfp)
14f8ab
+        return 0;
14f8ab
+
14f8ab
+    gf_msg_trace("glusterfsd", 0, "pidfile %s cleanup", volfile_obj->vol_id);
14f8ab
+
14f8ab
+    lockf(fileno(volfile_obj->pidfp), F_ULOCK, 0);
14f8ab
+    fclose(volfile_obj->pidfp);
14f8ab
+    volfile_obj->pidfp = NULL;
14f8ab
+
14f8ab
+    return 0;
14f8ab
+}
14f8ab
+
14f8ab
+int
14f8ab
 glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj)
14f8ab
 {
14f8ab
     xlator_t *last_xl = NULL;
14f8ab
@@ -1502,6 +1517,7 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj)
14f8ab
 
14f8ab
         list_del_init(&volfile_obj->volfile_list);
14f8ab
         glusterfs_mux_xlator_unlink(parent_graph->top, xl);
14f8ab
+        glusterfs_svc_mux_pidfile_cleanup(volfile_obj);
14f8ab
         parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph);
14f8ab
         parent_graph->xl_count -= graph->xl_count;
14f8ab
         parent_graph->leaf_count -= graph->leaf_count;
14f8ab
@@ -1531,8 +1547,126 @@ out:
14f8ab
 }
14f8ab
 
14f8ab
 int
14f8ab
+glusterfs_svc_mux_pidfile_setup(gf_volfile_t *volfile_obj, const char *pid_file)
14f8ab
+{
14f8ab
+    int ret = -1;
14f8ab
+    FILE *pidfp = NULL;
14f8ab
+
14f8ab
+    if (!pid_file || !volfile_obj)
14f8ab
+        goto out;
14f8ab
+
14f8ab
+    if (volfile_obj->pidfp) {
14f8ab
+        ret = 0;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+    pidfp = fopen(pid_file, "a+");
14f8ab
+    if (!pidfp) {
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+    volfile_obj->pidfp = pidfp;
14f8ab
+
14f8ab
+    ret = lockf(fileno(pidfp), F_TLOCK, 0);
14f8ab
+    if (ret) {
14f8ab
+        ret = 0;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
+
14f8ab
+int
14f8ab
+glusterfs_svc_mux_pidfile_update(gf_volfile_t *volfile_obj,
14f8ab
+                                 const char *pid_file, pid_t pid)
14f8ab
+{
14f8ab
+    int ret = 0;
14f8ab
+    FILE *pidfp = NULL;
14f8ab
+    int old_pid;
14f8ab
+
14f8ab
+    if (!volfile_obj->pidfp) {
14f8ab
+        ret = glusterfs_svc_mux_pidfile_setup(volfile_obj, pid_file);
14f8ab
+        if (ret == -1)
14f8ab
+            goto out;
14f8ab
+    }
14f8ab
+    pidfp = volfile_obj->pidfp;
14f8ab
+    ret = fscanf(pidfp, "%d", &old_pid);
14f8ab
+    if (ret <= 0) {
14f8ab
+        goto update;
14f8ab
+    }
14f8ab
+    if (old_pid == pid) {
14f8ab
+        ret = 0;
14f8ab
+        goto out;
14f8ab
+    } else {
14f8ab
+        gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED,
14f8ab
+               "Old pid=%d found in pidfile %s. Cleaning the old pid and "
14f8ab
+               "Updating new pid=%d",
14f8ab
+               old_pid, pid_file, pid);
14f8ab
+    }
14f8ab
+update:
14f8ab
+    ret = sys_ftruncate(fileno(pidfp), 0);
14f8ab
+    if (ret) {
14f8ab
+        gf_msg("glusterfsd", GF_LOG_ERROR, errno,
14f8ab
+               LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED,
14f8ab
+               "pidfile %s truncation failed", pid_file);
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    ret = fprintf(pidfp, "%d\n", pid);
14f8ab
+    if (ret <= 0) {
14f8ab
+        gf_msg("glusterfsd", GF_LOG_ERROR, errno,
14f8ab
+               LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, "pidfile %s write failed",
14f8ab
+               pid_file);
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    ret = fflush(pidfp);
14f8ab
+    if (ret) {
14f8ab
+        gf_msg("glusterfsd", GF_LOG_ERROR, errno,
14f8ab
+               LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED, "pidfile %s write failed",
14f8ab
+               pid_file);
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
+
14f8ab
+int
14f8ab
+glusterfs_update_mux_pid(dict_t *dict, gf_volfile_t *volfile_obj)
14f8ab
+{
14f8ab
+    char *file = NULL;
14f8ab
+    int ret = -1;
14f8ab
+
14f8ab
+    GF_VALIDATE_OR_GOTO("graph", dict, out);
14f8ab
+    GF_VALIDATE_OR_GOTO("graph", volfile_obj, out);
14f8ab
+
14f8ab
+    ret = dict_get_str(dict, "pidfile", &file;;
14f8ab
+    if (ret < 0) {
14f8ab
+        gf_msg("mgmt", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED,
14f8ab
+               "Failed to get pidfile from dict for  volfile_id=%s",
14f8ab
+               volfile_obj->vol_id);
14f8ab
+    }
14f8ab
+
14f8ab
+    ret = glusterfs_svc_mux_pidfile_update(volfile_obj, file, getpid());
14f8ab
+    if (ret < 0) {
14f8ab
+        ret = -1;
14f8ab
+        gf_msg("mgmt", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_SETUP_FAILED,
14f8ab
+               "Failed to update "
14f8ab
+               "the pidfile for volfile_id=%s",
14f8ab
+               volfile_obj->vol_id);
14f8ab
+
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    if (ret == 1)
14f8ab
+        gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_ATTACH_PID_FILE_UPDATED,
14f8ab
+               "PID %d updated in pidfile=%s", getpid(), file);
14f8ab
+    ret = 0;
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
+int
14f8ab
 glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
14f8ab
-                                   char *volfile_id, char *checksum)
14f8ab
+                                   char *volfile_id, char *checksum,
14f8ab
+                                   dict_t *dict)
14f8ab
 {
14f8ab
     glusterfs_graph_t *graph = NULL;
14f8ab
     glusterfs_graph_t *parent_graph = NULL;
14f8ab
@@ -1615,18 +1749,25 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
14f8ab
         ret = -1;
14f8ab
         goto out;
14f8ab
     }
14f8ab
+    volfile_obj->pidfp = NULL;
14f8ab
+    snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s",
14f8ab
+             volfile_id);
14f8ab
+
14f8ab
+    if (strcmp(ctx->cmd_args.process_name, "glustershd") == 0) {
14f8ab
+        ret = glusterfs_update_mux_pid(dict, volfile_obj);
14f8ab
+        if (ret == -1) {
14f8ab
+            goto out;
14f8ab
+        }
14f8ab
+    }
14f8ab
 
14f8ab
     graph->used = 1;
14f8ab
     parent_graph->id++;
14f8ab
     list_add(&graph->list, &ctx->graphs);
14f8ab
     INIT_LIST_HEAD(&volfile_obj->volfile_list);
14f8ab
     volfile_obj->graph = graph;
14f8ab
-    snprintf(volfile_obj->vol_id, sizeof(volfile_obj->vol_id), "%s",
14f8ab
-             volfile_id);
14f8ab
     memcpy(volfile_obj->volfile_checksum, checksum,
14f8ab
            sizeof(volfile_obj->volfile_checksum));
14f8ab
     list_add_tail(&volfile_obj->volfile_list, &ctx->volfile_list);
14f8ab
-
14f8ab
     gf_log_dump_graph(fp, graph);
14f8ab
     graph = NULL;
14f8ab
 
14f8ab
@@ -1654,7 +1795,8 @@ out:
14f8ab
 
14f8ab
 int
14f8ab
 glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
14f8ab
-                                  gf_volfile_t *volfile_obj, char *checksum)
14f8ab
+                                  gf_volfile_t *volfile_obj, char *checksum,
14f8ab
+                                  dict_t *dict)
14f8ab
 {
14f8ab
     glusterfs_graph_t *oldvolfile_graph = NULL;
14f8ab
     glusterfs_graph_t *newvolfile_graph = NULL;
14f8ab
@@ -1703,7 +1845,7 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
14f8ab
         }
14f8ab
         volfile_obj = NULL;
14f8ab
         ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id,
14f8ab
-                                                 checksum);
14f8ab
+                                                 checksum, dict);
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
diff --git a/rpc/xdr/src/glusterd1-xdr.x b/rpc/xdr/src/glusterd1-xdr.x
14f8ab
index 9b36d34..02ebec2 100644
14f8ab
--- a/rpc/xdr/src/glusterd1-xdr.x
14f8ab
+++ b/rpc/xdr/src/glusterd1-xdr.x
14f8ab
@@ -132,6 +132,7 @@ struct gd1_mgmt_brick_op_req {
14f8ab
         string  name<>;
14f8ab
         int     op;
14f8ab
         opaque  input<>;
14f8ab
+        opaque  dict<>;
14f8ab
 } ;
14f8ab
 
14f8ab
 struct gd1_mgmt_brick_op_rsp {
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
14f8ab
index af8a8a4..cc1f1df 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
14f8ab
@@ -5423,6 +5423,8 @@ glusterd_print_client_details(FILE *fp, dict_t *dict,
14f8ab
 
14f8ab
     brick_req->op = GLUSTERD_BRICK_STATUS;
14f8ab
     brick_req->name = "";
14f8ab
+    brick_req->dict.dict_val = NULL;
14f8ab
+    brick_req->dict.dict_len = 0;
14f8ab
 
14f8ab
     ret = dict_set_strn(dict, "brick-name", SLEN("brick-name"),
14f8ab
                         brickinfo->path);
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
14f8ab
index 1ba58c3..86dec82 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
14f8ab
@@ -203,7 +203,7 @@ out:
14f8ab
 
14f8ab
 size_t
14f8ab
 build_volfile_path(char *volume_id, char *path, size_t path_len,
14f8ab
-                   char *trusted_str)
14f8ab
+                   char *trusted_str, dict_t *dict)
14f8ab
 {
14f8ab
     struct stat stbuf = {
14f8ab
         0,
14f8ab
@@ -340,11 +340,19 @@ build_volfile_path(char *volume_id, char *path, size_t path_len,
14f8ab
 
14f8ab
         ret = glusterd_volinfo_find(volid_ptr, &volinfo);
14f8ab
         if (ret == -1) {
14f8ab
-            gf_log(this->name, GF_LOG_ERROR, "Couldn't find volinfo");
14f8ab
+            gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL,
14f8ab
+                   "Couldn't find volinfo for volid=%s", volid_ptr);
14f8ab
             goto out;
14f8ab
         }
14f8ab
 
14f8ab
         glusterd_svc_build_shd_volfile_path(volinfo, path, path_len);
14f8ab
+
14f8ab
+        ret = glusterd_svc_set_shd_pidfile(volinfo, dict);
14f8ab
+        if (ret == -1) {
14f8ab
+            gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
14f8ab
+                   "Couldn't set pidfile in dict for volid=%s", volid_ptr);
14f8ab
+            goto out;
14f8ab
+        }
14f8ab
         ret = 0;
14f8ab
         goto out;
14f8ab
     }
14f8ab
@@ -919,6 +927,7 @@ __server_getspec(rpcsvc_request_t *req)
14f8ab
     char addrstr[RPCSVC_PEER_STRLEN] = {0};
14f8ab
     peer_info_t *peerinfo = NULL;
14f8ab
     xlator_t *this = NULL;
14f8ab
+    dict_t *dict = NULL;
14f8ab
 
14f8ab
     this = THIS;
14f8ab
     GF_ASSERT(this);
14f8ab
@@ -971,6 +980,12 @@ __server_getspec(rpcsvc_request_t *req)
14f8ab
         goto fail;
14f8ab
     }
14f8ab
 
14f8ab
+    dict = dict_new();
14f8ab
+    if (!dict) {
14f8ab
+        ret = -ENOMEM;
14f8ab
+        goto fail;
14f8ab
+    }
14f8ab
+
14f8ab
     trans = req->trans;
14f8ab
     /* addrstr will be empty for cli socket connections */
14f8ab
     ret = rpcsvc_transport_peername(trans, (char *)&addrstr, sizeof(addrstr));
14f8ab
@@ -989,12 +1004,26 @@ __server_getspec(rpcsvc_request_t *req)
14f8ab
      */
14f8ab
     if (strlen(addrstr) == 0 || gf_is_local_addr(addrstr)) {
14f8ab
         ret = build_volfile_path(volume, filename, sizeof(filename),
14f8ab
-                                 TRUSTED_PREFIX);
14f8ab
+                                 TRUSTED_PREFIX, dict);
14f8ab
     } else {
14f8ab
-        ret = build_volfile_path(volume, filename, sizeof(filename), NULL);
14f8ab
+        ret = build_volfile_path(volume, filename, sizeof(filename), NULL,
14f8ab
+                                 dict);
14f8ab
     }
14f8ab
 
14f8ab
     if (ret == 0) {
14f8ab
+        if (dict->count > 0) {
14f8ab
+            ret = dict_allocate_and_serialize(dict, &rsp.xdata.xdata_val,
14f8ab
+                                              &rsp.xdata.xdata_len);
14f8ab
+            if (ret) {
14f8ab
+                gf_msg(this->name, GF_LOG_ERROR, 0,
14f8ab
+                       GD_MSG_DICT_SERL_LENGTH_GET_FAIL,
14f8ab
+                       "Failed to serialize dict "
14f8ab
+                       "to request buffer");
14f8ab
+                goto fail;
14f8ab
+            }
14f8ab
+            dict->extra_free = rsp.xdata.xdata_val;
14f8ab
+        }
14f8ab
+
14f8ab
         /* to allocate the proper buffer to hold the file data */
14f8ab
         ret = sys_stat(filename, &stbuf);
14f8ab
         if (ret < 0) {
14f8ab
@@ -1036,7 +1065,6 @@ __server_getspec(rpcsvc_request_t *req)
14f8ab
             goto fail;
14f8ab
         }
14f8ab
     }
14f8ab
-
14f8ab
     /* convert to XDR */
14f8ab
 fail:
14f8ab
     if (spec_fd >= 0)
14f8ab
@@ -1056,6 +1084,10 @@ fail:
14f8ab
                           (xdrproc_t)xdr_gf_getspec_rsp);
14f8ab
     free(args.key);  // malloced by xdr
14f8ab
     free(rsp.spec);
14f8ab
+
14f8ab
+    if (dict)
14f8ab
+        dict_unref(dict);
14f8ab
+
14f8ab
     if (args.xdata.xdata_val)
14f8ab
         free(args.xdata.xdata_val);
14f8ab
 
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
14f8ab
index 9ea695e..454877b 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
14f8ab
@@ -655,6 +655,8 @@ glusterd_brick_op_build_payload(glusterd_op_t op,
14f8ab
             break;
14f8ab
     }
14f8ab
 
14f8ab
+    brick_req->dict.dict_len = 0;
14f8ab
+    brick_req->dict.dict_val = NULL;
14f8ab
     ret = dict_allocate_and_serialize(dict, &brick_req->input.input_val,
14f8ab
                                       &brick_req->input.input_len);
14f8ab
     if (ret)
14f8ab
@@ -723,6 +725,8 @@ glusterd_node_op_build_payload(glusterd_op_t op, gd1_mgmt_brick_op_req **req,
14f8ab
             goto out;
14f8ab
     }
14f8ab
 
14f8ab
+    brick_req->dict.dict_len = 0;
14f8ab
+    brick_req->dict.dict_val = NULL;
14f8ab
     ret = dict_allocate_and_serialize(dict, &brick_req->input.input_val,
14f8ab
                                       &brick_req->input.input_len);
14f8ab
 
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
14f8ab
index 57ceda9..5661e39 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c
14f8ab
@@ -126,3 +126,28 @@ glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd)
14f8ab
 out:
14f8ab
     return;
14f8ab
 }
14f8ab
+
14f8ab
+int
14f8ab
+glusterd_svc_set_shd_pidfile(glusterd_volinfo_t *volinfo, dict_t *dict)
14f8ab
+{
14f8ab
+    int ret = -1;
14f8ab
+    glusterd_svc_t *svc = NULL;
14f8ab
+    xlator_t *this = NULL;
14f8ab
+
14f8ab
+    this = THIS;
14f8ab
+    GF_VALIDATE_OR_GOTO("glusterd", this, out);
14f8ab
+    GF_VALIDATE_OR_GOTO(this->name, volinfo, out);
14f8ab
+    GF_VALIDATE_OR_GOTO(this->name, dict, out);
14f8ab
+
14f8ab
+    svc = &(volinfo->shd.svc);
14f8ab
+
14f8ab
+    ret = dict_set_dynstr_with_alloc(dict, "pidfile", svc->proc.pidfile);
14f8ab
+    if (ret) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
14f8ab
+               "Failed to set pidfile %s in dict", svc->proc.pidfile);
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+    ret = 0;
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
14f8ab
index 59466ec..1f0984b 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.h
14f8ab
@@ -36,4 +36,7 @@ glusterd_recover_shd_attach_failure(glusterd_volinfo_t *volinfo,
14f8ab
 int
14f8ab
 glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo);
14f8ab
 
14f8ab
+int
14f8ab
+glusterd_svc_set_shd_pidfile(glusterd_volinfo_t *volinfo, dict_t *dict);
14f8ab
+
14f8ab
 #endif
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
14f8ab
index 8ad90a9..590169f 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
14f8ab
@@ -258,14 +258,20 @@ glusterd_shdsvc_manager(glusterd_svc_t *svc, void *data, int flags)
14f8ab
     gf_boolean_t shd_restart = _gf_false;
14f8ab
 
14f8ab
     conf = THIS->private;
14f8ab
-    volinfo = data;
14f8ab
     GF_VALIDATE_OR_GOTO("glusterd", conf, out);
14f8ab
     GF_VALIDATE_OR_GOTO("glusterd", svc, out);
14f8ab
+    volinfo = data;
14f8ab
     GF_VALIDATE_OR_GOTO("glusterd", volinfo, out);
14f8ab
 
14f8ab
     if (volinfo)
14f8ab
         glusterd_volinfo_ref(volinfo);
14f8ab
 
14f8ab
+    if (volinfo->is_snap_volume) {
14f8ab
+        /* healing of a snap volume is not supported yet*/
14f8ab
+        ret = 0;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
     while (conf->restart_shd) {
14f8ab
         synclock_unlock(&conf->big_lock);
14f8ab
         sleep(2);
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
14f8ab
index 400826f..e106111 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
14f8ab
@@ -519,7 +519,7 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc)
14f8ab
                 /* Take first entry from the process */
14f8ab
                 parent_svc = cds_list_entry(mux_proc->svcs.next, glusterd_svc_t,
14f8ab
                                             mux_svc);
14f8ab
-                sys_link(parent_svc->proc.pidfile, svc->proc.pidfile);
14f8ab
+                glusterd_copy_file(parent_svc->proc.pidfile, svc->proc.pidfile);
14f8ab
                 mux_conn = &parent_svc->conn;
14f8ab
                 if (volinfo)
14f8ab
                     volinfo->shd.attached = _gf_true;
14f8ab
@@ -623,12 +623,9 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count,
14f8ab
     glusterd_volinfo_t *volinfo = NULL;
14f8ab
     glusterd_shdsvc_t *shd = NULL;
14f8ab
     glusterd_svc_t *svc = frame->cookie;
14f8ab
-    glusterd_svc_t *parent_svc = NULL;
14f8ab
-    glusterd_svc_proc_t *mux_proc = NULL;
14f8ab
     glusterd_conf_t *conf = NULL;
14f8ab
     int *flag = (int *)frame->local;
14f8ab
     xlator_t *this = THIS;
14f8ab
-    int pid = -1;
14f8ab
     int ret = -1;
14f8ab
     gf_getspec_rsp rsp = {
14f8ab
         0,
14f8ab
@@ -679,27 +676,7 @@ glusterd_svc_attach_cbk(struct rpc_req *req, struct iovec *iov, int count,
14f8ab
     }
14f8ab
 
14f8ab
     if (rsp.op_ret == 0) {
14f8ab
-        pthread_mutex_lock(&conf->attach_lock);
14f8ab
-        {
14f8ab
-            if (!strcmp(svc->name, "glustershd")) {
14f8ab
-                mux_proc = svc->svc_proc;
14f8ab
-                if (mux_proc &&
14f8ab
-                    !gf_is_service_running(svc->proc.pidfile, &pid)) {
14f8ab
-                    /*
14f8ab
-                     * When svc's are restarting, there is a chance that the
14f8ab
-                     * attached svc might not have updated it's pid. Because
14f8ab
-                     * it was at connection stage. So in that case, we need
14f8ab
-                     * to retry the pid file copy.
14f8ab
-                     */
14f8ab
-                    parent_svc = cds_list_entry(mux_proc->svcs.next,
14f8ab
-                                                glusterd_svc_t, mux_svc);
14f8ab
-                    if (parent_svc)
14f8ab
-                        sys_link(parent_svc->proc.pidfile, svc->proc.pidfile);
14f8ab
-                }
14f8ab
-            }
14f8ab
-            svc->online = _gf_true;
14f8ab
-        }
14f8ab
-        pthread_mutex_unlock(&conf->attach_lock);
14f8ab
+        svc->online = _gf_true;
14f8ab
         gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_SVC_ATTACH_FAIL,
14f8ab
                "svc %s of volume %s attached successfully to pid %d", svc->name,
14f8ab
                volinfo->volname, glusterd_proc_get_pid(&svc->proc));
14f8ab
@@ -726,7 +703,7 @@ out:
14f8ab
 
14f8ab
 extern size_t
14f8ab
 build_volfile_path(char *volume_id, char *path, size_t path_len,
14f8ab
-                   char *trusted_str);
14f8ab
+                   char *trusted_str, dict_t *dict);
14f8ab
 
14f8ab
 int
14f8ab
 __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags,
14f8ab
@@ -751,6 +728,7 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags,
14f8ab
     ssize_t req_size = 0;
14f8ab
     call_frame_t *frame = NULL;
14f8ab
     gd1_mgmt_brick_op_req brick_req;
14f8ab
+    dict_t *dict = NULL;
14f8ab
     void *req = &brick_req;
14f8ab
     void *errlbl = &&err;
14f8ab
     struct rpc_clnt_connection *conn;
14f8ab
@@ -776,6 +754,8 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags,
14f8ab
     brick_req.name = volfile_id;
14f8ab
     brick_req.input.input_val = NULL;
14f8ab
     brick_req.input.input_len = 0;
14f8ab
+    brick_req.dict.dict_val = NULL;
14f8ab
+    brick_req.dict.dict_len = 0;
14f8ab
 
14f8ab
     frame = create_frame(this, this->ctx->pool);
14f8ab
     if (!frame) {
14f8ab
@@ -783,7 +763,13 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags,
14f8ab
     }
14f8ab
 
14f8ab
     if (op == GLUSTERD_SVC_ATTACH) {
14f8ab
-        (void)build_volfile_path(volfile_id, path, sizeof(path), NULL);
14f8ab
+        dict = dict_new();
14f8ab
+        if (!dict) {
14f8ab
+            ret = -ENOMEM;
14f8ab
+            goto *errlbl;
14f8ab
+        }
14f8ab
+
14f8ab
+        (void)build_volfile_path(volfile_id, path, sizeof(path), NULL, dict);
14f8ab
 
14f8ab
         ret = sys_stat(path, &stbuf);
14f8ab
         if (ret < 0) {
14f8ab
@@ -818,6 +804,18 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags,
14f8ab
             ret = -EIO;
14f8ab
             goto *errlbl;
14f8ab
         }
14f8ab
+        if (dict->count > 0) {
14f8ab
+            ret = dict_allocate_and_serialize(dict, &brick_req.dict.dict_val,
14f8ab
+                                              &brick_req.dict.dict_len);
14f8ab
+            if (ret) {
14f8ab
+                gf_msg(this->name, GF_LOG_ERROR, 0,
14f8ab
+                       GD_MSG_DICT_SERL_LENGTH_GET_FAIL,
14f8ab
+                       "Failed to serialize dict "
14f8ab
+                       "to request buffer");
14f8ab
+                goto *errlbl;
14f8ab
+            }
14f8ab
+            dict->extra_free = brick_req.dict.dict_val;
14f8ab
+        }
14f8ab
 
14f8ab
         frame->cookie = svc;
14f8ab
         frame->local = GF_CALLOC(1, sizeof(int), gf_gld_mt_int);
14f8ab
@@ -862,6 +860,8 @@ __glusterd_send_svc_configure_req(glusterd_svc_t *svc, int flags,
14f8ab
     GF_ATOMIC_INC(conf->blockers);
14f8ab
     ret = rpc_clnt_submit(rpc, &gd_brick_prog, op, cbkfn, &iov, 1, NULL, 0,
14f8ab
                           iobref, frame, NULL, 0, NULL, 0, NULL);
14f8ab
+    if (dict)
14f8ab
+        dict_unref(dict);
14f8ab
     GF_FREE(volfile_content);
14f8ab
     if (spec_fd >= 0)
14f8ab
         sys_close(spec_fd);
14f8ab
@@ -874,6 +874,9 @@ maybe_free_iobuf:
14f8ab
         iobuf_unref(iobuf);
14f8ab
     }
14f8ab
 err:
14f8ab
+    if (dict)
14f8ab
+        dict_unref(dict);
14f8ab
+
14f8ab
     GF_FREE(volfile_content);
14f8ab
     if (spec_fd >= 0)
14f8ab
         sys_close(spec_fd);
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
14f8ab
index 618d8bc..a8098df 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
14f8ab
@@ -143,6 +143,8 @@ gd_brick_op_req_free(gd1_mgmt_brick_op_req *req)
14f8ab
     if (!req)
14f8ab
         return;
14f8ab
 
14f8ab
+    if (req->dict.dict_val)
14f8ab
+        GF_FREE(req->dict.dict_val);
14f8ab
     GF_FREE(req->input.input_val);
14f8ab
     GF_FREE(req);
14f8ab
 }
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
14f8ab
index 4c487d0..2eb5116 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
14f8ab
@@ -5914,6 +5914,8 @@ send_attach_req(xlator_t *this, struct rpc_clnt *rpc, char *path,
14f8ab
     brick_req.name = path;
14f8ab
     brick_req.input.input_val = NULL;
14f8ab
     brick_req.input.input_len = 0;
14f8ab
+    brick_req.dict.dict_val = NULL;
14f8ab
+    brick_req.dict.dict_len = 0;
14f8ab
 
14f8ab
     req_size = xdr_sizeof((xdrproc_t)xdr_gd1_mgmt_brick_op_req, req);
14f8ab
     iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size);
14f8ab
@@ -5977,7 +5979,7 @@ err:
14f8ab
 
14f8ab
 extern size_t
14f8ab
 build_volfile_path(char *volume_id, char *path, size_t path_len,
14f8ab
-                   char *trusted_str);
14f8ab
+                   char *trusted_str, dict_t *dict);
14f8ab
 
14f8ab
 static int
14f8ab
 attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo,
14f8ab
@@ -6022,7 +6024,7 @@ attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo,
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
-    (void)build_volfile_path(full_id, path, sizeof(path), NULL);
14f8ab
+    (void)build_volfile_path(full_id, path, sizeof(path), NULL, NULL);
14f8ab
 
14f8ab
     for (tries = 15; tries > 0; --tries) {
14f8ab
         rpc = rpc_clnt_ref(other_brick->rpc);
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab