cb8e9e
From 4e48c71a771fa3ea38312a81de82437c351d68b1 Mon Sep 17 00:00:00 2001
cb8e9e
From: Susant Palai <spalai@redhat.com>
cb8e9e
Date: Mon, 25 May 2015 16:52:10 +0530
cb8e9e
Subject: [PATCH 130/190] features/quota: port QUOTA messages to new logging framework
cb8e9e
cb8e9e
BUG: 1233694
cb8e9e
Change-Id: Iff6d79b5884073306941e6c814a8ab9b18e383eb
cb8e9e
Signed-off-by: Susant Palai <spalai@redhat.com>
cb8e9e
Reviewed-on: http://review.gluster.org/7574
cb8e9e
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
cb8e9e
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra G <rgowdapp@redhat.com>
cb8e9e
Signed-off-by: Susant Palai <spalai@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/51134
cb8e9e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
---
cb8e9e
 xlators/features/quota/src/Makefile.am             |    3 +-
cb8e9e
 xlators/features/quota/src/quota-enforcer-client.c |   46 +-
cb8e9e
 xlators/features/quota/src/quota-messages.h        |  247 +++++++++
cb8e9e
 xlators/features/quota/src/quota.c                 |  585 ++++++++++----------
cb8e9e
 xlators/features/quota/src/quota.h                 |    6 +-
cb8e9e
 xlators/features/quota/src/quotad-aggregator.c     |   29 +-
cb8e9e
 6 files changed, 594 insertions(+), 322 deletions(-)
cb8e9e
 create mode 100644 xlators/features/quota/src/quota-messages.h
cb8e9e
cb8e9e
diff --git a/xlators/features/quota/src/Makefile.am b/xlators/features/quota/src/Makefile.am
cb8e9e
index 7165adc..79bc929 100644
cb8e9e
--- a/xlators/features/quota/src/Makefile.am
cb8e9e
+++ b/xlators/features/quota/src/Makefile.am
cb8e9e
@@ -10,7 +10,8 @@ quota_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
cb8e9e
 quotad_la_SOURCES = quotad.c quotad-helpers.c quotad-aggregator.c
cb8e9e
 quotad_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
cb8e9e
 
cb8e9e
-noinst_HEADERS = quota-mem-types.h quota.h quotad-aggregator.h quotad-helpers.h
cb8e9e
+noinst_HEADERS = quota-mem-types.h quota.h quotad-aggregator.h \
cb8e9e
+                 quotad-helpers.h quota-messages.h
cb8e9e
 
cb8e9e
 AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
cb8e9e
 	-I$(top_srcdir)/xlators/cluster/dht/src -I$(top_srcdir)/rpc/xdr/src/ \
cb8e9e
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c
cb8e9e
index 55e700c..067db6d 100644
cb8e9e
--- a/xlators/features/quota/src/quota-enforcer-client.c
cb8e9e
+++ b/xlators/features/quota/src/quota-enforcer-client.c
cb8e9e
@@ -44,6 +44,7 @@
cb8e9e
 #endif
cb8e9e
 
cb8e9e
 #include "quota.h"
cb8e9e
+#include "quota-messages.h"
cb8e9e
 
cb8e9e
 extern struct rpc_clnt_program quota_enforcer_clnt;
cb8e9e
 
cb8e9e
@@ -149,7 +150,9 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
 
cb8e9e
         ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lookup_rsp);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                        Q_MSG_XDR_DECODING_FAILED,
cb8e9e
+                        "XDR decoding failed");
cb8e9e
                 rsp.op_ret   = -1;
cb8e9e
                 op_errno = EINVAL;
cb8e9e
                 goto out;
cb8e9e
@@ -170,8 +173,8 @@ quota_enforcer_lookup_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
 
cb8e9e
         if ((!gf_uuid_is_null (inode->gfid))
cb8e9e
             && (gf_uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) {
cb8e9e
-                gf_log (frame->this->name, GF_LOG_DEBUG,
cb8e9e
-                        "gfid changed for %s", local->validate_loc.path);
cb8e9e
+                gf_msg_debug (frame->this->name, ESTALE,
cb8e9e
+                              "gfid changed for %s", local->validate_loc.path);
cb8e9e
                 rsp.op_ret = -1;
cb8e9e
                 op_errno = ESTALE;
cb8e9e
                 goto out;
cb8e9e
@@ -226,14 +229,14 @@ out:
cb8e9e
         if (rsp.op_ret == -1) {
cb8e9e
                 /* any error other than ENOENT */
cb8e9e
                 if (rsp.op_errno != ENOENT)
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "remote operation failed: %s. Path: %s (%s)",
cb8e9e
-                                strerror (rsp.op_errno),
cb8e9e
-                                local->validate_loc.path,
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, rsp.op_errno,
cb8e9e
+                                Q_MSG_LOOKUP_FAILED,
cb8e9e
+                                "Getting cluster-wide size of directory failed "
cb8e9e
+                                "(path: %s gfid:%s)", local->validate_loc.path,
cb8e9e
                                 loc_gfid_utoa (&local->validate_loc));
cb8e9e
                 else
cb8e9e
-                        gf_log (this->name, GF_LOG_TRACE,
cb8e9e
-                                "not found on remote node");
cb8e9e
+                        gf_msg_trace (this->name, ENOENT,
cb8e9e
+                                      "not found on remote node");
cb8e9e
 
cb8e9e
         } else if (local->quotad_conn_retry) {
cb8e9e
                 gf_log (this->name, GF_LOG_DEBUG, "connected to quotad after "
cb8e9e
@@ -263,6 +266,7 @@ _quota_enforcer_lookup (void *data)
cb8e9e
         call_frame_t           *frame      = NULL;
cb8e9e
         loc_t                  *loc        = NULL;
cb8e9e
         xlator_t               *this       = NULL;
cb8e9e
+        char                   *dir_path       = NULL;
cb8e9e
 
cb8e9e
         frame = data;
cb8e9e
         local = frame->local;
cb8e9e
@@ -291,6 +295,11 @@ _quota_enforcer_lookup (void *data)
cb8e9e
         else
cb8e9e
                 req.bname = "";
cb8e9e
 
cb8e9e
+        if (loc->path)
cb8e9e
+                dir_path = (char *)loc->path;
cb8e9e
+        else
cb8e9e
+                dir_path = "";
cb8e9e
+
cb8e9e
         ret = quota_enforcer_submit_request (&req, frame,
cb8e9e
                                              priv->quota_enforcer,
cb8e9e
                                              GF_AGGREGATOR_LOOKUP,
cb8e9e
@@ -299,7 +308,10 @@ _quota_enforcer_lookup (void *data)
cb8e9e
                                              (xdrproc_t)xdr_gfs3_lookup_req);
cb8e9e
 
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+			Q_MSG_RPC_SUBMIT_FAILED, "Couldn't send the request to "
cb8e9e
+                        "fetch cluster wide size of directory (path:%s gfid:%s)"
cb8e9e
+                        , dir_path, req.gfid);
cb8e9e
         }
cb8e9e
 
cb8e9e
         GF_FREE (req.xdata.xdata_val);
cb8e9e
@@ -351,19 +363,19 @@ quota_enforcer_notify (struct rpc_clnt *rpc, void *mydata,
cb8e9e
         switch (event) {
cb8e9e
         case RPC_CLNT_CONNECT:
cb8e9e
         {
cb8e9e
-                gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT");
cb8e9e
+                gf_msg_trace (this->name, 0, "got RPC_CLNT_CONNECT");
cb8e9e
                 break;
cb8e9e
         }
cb8e9e
 
cb8e9e
         case RPC_CLNT_DISCONNECT:
cb8e9e
         {
cb8e9e
-                gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT");
cb8e9e
+                gf_msg_trace (this->name, 0, "got RPC_CLNT_DISCONNECT");
cb8e9e
                 break;
cb8e9e
         }
cb8e9e
 
cb8e9e
         default:
cb8e9e
-                gf_log (this->name, GF_LOG_TRACE,
cb8e9e
-                        "got some other RPC event %d", event);
cb8e9e
+                gf_msg_trace (this->name, 0,
cb8e9e
+                              "got some other RPC event %d", event);
cb8e9e
                 ret = 0;
cb8e9e
                 break;
cb8e9e
         }
cb8e9e
@@ -449,7 +461,9 @@ quota_enforcer_init (xlator_t *this, dict_t *options)
cb8e9e
 
cb8e9e
         ret = rpc_clnt_register_notify (rpc, quota_enforcer_notify, this);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log ("cli", GF_LOG_ERROR, "failed to register notify");
cb8e9e
+                gf_msg ("quota", GF_LOG_ERROR, 0,
cb8e9e
+                        Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED,
cb8e9e
+                        "failed to register notify");
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -466,7 +480,7 @@ out:
cb8e9e
         }
cb8e9e
 
cb8e9e
         return rpc;
cb8e9e
-}
cb8e9e
+        }
cb8e9e
 
