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