Blob Blame History Raw
From 4e48c71a771fa3ea38312a81de82437c351d68b1 Mon Sep 17 00:00:00 2001
From: Susant Palai <spalai@redhat.com>
Date: Mon, 25 May 2015 16:52:10 +0530
Subject: [PATCH 130/190] features/quota: port QUOTA messages to new logging framework

BUG: 1233694
Change-Id: Iff6d79b5884073306941e6c814a8ab9b18e383eb
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: http://review.gluster.org/7574
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/51134
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
 xlators/features/quota/src/Makefile.am             |    3 +-
 xlators/features/quota/src/quota-enforcer-client.c |   46 +-
 xlators/features/quota/src/quota-messages.h        |  247 +++++++++
 xlators/features/quota/src/quota.c                 |  585 ++++++++++----------
 xlators/features/quota/src/quota.h                 |    6 +-
 xlators/features/quota/src/quotad-aggregator.c     |   29 +-
 6 files changed, 594 insertions(+), 322 deletions(-)
 create mode 100644 xlators/features/quota/src/quota-messages.h

diff --git a/xlators/features/quota/src/Makefile.am b/xlators/features/quota/src/Makefile.am
index 7165adc..79bc929 100644
--- a/xlators/features/quota/src/Makefile.am
+++ b/xlators/features/quota/src/Makefile.am
@@ -10,7 +10,8 @@ quota_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
 quotad_la_SOURCES = quotad.c quotad-helpers.c quotad-aggregator.c
 quotad_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
 
-noinst_HEADERS = quota-mem-types.h quota.h quotad-aggregator.h quotad-helpers.h
+noinst_HEADERS = quota-mem-types.h quota.h quotad-aggregator.h \
+                 quotad-helpers.h quota-messages.h
 
 AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
 	-I$(top_srcdir)/xlators/cluster/dht/src -I$(top_srcdir)/rpc/xdr/src/ \
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c
index 55e700c..067db6d 100644
--- a/xlators/features/quota/src/quota-enforcer-client.c
+++ b/xlators/features/quota/src/quota-enforcer-client.c
@@ -44,6 +44,7 @@
 #endif
 
 #include "quota.h"
+#include "quota-messages.h"
 
 extern struct rpc_clnt_program quota_enforcer_clnt;
 
@@ -149,7 +150,9 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov,
 
         ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lookup_rsp);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        Q_MSG_XDR_DECODING_FAILED,
+                        "XDR decoding failed");
                 rsp.op_ret   = -1;
                 op_errno = EINVAL;
                 goto out;
