From 7ef59472f10a69c90d94b73e97bca385c6b4b29e Mon Sep 17 00:00:00 2001 From: Pranith K Date: Mon, 7 Mar 2011 07:23:51 +0000 Subject: mgmt/glusterd: preserve delete volume payload structure for backward compatibility Signed-off-by: Pranith Kumar K Signed-off-by: Anand V. Avati BUG: 2494 ([glusterfs-3.1.3qa4]: replace brick and delete volume fails) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2494 --- xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 42 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-rpc-ops.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index fe97183c4..e7134c990 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -1298,6 +1298,7 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this, glusterd_conf_t *priv = NULL; call_frame_t *dummy_frame = NULL; dict_t *dict = NULL; + gf_boolean_t is_alloc = _gf_true; if (!this) { goto out; @@ -1315,15 +1316,23 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this, //peerinfo should not be in payload dict_del (dict, "peerinfo"); - ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); - - if (ret) - goto out; - 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; + } + dummy_frame = create_frame (this, this->ctx->pool); if (!dummy_frame) goto out; @@ -1335,7 +1344,7 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this, this, glusterd3_1_stage_op_cbk); out: - if (req.buf.buf_val) + if ((_gf_true == is_alloc) && req.buf.buf_val) GF_FREE (req.buf.buf_val); gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); @@ -1352,6 +1361,7 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this, glusterd_conf_t *priv = NULL; call_frame_t *dummy_frame = NULL; dict_t *dict = NULL; + gf_boolean_t is_alloc = _gf_true; if (!this) { goto out; @@ -1371,11 +1381,19 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this, glusterd_get_uuid (&req.uuid); req.op = glusterd_op_get_op (); - ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); + 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; + if (ret) + goto out; + } dummy_frame = create_frame (this, this->ctx->pool); if (!dummy_frame) @@ -1388,7 +1406,7 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this, this, glusterd3_1_commit_op_cbk); out: - if (req.buf.buf_val) + if ((_gf_true == is_alloc) && req.buf.buf_val) GF_FREE (req.buf.buf_val); gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret); -- cgit