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