summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-locks.c
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-03-12 16:55:20 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-06-14 23:55:59 -0700
commit40795d95697068a0beb52364b97818dc80e49440 (patch)
treed276ec63dfa8ab197110550ef8f3f77c7a61a5d4 /xlators/mgmt/glusterd/src/glusterd-locks.c
parent2ae034374ce449c54b1b4ae8350401371db1d8d3 (diff)
handshake,locks,mountbroker,syncop/glusterd:New logging framework
Change-Id: If491a6945b7a0afa10165ff9f9874a244aece36f BUG: 1194640 Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Reviewed-on: http://review.gluster.org/9864 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-locks.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-locks.c105
1 files changed, 65 insertions, 40 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c
index 5a4e00f6774..cbaa92d0bc6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-locks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-locks.c
@@ -19,6 +19,7 @@
#include "glusterd-errno.h"
#include "run.h"
#include "syscall.h"
+#include "glusterd-messages.h"
#include <signal.h>
@@ -108,7 +109,8 @@ glusterd_get_mgmt_v3_lock_owner (char *key, uuid_t *uuid)
GF_ASSERT (priv);
if (!key || !uuid) {
- gf_log (this->name, GF_LOG_ERROR, "key or uuid is null.");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "key or uuid is null.");
ret = -1;
goto out;
}
@@ -121,7 +123,7 @@ glusterd_get_mgmt_v3_lock_owner (char *key, uuid_t *uuid)
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -145,7 +147,7 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
GF_ASSERT (type);
if (locked_count == 0) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"No %s locked as part of this transaction",
type);
goto out;
@@ -160,7 +162,8 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
* as key in the dict snapname2 */
ret = dict_get_str (dict, name_buf, &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s locked_count = %d",
name_buf, locked_count);
op_ret = ret;
@@ -169,7 +172,8 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
ret = glusterd_mgmt_v3_unlock (name, uuid, type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_UNLOCK_FAIL,
"Failed to release lock for %s.",
name);
op_ret = ret;
@@ -177,7 +181,7 @@ glusterd_release_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
}
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", op_ret);
+ gf_msg_trace (this->name, 0, "Returning %d", op_ret);
return op_ret;
}
@@ -211,7 +215,8 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
* as key in the dict snapname2 */
ret = dict_get_str (dict, name_buf, &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to get %s count = %d",
name_buf, count);
break;
@@ -219,7 +224,8 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
ret = glusterd_mgmt_v3_lock (name, uuid, op_errno, type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_LOCK_GET_FAIL,
"Failed to acquire lock for %s %s "
"on behalf of %s. Reversing "
"this transaction", type, name,
@@ -240,13 +246,14 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid,
locked_count,
type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL,
"Failed to release multiple %s locks",
type);
}
ret = -1;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -290,14 +297,16 @@ glusterd_mgmt_v3_unlock_entity (dict_t *dict, uuid_t uuid, char *type,
type);
ret = dict_get_str (dict, name_buf, &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %sname", type);
goto out;
}
ret = glusterd_mgmt_v3_unlock (name, uuid, type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_UNLOCK_FAIL,
"Failed to release lock for %s %s "
"on behalf of %s.", type, name,
uuid_utoa(uuid));
@@ -310,7 +319,8 @@ glusterd_mgmt_v3_unlock_entity (dict_t *dict, uuid_t uuid, char *type,
count,
type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL,
"Failed to release all %s locks", type);
goto out;
}
@@ -318,7 +328,7 @@ glusterd_mgmt_v3_unlock_entity (dict_t *dict, uuid_t uuid, char *type,
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -361,14 +371,16 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno,
type);
ret = dict_get_str (dict, name_buf, &name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED,
"Unable to fetch %sname", type);
goto out;
}
ret = glusterd_mgmt_v3_lock (name, uuid, op_errno, type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MGMTV3_LOCK_GET_FAIL,
"Failed to acquire lock for %s %s "
"on behalf of %s.", type, name,
uuid_utoa(uuid));
@@ -382,7 +394,8 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno,
count,
type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MULTIPLE_LOCK_ACQUIRE_FAIL,
"Failed to acquire all %s locks", type);
goto out;
}
@@ -390,7 +403,7 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno,
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -408,7 +421,8 @@ glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid)
GF_ASSERT(this);
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR, "dict is null.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "dict is null.");
ret = -1;
goto out;
}
@@ -419,7 +433,8 @@ glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid)
valid_types[i].type,
valid_types[i].default_value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL,
"Unable to unlock all %s",
valid_types[i].type);
op_ret = ret;
@@ -428,7 +443,7 @@ glusterd_multiple_mgmt_v3_unlock (dict_t *dict, uuid_t uuid)
ret = op_ret;
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -446,7 +461,8 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno)
GF_ASSERT(this);
if (!dict) {
- gf_log (this->name, GF_LOG_ERROR, "dict is null.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_EMPTY, "dict is null.");
ret = -1;
goto out;
}
@@ -458,7 +474,8 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno)
valid_types[i].type,
valid_types[i].default_value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MULTIPLE_LOCK_ACQUIRE_FAIL,
"Unable to lock all %s",
valid_types[i].type);
break;
@@ -479,14 +496,15 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno)
valid_types[i].type,
valid_types[i].default_value);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_MULTIPLE_LOCK_RELEASE_FAIL,
"Unable to unlock all %s",
valid_types[i].type);
}
}
ret = -1;
out:
- gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -510,7 +528,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno,
GF_ASSERT (priv);
if (!name || !type) {
- gf_log (this->name, GF_LOG_ERROR, "name or type is null.");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "name or type is null.");
ret = -1;
goto out;
}
@@ -527,17 +546,18 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno,
ret = snprintf (key, sizeof(key), "%s_%s", name, type);
if (ret != strlen(name) + 1 + strlen(type)) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Unable to create key");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CREATE_KEY_FAIL, "Unable to create key");
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Trying to acquire lock of %s %s for %s as %s",
type, name, uuid_utoa (uuid), key);
ret = glusterd_get_mgmt_v3_lock_owner (key, &owner);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Unable to get mgmt_v3 lock owner");
goto out;
}
@@ -565,7 +585,8 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno,
ret = dict_set_bin (priv->mgmt_v3_lock, key, lock_obj,
sizeof(glusterd_mgmt_v3_lock_obj));
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_SET_FAILED,
"Unable to set lock owner in mgmt_v3 lock");
if (lock_obj)
GF_FREE (lock_obj);
@@ -578,19 +599,20 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno,
name, type);
ret = dict_set_dynstr_with_alloc (priv->mgmt_v3_lock, key, bt);
if (ret)
- gf_log (this->name, GF_LOG_WARNING, "Failed to save "
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_DICT_SET_FAILED, "Failed to save "
"the back trace for lock %s-%s granted to %s",
name, type, uuid_utoa (uuid));
ret = 0;
}
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Lock for %s %s successfully held by %s",
type, name, uuid_utoa (uuid));
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}
@@ -610,7 +632,8 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type)
GF_ASSERT (priv);
if (!name || !type) {
- gf_log (this->name, GF_LOG_ERROR, "name is null.");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "name is null.");
ret = -1;
goto out;
}
@@ -627,18 +650,19 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type)
ret = snprintf (key, sizeof(key), "%s_%s",
name, type);
if (ret != strlen(name) + 1 + strlen(type)) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to create key");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CREATE_KEY_FAIL, "Unable to create key");
ret = -1;
goto out;
}
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Trying to release lock of %s %s for %s as %s",
type, name, uuid_utoa (uuid), key);
ret = glusterd_get_mgmt_v3_lock_owner (key, &owner);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Unable to get mgmt_v3 lock owner");
goto out;
}
@@ -667,19 +691,20 @@ glusterd_mgmt_v3_unlock (const char *name, uuid_t uuid, char *type)
type);
if (ret != strlen ("debug.last-success-bt-") + strlen (name) +
strlen (type) + 1) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to create backtrace "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_CREATE_KEY_FAIL, "Unable to create backtrace "
"key");
ret = -1;
goto out;
}
dict_del (priv->mgmt_v3_lock, key);
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Lock for %s %s successfully released",
type, name);
ret = 0;
out:
- gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+ gf_msg_trace (this->name, 0, "Returning %d", ret);
return ret;
}