diff options
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 41 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.h | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 33 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 23 |
5 files changed, 26 insertions, 90 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 920bafa5b05..402e4d51189 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -504,12 +504,10 @@ glusterd_req_ctx_create (rpcsvc_request_t *rpc_req, gf_gld_mem_types_t mem_type, glusterd_req_ctx_t **req_ctx_out) { - int ret = -1; - glusterd_req_ctx_t *req_ctx = NULL; - char str[50] = {0,}; - dict_t *dict = NULL; - char volname[GLUSTERD_MAX_VOLUME_NAME] = {0}; - char *dup_volname = NULL; + int ret = -1; + char str[50] = {0,}; + glusterd_req_ctx_t *req_ctx = NULL; + dict_t *dict = NULL; uuid_unparse (uuid, str); gf_log ("glusterd", GF_LOG_INFO, @@ -518,40 +516,23 @@ glusterd_req_ctx_create (rpcsvc_request_t *rpc_req, dict = dict_new (); if (!dict) goto out; - req_ctx = GF_CALLOC (1, sizeof (*req_ctx), mem_type); + req_ctx = GF_CALLOC (1, sizeof (*req_ctx), mem_type); if (!req_ctx) { goto out; } uuid_copy (req_ctx->uuid, uuid); req_ctx->op = op; - if (GD_OP_DELETE_VOLUME == op) { - strncpy (volname, buf_val, buf_len); - dup_volname = gf_strdup (volname); - if (dup_volname) { - ret = dict_set_dynstr (dict, "volname", dup_volname); - if (ret) { - gf_log ("", GF_LOG_WARNING, - "failed to set volume name from payload"); - goto out; - } - } else { - ret = -1; - goto out; - } - } else { - ret = dict_unserialize (buf_val, buf_len, &dict); - - if (ret) { - gf_log ("", GF_LOG_WARNING, - "failed to unserialize the dictionary"); - goto out; - } + ret = dict_unserialize (buf_val, buf_len, &dict); + if (ret) { + gf_log ("", GF_LOG_WARNING, + "failed to unserialize the dictionary"); + goto out; } req_ctx->dict = dict; - req_ctx->req = rpc_req; + req_ctx->req = rpc_req; *req_ctx_out = req_ctx; ret = 0; out: diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index f933bbc37f7..61f3b70a3eb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1497,15 +1497,6 @@ glusterd_op_build_payload (dict_t **req) break; case GD_OP_DELETE_VOLUME: - { - glusterd_op_delete_volume_ctx_t *ctx1 = ctx; - ret = dict_set_str (req_dict, "volname", - ctx1->volume_name); - if (ret) - goto out; - } - break; - case GD_OP_START_VOLUME: case GD_OP_STOP_VOLUME: case GD_OP_ADD_BRICK: @@ -3469,6 +3460,7 @@ glusterd_op_free_ctx (glusterd_op_t op, void *ctx) if (ctx) { switch (op) { case GD_OP_CREATE_VOLUME: + case GD_OP_DELETE_VOLUME: case GD_OP_STOP_VOLUME: case GD_OP_ADD_BRICK: case GD_OP_REMOVE_BRICK: @@ -3489,9 +3481,6 @@ glusterd_op_free_ctx (glusterd_op_t op, void *ctx) case GD_OP_STATEDUMP_VOLUME: dict_unref (ctx); break; - case GD_OP_DELETE_VOLUME: - GF_FREE (ctx); - break; default: GF_ASSERT (0); break; diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h index 31551ca430f..e658e6ece79 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h @@ -118,12 +118,6 @@ struct glusterd_op_info_ { typedef struct glusterd_op_info_ glusterd_op_info_t; -struct glusterd_op_delete_volume_ctx_ { - char volume_name[GD_VOLUME_NAME_MAX]; -}; - -typedef struct glusterd_op_delete_volume_ctx_ glusterd_op_delete_volume_ctx_t; - struct glusterd_op_log_filename_ctx_ { char volume_name[GD_VOLUME_NAME_MAX]; char brick[GD_VOLUME_NAME_MAX]; diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index f6b0908ae9b..d6ec18a3db3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -1541,19 +1541,11 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this, glusterd_get_uuid (&req.uuid); req.op = glusterd_op_get_op (); - if (GD_OP_DELETE_VOLUME == req.op) { - ret = dict_get_str (dict, "volname", &req.buf.buf_val); - if (ret) - goto out; - req.buf.buf_len = strlen (req.buf.buf_val); - is_alloc = _gf_false; - } else { - ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); + ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, + (size_t *)&req.buf.buf_len); + if (ret) + goto out; - if (ret) - goto out; - } dummy_frame = create_frame (this, this->ctx->pool); if (!dummy_frame) @@ -1603,19 +1595,10 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this, glusterd_get_uuid (&req.uuid); req.op = glusterd_op_get_op (); - if (GD_OP_DELETE_VOLUME == req.op) { - ret = dict_get_str (dict, "volname", &req.buf.buf_val); - if (ret) - goto out; - req.buf.buf_len = strlen (req.buf.buf_val); - is_alloc = _gf_false; - } else { - ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); - - if (ret) - goto out; - } + ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, + (size_t *)&req.buf.buf_len); + if (ret) + goto out; dummy_frame = create_frame (this, this->ctx->pool); if (!dummy_frame) diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 6c3da47ea24..33b9c7f3e26 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -358,12 +358,11 @@ out: int glusterd_handle_cli_delete_volume (rpcsvc_request_t *req) { - int32_t ret = -1; - gf_cli_req cli_req = {{0,}}; - glusterd_op_delete_volume_ctx_t *ctx = NULL; - glusterd_op_t cli_op = GD_OP_DELETE_VOLUME; - char *volname = NULL; - dict_t *dict = NULL; + int32_t ret = -1; + gf_cli_req cli_req = {{0,},}; + glusterd_op_t cli_op = GD_OP_DELETE_VOLUME; + dict_t *dict = NULL; + char *volname = NULL; GF_ASSERT (req); @@ -402,14 +401,7 @@ glusterd_handle_cli_delete_volume (rpcsvc_request_t *req) gf_log ("glusterd", GF_LOG_INFO, "Received delete vol req" "for volume %s", volname); - - ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_delete_volume_ctx_t); - if (!ctx) - goto out; - - strncpy (ctx->volume_name, volname, GD_VOLUME_NAME_MAX); - - ret = glusterd_op_begin (req, GD_OP_DELETE_VOLUME, ctx); + ret = glusterd_op_begin (req, GD_OP_DELETE_VOLUME, dict); gf_cmd_log ("Volume delete", "on volname: %s %s", volname, ((ret) ? "FAILED" : "SUCCESS")); @@ -423,9 +415,6 @@ out: glusterd_op_sm (); if (ret) { - if (ctx) - GF_FREE (ctx); - ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, NULL, "operation failed"); } |