@@ -170,8 +173,8 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov,
 
         if ((!gf_uuid_is_null (inode->gfid))
             && (gf_uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) {
-                gf_log (frame->this->name, GF_LOG_DEBUG,
-                        "gfid changed for %s", local->validate_loc.path);
+                gf_msg_debug (frame->this->name, ESTALE,
+                              "gfid changed for %s", local->validate_loc.path);
                 rsp.op_ret = -1;
                 op_errno = ESTALE;
                 goto out;
@@ -226,14 +229,14 @@ out:
         if (rsp.op_ret == -1) {
                 /* any error other than ENOENT */
                 if (rsp.op_errno != ENOENT)
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "remote operation failed: %s. Path: %s (%s)",
-                                strerror (rsp.op_errno),
-                                local->validate_loc.path,
+                        gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno,
+                                Q_MSG_LOOKUP_FAILED,
+                                "Getting cluster-wide size of directory failed "
+                                "(path: %s gfid:%s)", local->validate_loc.path,
                                 loc_gfid_utoa (&local->validate_loc));
                 else
-                        gf_log (this->name, GF_LOG_TRACE,
-                                "not found on remote node");
+                        gf_msg_trace (this->name, ENOENT,
+                                      "not found on remote node");
 
         } else if (local->quotad_conn_retry) {
                 gf_log (this->name, GF_LOG_DEBUG, "connected to quotad after "
@@ -263,6 +266,7 @@ _quota_enforcer_lookup (void *data)
         call_frame_t           *frame      = NULL;
         loc_t                  *loc        = NULL;
         xlator_t               *this       = NULL;
+        char                   *dir_path       = NULL;
 
         frame = data;
         local = frame->local;
@@ -291,6 +295,11 @@ _quota_enforcer_lookup (void *data)
         else
                 req.bname = "";
 
+        if (loc->path)
+                dir_path = (char *)loc->path;
+        else
+                dir_path = "";
+
         ret = quota_enforcer_submit_request (&req, frame,
                                              priv->quota_enforcer,
                                              GF_AGGREGATOR_LOOKUP,
@@ -299,7 +308,10 @@ _quota_enforcer_lookup (void *data)
                                              (xdrproc_t)xdr_gfs3_lookup_req);
 
         if (ret) {
-                gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+			Q_MSG_RPC_SUBMIT_FAILED, "Couldn't send the request to "
+                        "fetch cluster wide size of directory (path:%s gfid:%s)"
+                        , dir_path, req.gfid);
         }
 
         GF_FREE (req.xdata.xdata_val);
@@ -351,19 +363,19 @@ quota_enforcer_notify (struct rpc_clnt *rpc, void *mydata,
         switch (event) {
         case RPC_CLNT_CONNECT:
         {
-                gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT");
+                gf_msg_trace (this->name, 0, "got RPC_CLNT_CONNECT");
                 break;
         }
 
         case RPC_CLNT_DISCONNECT:
         {
-                gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT");
+                gf_msg_trace (this->name, 0, "got RPC_CLNT_DISCONNECT");
                 break;
         }
 
         default:
-                gf_log (this->name, GF_LOG_TRACE,
-                        "got some other RPC event %d", event);
+                gf_msg_trace (this->name, 0,
+                              "got some other RPC event %d", event);
                 ret = 0;
                 break;
         }
@@ -449,7 +461,9 @@ quota_enforcer_init (xlator_t *this, dict_t *options)
 
         ret = rpc_clnt_register_notify (rpc, quota_enforcer_notify, this);
         if (ret) {
-                gf_log ("cli", GF_LOG_ERROR, "failed to register notify");
+                gf_msg ("quota", GF_LOG_ERROR, 0,
+                        Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED,
+                        "failed to register notify");
                 goto out;
         }
 
@@ -466,7 +480,7 @@ out:
         }
 
         return rpc;
-}
+        }
 
 struct rpc_clnt_procedure quota_enforcer_actors[GF_AGGREGATOR_MAXVALUE] = {
         [GF_AGGREGATOR_NULL]     = {"NULL", NULL},
diff --git a/xlators/features/quota/src/quota-messages.h b/xlators/features/quota/src/quota-messages.h
new file mode 100644
index 0000000..d39b8d0
--- /dev/null
+++ b/xlators/features/quota/src/quota-messages.h
@@ -0,0 +1,247 @@
+/*
+  Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
+  This file is part of GlusterFS.
+
+  This file is licensed to you under your choice of the GNU Lesser
+  General Public License, version 3 or any later version (LGPLv3 or
+  later), or the GNU General Public License, version 2 (GPLv2), in all
+  cases as published by the Free Software Foundation.
+*/
+
+#ifndef _QUOTA_MESSAGES_H_
+#define _QUOTA_MESSAGES_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glfs-message-id.h"
+
+/*! \file quota-messages.h
+ *  \brief Quota log-message IDs and their descriptions
+ *
+ */
+
+/* NOTE: Rules for message additions
+ * 1) Each instance of a message is _better_ left with a unique message ID, even
+ *    if the message format is the same. Reasoning is that, if the message
+ *    format needs to change in one instance, the other instances are not
+ *    impacted or the new change does not change the ID of the instance being
+ *    modified.
+ * 2) Addition of a message,
+ *       - Should increment the GLFS_NUM_MESSAGES
+ *       - Append to the list of messages defined, towards the end
+ *       - Retain macro naming as glfs_msg_X (for redability across developers)
+ * NOTE: Rules for message format modifications
+ * 3) Check across the code if the message ID macro in question is reused
+ *    anywhere. If reused then the modifications should ensure correctness
+ *    everywhere, or needs a new message ID as (1) above was not adhered to. If
+ *    not used anywhere, proceed with the required modification.
+ * NOTE: Rules for message deletion
+ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used
+ *    anywhere, then can be deleted, but will leave a hole by design, as
+ *    addition rules specify modification to the end of the list and not filling
+ *    holes.
+ */
+
+#define GLFS_QUOTA_BASE          GLFS_MSGID_COMP_QUOTA
+#define GLFS_NUM_MESSAGES        23
+#define GLFS_MSGID_END     (GLFS_QUOTA_BASE + GLFS_NUM_MESSAGES + 1)
+/* Messaged with message IDs */
+#define glfs_msg_start_x GLFS_QUOTA_BASE, "Invalid: Start of messages"
+/*------------*/
+
+/*!
+ * @messageid 110001
+ * @diagnosis Quota enforcement has failed.
+ * @recommendedaction None
+ */
+#define Q_MSG_ENFORCEMENT_FAILED        (GLFS_QUOTA_BASE + 1)
+
+
+/*!
+* @messageid 110002
+* @diagnosis system is out of memory
+* @recommendedaction None
+*/
+#define Q_MSG_ENOMEM    (GLFS_QUOTA_BASE + 2)
+
+/*!
+ * @messageid 110003
+ * @diagnosis Parent inode is not present in the  inode table due to the
+ * inode table limits or the brick was restarted recently.
+ * @recommendedaction If it is a brick restart then perform a crawl on the
+ * file system or the specific directory in which the problem is observed.
+ * If inode table limit has been reached,please increase the limit of
+ * network.inode-lru-limit to a higher value(can be set through CLI).
+ */
+#define Q_MSG_PARENT_NULL       (GLFS_QUOTA_BASE + 3)
+
+/*!
+ * @messageid 110005
+ * @diagnosis This is to inform the admin that the user has crossed the soft limit
+ * of the quota configured on the directory and expected to cross the hard limit soon.
+ * @recommendedaction You may reconfigure your quota limits.
+ */
+#define Q_MSG_CROSSED_SOFT_LIMIT        (GLFS_QUOTA_BASE + 4)
+
+/*!
+ * @messageid 110007
+ * @diagnosis Quota translator failed to connect to quotad. This could be
+ * due to one or more of the following reasons, (1) Quotad is not running.
+ * (2) Brick process has run out of memory.
+ * @recommendedaction If quotad is not running, consider starting quotad.
+ * else check system memory consumption.
+ */
+#define Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED            (GLFS_QUOTA_BASE + 5)
+
+/*!
+ * @messageid 110008
+ * @diagnosis Getting cluster-wide size failed
+ * @recommendedaction Restart quotad. Kill quotad by searching
+ * "ps ax | grep quotad" and use volume start force to restart it.
+ */
+
+#define Q_MSG_REMOTE_OPERATION_FAILED   (GLFS_QUOTA_BASE + 6)
+
+/*!
+ * @messageid 110009
+ * @diagnosis Updation of global quota size failed. This may be due to quotad
+ * is down or lost connection with quotad.
+ * @recommendedaction Please restart quotad.
+ */
+
+#define Q_MSG_FAILED_TO_SEND_FOP        (GLFS_QUOTA_BASE + 7)
+
+/*!
+ * @messageid 110010
+ * @diagnosis
+ * @recommendedaction Check volfile for correctness
+ */
+
+#define Q_MSG_INVALID_VOLFILE        (GLFS_QUOTA_BASE + 8)
+
+/*!
+ * @messageid 110011
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_INODE_PARENT_NOT_FOUND        (GLFS_QUOTA_BASE + 9)
+
+/*!
+ * @messageid 110012
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_XDR_DECODE_ERROR        (GLFS_QUOTA_BASE + 10)
+
+/*!
+ * @messageid 110013
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_DICT_UNSERIALIZE_FAIL        (GLFS_QUOTA_BASE + 11)
+
+/*!
+ * @messageid 110014
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_DICT_SERIALIZE_FAIL        (GLFS_QUOTA_BASE + 12)
+
+/*!
+ * @messageid 110015
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_RPCSVC_INIT_FAILED        (GLFS_QUOTA_BASE + 13)
+
+/*!
+ * @messageid 110016
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_RPCSVC_LISTENER_CREATION_FAILED        (GLFS_QUOTA_BASE + 14)
+
+/*!
+ * @messageid 110017
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_RPCSVC_REGISTER_FAILED        (GLFS_QUOTA_BASE + 15)
+
+/*!
+ * @messageid 110018
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_XDR_DECODING_FAILED        (GLFS_QUOTA_BASE + 16)
+/*!
+ * @messageid 110019
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED        (GLFS_QUOTA_BASE + 17)
+/*!
+ * @messageid 110020
+ * @diagnosis
+ * @recommendedaction Umount and mount the corresponing volume
+ */
+
+#define Q_MSG_ANCESTRY_BUILD_FAILED        (GLFS_QUOTA_BASE + 18)
+
+/*!
+ * @messageid 110021
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_SIZE_KEY_MISSING        (GLFS_QUOTA_BASE + 19)
+
+/*!
+ * @messageid 110022
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_INODE_CTX_GET_FAILED     (GLFS_QUOTA_BASE + 20)
+
+/*!
+ * @messageid 110023
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_INODE_CTX_SET_FAILED     (GLFS_QUOTA_BASE + 21)
+
+/*!
+ * @messageid 110024
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_LOOKUP_FAILED     (GLFS_QUOTA_BASE + 22)
+
+/*!
+ * @messageid 110025
+ * @diagnosis
+ * @recommendedaction
+ */
+
+#define Q_MSG_RPC_SUBMIT_FAILED     (GLFS_QUOTA_BASE + 23)
+
+/*------------*/
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+
+#endif /* !_QUOTA_MESSAGES_H_ */
+
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index ef094f8..3212cb0 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;
                 }
 
