From 96968a916336f70bfc77a353c6b31d4dedd91167 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Tue, 4 Mar 2014 02:08:51 +0000 Subject: glusterd/mgmt_v3 locks: Using snaps as an entity for mgmt_v3 locks. Created framework to process single volume lock, single snap lock, multiple volume locks, multiple snap locks, and multiple snap and volume locks requests. Change-Id: I3f87bdec0bf142d6a1fd3f9d9f5012cc44eaf4bd Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/7189 Reviewed-by: Rajesh Joseph Tested-by: Rajesh Joseph --- xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c | 74 +++++++---------------- 1 file changed, 23 insertions(+), 51 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c index 5077a0092..27d40b3a7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c @@ -30,9 +30,12 @@ static int glusterd_mgmt_v3_lock_send_resp (rpcsvc_request_t *req, int32_t status) { - gd1_mgmt_v3_lock_rsp rsp = {{0},}; - int ret = -1; + gd1_mgmt_v3_lock_rsp rsp = {{0},}; + int ret = -1; + xlator_t *this = NULL; + this = THIS; + GF_ASSERT (this); GF_ASSERT (req); rsp.op_ret = status; @@ -44,7 +47,7 @@ glusterd_mgmt_v3_lock_send_resp (rpcsvc_request_t *req, int32_t status) ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gd1_mgmt_v3_lock_rsp); - gf_log (THIS->name, GF_LOG_DEBUG, + gf_log (this->name, GF_LOG_DEBUG, "Responded to mgmt_v3 lock, ret: %d", ret); return ret; @@ -56,9 +59,7 @@ glusterd_synctasked_mgmt_v3_lock (rpcsvc_request_t *req, glusterd_op_lock_ctx_t *ctx) { int32_t ret = -1; - int32_t volcount = -1; xlator_t *this = NULL; - char *volname = NULL; this = THIS; GF_ASSERT (this); @@ -66,29 +67,13 @@ glusterd_synctasked_mgmt_v3_lock (rpcsvc_request_t *req, GF_ASSERT (ctx); GF_ASSERT (ctx->dict); - ret = dict_get_int32 (ctx->dict, "volcount", &volcount); - if (ret) { - ret = dict_get_str (ctx->dict, "volname", &volname); - if (ret) { - gf_log ("", GF_LOG_ERROR, - "Failed to get volname"); - goto out; - } - ret = glusterd_mgmt_v3_lock (volname, ctx->uuid, "vol"); - - if (ret) - gf_log (this->name, GF_LOG_ERROR, - "Unable to acquire local lock for %s", volname); - } else { - /* Trying to acquire multiple mgmt_v3 locks */ - ret = glusterd_multiple_mgmt_v3_lock (ctx->dict, ctx->uuid); - if (ret) - gf_log ("", GF_LOG_ERROR, - "Failed to acquire mgmt_v3 locks for %s", - uuid_utoa (ctx->uuid)); - } + /* Trying to acquire multiple mgmt_v3 locks */ + ret = glusterd_multiple_mgmt_v3_lock (ctx->dict, ctx->uuid); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to acquire mgmt_v3 locks for %s", + uuid_utoa (ctx->uuid)); -out: ret = glusterd_mgmt_v3_lock_send_resp (req, ret); gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); @@ -712,9 +697,12 @@ static int glusterd_mgmt_v3_unlock_send_resp (rpcsvc_request_t *req, int32_t status) { - gd1_mgmt_v3_unlock_rsp rsp = {{0},}; - int ret = -1; + gd1_mgmt_v3_unlock_rsp rsp = {{0},}; + int ret = -1; + xlator_t *this = NULL; + this = THIS; + GF_ASSERT (this); GF_ASSERT (req); rsp.op_ret = status; @@ -726,7 +714,7 @@ glusterd_mgmt_v3_unlock_send_resp (rpcsvc_request_t *req, int32_t status) ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gd1_mgmt_v3_unlock_rsp); - gf_log (THIS->name, GF_LOG_DEBUG, + gf_log (this->name, GF_LOG_DEBUG, "Responded to mgmt_v3 unlock, ret: %d", ret); return ret; @@ -738,37 +726,21 @@ glusterd_synctasked_mgmt_v3_unlock (rpcsvc_request_t *req, glusterd_op_lock_ctx_t *ctx) { int32_t ret = -1; - int32_t volcount = -1; xlator_t *this = NULL; - char *volname = NULL; this = THIS; GF_ASSERT (this); GF_ASSERT (req); GF_ASSERT (ctx); - ret = dict_get_int32 (ctx->dict, "volcount", &volcount); + /* Trying to release multiple mgmt_v3 locks */ + ret = glusterd_multiple_mgmt_v3_unlock (ctx->dict, ctx->uuid); if (ret) { - ret = dict_get_str (ctx->dict, "volname", &volname); - if (ret) { - gf_log ("", GF_LOG_ERROR, - "Failed to get volname"); - goto out; - } - ret = glusterd_mgmt_v3_unlock (volname, ctx->uuid, "vol"); - if (ret) - gf_log (this->name, GF_LOG_ERROR, - "Unable to release lock for %s", volname); - } else { - /* Trying to release multiple mgmt_v3 locks */ - ret = glusterd_multiple_mgmt_v3_unlock (ctx->dict, ctx->uuid); - if (ret) - gf_log ("", GF_LOG_ERROR, - "Failed to release mgmt_v3 locks for %s", - uuid_utoa(ctx->uuid)); + gf_log (this->name, GF_LOG_ERROR, + "Failed to release mgmt_v3 locks for %s", + uuid_utoa(ctx->uuid)); } -out: ret = glusterd_mgmt_v3_unlock_send_resp (req, ret); gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); -- cgit