cb8e9e
 struct rpc_clnt_procedure quota_enforcer_actors[GF_AGGREGATOR_MAXVALUE] = {
cb8e9e
         [GF_AGGREGATOR_NULL]     = {"NULL", NULL},
cb8e9e
diff --git a/xlators/features/quota/src/quota-messages.h b/xlators/features/quota/src/quota-messages.h
cb8e9e
new file mode 100644
cb8e9e
index 0000000..d39b8d0
cb8e9e
--- /dev/null
cb8e9e
+++ b/xlators/features/quota/src/quota-messages.h
cb8e9e
@@ -0,0 +1,247 @@
cb8e9e
+/*
cb8e9e
+  Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
cb8e9e
+  This file is part of GlusterFS.
cb8e9e
+
cb8e9e
+  This file is licensed to you under your choice of the GNU Lesser
cb8e9e
+  General Public License, version 3 or any later version (LGPLv3 or
cb8e9e
+  later), or the GNU General Public License, version 2 (GPLv2), in all
cb8e9e
+  cases as published by the Free Software Foundation.
cb8e9e
+*/
cb8e9e
+
cb8e9e
+#ifndef _QUOTA_MESSAGES_H_
cb8e9e
+#define _QUOTA_MESSAGES_H_
cb8e9e
+
cb8e9e
+#ifndef _CONFIG_H
cb8e9e
+#define _CONFIG_H
cb8e9e
+#include "config.h"
cb8e9e
+#endif
cb8e9e
+
cb8e9e
+#include "glfs-message-id.h"
cb8e9e
+
cb8e9e
+/*! \file quota-messages.h
cb8e9e
+ *  \brief Quota log-message IDs and their descriptions
cb8e9e
+ *
cb8e9e
+ */
cb8e9e
+
cb8e9e
+/* NOTE: Rules for message additions
cb8e9e
+ * 1) Each instance of a message is _better_ left with a unique message ID, even
cb8e9e
+ *    if the message format is the same. Reasoning is that, if the message
cb8e9e
+ *    format needs to change in one instance, the other instances are not
cb8e9e
+ *    impacted or the new change does not change the ID of the instance being
cb8e9e
+ *    modified.
cb8e9e
+ * 2) Addition of a message,
cb8e9e
+ *       - Should increment the GLFS_NUM_MESSAGES
cb8e9e
+ *       - Append to the list of messages defined, towards the end
cb8e9e
+ *       - Retain macro naming as glfs_msg_X (for redability across developers)
cb8e9e
+ * NOTE: Rules for message format modifications
cb8e9e
+ * 3) Check across the code if the message ID macro in question is reused
cb8e9e
+ *    anywhere. If reused then the modifications should ensure correctness
cb8e9e
+ *    everywhere, or needs a new message ID as (1) above was not adhered to. If
cb8e9e
+ *    not used anywhere, proceed with the required modification.
cb8e9e
+ * NOTE: Rules for message deletion
cb8e9e
+ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used
cb8e9e
+ *    anywhere, then can be deleted, but will leave a hole by design, as
cb8e9e
+ *    addition rules specify modification to the end of the list and not filling
cb8e9e
+ *    holes.
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define GLFS_QUOTA_BASE          GLFS_MSGID_COMP_QUOTA
cb8e9e
+#define GLFS_NUM_MESSAGES        23
cb8e9e
+#define GLFS_MSGID_END     (GLFS_QUOTA_BASE + GLFS_NUM_MESSAGES + 1)
cb8e9e
+/* Messaged with message IDs */
cb8e9e
+#define glfs_msg_start_x GLFS_QUOTA_BASE, "Invalid: Start of messages"
cb8e9e
+/*------------*/
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110001
cb8e9e
+ * @diagnosis Quota enforcement has failed.
cb8e9e
+ * @recommendedaction None
cb8e9e
+ */
cb8e9e
+#define Q_MSG_ENFORCEMENT_FAILED        (GLFS_QUOTA_BASE + 1)
cb8e9e
+
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+* @messageid 110002
cb8e9e
+* @diagnosis system is out of memory
cb8e9e
+* @recommendedaction None
cb8e9e
+*/
cb8e9e
+#define Q_MSG_ENOMEM    (GLFS_QUOTA_BASE + 2)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110003
cb8e9e
+ * @diagnosis Parent inode is not present in the  inode table due to the
cb8e9e
+ * inode table limits or the brick was restarted recently.
cb8e9e
+ * @recommendedaction If it is a brick restart then perform a crawl on the
cb8e9e
+ * file system or the specific directory in which the problem is observed.
cb8e9e
+ * If inode table limit has been reached,please increase the limit of
cb8e9e
+ * network.inode-lru-limit to a higher value(can be set through CLI).
cb8e9e
+ */
cb8e9e
+#define Q_MSG_PARENT_NULL       (GLFS_QUOTA_BASE + 3)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110005
cb8e9e
+ * @diagnosis This is to inform the admin that the user has crossed the soft limit
cb8e9e
+ * of the quota configured on the directory and expected to cross the hard limit soon.
cb8e9e
+ * @recommendedaction You may reconfigure your quota limits.
cb8e9e
+ */
cb8e9e
+#define Q_MSG_CROSSED_SOFT_LIMIT        (GLFS_QUOTA_BASE + 4)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110007
cb8e9e
+ * @diagnosis Quota translator failed to connect to quotad. This could be
cb8e9e
+ * due to one or more of the following reasons, (1) Quotad is not running.
cb8e9e
+ * (2) Brick process has run out of memory.
cb8e9e
+ * @recommendedaction If quotad is not running, consider starting quotad.
cb8e9e
+ * else check system memory consumption.
cb8e9e
+ */
cb8e9e
+#define Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED            (GLFS_QUOTA_BASE + 5)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110008
cb8e9e
+ * @diagnosis Getting cluster-wide size failed
cb8e9e
+ * @recommendedaction Restart quotad. Kill quotad by searching
cb8e9e
+ * "ps ax | grep quotad" and use volume start force to restart it.
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_REMOTE_OPERATION_FAILED   (GLFS_QUOTA_BASE + 6)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110009
cb8e9e
+ * @diagnosis Updation of global quota size failed. This may be due to quotad
cb8e9e
+ * is down or lost connection with quotad.
cb8e9e
+ * @recommendedaction Please restart quotad.
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_FAILED_TO_SEND_FOP        (GLFS_QUOTA_BASE + 7)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110010
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction Check volfile for correctness
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_INVALID_VOLFILE        (GLFS_QUOTA_BASE + 8)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110011
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_INODE_PARENT_NOT_FOUND        (GLFS_QUOTA_BASE + 9)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110012
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_XDR_DECODE_ERROR        (GLFS_QUOTA_BASE + 10)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110013
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_DICT_UNSERIALIZE_FAIL        (GLFS_QUOTA_BASE + 11)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110014
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_DICT_SERIALIZE_FAIL        (GLFS_QUOTA_BASE + 12)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110015
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_RPCSVC_INIT_FAILED        (GLFS_QUOTA_BASE + 13)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110016
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_RPCSVC_LISTENER_CREATION_FAILED        (GLFS_QUOTA_BASE + 14)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110017
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_RPCSVC_REGISTER_FAILED        (GLFS_QUOTA_BASE + 15)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110018
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_XDR_DECODING_FAILED        (GLFS_QUOTA_BASE + 16)
cb8e9e
+/*!
cb8e9e
+ * @messageid 110019
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED        (GLFS_QUOTA_BASE + 17)
cb8e9e
+/*!
cb8e9e
+ * @messageid 110020
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction Umount and mount the corresponing volume
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_ANCESTRY_BUILD_FAILED        (GLFS_QUOTA_BASE + 18)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110021
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_SIZE_KEY_MISSING        (GLFS_QUOTA_BASE + 19)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110022
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_INODE_CTX_GET_FAILED     (GLFS_QUOTA_BASE + 20)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110023
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_INODE_CTX_SET_FAILED     (GLFS_QUOTA_BASE + 21)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110024
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_LOOKUP_FAILED     (GLFS_QUOTA_BASE + 22)
cb8e9e
+
cb8e9e
+/*!
cb8e9e
+ * @messageid 110025
cb8e9e
+ * @diagnosis
cb8e9e
+ * @recommendedaction
cb8e9e
+ */
cb8e9e
+
cb8e9e
+#define Q_MSG_RPC_SUBMIT_FAILED     (GLFS_QUOTA_BASE + 23)
cb8e9e
+
cb8e9e
+/*------------*/
cb8e9e
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
cb8e9e
+
cb8e9e
+#endif /* !_QUOTA_MESSAGES_H_ */
cb8e9e
+
cb8e9e
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
cb8e9e
index ef094f8..3212cb0 100644
cb8e9e
--- a/xlators/features/quota/src/quota.c
cb8e9e
+++ b/xlators/features/quota/src/quota.c
cb8e9e
@@ -14,6 +14,7 @@
cb8e9e
 #include "defaults.h"
cb8e9e
 #include "statedump.h"
cb8e9e
 #include "quota-common-utils.h"
cb8e9e
+#include "quota-messages.h"
cb8e9e
 
cb8e9e
 struct volume_options options[];
cb8e9e
 
cb8e9e
@@ -40,9 +41,9 @@ __quota_init_inode_ctx (inode_t *inode, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = __inode_ctx_put (inode, this, (uint64_t )(long)ctx);
cb8e9e
         if (ret == -1) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "cannot set quota context in inode (gfid:%s)",
cb8e9e
-                        uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_INODE_CTX_SET_FAILED, "cannot set quota context "
cb8e9e
+                        "in inode (gfid:%s)", uuid_utoa (inode->gfid));
cb8e9e
         }