@@ -1184,7 +1195,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
                         goto done;
 
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to check "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                Q_MSG_ENFORCEMENT_FAILED, "Failed to check "
                                 "quota object limit");
                         goto err;
                 }
@@ -1196,7 +1208,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
                         goto done;
 
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to check "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                Q_MSG_ENFORCEMENT_FAILED, "Failed to check "
                                 "quota size limit");
                         goto err;
                 }
@@ -1334,9 +1347,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;
@@ -1374,11 +1387,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;
@@ -1457,14 +1471,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;
         }
@@ -1509,15 +1524,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;
@@ -1551,10 +1568,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;
@@ -1647,11 +1662,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,
@@ -1733,10 +1747,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;
 
@@ -1781,7 +1793,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;
         }
 
@@ -1836,9 +1849,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;
@@ -1851,9 +1864,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;
@@ -1881,12 +1894,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;
@@ -1931,7 +1942,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;
         }
@@ -1987,8 +1999,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;
         }
@@ -2036,7 +2049,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;
         }
 
@@ -2079,11 +2093,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;
         }
 
@@ -2093,13 +2106,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;
                         }
                 }
 
@@ -2108,9 +2123,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;
@@ -2142,10 +2158,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;
 
@@ -2192,7 +2206,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;
@@ -2223,11 +2238,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);
@@ -2274,9 +2288,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;
         }
 
