summaryrefslogtreecommitdiffstats
path: root/xlators/features/quota/src/quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/features/quota/src/quota.c')
-rw-r--r--xlators/features/quota/src/quota.c586
1 files changed, 292 insertions, 294 deletions
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index f4f09d75a97..18ad3c93d7b 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -14,6 +14,7 @@
#include "defaults.h"
#include "statedump.h"
#include "quota-common-utils.h"
+#include "quota-messages.h"
struct volume_options options[];
@@ -40,9 +41,9 @@ __quota_init_inode_ctx (inode_t *inode, xlator_t *this,
ret = __inode_ctx_put (inode, this, (uint64_t )(long)ctx);
if (ret == -1) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot set quota context in inode (gfid:%s)",
- uuid_utoa (inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_SET_FAILED, "cannot set quota context "
+ "in inode (gfid:%s)", uuid_utoa (inode->gfid));
}
out:
return ret;
@@ -124,22 +125,21 @@ quota_inode_loc_fill (inode_t *inode, loc_t *loc)
parent = inode_parent (inode, 0, NULL);
if (!parent) {
- gf_log (this->name, GF_LOG_DEBUG,
- "cannot find parent for inode (gfid:%s)",
- uuid_utoa (inode->gfid));
+ gf_msg_debug (this->name, 0, "cannot find parent for "
+ "inode (gfid:%s)", uuid_utoa (inode->gfid));
}
ignore_parent:
ret = inode_path (inode, NULL, &resolvedpath);
if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "cannot construct path for inode (gfid:%s)",
- uuid_utoa (inode->gfid));
+ gf_msg_debug (this->name, 0, "cannot construct path for "
+ "inode (gfid:%s)", uuid_utoa (inode->gfid));
}
ret = quota_loc_fill (loc, inode, parent, resolvedpath);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "cannot fill loc");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
+ "cannot fill loc");
goto err;
}
@@ -260,7 +260,9 @@ quota_inode_parent (inode_t *inode, uuid_t pargfid, const char *name)
parent = __quota_inode_parent (inode, pargfid, name);
if (!parent)
- gf_log_callingfn (THIS->name, GF_LOG_ERROR, "Failed to find "
+ gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0,
+ Q_MSG_PARENT_NULL,
+ "Failed to find "
"ancestor for inode (%s)",
uuid_utoa(inode->gfid));
@@ -349,7 +351,8 @@ check_ancestory_continue (struct list_head *parents, inode_t *inode,
local = frame->local;
if (parents && list_empty (parents)) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, EIO,
+ Q_MSG_ANCESTRY_BUILD_FAILED,
"Couldn't build ancestry for inode (gfid:%s). "
"Without knowing ancestors till root, quota "
"cannot be enforced. "
@@ -413,7 +416,8 @@ check_ancestory_2_cbk (struct list_head *parents, inode_t *inode,
goto out;
if (parents == NULL || list_empty (parents)) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ Q_MSG_ENFORCEMENT_FAILED,
"Couldn't build ancestry for inode (gfid:%s). "
"Without knowing ancestors till root, quota "
"cannot be enforced.",
@@ -558,8 +562,9 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ctx = (quota_inode_ctx_t *)(unsigned long)value;
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_WARNING,
- "quota context is not present in inode (gfid:%s)",
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_INODE_CTX_GET_FAILED, "quota context is"
+ " not present in inode (gfid:%s)",
uuid_utoa (local->validate_loc.inode->gfid));
op_errno = EINVAL;
goto unwind;
@@ -567,8 +572,9 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = quota_dict_get_meta (xdata, QUOTA_SIZE_KEY, &size);
if (ret == -1) {
- gf_log (this->name, GF_LOG_WARNING, "dict get failed "
- "on quota size");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_SIZE_KEY_MISSING, "quota size key not present "
+ "in dict");
op_errno = EINVAL;
}
@@ -662,7 +668,8 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
parent = inode_parent (local->loc.inode, 0, NULL);
if (parent == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "parent is NULL");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_PARENT_NULL, "parent is NULL");
op_errno = EINVAL;
goto err;
}
@@ -855,8 +862,9 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this,
ret = quota_inode_loc_fill (inode, &local->validate_loc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot fill loc for inode (gfid:%s), hence "
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENFORCEMENT_FAILED,
+ "cannot fill loc for inode (gfid:%s), hence "
"aborting quota-checks and continuing with fop",
uuid_utoa (inode->gfid));
}
@@ -876,14 +884,16 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this,
ret = dict_set_int8 (xdata, QUOTA_SIZE_KEY, 1);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "dict set failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "dict set failed");
ret = -ENOMEM;
goto err;
}
ret = dict_set_str (xdata, "volume-uuid", priv->volume_uuid);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "dict set failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "dict set failed");
ret = -ENOMEM;
goto err;
}
@@ -919,12 +929,13 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode,
if ((op_ret < 0) || list_empty (parents)) {
if (op_ret >= 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, EIO,
+ Q_MSG_ANCESTRY_BUILD_FAILED,
"Couldn't build ancestry for inode (gfid:%s). "
- "Without knowing ancestors till root, quota "
+ "Without knowing ancestors till root, quota"
"cannot be enforced. "
"Hence, failing fop with EIO",
- uuid_utoa (inode->gfid));
+ uuid_utoa (inode->gfid));
op_errno = EIO;
}
@@ -1186,10 +1197,10 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
if (ret) {
if (op_errno != EDQUOT)
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ Q_MSG_ENFORCEMENT_FAILED, "Failed to "
"check quota object limit: %s",
strerror (op_errno));
-
goto err;
}
@@ -1201,7 +1212,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
if (ret) {
if (op_errno != EDQUOT)
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ Q_MSG_ENFORCEMENT_FAILED, "Failed to "
"check quota size limit: %s",
strerror (op_errno));
goto err;
@@ -1340,9 +1352,9 @@ quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict,
ret = quota_inode_ctx_get (inode, this, &ctx, 1);
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_WARNING, "cannot create quota "
- "context in inode(gfid:%s)",
- uuid_utoa (inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_INODE_CTX_GET_FAILED, "cannot create quota "
+ "context in inode(gfid:%s)", uuid_utoa (inode->gfid));
ret = -1;
*op_errno = ENOMEM;
goto out;
@@ -1380,11 +1392,12 @@ quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict,
loc->parent->gfid);
if (dentry == NULL) {
/*
- gf_log (this->name, GF_LOG_WARNING,
- "cannot create a new dentry (par:%"
- PRId64", name:%s) for inode(ino:%"
- PRId64", gfid:%s)",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM,
+ "cannot create a new dentry (par:%"
+- PRId64", name:%s) for inode(ino:%"
+- PRId64", gfid:%s)",
+- uuid_utoa (local->loc.inode->gfid));
*/
ret = -1;
*op_errno = ENOMEM;
@@ -1463,14 +1476,15 @@ quota_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_KEY, 1);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "dict set of key for hard-limit failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "dict set of key for "
+ "hard-limit failed");
goto err;
}
ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_OBJECTS_KEY, 1);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
"dict set of key for quota object limit failed");
goto err;
}
@@ -1515,15 +1529,17 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = inode_ctx_get (local->loc.inode, this, &ctx_int);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
- "%s: failed to get the context", local->loc.path);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_GET_FAILED, "%s: failed to get the "
+ "context", local->loc.path);
goto out;
}
ctx = (quota_inode_ctx_t *)(unsigned long) ctx_int;
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_GET_FAILED,
"quota context not set in %s (gfid:%s)",
local->loc.path, uuid_utoa (local->loc.inode->gfid));
goto out;
@@ -1557,10 +1573,8 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
if (local->op_ret == -1) {
op_errno = local->op_errno;
@@ -1653,11 +1667,10 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
ret = quota_inode_ctx_get (fd->inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (fd->inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (fd->inode->gfid));
}
stub = fop_writev_stub (frame, quota_writev_helper, fd, vector, count,
@@ -1739,10 +1752,8 @@ quota_mkdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
int32_t op_errno = EINVAL;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
op_errno = local->op_errno;
@@ -1787,7 +1798,8 @@ quota_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
ret = loc_copy (&local->loc, loc);
if (ret) {
op_errno = ENOMEM;
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto err;
}
@@ -1842,9 +1854,9 @@ quota_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = quota_inode_ctx_get (inode, this, &ctx, 1);
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_WARNING, "cannot create quota "
- "context in inode(gfid:%s)",
- uuid_utoa (inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_INODE_CTX_GET_FAILED, "cannot create quota "
+ "context in inode(gfid:%s)", uuid_utoa (inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
goto unwind;
@@ -1857,9 +1869,9 @@ quota_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dentry = __quota_dentry_new (ctx, (char *)local->loc.name,
local->loc.parent->gfid);
if (dentry == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot create a new dentry (name:%s) for "
- "inode(gfid:%s)", local->loc.name,
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "cannot create a new dentry "
+ "(name:%s) for inode(gfid:%s)", local->loc.name,
uuid_utoa (local->loc.inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
@@ -1887,12 +1899,10 @@ quota_create_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
local = frame->local;
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
+
priv = this->private;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
if (local->op_ret == -1) {
op_errno = local->op_errno;
@@ -1937,7 +1947,8 @@ quota_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
ret = loc_copy (&local->loc, loc);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
op_errno = ENOMEM;
goto err;
}
@@ -1993,8 +2004,9 @@ quota_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ctx = (quota_inode_ctx_t *)(unsigned long)value;
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "quota context not set in inode (gfid:%s)",
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_INODE_CTX_GET_FAILED,
+ "quota context not set inode (gfid:%s)",
uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -2042,7 +2054,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
ret = loc_copy (&local->loc, loc);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto err;
}
@@ -2085,11 +2098,10 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = quota_inode_ctx_get (inode, this, &ctx, 0);
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (inode->gfid));
goto out;
}
@@ -2099,13 +2111,15 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if ((strcmp (dentry->name, local->loc.name) == 0) &&
(gf_uuid_compare (local->loc.parent->gfid,
dentry->par) == 0)) {
- found = 1;
- gf_log (this->name, GF_LOG_WARNING,
- "new entry being linked (name:%s) for "
- "inode (gfid:%s) is already present "
- "in inode-dentry-list", dentry->name,
- uuid_utoa (local->loc.inode->gfid));
- break;
+ found = 1;
+
+ gf_msg_debug (this->name, 0, "new entry being"
+ " linked (name:%s) for inode "
+ "(gfid:%s) is already present "
+ "in inode-dentry-list",
+ dentry->name,
+ uuid_utoa (local->loc.inode->gfid));
+ break;
}
}
@@ -2114,9 +2128,10 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
(char *)local->loc.name,
local->loc.parent->gfid);
if (dentry == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot create a new dentry (name:%s) "
- "for inode(gfid:%s)", local->loc.name,
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM,
+ "cannot create a new dentry (name:%s)"
+ "for inode(gfid:%s)", local->loc.name,
uuid_utoa (local->loc.inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
@@ -2148,10 +2163,8 @@ quota_link_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
priv = this->private;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
op_errno = local->op_errno;
@@ -2198,7 +2211,8 @@ quota_link_continue (call_frame_t *frame)
local->newloc.parent,
&common_ancestor);
if (ret < 0 || gf_uuid_is_null(common_ancestor)) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, ESTALE,
+ Q_MSG_ANCESTRY_BUILD_FAILED, "failed to get "
"common_ancestor for %s and %s",
local->oldloc.path, local->newloc.path);
op_errno = ESTALE;
@@ -2229,11 +2243,10 @@ quota_link_continue (call_frame_t *frame)
quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->oldloc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->oldloc.inode->gfid));
}
LOCK (&local->lock);
@@ -2280,9 +2293,9 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
/* No need to check quota limit if src and dst parents are same */
if (oldloc->parent && newloc->parent &&
!gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) {
- gf_log (this->name, GF_LOG_DEBUG, "link %s -> %s are "
- "in the same directory, so skip check limit",
- oldloc->path, newloc->path);
+ gf_msg_debug (this->name, GF_LOG_DEBUG, "link %s -> %s are "
+ "in the same directory, so skip check limit",
+ oldloc->path, newloc->path);
goto off;
}
@@ -2298,19 +2311,22 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
ret = loc_copy (&local->loc, newloc);
if (ret == -1) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto err;
}
ret = loc_copy (&local->oldloc, oldloc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
+ "loc_copy failed");
goto err;
}
ret = loc_copy (&local->newloc, newloc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
+ "loc_copy failed");
goto err;
}
@@ -2365,12 +2381,8 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- op_ret = -1;
- op_errno = EINVAL;
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) {
size = buf->ia_blocks * 512;
@@ -2382,11 +2394,10 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0);
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->oldloc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->oldloc.inode->gfid));
goto out;
}
@@ -2403,10 +2414,9 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
(gf_uuid_compare (local->newloc.parent->gfid,
dentry->par) == 0)) {
new_dentry_found = 1;
- gf_log (this->name, GF_LOG_WARNING,
- "new entry being linked (name:%s) for "
- "inode (gfid:%s) is already present "
- "in inode-dentry-list", dentry->name,
+ gf_msg_debug (this->name, 0, "new entry being "
+ "linked (name:%s) for inode (gfid:%s) "
+ "is in inode-dentry-list", dentry->name,
uuid_utoa (local->oldloc.inode->gfid));
}
@@ -2417,9 +2427,9 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (old_dentry != NULL) {
__quota_dentry_free (old_dentry);
} else {
- gf_log (this->name, GF_LOG_WARNING,
- "dentry corresponding to the path just renamed "
- "(name:%s) is not present", local->oldloc.name);
+ gf_msg_debug (this->name, 0, "dentry corresponding"
+ "the path just renamed (name:%s) is not"
+ " present", local->oldloc.name);
}
if (!new_dentry_found) {
@@ -2427,11 +2437,12 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
(char *)local->newloc.name,
local->newloc.parent->gfid);
if (dentry == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot create a new dentry (name:%s) "
- "for inode(gfid:%s)",
- local->newloc.name,
- uuid_utoa (local->oldloc.inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM,
+ "cannot create a new dentry (name:%s) "
+ "for inode(gfid:%s)",
+ local->newloc.name,
+ uuid_utoa (local->newloc.inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
goto unlock;
@@ -2462,10 +2473,8 @@ quota_rename_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
priv = this->private;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
op_errno = local->op_errno;
@@ -2511,8 +2520,8 @@ quota_rename_get_size_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = dict_get_bin (xdata, QUOTA_SIZE_KEY, (void **) &size);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "size key not present in dict");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_SIZE_KEY_MISSING, "size key not present in dict");
op_errno = EINVAL;
goto out;
}
@@ -2548,7 +2557,8 @@ quota_rename_continue (call_frame_t *frame)
local->newloc.parent,
&common_ancestor);
if (ret < 0 || gf_uuid_is_null(common_ancestor)) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get "
+ gf_msg (this->name, GF_LOG_ERROR, ESTALE,
+ Q_MSG_ANCESTRY_BUILD_FAILED, "failed to get "
"common_ancestor for %s and %s",
local->oldloc.path, local->newloc.path);
op_errno = ESTALE;
@@ -2565,11 +2575,14 @@ quota_rename_continue (call_frame_t *frame)
if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) {
ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_GET_FAILED,
"quota context not set in inode (gfid:%s), "
"considering file size as zero while enforcing "
"quota on new ancestry",
uuid_utoa (local->oldloc.inode->gfid));
+
+
local->delta = 0;
} else {
@@ -2625,9 +2638,9 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
/* No need to check quota limit if src and dst parents are same */
if (oldloc->parent && newloc->parent &&
!gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) {
- gf_log (this->name, GF_LOG_DEBUG, "rename %s -> %s are "
- "in the same directory, so skip check limit",
- oldloc->path, newloc->path);
+ gf_msg_debug (this->name, 0, "rename %s -> %s are "
+ "in the same directory, so skip check limit",
+ oldloc->path, newloc->path);
goto off;
}
@@ -2640,13 +2653,15 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
ret = loc_copy (&local->oldloc, oldloc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
+ "loc_copy failed");
goto err;
}
ret = loc_copy (&local->newloc, newloc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
+ "loc_copy failed");
goto err;
}
@@ -2703,11 +2718,10 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
quota_inode_ctx_get (local->loc.inode, this, &ctx, 1);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -2719,10 +2733,11 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dentry = __quota_dentry_new (ctx, (char *)local->loc.name,
local->loc.parent->gfid);
if (dentry == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot create a new dentry (name:%s) for "
- "inode(gfid:%s)", local->loc.name,
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "cannot create "
+ "a new dentry (name:%s) for inode(gfid:%s)",
+ local->loc.name,
+ uuid_utoa (local->loc.inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
}
@@ -2746,10 +2761,8 @@ quota_symlink_helper (call_frame_t *frame, xlator_t *this, const char *linkpath,
quota_priv_t *priv = NULL;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
priv = this->private;
@@ -2793,7 +2806,8 @@ quota_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
ret = loc_copy (&local->loc, loc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto err;
}
@@ -2841,18 +2855,15 @@ quota_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -2890,7 +2901,8 @@ quota_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
ret = loc_copy (&local->loc, loc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto err;
}
@@ -2923,18 +2935,15 @@ quota_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -3024,7 +3033,7 @@ dict_set:
if (ret < 0)
goto out;
- gf_log (this->name, GF_LOG_DEBUG, "str = %s", dir_limit);
+ gf_msg_debug (this->name, 0, "str = %s", dir_limit);
QUOTA_STACK_UNWIND (getxattr, frame, 0, 0, dict, NULL);
@@ -3089,19 +3098,15 @@ quota_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
if (!IA_ISDIR (buf->ia_type)) {
- gf_log (this->name, GF_LOG_DEBUG,
- "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler "
- "has finished crawling, its an error",
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
uuid_utoa (local->loc.inode->gfid));
}
@@ -3140,7 +3145,8 @@ quota_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
frame->local = local;
ret = loc_copy (&local->loc, loc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto unwind;
}
@@ -3174,19 +3180,15 @@ quota_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
if (!IA_ISDIR (buf->ia_type)) {
- gf_log (this->name, GF_LOG_DEBUG,
- "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler "
- "has finished crawling, its an error",
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
uuid_utoa (local->loc.inode->gfid));
}
@@ -3255,18 +3257,15 @@ quota_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -3304,7 +3303,8 @@ quota_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
ret = loc_copy (&local->loc, loc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto unwind;
}
@@ -3339,18 +3339,15 @@ quota_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -3418,18 +3415,15 @@ quota_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
- "inode (%s). "
- "If quota is not enabled recently and crawler has "
- "finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -3496,18 +3490,15 @@ quota_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
if (!IA_ISDIR (statpost->ia_type)) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is "
- "NULL on inode (%s). "
- "If quota is not enabled recently and crawler "
- "has finished crawling, its an error",
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
uuid_utoa (local->loc.inode->gfid));
}
@@ -3549,7 +3540,8 @@ quota_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
ret = loc_copy (&local->loc, loc);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto unwind;
}
@@ -3583,18 +3575,15 @@ quota_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto out;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, out);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
if (!IA_ISDIR (statpost->ia_type)) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is "
- "NULL on inode (%s). "
- "If quota is not enabled recently and crawler "
- "has finished crawling, its an error",
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
uuid_utoa (local->loc.inode->gfid));
}
@@ -3669,8 +3658,10 @@ quota_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = quota_inode_ctx_get (inode, this, &ctx, 1);
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_WARNING, "cannot create quota "
- "context in inode (gfid:%s)", uuid_utoa (inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_GET_FAILED,
+ "cannot create quota context in "
+ "inode(gfid:%s)", uuid_utoa (inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
goto unwind;
@@ -3683,10 +3674,10 @@ quota_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dentry = __quota_dentry_new (ctx, (char *)local->loc.name,
local->loc.parent->gfid);
if (dentry == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot create a new dentry (name:%s) for "
- "inode(gfid:%s)", local->loc.name,
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "cannot create a new dentry "
+ "(name:%s) for inode(gfid:%s)", local->loc.name,
+ uuid_utoa (local->loc.inode->gfid));
op_ret = -1;
op_errno = ENOMEM;
goto unlock;
@@ -3711,10 +3702,8 @@ quota_mknod_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
quota_priv_t *priv = NULL;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
priv = this->private;
@@ -3759,7 +3748,8 @@ quota_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
ret = loc_copy (&local->loc, loc);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "loc_copy failed");
goto err;
}
@@ -4117,11 +4107,8 @@ quota_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
* cookie, and it would only do so if the value was non-NULL. This
* check is therefore just routine defensive coding.
*/
- if (!inode) {
- gf_log(this->name,GF_LOG_WARNING,
- "null inode, cannot adjust for quota");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", inode, unwind);
inode_ctx_get (inode, this, &value);
ctx = (quota_inode_ctx_t *)(unsigned long)value;
@@ -4155,8 +4142,9 @@ quota_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = dict_set_int8 (xdata, "quota-deem-statfs", 1);
if (-1 == ret)
- gf_log (this->name, GF_LOG_ERROR, "Dict set failed, "
- "deem-statfs option may have no effect");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ Q_MSG_ENOMEM, "Dict set failed, deem-statfs option may "
+ "have no effect");
unwind:
QUOTA_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata);
@@ -4221,8 +4209,9 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ctx = (quota_inode_ctx_t *)(unsigned long)value;
if ((ret == -1) || (ctx == NULL)) {
- gf_log (this->name, GF_LOG_WARNING,
- "quota context is not present in inode (gfid:%s)",
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_INODE_CTX_GET_FAILED,
+ "quota context is not present in inode (gfid:%s)",
uuid_utoa (local->validate_loc.inode->gfid));
op_errno = EINVAL;
goto resume;
@@ -4230,8 +4219,9 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = quota_dict_get_meta (xdata, QUOTA_SIZE_KEY, &size);
if (ret == -1) {
- gf_log (this->name, GF_LOG_WARNING, "dict get failed "
- "on quota size");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ Q_MSG_SIZE_KEY_MISSING, "size key not present in "
+ "dict");
op_errno = EINVAL;
}
@@ -4265,7 +4255,8 @@ quota_get_limit_dir_continuation (struct list_head *parents, inode_t *inode,
if ((op_ret < 0) || list_empty (parents)) {
if (op_ret >= 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, EIO,
+ Q_MSG_ANCESTRY_BUILD_FAILED,
"Couldn't build ancestry for inode (gfid:%s). "
"Without knowing ancestors till root, quota "
"cannot be enforced. "
@@ -4351,8 +4342,8 @@ quota_get_limit_dir (call_frame_t *frame, inode_t *cur_inode, xlator_t *this)
return;
off:
- gf_log (this->name, GF_LOG_DEBUG,
- "No limit set on the inode or it's parents.");
+ gf_msg_debug (this->name, 0,
+ "No limit set on the inode or it's parents.");
QUOTA_STACK_WIND_TAIL (frame, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->statfs,
@@ -4435,7 +4426,6 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
gf_log (this->name, GF_LOG_ERROR,
"Missing inode, can't adjust for quota");
-
off:
STACK_WIND_TAIL (frame, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->statfs, loc, xdata);
@@ -4516,8 +4506,9 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
if (dict) {
ret = dict_set_int8 (dict, QUOTA_LIMIT_KEY, 1);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "dict set of key for hard-limit failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM,
+ "dict set of key for hard-limit");
goto err;
}
}
@@ -4525,8 +4516,9 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
if (dict) {
ret = dict_set_int8 (dict, QUOTA_LIMIT_OBJECTS_KEY, 1);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "dict set of key for hard-limit failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ Q_MSG_ENOMEM, "dict set of key for hard-limit "
+ "failed");
goto err;
}
}
@@ -4574,16 +4566,18 @@ quota_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
ret = inode_ctx_get (local->loc.inode, this, &ctx_int);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
- "%s: failed to get the context", local->loc.path);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_GET_FAILED,
+ "%s: failed to get the context", local->loc.path);
goto out;
}
ctx = (quota_inode_ctx_t *)(unsigned long) ctx_int;
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
- "quota context not set in %s (gfid:%s)",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INODE_CTX_GET_FAILED,
+ "quota context not set in %s (gfid:%s)",
local->loc.path, uuid_utoa (local->loc.inode->gfid));
goto out;
}
@@ -4611,10 +4605,8 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
quota_priv_t *priv = NULL;
local = frame->local;
- if (local == NULL) {
- gf_log (this->name, GF_LOG_WARNING, "local is NULL");
- goto unwind;
- }
+
+ GF_VALIDATE_OR_GOTO ("quota", local, unwind);
priv = this->private;
@@ -4682,11 +4674,10 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
ret = quota_inode_ctx_get (fd->inode, this, &ctx, 0);
if (ctx == NULL) {
- gf_log (this->name, GF_LOG_DEBUG, "quota context is "
- "NULL on inode (%s). "
- "If quota is not enabled recently and crawler "
- "has finished crawling, its an error",
- uuid_utoa (local->loc.inode->gfid));
+ gf_msg_debug (this->name, 0, "quota context is NULL on inode"
+ " (%s). If quota is not enabled recently and "
+ "crawler has finished crawling, its an error",
+ uuid_utoa (local->loc.inode->gfid));
}
stub = fop_fallocate_stub(frame, quota_fallocate_helper, fd, mode,
@@ -4754,8 +4745,9 @@ quota_log_helper (char **usage_str, int64_t cur_size, inode_t *inode,
*usage_str = gf_uint64_2human_readable (cur_size);
if (!(*usage_str))
- gf_log (this->name, GF_LOG_ERROR, "integer to string "
- "conversion failed Reason:\"Cannot allocate memory\"");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM,
+ "integer to string conversion failed Reason"
+ ":\"Cannot allocate memory\"");
inode_path (inode, NULL, path);
if (!(*path))
@@ -4790,8 +4782,9 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
quota_log_helper (&usage_str, cur_size, inode,
&path, &cur_time);
- gf_log (this->name, GF_LOG_ALERT, "Usage crossed "
- "soft limit: %s used by %s", usage_str, path);
+ gf_msg (this->name, GF_LOG_ALERT, 0,
+ Q_MSG_CROSSED_SOFT_LIMIT, "Usage crossed soft limit: "
+ "%s used by %s", usage_str, path);
ctx->prev_log = cur_time;
}
/* Usage is above soft limit */
@@ -4801,8 +4794,9 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
quota_log_helper (&usage_str, cur_size, inode,
&path, &cur_time);
- gf_log (this->name, GF_LOG_ALERT, "Usage is above "
- "soft limit: %s used by %s", usage_str, path);
+ gf_msg (this->name, GF_LOG_ALERT, 0, Q_MSG_CROSSED_SOFT_LIMIT,
+ "Usage is above soft limit: %s used by %s",
+ usage_str, path);
ctx->prev_log = cur_time;
}
@@ -4821,8 +4815,8 @@ mem_acct_init (xlator_t *this)
ret = xlator_mem_acct_init (this, gf_quota_mt_end + 1);
if (ret != 0) {
- gf_log (this->name, GF_LOG_WARNING, "Memory accounting"
- "init failed");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
+ "Memory accounting init failed");
return ret;
}
@@ -4870,14 +4864,16 @@ init (xlator_t *this)
if ((this->children == NULL)
|| this->children->next) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ Q_MSG_INVALID_VOLFILE,
"FATAL: quota (%s) not configured with "
"exactly one child", this->name);
return -1;
}
if (this->parents == NULL) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_INVALID_VOLFILE,
"dangling volume. check volfile");
}
@@ -4899,8 +4895,8 @@ init (xlator_t *this)
this->local_pool = mem_pool_new (quota_local_t, 64);
if (!this->local_pool) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
- "failed to create local_t's memory pool");
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ Q_MSG_ENOMEM, "failed to create local_t's memory pool");
goto err;
}
@@ -4908,8 +4904,9 @@ init (xlator_t *this)
rpc = quota_enforcer_init (this, this->options);
if (rpc == NULL) {
ret = -1;
- gf_log (this->name, GF_LOG_WARNING,
- "quota enforcer rpc init failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED,
+ "quota enforcer rpc init failed");
goto err;
}
@@ -4953,8 +4950,9 @@ reconfigure (xlator_t *this, dict_t *options)
this->options);
if (priv->rpc_clnt == NULL) {
ret = -1;
- gf_log (this->name, GF_LOG_WARNING,
- "quota enforcer rpc init failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED,
+ "quota enforcer rpc init failed");
goto out;
}