cb8e9e
 out:
cb8e9e
         return ret;
cb8e9e
@@ -124,22 +125,21 @@ quota_inode_loc_fill (inode_t *inode, loc_t *loc)
cb8e9e
 
cb8e9e
         parent = inode_parent (inode, 0, NULL);
cb8e9e
         if (!parent) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG,
cb8e9e
-                        "cannot find parent for inode (gfid:%s)",
cb8e9e
-                        uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "cannot find parent for "
cb8e9e
+                              "inode (gfid:%s)", uuid_utoa (inode->gfid));
cb8e9e
         }
cb8e9e
 
cb8e9e
 ignore_parent:
cb8e9e
         ret = inode_path (inode, NULL, &resolvedpath);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG,
cb8e9e
-                        "cannot construct path for inode (gfid:%s)",
cb8e9e
-                        uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "cannot construct path for "
cb8e9e
+                              "inode (gfid:%s)",  uuid_utoa (inode->gfid));
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = quota_loc_fill (loc, inode, parent, resolvedpath);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "cannot fill loc");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "cannot fill loc");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -260,7 +260,9 @@ quota_inode_parent (inode_t *inode, uuid_t pargfid, const char *name)
cb8e9e
 
cb8e9e
         parent = __quota_inode_parent (inode, pargfid, name);
cb8e9e
         if (!parent)