@@ -2292,19 +2306,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;
         }
 
@@ -2359,12 +2376,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;
@@ -2376,11 +2389,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;
         }
@@ -2397,10 +2409,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));
                         }
 
@@ -2411,9 +2422,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) {
@@ -2421,11 +2432,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;
@@ -2456,10 +2468,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;
 
@@ -2505,8 +2515,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;
         }
@@ -2542,7 +2552,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;
@@ -2559,11 +2570,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 {
 
@@ -2619,9 +2633,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;
         }
 
@@ -2634,13 +2648,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;
         }
 
@@ -2697,11 +2713,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;
         }
@@ -2713,10 +2728,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;
                 }
@@ -2740,10 +2756,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;
 
@@ -2787,7 +2801,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;
         }
 
@@ -2835,18 +2850,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;
         }
 
@@ -2884,7 +2896,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;
         }
 
@@ -2917,18 +2930,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;
         }
 
@@ -3018,7 +3028,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);
 
@@ -3083,19 +3093,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));
                 }
 
@@ -3134,7 +3140,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;
         }
 
@@ -3168,19 +3175,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));
                 }
 
@@ -3249,18 +3252,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;
         }
 
@@ -3298,7 +3298,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;
         }
 
@@ -3333,18 +3334,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;
         }
 
@@ -3412,18 +3410,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;
         }
 
@@ -3490,18 +3485,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));
                 }
 
@@ -3543,7 +3535,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;
         }
 
@@ -3577,18 +3570,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));
                 }
 
@@ -3663,8 +3653,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;
@@ -3677,10 +3669,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;
@@ -3705,10 +3697,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;
 
@@ -3753,7 +3743,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;
         }
 
@@ -4111,11 +4102,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;
@@ -4149,8 +4137,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);
@@ -4215,8 +4204,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;
@@ -4224,8 +4214,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;
         }
 
@@ -4259,7 +4250,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. "
@@ -4345,8 +4337,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,
@@ -4429,7 +4421,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);
@@ -4510,8 +4501,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;
                 }
         }
@@ -4519,8 +4511,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;
                 }
         }
@@ -4568,16 +4561,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;
         }
@@ -4605,10 +4600,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;
 
@@ -4676,11 +4669,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,
@@ -4748,8 +4740,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))
@@ -4784,8 +4777,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 */
@@ -4795,8 +4789,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;
         }
 
@@ -4815,8 +4810,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;
         }
 
@@ -4864,14 +4859,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");
         }
 
@@ -4893,8 +4890,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;
         }
 
@@ -4902,8 +4899,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;
                 }
 
