summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
index 0a4f2b519..63bbc6687 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
@@ -56,6 +56,7 @@ glusterd_syctasked_volume_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;
@@ -63,20 +64,30 @@ glusterd_syctasked_volume_lock (rpcsvc_request_t *req,
GF_ASSERT (this);
GF_ASSERT (req);
- ret = dict_get_str (ctx->dict, "volname", &volname);
- if (ret)
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to acquire volname");
- else {
- ret = glusterd_volume_lock (volname, lock_req->uuid);
+ 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_volume_lock (volname, MY_UUID);
+
if (ret)
gf_log (this->name, GF_LOG_ERROR,
- "Unable to acquire lock for %s",
- volname);
-
- glusterd_mgmt_v3_vol_lock_send_resp (req, ret);
+ "Unable to acquire local lock for %s", volname);
+ } else {
+ /* Trying to acquire volume locks on multiple volumes */
+ ret = glusterd_multiple_volumes_lock (ctx->dict, MY_UUID);
+ if (ret)
+ gf_log ("", GF_LOG_ERROR,
+ "Failed to acquire volume locks on localhost");
}
+out:
+ glusterd_mgmt_v3_vol_lock_send_resp (req, ret);
+
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -176,7 +187,7 @@ glusterd_handle_volume_lock_fn (rpcsvc_request_t *req)
goto out;
}
- is_synctasked = dict_get_str_boolean (ctx->dict, "force", _gf_false);
+ is_synctasked = dict_get_str_boolean (ctx->dict, "is_synctasked", _gf_false);
if (is_synctasked)
ret = glusterd_syctasked_volume_lock (req, &lock_req, ctx);
else
@@ -721,6 +732,7 @@ glusterd_syctasked_volume_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;
@@ -729,20 +741,29 @@ glusterd_syctasked_volume_unlock (rpcsvc_request_t *req,
GF_ASSERT (req);
GF_ASSERT (ctx);
- ret = dict_get_str (ctx->dict, "volname", &volname);
- if (ret)
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to acquire volname");
- else {
- ret = glusterd_volume_unlock (volname, unlock_req->uuid);
+ 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_volume_unlock (volname, MY_UUID);
if (ret)
gf_log (this->name, GF_LOG_ERROR,
- "Unable to release lock for %s",
- volname);
-
- glusterd_mgmt_v3_vol_unlock_send_resp (req, ret);
+ "Unable to acquire local lock for %s", volname);
+ } else {
+ /* Trying to release volume locks on multiple volumes */
+ ret = glusterd_multiple_volumes_unlock (ctx->dict, MY_UUID);
+ if (ret)
+ gf_log ("", GF_LOG_ERROR,
+ "Failed to release volume locks on localhost");
}
+out:
+ glusterd_mgmt_v3_vol_unlock_send_resp (req, ret);
+
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -830,7 +851,7 @@ glusterd_handle_volume_unlock_fn (rpcsvc_request_t *req)
goto out;
}
- is_synctasked = dict_get_str_boolean (ctx->dict, "force", _gf_false);
+ is_synctasked = dict_get_str_boolean (ctx->dict, "is_synctasked", _gf_false);
if (is_synctasked)
ret = glusterd_syctasked_volume_unlock (req, &lock_req, ctx);
else