cb8e9e
-                gf_log_callingfn (THIS->name, GF_LOG_ERROR, "Failed to find "
cb8e9e
+                gf_msg_callingfn (THIS->name, GF_LOG_ERROR, 0,
cb8e9e
+                                  Q_MSG_PARENT_NULL,
cb8e9e
+                                  "Failed to find "
cb8e9e
                                   "ancestor for inode (%s)",
cb8e9e
                                   uuid_utoa(inode->gfid));
cb8e9e
 
cb8e9e
@@ -349,7 +351,8 @@ check_ancestory_continue (struct list_head *parents, inode_t *inode,
cb8e9e
         local = frame->local;
cb8e9e
 
cb8e9e
         if (parents && list_empty (parents)) {
cb8e9e
-                gf_log (THIS->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (THIS->name, GF_LOG_WARNING, EIO,
cb8e9e
+                        Q_MSG_ANCESTRY_BUILD_FAILED,
cb8e9e
                         "Couldn't build ancestry for inode (gfid:%s). "
cb8e9e
                         "Without knowing ancestors till root, quota "
cb8e9e
                         "cannot be enforced. "
cb8e9e
@@ -413,7 +416,8 @@ check_ancestory_2_cbk (struct list_head *parents, inode_t *inode,
cb8e9e
                 goto out;
cb8e9e
 
cb8e9e
         if (parents == NULL || list_empty (parents)) {
cb8e9e
-                gf_log (THIS->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (THIS->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_ENFORCEMENT_FAILED,
cb8e9e
                         "Couldn't build ancestry for inode (gfid:%s). "
cb8e9e
                         "Without knowing ancestors till root, quota "
cb8e9e
                         "cannot be enforced.",
cb8e9e
@@ -558,8 +562,9 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ctx = (quota_inode_ctx_t *)(unsigned long)value;
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "quota context is not present in inode (gfid:%s)",
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+			Q_MSG_INODE_CTX_GET_FAILED, "quota context is"
cb8e9e
+			" not present in  inode (gfid:%s)",
cb8e9e
                         uuid_utoa (local->validate_loc.inode->gfid));
cb8e9e
                 op_errno = EINVAL;
cb8e9e
                 goto unwind;
cb8e9e
@@ -567,8 +572,9 @@ quota_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = quota_dict_get_meta (xdata, QUOTA_SIZE_KEY, &size);
cb8e9e
         if (ret == -1) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "dict get failed "
cb8e9e
-                        "on quota size");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+			Q_MSG_SIZE_KEY_MISSING, "quota size key not present "
cb8e9e
+                        "in dict");
cb8e9e
                 op_errno = EINVAL;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -662,7 +668,8 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         parent = inode_parent (local->loc.inode, 0, NULL);
cb8e9e
         if (parent == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "parent is NULL");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+                        Q_MSG_PARENT_NULL, "parent is NULL");
cb8e9e
                 op_errno = EINVAL;
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
@@ -855,8 +862,9 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this,
cb8e9e
 
cb8e9e
                 ret = quota_inode_loc_fill (inode, &local->validate_loc);
cb8e9e
                 if (ret < 0) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "cannot fill loc for inode (gfid:%s), hence "
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                Q_MSG_ENFORCEMENT_FAILED,
cb8e9e
+				"cannot fill loc for inode (gfid:%s), hence "
cb8e9e
                                 "aborting quota-checks and continuing with fop",
cb8e9e
                                 uuid_utoa (inode->gfid));
cb8e9e
                 }
cb8e9e
@@ -876,14 +884,16 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = dict_set_int8 (xdata, QUOTA_SIZE_KEY, 1);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "dict set failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "dict set failed");
cb8e9e
                 ret = -ENOMEM;
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = dict_set_str (xdata, "volume-uuid", priv->volume_uuid);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "dict set failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "dict set failed");
cb8e9e
                 ret = -ENOMEM;
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
@@ -919,12 +929,13 @@ quota_check_limit_continuation (struct list_head *parents, inode_t *inode,
cb8e9e
 
cb8e9e
         if ((op_ret < 0) || list_empty (parents)) {
cb8e9e
                 if (op_ret >= 0) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, EIO,
cb8e9e
+				Q_MSG_ANCESTRY_BUILD_FAILED,
cb8e9e
                                 "Couldn't build ancestry for inode (gfid:%s). "
cb8e9e
-                                "Without knowing ancestors till root, quota "
cb8e9e
+				"Without knowing ancestors till root, quota"
cb8e9e
                                 "cannot be enforced. "
cb8e9e
                                 "Hence, failing fop with EIO",
cb8e9e
-                                uuid_utoa (inode->gfid));
cb8e9e
+				uuid_utoa (inode->gfid));
cb8e9e
                         op_errno = EIO;
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -1184,7 +1195,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
cb8e9e
                         goto done;
cb8e9e
 
cb8e9e
                 if (ret) {
cb8e9e
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to check "
cb8e9e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                                Q_MSG_ENFORCEMENT_FAILED, "Failed to check "
cb8e9e
                                 "quota object limit");
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
@@ -1196,7 +1208,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
cb8e9e
                         goto done;
cb8e9e
 
cb8e9e
                 if (ret) {
cb8e9e
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to check "
cb8e9e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                                Q_MSG_ENFORCEMENT_FAILED, "Failed to check "
cb8e9e
                                 "quota size limit");
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
@@ -1334,9 +1347,9 @@ quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (inode, this, &ctx, 1);
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "cannot create quota "
cb8e9e
-                        "context in inode(gfid:%s)",
cb8e9e
-                        uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                        Q_MSG_INODE_CTX_GET_FAILED, "cannot create quota "
cb8e9e
+                        "context in inode(gfid:%s)", uuid_utoa (inode->gfid));
cb8e9e
                 ret = -1;
cb8e9e
                 *op_errno = ENOMEM;
cb8e9e
                 goto out;
cb8e9e
@@ -1374,11 +1387,12 @@ quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict,
cb8e9e
                                                      loc->parent->gfid);
cb8e9e
                         if (dentry == NULL) {
cb8e9e
                                 /*
cb8e9e
-                                  gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                        "cannot create a new dentry (par:%"
cb8e9e
-                                        PRId64", name:%s) for inode(ino:%"
cb8e9e
-                                        PRId64", gfid:%s)",
cb8e9e
-                                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                                  gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+					  Q_MSG_ENOMEM,
cb8e9e
+                                          "cannot create a new dentry (par:%"
cb8e9e
+-                                          PRId64", name:%s) for inode(ino:%"
cb8e9e
+-                                          PRId64", gfid:%s)",
cb8e9e
+-                                          uuid_utoa (local->loc.inode->gfid));
cb8e9e
                                 */
cb8e9e
                                 ret = -1;
cb8e9e
                                 *op_errno = ENOMEM;
cb8e9e
@@ -1457,14 +1471,15 @@ quota_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
cb8e9e
 
cb8e9e
         ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_KEY, 1);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "dict set of key for hard-limit failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "dict set of key for "
cb8e9e
+                        "hard-limit failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_OBJECTS_KEY, 1);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
                         "dict set of key for quota object limit failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
@@ -1509,15 +1524,17 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = inode_ctx_get (local->loc.inode, this, &ctx_int);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "%s: failed to get the context", local->loc.path);
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_INODE_CTX_GET_FAILED, "%s: failed to get the "
cb8e9e
+			"context", local->loc.path);
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ctx = (quota_inode_ctx_t *)(unsigned long) ctx_int;
cb8e9e
 
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+			Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
                         "quota context not set in %s (gfid:%s)",
cb8e9e
                         local->loc.path, uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
@@ -1551,10 +1568,8 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         if (local->op_ret == -1) {
cb8e9e
                 op_errno = local->op_errno;
cb8e9e
@@ -1647,11 +1662,10 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (fd->inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (fd->inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (fd->inode->gfid));
cb8e9e
         }
cb8e9e
 
cb8e9e
         stub = fop_writev_stub (frame, quota_writev_helper, fd, vector, count,
cb8e9e
@@ -1733,10 +1747,8 @@ quota_mkdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
cb8e9e
         int32_t        op_errno = EINVAL;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         op_errno = local->op_errno;
cb8e9e
 
cb8e9e
@@ -1781,7 +1793,8 @@ quota_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret) {
cb8e9e
                 op_errno = ENOMEM;
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -1836,9 +1849,9 @@ quota_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (inode, this, &ctx, 1);
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "cannot create quota "
cb8e9e
-                        "context in inode(gfid:%s)",
cb8e9e
-                        uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                        Q_MSG_INODE_CTX_GET_FAILED, "cannot create quota "
cb8e9e
+                        "context in inode(gfid:%s)", uuid_utoa (inode->gfid));
cb8e9e
                 op_ret = -1;
cb8e9e
                 op_errno = ENOMEM;
cb8e9e
                 goto unwind;
cb8e9e
@@ -1851,9 +1864,9 @@ quota_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                 dentry = __quota_dentry_new (ctx, (char *)local->loc.name,
cb8e9e
                                              local->loc.parent->gfid);
cb8e9e
                 if (dentry == NULL) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "cannot create a new dentry (name:%s) for "
cb8e9e
-                                "inode(gfid:%s)", local->loc.name,
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                Q_MSG_ENOMEM, "cannot create a new dentry "
cb8e9e
+                                "(name:%s) for inode(gfid:%s)", local->loc.name,
cb8e9e
                                 uuid_utoa (local->loc.inode->gfid));
cb8e9e
                         op_ret = -1;
cb8e9e
                         op_errno = ENOMEM;
cb8e9e
@@ -1881,12 +1894,10 @@ quota_create_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
 
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
+
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
 
cb8e9e
         if (local->op_ret == -1) {
cb8e9e
                 op_errno = local->op_errno;
cb8e9e
@@ -1931,7 +1942,8 @@ quota_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 op_errno = ENOMEM;
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
@@ -1987,8 +1999,9 @@ quota_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         ctx = (quota_inode_ctx_t *)(unsigned long)value;
cb8e9e
 
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "quota context not set in inode (gfid:%s)",
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+			Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
+			"quota context not set inode (gfid:%s)",
cb8e9e
                         uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
@@ -2036,7 +2049,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2079,11 +2093,10 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (inode, this, &ctx, 0);
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2093,13 +2106,15 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                         if ((strcmp (dentry->name, local->loc.name) == 0) &&
cb8e9e
                             (gf_uuid_compare (local->loc.parent->gfid,
cb8e9e
                                            dentry->par) == 0)) {
cb8e9e
-                                found = 1;
cb8e9e
-                                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                        "new entry being linked (name:%s) for "
cb8e9e
-                                        "inode (gfid:%s) is already present "
cb8e9e
-                                        "in inode-dentry-list", dentry->name,
cb8e9e
-                                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
-                                break;
cb8e9e
+                               found = 1;
cb8e9e
+
cb8e9e
+                               gf_msg_debug (this->name, 0, "new entry being"
cb8e9e
+                                            " linked (name:%s) for inode "
cb8e9e
+                                            "(gfid:%s) is already present "
cb8e9e
+                                            "in inode-dentry-list",
cb8e9e
+                                            dentry->name,
cb8e9e
+                                           uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                               break;
cb8e9e
                         }
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -2108,9 +2123,10 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                                                      (char *)local->loc.name,
cb8e9e
                                                      local->loc.parent->gfid);
cb8e9e
                         if (dentry == NULL) {
cb8e9e
-                                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                        "cannot create a new dentry (name:%s) "
cb8e9e
-                                        "for inode(gfid:%s)", local->loc.name,
cb8e9e
+                                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                        Q_MSG_ENOMEM,
cb8e9e
+					"cannot create a new dentry (name:%s)"
cb8e9e
+					"for inode(gfid:%s)", local->loc.name,
cb8e9e
                                         uuid_utoa (local->loc.inode->gfid));
cb8e9e
                                 op_ret = -1;
cb8e9e
                                 op_errno = ENOMEM;
cb8e9e
@@ -2142,10 +2158,8 @@ quota_link_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         op_errno = local->op_errno;
cb8e9e
 
cb8e9e
@@ -2192,7 +2206,8 @@ quota_link_continue (call_frame_t *frame)
cb8e9e
                                                   local->newloc.parent,
cb8e9e
                                                   &common_ancestor);
