summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShishir Gowda <sgowda@redhat.com>2013-11-05 20:24:05 -0800
committerGerrit Code Review <review@dev.gluster.org>2013-11-05 20:24:05 -0800
commitdac1a4cfcd117a18ceefd0bb1d5c6a5f35689329 (patch)
tree9d92f8dab7e87f566e4eb49633ede392d7f0f913
parenta4b38dedec09370e955fd01fe11367a42abf35f2 (diff)
parentecdc539754d4b3a5ed5a898f4b4a3387fef6dd9f (diff)
Merge "glusterd/Jarvis: Added aggr rsp dict in jarvis framework" into snap_devel
-rw-r--r--cli/src/cli-rpc-ops.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-jarvis.c48
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c82
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h2
7 files changed, 154 insertions, 12 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index de846974f..c6ed33592 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7861,11 +7861,12 @@ gf_cli_snapshot_cbk (struct rpc_req *req, struct iovec *iov,
ret = -1;
goto out;
}
- cli_out ("Max snapshot count set for %s is %"PRIu64,
+ cli_out ("snapshot config: snap-max-limit for "
+ "%s set to %"PRIu64,
volname, limit);
} else {
- cli_out ("Snapshot config max set for %s successfull",
- volname);
+ cli_out ("snapshot config: snap-max-limit "
+ "for %s set successfully", volname);
}
break;
@@ -7902,7 +7903,7 @@ gf_cli_snapshot (call_frame_t *frame, xlator_t *this,
GLUSTER_CLI_SNAP, this, cli_rpc_prog,
NULL);
out:
- gf_log ("cli", GF_LOG_ERROR, "Returning %d", ret);
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
GF_FREE (req.dict.dict_val);
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-jarvis.c b/xlators/mgmt/glusterd/src/glusterd-jarvis.c
index 57512636d..f3b21dd2a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-jarvis.c
+++ b/xlators/mgmt/glusterd/src/glusterd-jarvis.c
@@ -351,6 +351,7 @@ glusterd_jarvis_initiate_lockdown (glusterd_conf_t *conf, glusterd_op_t op,
}
/* Sending Volume lock req to other nodes in the cluster */
+ gd_syncargs_init (&args, NULL);
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
@@ -527,6 +528,7 @@ glusterd_jarvis_pre_validate (glusterd_conf_t *conf, glusterd_op_t op,
}
/* Sending Pre Validation req to other nodes in the cluster */
+ gd_syncargs_init (&args, NULL);
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
@@ -726,6 +728,7 @@ glusterd_jarvis_brick_op (glusterd_conf_t *conf, glusterd_op_t op,
}
/* Sending brick op req to other nodes in the cluster */
+ gd_syncargs_init (&args, NULL);
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
@@ -762,6 +765,7 @@ gd_jarvis_mgmt_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
call_frame_t *frame = NULL;
int op_ret = -1;
int op_errno = -1;
+ dict_t *rsp_dict = NULL;
GF_ASSERT(req);
GF_ASSERT(iov);
@@ -783,7 +787,32 @@ gd_jarvis_mgmt_commit_cbk_fn (struct rpc_req *req, struct iovec *iov,
if (ret < 0)
goto out;
+ if (rsp.dict.dict_len) {
+ /* Unserialize the dictionary */
+ rsp_dict = dict_new ();
+
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
+ &rsp_dict);
+ if (ret < 0) {
+ GF_FREE (rsp.dict.dict_val);
+ goto out;
+ } else {
+ rsp_dict->extra_stdfree = rsp.dict.dict_val;
+ }
+ }
+
uuid_copy (args->uuid, rsp.uuid);
+ pthread_mutex_lock (&args->lock_dict);
+ {
+ ret = glusterd_syncop_aggr_rsp_dict (rsp.op, args->dict,
+ rsp_dict);
+ if (ret)
+ gf_log ("", GF_LOG_ERROR, "%s",
+ "Failed to aggregate response from "
+ " node/brick");
+ }
+ pthread_mutex_unlock (&args->lock_dict);
op_ret = rsp.op_ret;
op_errno = rsp.op_errno;
@@ -840,7 +869,8 @@ out:
int
glusterd_jarvis_commit (glusterd_conf_t *conf, glusterd_op_t op,
- dict_t *req_dict, char **op_errstr, int npeers)
+ dict_t *op_ctx, dict_t *req_dict,
+ char **op_errstr, int npeers)
{
int ret = -1;
int peer_cnt = 0;
@@ -883,6 +913,15 @@ glusterd_jarvis_commit (glusterd_conf_t *conf, glusterd_op_t op,
goto out;
}
+ ret = glusterd_syncop_aggr_rsp_dict (op, op_ctx,
+ rsp_dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "%s",
+ "Failed to aggregate response from "
+ " node/brick");
+ goto out;
+ }
+
dict_unref (rsp_dict);
rsp_dict = NULL;
@@ -892,6 +931,7 @@ glusterd_jarvis_commit (glusterd_conf_t *conf, glusterd_op_t op,
}
/* Sending commit req to other nodes in the cluster */
+ gd_syncargs_init (&args, op_ctx);
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
@@ -1058,6 +1098,7 @@ glusterd_jarvis_post_validate (glusterd_conf_t *conf, glusterd_op_t op,
}
/* Sending Post Validation req to other nodes in the cluster */
+ gd_syncargs_init (&args, NULL);
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
@@ -1197,6 +1238,7 @@ glusterd_jarvis_release_peer_locks (glusterd_conf_t *conf, glusterd_op_t op,
}
/* Sending Volume unlock req to other nodes in the cluster */
+ gd_syncargs_init (&args, NULL);
synctask_barrier_init((&args));
peer_cnt = 0;
list_for_each_entry (peerinfo, peers, op_peers_list) {
@@ -1303,7 +1345,7 @@ glusterd_jarvis_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op,
}
/* COMMIT OP PHASE */
- ret = glusterd_jarvis_commit (conf, op, req_dict,
+ ret = glusterd_jarvis_commit (conf, op, dict, req_dict,
&op_errstr, npeers);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Commit Op Failed");
@@ -1453,7 +1495,7 @@ glusterd_jarvis_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
}
/* COMMIT OP PHASE */
- ret = glusterd_jarvis_commit (conf, op, req_dict,
+ ret = glusterd_jarvis_commit (conf, op, dict, req_dict,
&op_errstr, npeers);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Commit Op Failed");
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index c9512d142..b3d077a43 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -408,6 +408,7 @@ glusterd_snapshot_config_limit_prevalidate (dict_t *dict, char **op_errstr,
GF_ASSERT (this);
GF_ASSERT (dict);
+ GF_ASSERT (op_errstr);
conf = this->private;
@@ -3025,6 +3026,7 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
GF_ASSERT (this);
GF_ASSERT (dict);
GF_ASSERT (rsp_dict);
+ GF_ASSERT (op_errstr);
conf = this->private;
@@ -3146,6 +3148,7 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
" volume name");
goto out;
}
+
ret = dict_set_int32 (dict, "config-command", config_command);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
@@ -3153,8 +3156,10 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
goto out;
}
out:
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
+
int32_t
glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
{
@@ -3207,11 +3212,9 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
break;
}
-
-
ret = 0;
-
out:
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index b1cbbdb65..5cef8ab5b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -122,7 +122,7 @@ gd_collate_errors (struct syncargs *args, int op_ret, int op_errno,
return;
}
-static void
+void
gd_syncargs_init (struct syncargs *args, dict_t *op_ctx)
{
args->dict = op_ctx;
@@ -225,7 +225,7 @@ out:
extern struct rpc_clnt_program gd_mgmt_prog;
extern struct rpc_clnt_program gd_brick_prog;
-static int
+int
glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
{
int ret = 0;
@@ -292,6 +292,12 @@ glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp)
goto out;
break;
+ case GD_OP_SNAP:
+ ret = glusterd_snap_use_rsp_dict (aggr, rsp);
+ if (ret)
+ goto out;
+ break;
+
default:
break;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.h b/xlators/mgmt/glusterd/src/glusterd-syncop.h
index 35215a78a..e83ea2f4c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.h
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.h
@@ -62,4 +62,10 @@ gd_build_peers_list (struct list_head *peers, struct list_head *xact_peers,
int
gd_brick_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
char **op_errstr);
+
+int
+glusterd_syncop_aggr_rsp_dict (glusterd_op_t op, dict_t *aggr, dict_t *rsp);
+
+void
+gd_syncargs_init (struct syncargs *args, dict_t *op_ctx);
#endif /* __RPC_SYNCOP_H */
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index cc504d5d4..0f50a39b9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -7370,6 +7370,88 @@ out:
}
int
+glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
+{
+ int ret = -1;
+ uint64_t limit = 0;
+ int config_command = 0;
+
+ if (!dst || !src) {
+ gf_log ("", GF_LOG_ERROR, "Source or Destination "
+ "dict is empty.");
+ goto out;
+ }
+
+ ret = dict_get_int32 (dst, "config-command", &config_command);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "failed to get config-command type");
+ goto out;
+ }
+
+ switch (config_command) {
+ case GF_SNAP_CONFIG_DISPLAY:
+ ret = dict_get_uint64 (src, "limit", &limit);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to fetch limit");
+ goto out;
+ }
+
+ ret = dict_set_uint64 (dst, "limit", limit);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to set limit");
+ goto out;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ ret = 0;
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
+int
+glusterd_snap_use_rsp_dict (dict_t *dst, dict_t *src)
+{
+ int ret = -1;
+ int32_t snap_command = 0;
+
+ if (!dst || !src) {
+ gf_log ("", GF_LOG_ERROR, "Source or Destination "
+ "dict is empty.");
+ goto out;
+ }
+
+ ret = dict_get_int32 (dst, "type", &snap_command);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "unable to get the type of "
+ "the snapshot command");
+ goto out;
+ }
+
+ switch (snap_command) {
+ case GF_SNAP_OPTION_TYPE_CONFIG:
+ ret = glusterd_snap_config_use_rsp_dict (dst, src);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to use rsp dict");
+ goto out;
+ }
+ break;
+ default:
+ break;
+ }
+
+ ret = 0;
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
+int
glusterd_sys_exec_output_rsp_dict (dict_t *dst, dict_t *src)
{
char output_name[PATH_MAX] = "";
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 306ad736f..5047f6fda 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -493,6 +493,8 @@ int
glusterd_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
int
glusterd_sys_exec_output_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
+int
+glusterd_snap_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict);
int32_t
glusterd_handle_node_rsp (dict_t *req_ctx, void *pending_entry,
glusterd_op_t op, dict_t *rsp_dict, dict_t *op_ctx,