@@ -4947,8 +4945,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;
                 }
 
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
index 566302c..56876f0 100644
--- a/xlators/features/quota/src/quota.h
+++ b/xlators/features/quota/src/quota.h
@@ -36,6 +36,7 @@
 #include "compat-errno.h"
 #include "protocol-common.h"
 #include "quota-common-utils.h"
+#include "quota-messages.h"
 
 #define DIRTY                   "dirty"
 #define SIZE                    "size"
@@ -79,8 +80,9 @@
                 var = GF_CALLOC (sizeof (type), 1,      \
                                  gf_quota_mt_##type);   \
                 if (!var) {                             \
-                        gf_log ("", GF_LOG_ERROR,       \
-                                "out of memory");    \
+                        gf_msg ("", GF_LOG_ERROR,       \
+                                ENOMEM, Q_MSG_ENOMEM,   \
+				"out of memory");       \
                         ret = -1;                       \
                         goto label;                     \
                 }                                       \
diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c
index 6f2f6e8..6c9c40a 100644
--- a/xlators/features/quota/src/quotad-aggregator.c
+++ b/xlators/features/quota/src/quotad-aggregator.c
@@ -90,7 +90,8 @@ quotad_aggregator_submit_reply (call_frame_t *frame, rpcsvc_request_t *req,
 
         iob = quotad_serialize_reply (req, arg, &rsp, xdrproc);
         if (!iob) {
-                gf_log ("", GF_LOG_ERROR, "Failed to serialize reply");
+                gf_msg ("", GF_LOG_ERROR, 0, Q_MSG_DICT_SERIALIZE_FAIL,
+                        "Failed to serialize reply");
                 goto ret;
         }
 
@@ -148,7 +149,9 @@ quotad_aggregator_getlimit_cbk (xlator_t *this, call_frame_t *frame,
 out:
         rsp->op_ret = ret;
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "failed to unserialize "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        Q_MSG_DICT_UNSERIALIZE_FAIL,
+                        "failed to unserialize "
                         "nameless lookup rsp");
                 goto reply;
         }
@@ -193,7 +196,8 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req)
         ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req);
         if (ret < 0)  {
                 //failed to decode msg;
-                gf_log ("", GF_LOG_ERROR, "xdr decoding error");
+                gf_msg ("this->name", GF_LOG_ERROR, 0, Q_MSG_XDR_DECODE_ERROR,
+                        "xdr decoding error");
                 req->rpc_err = GARBAGE_ARGS;
                 goto err;
         }
@@ -203,8 +207,10 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req)
                 ret = dict_unserialize (cli_req.dict.dict_val,
                                         cli_req.dict.dict_len, &dict);
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to "
-                                "unserialize req-buffer to dictionary");
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                Q_MSG_DICT_UNSERIALIZE_FAIL,
+                                "Failed to unserialize req-buffer to "
+                                "dictionary");
                         goto err;
                 }
         }
@@ -230,8 +236,8 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req)
 
         ret = dict_set_int32 (state->xdata, QUOTA_LIMIT_OBJECTS_KEY, 42);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to set "
-                        "QUOTA_LIMIT_OBJECTS_KEY");
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM,
+                        "Failed to set QUOTA_LIMIT_OBJECTS_KEY");
                 goto err;
         }
 
@@ -384,7 +390,8 @@ quotad_aggregator_init (xlator_t *this)
         /* RPC related */
         priv->rpcsvc = rpcsvc_init (this, this->ctx, this->options, 0);
         if (priv->rpcsvc == NULL) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        Q_MSG_RPCSVC_INIT_FAILED,
                         "creation of rpcsvc failed");
                 ret = -1;
                 goto out;
@@ -393,7 +400,8 @@ quotad_aggregator_init (xlator_t *this)
         ret = rpcsvc_create_listeners (priv->rpcsvc, this->options,
                                        this->name);
         if (ret < 1) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        Q_MSG_RPCSVC_LISTENER_CREATION_FAILED,
                         "creation of listener failed");
                 ret = -1;
                 goto out;
@@ -404,7 +412,8 @@ quotad_aggregator_init (xlator_t *this)
 
         ret = rpcsvc_program_register (priv->rpcsvc, &quotad_aggregator_prog);
         if (ret) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        Q_MSG_RPCSVC_REGISTER_FAILED,
                         "registration of program (name:%s, prognum:%d, "
                         "progver:%d) failed", quotad_aggregator_prog.progname,
                         quotad_aggregator_prog.prognum,
-- 
1.7.1