cb8e9e
                 if (ret < 0 || gf_uuid_is_null(common_ancestor)) {
cb8e9e
-                        gf_log (this->name, GF_LOG_ERROR, "failed to get "
cb8e9e
+                        gf_msg (this->name, GF_LOG_ERROR, ESTALE,
cb8e9e
+                                Q_MSG_ANCESTRY_BUILD_FAILED, "failed to get "
cb8e9e
                                 "common_ancestor for %s and %s",
cb8e9e
                                 local->oldloc.path, local->newloc.path);
cb8e9e
                         op_errno = ESTALE;
cb8e9e
@@ -2223,11 +2238,10 @@ quota_link_continue (call_frame_t *frame)
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
         }
cb8e9e
 
cb8e9e
         LOCK (&local->lock);
cb8e9e
@@ -2274,9 +2288,9 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
cb8e9e
         /* No need to check quota limit if src and dst parents are same */
cb8e9e
         if (oldloc->parent && newloc->parent &&
cb8e9e
             !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "link %s -> %s are "
cb8e9e
-                        "in the same directory, so skip check limit",
cb8e9e
-                        oldloc->path, newloc->path);
cb8e9e
+                gf_msg_debug (this->name, GF_LOG_DEBUG, "link %s -> %s are "
cb8e9e
+                              "in the same directory, so skip check limit",
cb8e9e
+                              oldloc->path, newloc->path);
cb8e9e
                 goto off;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2292,19 +2306,22 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, newloc);
cb8e9e
         if (ret == -1) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->oldloc, oldloc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->newloc, newloc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2359,12 +2376,8 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                op_ret = -1;
cb8e9e
-                op_errno = EINVAL;
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) {
cb8e9e
                 size = buf->ia_blocks * 512;
cb8e9e
@@ -2376,11 +2389,10 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0);
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
 
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
@@ -2397,10 +2409,9 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                                    (gf_uuid_compare (local->newloc.parent->gfid,
cb8e9e
                                                   dentry->par) == 0)) {
cb8e9e
                                 new_dentry_found = 1;
cb8e9e
-                                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                        "new entry being linked (name:%s) for "
cb8e9e
-                                        "inode (gfid:%s) is already present "
cb8e9e
-                                        "in inode-dentry-list", dentry->name,
cb8e9e
+                                gf_msg_debug (this->name, 0, "new entry being "
cb8e9e
+                                       "linked (name:%s) for inode (gfid:%s) "
cb8e9e
+                                       "is in inode-dentry-list", dentry->name,
cb8e9e
                                         uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
                         }
cb8e9e
 
cb8e9e
@@ -2411,9 +2422,9 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                 if (old_dentry != NULL) {
cb8e9e
                         __quota_dentry_free (old_dentry);
cb8e9e
                 } else {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "dentry corresponding to the path just renamed "
cb8e9e
-                                "(name:%s) is not present", local->oldloc.name);
cb8e9e
+                        gf_msg_debug (this->name, 0, "dentry corresponding"
cb8e9e
+                                     "the path just renamed (name:%s) is not"
cb8e9e
+                                     " present", local->oldloc.name);
cb8e9e
                 }
cb8e9e
 
cb8e9e
                 if (!new_dentry_found) {
cb8e9e
@@ -2421,11 +2432,12 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                                                      (char *)local->newloc.name,
cb8e9e
                                                      local->newloc.parent->gfid);
cb8e9e
                         if (dentry == NULL) {
cb8e9e
-                                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                        "cannot create a new dentry (name:%s) "
cb8e9e
-                                        "for inode(gfid:%s)",
cb8e9e
-                                        local->newloc.name,
cb8e9e
-                                        uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
+                                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                        Q_MSG_ENOMEM,
cb8e9e
+					"cannot create a new dentry (name:%s) "
cb8e9e
+					"for inode(gfid:%s)",
cb8e9e
+					local->newloc.name,
cb8e9e
+                                        uuid_utoa (local->newloc.inode->gfid));
cb8e9e
                                 op_ret = -1;
cb8e9e
                                 op_errno = ENOMEM;
cb8e9e
                                 goto unlock;
cb8e9e
@@ -2456,10 +2468,8 @@ quota_rename_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         op_errno = local->op_errno;
cb8e9e
 
cb8e9e
@@ -2505,8 +2515,8 @@ quota_rename_get_size_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = dict_get_bin (xdata, QUOTA_SIZE_KEY, (void **) &size);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "size key not present in dict");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+			Q_MSG_SIZE_KEY_MISSING, "size key not present in dict");
cb8e9e
                 op_errno = EINVAL;
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
@@ -2542,7 +2552,8 @@ quota_rename_continue (call_frame_t *frame)
cb8e9e
                                           local->newloc.parent,
cb8e9e
                                           &common_ancestor);
cb8e9e
         if (ret < 0 || gf_uuid_is_null(common_ancestor)) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "failed to get "
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ESTALE,
cb8e9e
+                        Q_MSG_ANCESTRY_BUILD_FAILED, "failed to get "
cb8e9e
                         "common_ancestor for %s and %s",
cb8e9e
                         local->oldloc.path, local->newloc.path);
cb8e9e
                 op_errno = ESTALE;
cb8e9e
@@ -2559,11 +2570,14 @@ quota_rename_continue (call_frame_t *frame)
cb8e9e
         if (QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) {
cb8e9e
                 ret = quota_inode_ctx_get (local->oldloc.inode, this, &ctx, 0);
cb8e9e
                 if (ctx == NULL) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                                Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
                                 "quota context not set in inode (gfid:%s), "
cb8e9e
                                 "considering file size as zero while enforcing "
cb8e9e
                                 "quota on new ancestry",
cb8e9e
                                 uuid_utoa (local->oldloc.inode->gfid));
cb8e9e
+
cb8e9e
+
cb8e9e
                         local->delta = 0;
cb8e9e
                 } else {
cb8e9e
 
cb8e9e
@@ -2619,9 +2633,9 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
cb8e9e
         /* No need to check quota limit if src and dst parents are same */
cb8e9e
         if (oldloc->parent && newloc->parent &&
cb8e9e
             !gf_uuid_compare(oldloc->parent->gfid, newloc->parent->gfid)) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "rename %s -> %s are "
cb8e9e
-                        "in the same directory, so skip check limit",
cb8e9e
-                        oldloc->path, newloc->path);
cb8e9e
+                gf_msg_debug (this->name, 0, "rename %s -> %s are "
cb8e9e
+                              "in the same directory, so skip check limit",
cb8e9e
+                              oldloc->path, newloc->path);
cb8e9e
                 goto off;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2634,13 +2648,15 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->oldloc, oldloc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->newloc, newloc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2697,11 +2713,10 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 1);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
 
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
@@ -2713,10 +2728,11 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                 dentry = __quota_dentry_new (ctx, (char *)local->loc.name,
cb8e9e
                                              local->loc.parent->gfid);
