summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-12-26 05:38:44 +0000
committerAvra Sengupta <asengupt@redhat.com>2014-01-09 01:00:31 +0000
commitade2e39f33c833dcf9811f46fca4c6f443b0f09b (patch)
tree59034e2c3c5cb3c2b3a8e82df90154fdc9a20cbb
parentd12308bc5bc3fd200f67a1167e1bb350713037ab (diff)
glusterd/multiple volume locks: Fix for lock requests received in synctasked volume locks
The synctasked volume lock function was locking every node with it's own UUID, instead of received UUID, which resulted in deadlock when multiple snapshot commands were executed. Change-Id: Ida76da1a057eae04178c202d626f9c1e671c1fee BUG: 1043862 Signed-off-by: Avra Sengupta <asengupt@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-locks.c56
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c22
2 files changed, 48 insertions, 30 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c
index f0658da..0737a73 100644
--- a/xlators/mgmt/glusterd/src/glusterd-locks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-locks.c
@@ -169,9 +169,10 @@ glusterd_multiple_volumes_lock (dict_t *dict, uuid_t uuid)
ret = glusterd_volume_lock (volname, uuid);
if (ret) {
gf_log ("", GF_LOG_ERROR,
- "Failed to acquire lock for %s. "
- "Unlocking other volumes locked "
- "by this transaction", volname);
+ "Failed to acquire lock for %s "
+ "on behalf of %s. Unlocking "
+ "other volumes locked by this "
+ "transaction", volname, uuid_utoa(uuid));
break;
}
locked_volcount ++;
@@ -214,23 +215,27 @@ glusterd_volume_lock (char *volname, uuid_t uuid)
uuid_t owner = {0};
if (!volname) {
- gf_log ("", GF_LOG_ERROR, "volname is null.");
+ gf_log (THIS->name, GF_LOG_ERROR, "volname is null.");
ret = -1;
goto out;
}
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "Trying to acquire lock of %s for %s",
+ volname, uuid_utoa (uuid));
+
ret = glusterd_get_vol_lock_owner (volname, &owner);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "Unable to get volume lock owner");
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "Unable to get volume lock owner");
goto out;
}
/* If the lock has already been held for the given volume
* we fail */
if (!uuid_is_null (owner)) {
- gf_log ("", GF_LOG_ERROR, "Unable to acquire lock. "
- "Lock for %s held by %s", volname,
- uuid_utoa (owner));
+ gf_log (THIS->name, GF_LOG_ERROR, "Lock for %s held by %s",
+ volname, uuid_utoa (owner));
ret = -1;
goto out;
}
@@ -244,21 +249,22 @@ glusterd_volume_lock (char *volname, uuid_t uuid)
uuid_copy (lock_obj->lock_owner, uuid);
- ret = dict_set_bin (vol_lock, volname, lock_obj, sizeof(vol_lock_obj));
+ ret = dict_set_bin (vol_lock, volname, lock_obj,
+ sizeof(vol_lock_obj));
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set lock owner "
- "in volume lock");
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Unable to set lock owner in volume lock");
if (lock_obj)
GF_FREE (lock_obj);
goto out;
}
- gf_log ("", GF_LOG_DEBUG, "Lock for %s successfully held by %s",
+ gf_log (THIS->name, GF_LOG_DEBUG, "Lock for %s successfully held by %s",
volname, uuid_utoa (uuid));
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log (THIS->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -269,37 +275,45 @@ glusterd_volume_unlock (char *volname, uuid_t uuid)
uuid_t owner = {0};
if (!volname) {
- gf_log ("", GF_LOG_ERROR, "volname is null.");
+ gf_log (THIS->name, GF_LOG_ERROR, "volname is null.");
ret = -1;
goto out;
}
+ gf_log (THIS->name, GF_LOG_TRACE, "Trying to release lock of %s for %s",
+ volname, uuid_utoa (uuid));
+
ret = glusterd_get_vol_lock_owner (volname, &owner);
- if (ret)
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "Unable to get volume lock owner");
goto out;
+ }
if (uuid_is_null (owner)) {
- gf_log ("", GF_LOG_ERROR, "Lock for %s not held", volname);
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Lock for %s not held", volname);
ret = -1;
goto out;
}
ret = uuid_compare (uuid, owner);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Lock for %s held by %s. "
- "Unlock req received from %s", volname,
- uuid_utoa (owner), uuid_utoa (uuid));
+
+ gf_log (THIS->name, GF_LOG_ERROR, "Lock owner mismatch. "
+ "Lock for %s held by %s",
+ volname, uuid_utoa (owner));
goto out;
}
/* Removing the volume lock from the global list */
dict_del (vol_lock, volname);
- gf_log ("", GF_LOG_DEBUG, "Lock for %s successfully released",
+ gf_log (THIS->name, GF_LOG_DEBUG, "Lock for %s successfully released",
volname);
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log (THIS->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
index 236d9b7..2ebe372 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt-handler.c
@@ -63,6 +63,8 @@ glusterd_syctasked_volume_lock (rpcsvc_request_t *req,
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
+ GF_ASSERT (ctx);
+ GF_ASSERT (ctx->dict);
ret = dict_get_int32 (ctx->dict, "volcount", &volcount);
if (ret) {
@@ -72,21 +74,22 @@ glusterd_syctasked_volume_lock (rpcsvc_request_t *req,
"Failed to get volname");
goto out;
}
- ret = glusterd_volume_lock (volname, MY_UUID);
+ ret = glusterd_volume_lock (volname, ctx->uuid);
if (ret)
gf_log (this->name, GF_LOG_ERROR,
"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);
+ ret = glusterd_multiple_volumes_lock (ctx->dict, ctx->uuid);
if (ret)
gf_log ("", GF_LOG_ERROR,
- "Failed to acquire volume locks on localhost");
+ "Failed to acquire volume locks for %s",
+ uuid_utoa (ctx->uuid));
}
out:
- glusterd_mgmt_v3_vol_lock_send_resp (req, ret);
+ ret = glusterd_mgmt_v3_vol_lock_send_resp (req, ret);
gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
@@ -749,20 +752,21 @@ glusterd_syctasked_volume_unlock (rpcsvc_request_t *req,
"Failed to get volname");
goto out;
}
- ret = glusterd_volume_unlock (volname, MY_UUID);
+ ret = glusterd_volume_unlock (volname, ctx->uuid);
if (ret)
gf_log (this->name, GF_LOG_ERROR,
- "Unable to acquire local lock for %s", volname);
+ "Unable to release lock for %s", volname);
} else {
/* Trying to release volume locks on multiple volumes */
- ret = glusterd_multiple_volumes_unlock (ctx->dict, MY_UUID);
+ ret = glusterd_multiple_volumes_unlock (ctx->dict, ctx->uuid);
if (ret)
gf_log ("", GF_LOG_ERROR,
- "Failed to release volume locks on localhost");
+ "Failed to release volume locks for %s",
+ uuid_utoa(ctx->uuid));
}
out:
- glusterd_mgmt_v3_vol_unlock_send_resp (req, ret);
+ ret = glusterd_mgmt_v3_vol_unlock_send_resp (req, ret);
gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;