summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-locks.c
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 /xlators/mgmt/glusterd/src/glusterd-locks.c
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>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-locks.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-locks.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c
index f0658da3a..0737a731e 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;
}