cb8e9e
                 if (dentry == NULL) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "cannot create a new dentry (name:%s) for "
cb8e9e
-                                "inode(gfid:%s)", local->loc.name,
cb8e9e
-                                uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                Q_MSG_ENOMEM, "cannot create "
cb8e9e
+				"a new dentry (name:%s) for inode(gfid:%s)",
cb8e9e
+				local->loc.name,
cb8e9e
+				uuid_utoa (local->loc.inode->gfid));
cb8e9e
                         op_ret = -1;
cb8e9e
                         op_errno = ENOMEM;
cb8e9e
                 }
cb8e9e
@@ -2740,10 +2756,8 @@ quota_symlink_helper (call_frame_t *frame, xlator_t *this, const char *linkpath,
cb8e9e
         quota_priv_t  *priv     = NULL;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
@@ -2787,7 +2801,8 @@ quota_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2835,18 +2850,15 @@ quota_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2884,7 +2896,8 @@ quota_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
cb8e9e
 
cb8e9e
         ret =  loc_copy (&local->loc, loc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -2917,18 +2930,15 @@ quota_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3018,7 +3028,7 @@ dict_set:
cb8e9e
         if (ret < 0)
cb8e9e
                 goto out;
cb8e9e
 
cb8e9e
-        gf_log (this->name, GF_LOG_DEBUG, "str = %s", dir_limit);
cb8e9e
+        gf_msg_debug (this->name, 0, "str = %s", dir_limit);
cb8e9e
 
cb8e9e
         QUOTA_STACK_UNWIND (getxattr, frame, 0, 0, dict, NULL);
cb8e9e
 
cb8e9e
@@ -3083,19 +3093,15 @@ quota_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
                 if (!IA_ISDIR (buf->ia_type)) {
cb8e9e
-                        gf_log (this->name, GF_LOG_DEBUG,
cb8e9e
-                                "quota context is NULL on "
cb8e9e
-                                "inode (%s). "
cb8e9e
-                                "If quota is not enabled recently and crawler "
cb8e9e
-                                "has finished crawling, its an error",
cb8e9e
+                  gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                                " (%s). If quota is not enabled recently and "
cb8e9e
+                                "crawler has finished crawling, its an error",
cb8e9e
                                 uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -3134,7 +3140,8 @@ quota_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
cb8e9e
         frame->local = local;
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto unwind;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3168,19 +3175,15 @@ quota_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
                 if (!IA_ISDIR (buf->ia_type)) {
cb8e9e
-                        gf_log (this->name, GF_LOG_DEBUG,
cb8e9e
-                                "quota context is NULL on "
cb8e9e
-                                "inode (%s). "
cb8e9e
-                                "If quota is not enabled recently and crawler "
cb8e9e
-                                "has finished crawling, its an error",
cb8e9e
+                  gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                                " (%s). If quota is not enabled recently and "
cb8e9e
+                                "crawler has finished crawling, its an error",
cb8e9e
                                 uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -3249,18 +3252,15 @@ quota_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3298,7 +3298,8 @@ quota_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto unwind;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3333,18 +3334,15 @@ quota_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3412,18 +3410,15 @@ quota_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
cb8e9e
-                        "inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler has "
cb8e9e
-                        "finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3490,18 +3485,15 @@ quota_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
                 if (!IA_ISDIR (statpost->ia_type)) {
cb8e9e
-                        gf_log (this->name, GF_LOG_DEBUG, "quota context is "
cb8e9e
-                                "NULL on inode (%s). "
cb8e9e
-                                "If quota is not enabled recently and crawler "
cb8e9e
-                                "has finished crawling, its an error",
cb8e9e
+                  gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                                " (%s). If quota is not enabled recently and "
cb8e9e
+                                "crawler has finished crawling, its an error",
cb8e9e
                                 uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -3543,7 +3535,8 @@ quota_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret < 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto unwind;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -3577,18 +3570,15 @@ quota_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
         }
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, out);
cb8e9e
 
cb8e9e
         quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
                 if (!IA_ISDIR (statpost->ia_type)) {
cb8e9e
-                        gf_log (this->name, GF_LOG_DEBUG, "quota context is "
cb8e9e
-                                "NULL on inode (%s). "
cb8e9e
-                                "If quota is not enabled recently and crawler "
cb8e9e
-                                "has finished crawling, its an error",
cb8e9e
+                  gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                                " (%s). If quota is not enabled recently and "
cb8e9e
+                                "crawler has finished crawling, its an error",
cb8e9e
                                 uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -3663,8 +3653,10 @@ quota_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (inode, this, &ctx, 1);
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "cannot create quota "
cb8e9e
-                        "context in inode (gfid:%s)", uuid_utoa (inode->gfid));
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
+                        "cannot create quota context in "
cb8e9e
+                        "inode(gfid:%s)", uuid_utoa (inode->gfid));
cb8e9e
                 op_ret = -1;
cb8e9e
                 op_errno = ENOMEM;
cb8e9e
                 goto unwind;
cb8e9e
@@ -3677,10 +3669,10 @@ quota_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
                 dentry = __quota_dentry_new (ctx, (char *)local->loc.name,
cb8e9e
                                              local->loc.parent->gfid);
cb8e9e
                 if (dentry == NULL) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "cannot create a new dentry (name:%s) for "
cb8e9e
-                                "inode(gfid:%s)", local->loc.name,
cb8e9e
-                                uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                Q_MSG_ENOMEM, "cannot create a new dentry "
cb8e9e
+                                "(name:%s) for inode(gfid:%s)", local->loc.name,
cb8e9e
+				uuid_utoa (local->loc.inode->gfid));
cb8e9e
                         op_ret = -1;
cb8e9e
                         op_errno = ENOMEM;
cb8e9e
                         goto unlock;
cb8e9e
@@ -3705,10 +3697,8 @@ quota_mknod_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
cb8e9e
         quota_priv_t  *priv     = NULL;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
@@ -3753,7 +3743,8 @@ quota_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
cb8e9e
 
cb8e9e
         ret = loc_copy (&local->loc, loc);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "loc_copy failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "loc_copy failed");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -4111,11 +4102,8 @@ quota_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 	 * cookie, and it would only do so if the value was non-NULL.  This
cb8e9e
 	 * check is therefore just routine defensive coding.
cb8e9e
 	 */
cb8e9e
-	if (!inode) {
cb8e9e
-		gf_log(this->name,GF_LOG_WARNING,
cb8e9e
-		       "null inode, cannot adjust for quota");
cb8e9e
-		goto unwind;
cb8e9e
-	}
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", inode, unwind);
cb8e9e
 
cb8e9e
         inode_ctx_get (inode, this, &value);
cb8e9e
         ctx = (quota_inode_ctx_t *)(unsigned long)value;
cb8e9e
@@ -4149,8 +4137,9 @@ quota_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = dict_set_int8 (xdata, "quota-deem-statfs", 1);
cb8e9e
         if (-1 == ret)
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "Dict set failed, "
cb8e9e
-                        "deem-statfs option may have no effect");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
cb8e9e
+                        Q_MSG_ENOMEM, "Dict set failed, deem-statfs option may "
cb8e9e
+                        "have no effect");
cb8e9e
 
cb8e9e
 unwind:
cb8e9e
         QUOTA_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata);
cb8e9e
@@ -4215,8 +4204,9 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ctx = (quota_inode_ctx_t *)(unsigned long)value;
cb8e9e
         if ((ret == -1) || (ctx == NULL)) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "quota context is not present in inode (gfid:%s)",
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+			Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
+			"quota context is not present in inode (gfid:%s)",
cb8e9e
                         uuid_utoa (local->validate_loc.inode->gfid));
cb8e9e
                 op_errno = EINVAL;
cb8e9e
                 goto resume;
cb8e9e
@@ -4224,8 +4214,9 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = quota_dict_get_meta (xdata, QUOTA_SIZE_KEY, &size);
cb8e9e
         if (ret == -1) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "dict get failed "
cb8e9e
-                        "on quota size");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
cb8e9e
+			Q_MSG_SIZE_KEY_MISSING, "size key not present in "
cb8e9e
+                        "dict");
cb8e9e
                 op_errno = EINVAL;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -4259,7 +4250,8 @@ quota_get_limit_dir_continuation (struct list_head *parents, inode_t *inode,
cb8e9e
 
cb8e9e
         if ((op_ret < 0) || list_empty (parents)) {
cb8e9e
                 if (op_ret >= 0) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, EIO,
cb8e9e
+                                Q_MSG_ANCESTRY_BUILD_FAILED,
cb8e9e
                                 "Couldn't build ancestry for inode (gfid:%s). "
cb8e9e
                                 "Without knowing ancestors till root, quota "
cb8e9e
                                 "cannot be enforced. "
cb8e9e
@@ -4345,8 +4337,8 @@ quota_get_limit_dir (call_frame_t *frame, inode_t *cur_inode, xlator_t *this)
cb8e9e
         return;
cb8e9e
 
cb8e9e
 off:
cb8e9e
-        gf_log (this->name, GF_LOG_DEBUG,
cb8e9e
-                "No limit set on the inode or it's parents.");
cb8e9e
+        gf_msg_debug (this->name, 0,
cb8e9e
+                      "No limit set on the inode or it's parents.");
cb8e9e
 
cb8e9e
         QUOTA_STACK_WIND_TAIL (frame, FIRST_CHILD(this),
cb8e9e
                                FIRST_CHILD(this)->fops->statfs,
cb8e9e
@@ -4429,7 +4421,6 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
cb8e9e
                 gf_log (this->name, GF_LOG_ERROR,
cb8e9e
                         "Missing inode, can't adjust for quota");
cb8e9e
 
cb8e9e
-
cb8e9e
 off:
cb8e9e
         STACK_WIND_TAIL (frame, FIRST_CHILD(this),
cb8e9e
                          FIRST_CHILD(this)->fops->statfs, loc, xdata);
cb8e9e
@@ -4510,8 +4501,9 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
cb8e9e
         if (dict) {
cb8e9e
                 ret = dict_set_int8 (dict, QUOTA_LIMIT_KEY, 1);
cb8e9e
                 if (ret < 0) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "dict set of key for hard-limit failed");
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+				Q_MSG_ENOMEM,
cb8e9e
+				"dict set of key for hard-limit");
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
         }
cb8e9e
@@ -4519,8 +4511,9 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
cb8e9e
         if (dict) {
cb8e9e
                 ret = dict_set_int8 (dict, QUOTA_LIMIT_OBJECTS_KEY, 1);
cb8e9e
                 if (ret < 0) {
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "dict set of key for hard-limit failed");
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
cb8e9e
+                                Q_MSG_ENOMEM, "dict set of key for hard-limit "
cb8e9e
+                                "failed");
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
         }
cb8e9e
@@ -4568,16 +4561,18 @@ quota_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
cb8e9e
 
cb8e9e
         ret = inode_ctx_get (local->loc.inode, this, &ctx_int);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "%s: failed to get the context", local->loc.path);
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
+			"%s: failed to get the context", local->loc.path);
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
         ctx = (quota_inode_ctx_t *)(unsigned long) ctx_int;
cb8e9e
 
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                        "quota context not set in %s (gfid:%s)",
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+			Q_MSG_INODE_CTX_GET_FAILED,
cb8e9e
+			"quota context not set in %s (gfid:%s)",
cb8e9e
                         local->loc.path, uuid_utoa (local->loc.inode->gfid));
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
@@ -4605,10 +4600,8 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
         quota_priv_t  *priv     = NULL;
cb8e9e
 
cb8e9e
         local = frame->local;
cb8e9e
-        if (local == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "local is NULL");
cb8e9e
-                goto unwind;
cb8e9e
-        }
cb8e9e
+
cb8e9e
+        GF_VALIDATE_OR_GOTO ("quota", local, unwind);
cb8e9e
 
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
@@ -4676,11 +4669,10 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
cb8e9e
 
cb8e9e
         ret = quota_inode_ctx_get (fd->inode, this, &ctx, 0);
cb8e9e
         if (ctx == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_DEBUG, "quota context is "
cb8e9e
-                        "NULL on inode (%s). "
cb8e9e
-                        "If quota is not enabled recently and crawler "
cb8e9e
-                        "has finished crawling, its an error",
cb8e9e
-                        uuid_utoa (local->loc.inode->gfid));
cb8e9e
+                gf_msg_debug (this->name, 0, "quota context is NULL on inode"
cb8e9e
+                              " (%s). If quota is not enabled recently and "
cb8e9e
+                              "crawler has finished crawling, its an error",
cb8e9e
+                              uuid_utoa (local->loc.inode->gfid));
cb8e9e
         }
cb8e9e
 
cb8e9e
         stub = fop_fallocate_stub(frame, quota_fallocate_helper, fd, mode,
cb8e9e
@@ -4748,8 +4740,9 @@ quota_log_helper (char **usage_str, int64_t cur_size, inode_t *inode,
cb8e9e
 
cb8e9e
         *usage_str = gf_uint64_2human_readable (cur_size);
cb8e9e
         if (!(*usage_str))
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "integer to string "
cb8e9e
-                        "conversion failed Reason:\"Cannot allocate memory\"");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "integer to string conversion failed Reason"
cb8e9e
+                        ":\"Cannot allocate memory\"");
cb8e9e
 
cb8e9e
         inode_path (inode, NULL, path);
cb8e9e
         if (!(*path))
cb8e9e
@@ -4784,8 +4777,9 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
cb8e9e
                 quota_log_helper (&usage_str, cur_size, inode,
cb8e9e
                                   &path, &cur_time);
cb8e9e
 
cb8e9e
-                gf_log (this->name, GF_LOG_ALERT, "Usage crossed "
cb8e9e
-                        "soft limit: %s used by %s", usage_str, path);
cb8e9e
+                gf_msg (this->name, GF_LOG_ALERT, 0,
cb8e9e
+                        Q_MSG_CROSSED_SOFT_LIMIT, "Usage crossed soft limit: "
cb8e9e
+                        "%s used by %s", usage_str, path);
cb8e9e
                 ctx->prev_log = cur_time;
cb8e9e
         }
cb8e9e
         /* Usage is above soft limit */
cb8e9e
@@ -4795,8 +4789,9 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
cb8e9e
                 quota_log_helper (&usage_str, cur_size, inode,
cb8e9e
                                   &path, &cur_time);
cb8e9e
 
cb8e9e
-                gf_log (this->name, GF_LOG_ALERT, "Usage is above "
cb8e9e
-                        "soft limit: %s used by %s", usage_str, path);
cb8e9e
+                gf_msg (this->name, GF_LOG_ALERT, 0, Q_MSG_CROSSED_SOFT_LIMIT,
cb8e9e
+                        "Usage is above soft limit: %s used by %s",
cb8e9e
+                        usage_str, path);
cb8e9e
                 ctx->prev_log = cur_time;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -4815,8 +4810,8 @@ mem_acct_init (xlator_t *this)
cb8e9e
         ret = xlator_mem_acct_init (this, gf_quota_mt_end + 1);
cb8e9e
 
cb8e9e
         if (ret != 0) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING, "Memory accounting"
cb8e9e
-                        "init failed");
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "Memory accounting init failed");
cb8e9e
                 return ret;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -4864,14 +4859,16 @@ init (xlator_t *this)
cb8e9e
 
cb8e9e
         if ((this->children == NULL)
cb8e9e
             || this->children->next) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR,
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                        Q_MSG_INVALID_VOLFILE,
cb8e9e
                         "FATAL: quota (%s) not configured with "
cb8e9e
                         "exactly one child", this->name);
cb8e9e
                 return -1;
cb8e9e
         }
cb8e9e
 
cb8e9e
         if (this->parents == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_INVALID_VOLFILE,
cb8e9e
                         "dangling volume. check volfile");
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -4893,8 +4890,8 @@ init (xlator_t *this)
cb8e9e
         this->local_pool = mem_pool_new (quota_local_t, 64);
cb8e9e
         if (!this->local_pool) {
cb8e9e
                 ret = -1;
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR,
cb8e9e
-                        "failed to create local_t's memory pool");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
cb8e9e
+			Q_MSG_ENOMEM, "failed to create local_t's memory pool");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -4902,8 +4899,9 @@ init (xlator_t *this)
cb8e9e
                 rpc = quota_enforcer_init (this, this->options);
cb8e9e
                 if (rpc == NULL) {
cb8e9e
                         ret = -1;
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "quota enforcer rpc init failed");
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+				Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED,
cb8e9e
+				"quota enforcer rpc init failed");
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
 
cb8e9e
@@ -4947,8 +4945,9 @@ reconfigure (xlator_t *this, dict_t *options)
cb8e9e
                                                       this->options);
cb8e9e
                 if (priv->rpc_clnt == NULL) {
cb8e9e
                         ret = -1;
cb8e9e
-                        gf_log (this->name, GF_LOG_WARNING,
cb8e9e
-                                "quota enforcer rpc init failed");
cb8e9e
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+				Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED,
cb8e9e
+				"quota enforcer rpc init failed");
cb8e9e
                         goto out;
cb8e9e
                 }
cb8e9e
 
cb8e9e
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
cb8e9e
index 566302c..56876f0 100644
cb8e9e
--- a/xlators/features/quota/src/quota.h
cb8e9e
+++ b/xlators/features/quota/src/quota.h
cb8e9e
@@ -36,6 +36,7 @@
cb8e9e
 #include "compat-errno.h"
cb8e9e
 #include "protocol-common.h"
cb8e9e
 #include "quota-common-utils.h"
cb8e9e
+#include "quota-messages.h"
cb8e9e
 
cb8e9e
 #define DIRTY                   "dirty"
cb8e9e
 #define SIZE                    "size"
cb8e9e
@@ -79,8 +80,9 @@
cb8e9e
                 var = GF_CALLOC (sizeof (type), 1,      \
cb8e9e
                                  gf_quota_mt_##type);   \
cb8e9e
                 if (!var) {                             \
cb8e9e
-                        gf_log ("", GF_LOG_ERROR,       \
cb8e9e
-                                "out of memory");    \
cb8e9e
+                        gf_msg ("", GF_LOG_ERROR,       \
cb8e9e
+                                ENOMEM, Q_MSG_ENOMEM,   \
cb8e9e
+				"out of memory");       \
cb8e9e
                         ret = -1;                       \
cb8e9e
                         goto label;                     \
cb8e9e
                 }                                       \
cb8e9e
diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c
cb8e9e
index 6f2f6e8..6c9c40a 100644
cb8e9e
--- a/xlators/features/quota/src/quotad-aggregator.c
cb8e9e
+++ b/xlators/features/quota/src/quotad-aggregator.c
cb8e9e
@@ -90,7 +90,8 @@ quotad_aggregator_submit_reply (call_frame_t *frame, rpcsvc_request_t *req,
cb8e9e
 
cb8e9e
         iob = quotad_serialize_reply (req, arg, &rsp, xdrproc);
cb8e9e
         if (!iob) {
cb8e9e
-                gf_log ("", GF_LOG_ERROR, "Failed to serialize reply");
cb8e9e
+                gf_msg ("", GF_LOG_ERROR, 0, Q_MSG_DICT_SERIALIZE_FAIL,
cb8e9e
+                        "Failed to serialize reply");
cb8e9e
                 goto ret;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -148,7 +149,9 @@ quotad_aggregator_getlimit_cbk (xlator_t *this, call_frame_t *frame,
cb8e9e
 out:
cb8e9e
         rsp->op_ret = ret;
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "failed to unserialize "
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                        Q_MSG_DICT_UNSERIALIZE_FAIL,
cb8e9e
+                        "failed to unserialize "
cb8e9e
                         "nameless lookup rsp");
cb8e9e
                 goto reply;
cb8e9e
         }
cb8e9e
@@ -193,7 +196,8 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req)
cb8e9e
         ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req);
cb8e9e
         if (ret < 0)  {
cb8e9e
                 //failed to decode msg;
cb8e9e
-                gf_log ("", GF_LOG_ERROR, "xdr decoding error");
cb8e9e
+                gf_msg ("this->name", GF_LOG_ERROR, 0, Q_MSG_XDR_DECODE_ERROR,
cb8e9e
+                        "xdr decoding error");
cb8e9e
                 req->rpc_err = GARBAGE_ARGS;
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
@@ -203,8 +207,10 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req)
cb8e9e
                 ret = dict_unserialize (cli_req.dict.dict_val,
cb8e9e
                                         cli_req.dict.dict_len, &dict);
cb8e9e
                 if (ret < 0) {
cb8e9e
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to "
cb8e9e
-                                "unserialize req-buffer to dictionary");
cb8e9e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
+                                Q_MSG_DICT_UNSERIALIZE_FAIL,
cb8e9e
+                                "Failed to unserialize req-buffer to "
cb8e9e
+                                "dictionary");
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
         }
cb8e9e
@@ -230,8 +236,8 @@ quotad_aggregator_getlimit (rpcsvc_request_t *req)
cb8e9e
 
cb8e9e
         ret = dict_set_int32 (state->xdata, QUOTA_LIMIT_OBJECTS_KEY, 42);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_ERROR, "Failed to set "
cb8e9e
-                        "QUOTA_LIMIT_OBJECTS_KEY");
cb8e9e
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM,
cb8e9e
+                        "Failed to set QUOTA_LIMIT_OBJECTS_KEY");
cb8e9e
                 goto err;
cb8e9e
         }
cb8e9e
 
cb8e9e
@@ -384,7 +390,8 @@ quotad_aggregator_init (xlator_t *this)
cb8e9e
         /* RPC related */
cb8e9e
         priv->rpcsvc = rpcsvc_init (this, this->ctx, this->options, 0);
cb8e9e
         if (priv->rpcsvc == NULL) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_RPCSVC_INIT_FAILED,
cb8e9e
                         "creation of rpcsvc failed");
cb8e9e
                 ret = -1;
cb8e9e
                 goto out;
cb8e9e
@@ -393,7 +400,8 @@ quotad_aggregator_init (xlator_t *this)
cb8e9e
         ret = rpcsvc_create_listeners (priv->rpcsvc, this->options,
cb8e9e
                                        this->name);
cb8e9e
         if (ret < 1) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_RPCSVC_LISTENER_CREATION_FAILED,
cb8e9e
                         "creation of listener failed");
cb8e9e
                 ret = -1;
cb8e9e
                 goto out;
cb8e9e
@@ -404,7 +412,8 @@ quotad_aggregator_init (xlator_t *this)
cb8e9e
 
cb8e9e
         ret = rpcsvc_program_register (priv->rpcsvc, &quotad_aggregator_prog);
cb8e9e
         if (ret) {
cb8e9e
-                gf_log (this->name, GF_LOG_WARNING,
cb8e9e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
cb8e9e
+                        Q_MSG_RPCSVC_REGISTER_FAILED,
cb8e9e
                         "registration of program (name:%s, prognum:%d, "
cb8e9e
                         "progver:%d) failed", quotad_aggregator_prog.progname,
cb8e9e
                         quotad_aggregator_prog.prognum,
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e