Blob Blame History Raw
From 4f5ae8f4d37677c2ee104a57c709501de467fd76 Mon Sep 17 00:00:00 2001
From: Hari Gowtham <hgowtham@dhcp35-85.lab.eng.blr.redhat.com>
Date: Wed, 27 May 2015 13:17:30 +0530
Subject: [PATCH 109/129] Porting new log messages for posix

Change-Id: I29bdeefb755805858e3cb1817b679cb6f9a476a9
BUG: 1231780
Signed-off-by: Hari Gowtham <hgowtham@dhcp35-85.lab.eng.blr.redhat.com>
Reviewed-on: http://review.gluster.org/9893
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50991
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
---
 glusterfsd/src/glusterfsd-messages.h       |    2 +-
 libglusterfs/src/glfs-message-id.h         |    1 +
 xlators/storage/posix/src/Makefile.am      |    3 +-
 xlators/storage/posix/src/posix-aio.c      |   76 +-
 xlators/storage/posix/src/posix-handle.c   |  178 +++--
 xlators/storage/posix/src/posix-handle.h   |   53 +-
 xlators/storage/posix/src/posix-helpers.c  |  323 +++++----
 xlators/storage/posix/src/posix-messages.h |  899 ++++++++++++++++++++
 xlators/storage/posix/src/posix.c          | 1228 ++++++++++++++--------------
 9 files changed, 1872 insertions(+), 891 deletions(-)
 create mode 100644 xlators/storage/posix/src/posix-messages.h

diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h
index ba3b7a5..1e1d170 100644
--- a/glusterfsd/src/glusterfsd-messages.h
+++ b/glusterfsd/src/glusterfsd-messages.h
@@ -41,7 +41,7 @@
  */
 
 #define GLFS_COMP_BASE          GLFS_MSGID_COMP_GLUSTERFSD
-#define GLFS_NUM_MESSAGES       33
+#define GLFS_NUM_MESSAGES       34
 #define GLFS_MSGID_END          (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1)
 /* Messaged with message IDs */
 #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages"
diff --git a/libglusterfs/src/glfs-message-id.h b/libglusterfs/src/glfs-message-id.h
index e28327d..df7caa2 100644
--- a/libglusterfs/src/glfs-message-id.h
+++ b/libglusterfs/src/glfs-message-id.h
@@ -65,6 +65,7 @@
 #define GLFS_MSGID_COMP_DHT_END            GLFS_MSGID_COMP_DHT +\
                                            GLFS_MSGID_SEGMENT
 
+
 /* there is no component called 'common', however reserving this segment
  * for common actions/errors like dict_{get/set}, memory accounting*/
 
diff --git a/xlators/storage/posix/src/Makefile.am b/xlators/storage/posix/src/Makefile.am
index 509b052..9dd89e7 100644
--- a/xlators/storage/posix/src/Makefile.am
+++ b/xlators/storage/posix/src/Makefile.am
@@ -8,7 +8,8 @@ posix_la_SOURCES = posix.c posix-helpers.c posix-handle.c posix-aio.c
 posix_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(LIBAIO) \
                   $(ACL_LIBS)
 
-noinst_HEADERS = posix.h posix-mem-types.h posix-handle.h posix-aio.h
+noinst_HEADERS = posix.h posix-mem-types.h posix-handle.h posix-aio.h \
+		 posix-messages.h
 
 AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
             -I$(top_srcdir)/rpc/xdr/src \
diff --git a/xlators/storage/posix/src/posix-aio.c b/xlators/storage/posix/src/posix-aio.c
index c3bbddd..3d4d2f6 100644
--- a/xlators/storage/posix/src/posix-aio.c
+++ b/xlators/storage/posix/src/posix-aio.c
@@ -16,6 +16,7 @@
 #include "glusterfs.h"
 #include "posix.h"
 #include <sys/uio.h>
+#include "posix-messages.h"
 
 #ifdef HAVE_LIBAIO
 #include <libaio.h>
@@ -55,9 +56,9 @@ __posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags,
 	}
 
 	if (ret) {
-		gf_log (THIS->name, GF_LOG_WARNING,
-			"fcntl() failed (%s). fd=%d flags=%d pfd->odirect=%d",
-			strerror (errno), pfd->fd, flags, pfd->odirect);
+		gf_msg (THIS->name, GF_LOG_WARNING, errno, P_MSG_FCNTL_FAILED,
+			"fcntl() failed. fd=%d flags=%d pfd->odirect=%d",
+			 pfd->fd, flags, pfd->odirect);
 	}
 }
 
@@ -101,11 +102,11 @@ posix_aio_readv_complete (struct posix_aio_cb *paiocb, int res, int res2)
         if (res < 0) {
                 op_ret = -1;
                 op_errno = -res;
-		gf_log (this->name, GF_LOG_ERROR,
-			"readv(async) failed fd=%d,size=%lu,offset=%llu (%d/%s)",
+		gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_READV_FAILED,
+			"readv(async) failed fd=%d,size=%lu,offset=%llu (%d)",
 			_fd, paiocb->iocb.u.c.nbytes,
 			(unsigned long long) paiocb->offset,
-			res, strerror (op_errno));
+			res);
                 goto out;
         }
 
@@ -113,9 +114,8 @@ posix_aio_readv_complete (struct posix_aio_cb *paiocb, int res, int res2)
 	if (ret != 0) {
 		op_ret = -1;
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fstat failed on fd=%d: %s", _fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED,
+                        "fstat failed on fd=%d", _fd);
                 goto out;
 	}
 
@@ -182,7 +182,7 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto err;
         }
@@ -190,7 +190,8 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
 
         if (!size) {
                 op_errno = EINVAL;
-                gf_log (this->name, GF_LOG_WARNING, "size=%"GF_PRI_SIZET, size);
+                gf_msg (this->name, GF_LOG_WARNING, op_errno,
+                        P_MSG_INVALID_ARGUMENT, "size=%"GF_PRI_SIZET, size);
                 goto err;
         }
 
@@ -232,9 +233,10 @@ posix_aio_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
 	UNLOCK (&fd->lock);
 
         if (ret != 1) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "io_submit() returned %d", ret);
                 op_errno = -ret;
+                gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                        P_MSG_IO_SUBMIT_FAILED,
+                        "io_submit() returned %d", ret);
                 goto err;
         }
 
@@ -274,10 +276,10 @@ posix_aio_writev_complete (struct posix_aio_cb *paiocb, int res, int res2)
         if (res < 0) {
                 op_ret = -1;
                 op_errno = -res;
-		gf_log (this->name, GF_LOG_ERROR,
-			"writev(async) failed fd=%d,offset=%llu (%d/%s)",
-			_fd, (unsigned long long) paiocb->offset, res,
-			strerror (op_errno));
+		gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                        P_MSG_WRITEV_FAILED,
+			"writev(async) failed fd=%d,offset=%llu (%d)",
+			_fd, (unsigned long long) paiocb->offset, res);
 
                 goto out;
         }
@@ -286,9 +288,8 @@ posix_aio_writev_complete (struct posix_aio_cb *paiocb, int res, int res2)
 	if (ret != 0) {
 		op_ret = -1;
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fstat failed on fd=%d: %s", _fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED,
+                        "fstat failed on fd=%d", _fd);
                 goto out;
 	}
 
@@ -339,7 +340,7 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto err;
         }
@@ -371,9 +372,8 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
         ret = posix_fdstat (this, _fd, &paiocb->prebuf);
 	if (ret != 0) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fstat failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_FSTAT_FAILED,
+                        "fstat failed on fd=%p", fd);
                 goto err;
 	}
 
@@ -388,9 +388,11 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
 	UNLOCK (&fd->lock);
 
         if (ret != 1) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "io_submit() returned %d", ret);
                 op_errno = -ret;
+                gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                        P_MSG_IO_SUBMIT_FAILED,
+                        "io_submit() returned %d,gfid=%s", ret,
+                        uuid_utoa(fd->inode->gfid));
                 goto err;
         }
 
@@ -428,7 +430,8 @@ posix_aio_thread (void *data)
                 ret = io_getevents (priv->ctxp, 1, POSIX_AIO_MAX_NR_GETEVENTS,
 				    &events[0], NULL);
                 if (ret <= 0) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, -ret,
+                                P_MSG_IO_GETEVENTS_FAILED,
                                 "io_getevents() returned %d", ret);
                         if (ret == -EINTR)
                                 continue;
@@ -450,7 +453,8 @@ posix_aio_thread (void *data)
 							   event->res2);
 				break;
 			default:
-				gf_log (this->name, GF_LOG_ERROR,
+				gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        P_MSG_UNKNOWN_OP,
 					"unknown op %d found in piocb",
 					paiocb->op);
 				break;
@@ -472,7 +476,7 @@ posix_aio_init (xlator_t *this)
 
         ret = io_setup (POSIX_AIO_MAX_NR_EVENTS, &priv->ctxp);
         if ((ret == -1 && errno == ENOSYS) || ret == -ENOSYS) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_AIO_UNAVAILABLE,
                         "Linux AIO not available at run-time."
 			" Continuing with synchronous IO");
                 ret = 0;
@@ -480,9 +484,10 @@ posix_aio_init (xlator_t *this)
         }
 
         if (ret < 0) {
-		gf_log (this->name, GF_LOG_WARNING,
-			"io_setup() failed. ret=%d, errno=%d",
-			ret, errno);
+		gf_msg (this->name, GF_LOG_WARNING, -ret,
+                        P_MSG_IO_SETUP_FAILED,
+			"io_setup() failed. ret=%d",
+			ret);
                 goto out;
 	}
 
@@ -541,7 +546,7 @@ posix_aio_off (xlator_t *this)
 int
 posix_aio_on (xlator_t *this)
 {
-        gf_log (this->name, GF_LOG_INFO,
+        gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_AIO_UNAVAILABLE,
                 "Linux AIO not available at build-time."
 		" Continuing with synchronous IO");
         return 0;
@@ -550,7 +555,7 @@ posix_aio_on (xlator_t *this)
 int
 posix_aio_off (xlator_t *this)
 {
-        gf_log (this->name, GF_LOG_INFO,
+        gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_AIO_UNAVAILABLE,
                 "Linux AIO not available at build-time."
 		" Continuing with synchronous IO");
         return 0;
@@ -561,9 +566,10 @@ __posix_fd_set_odirect (fd_t *fd, struct posix_fd *pfd, int opflags,
                         off_t offset, size_t size)
 {
         xlator_t        *this = THIS;
-        gf_log (this->name, GF_LOG_INFO,
+        gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_AIO_UNAVAILABLE,
                 "Linux AIO not available at build-time."
                 " Continuing with synchronous IO");
         return;
 }
+
 #endif
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 6182fd8..281d52f 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -25,6 +25,7 @@
 #include "posix.h"
 #include "xlator.h"
 #include "syscall.h"
+#include "posix-messages.h"
 
 #include "compat-errno.h"
 
@@ -72,12 +73,8 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize,
 
         if (type & POSIX_ANCESTRY_DENTRY) {
                 entry = gf_dirent_for_name (dir_name);
-                if (!entry) {
-                        gf_log (THIS->name, GF_LOG_ERROR,
-                                "could not create gf_dirent for entry %s: (%s)",
-                                dir_name, strerror (errno));
+                if (!entry)
                         goto out;
-                }
 
                 entry->d_stat = *iabuf;
                 entry->inode = inode_ref (inode);
@@ -152,9 +149,9 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
 
         len = readlink (dir_handle, linkname, PATH_MAX);
         if (len < 0) {
-                gf_log (this->name, GF_LOG_ERROR, "could not read the link "
-                        "from the gfid handle %s (%s)", dir_handle,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED,
+                        "could not read the link from the gfid handle %s ",
+                        dir_handle);
                 goto out;
         }
 
@@ -245,9 +242,9 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,
         /* is a directory's symlink-handle */
         ret = readlink (base_str, linkname, 512);
         if (ret == -1) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "internal readlink failed on %s (%s)",
-                        base_str, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED,
+                        "internal readlink failed on %s ",
+                        base_str);
                 goto err;
         }
 
@@ -264,14 +261,14 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,
         }
 
         if (ret < 50 || ret >= 512) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LINK_FAILED,
                         "malformed internal link %s for %s",
                         linkname, base_str);
                 goto err;
         }
 
         if (memcmp (linkname, "../../", 6) != 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED,
                         "malformed internal link %s for %s",
                         linkname, base_str);
                 goto err;
@@ -282,7 +279,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,
             (linkname[8] != '/') ||
             (linkname[11] != '/') ||
             (linkname[48] != '/')) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED,
                         "malformed internal link %s for %s",
                         linkname, base_str);
                 goto err;
@@ -292,7 +289,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,
             (linkname[25] != '-') ||
             (linkname[30] != '-') ||
             (linkname[35] != '-')) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED,
                         "malformed internal link %s for %s",
                         linkname, base_str);
                 goto err;
@@ -301,7 +298,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,
         blen = link_len - 48;
 
         if (len + blen >= maxlen) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLEPATH_FAILED,
                         "Unable to form handle path for %s (maxlen = %d)",
                         buf, maxlen);
                 goto err;
@@ -461,7 +458,8 @@ posix_handle_init (xlator_t *this)
 
         ret = stat (priv->base_path, &exportbuf);
         if (ret || !S_ISDIR (exportbuf.st_mode)) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        P_MSG_HANDLE_CREATE,
                         "Not a directory: %s", priv->base_path);
                 return -1;
         }
@@ -477,21 +475,24 @@ posix_handle_init (xlator_t *this)
                 if (errno == ENOENT) {
                         ret = mkdir (handle_pfx, 0600);
                         if (ret != 0) {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "Creating directory %s failed: %s",
-                                        handle_pfx, strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_HANDLE_CREATE,
+                                        "Creating directory %s failed",
+                                        handle_pfx);
                                 return -1;
                         }
                 } else {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "Checking for %s failed: %s",
-                                handle_pfx, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "Checking for %s failed",
+                                handle_pfx);
                         return -1;
                 }
                 break;
         case 0:
                 if (!S_ISDIR (stbuf.st_mode)) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_HANDLE_CREATE,
                                 "Not a directory: %s",
                                 handle_pfx);
                         return -1;
@@ -509,25 +510,26 @@ posix_handle_init (xlator_t *this)
         switch (ret) {
         case -1:
                 if (errno != ENOENT) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "%s: %s", priv->base_path,
-                                strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "%s", priv->base_path);
                         return -1;
                 }
 
                 ret = posix_handle_mkdir_hashes (this, rootstr);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "mkdir %s failed (%s)",
-                                rootstr, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "mkdir %s failed", rootstr);
                         return -1;
                 }
 
                 ret = symlink ("../../..", rootstr);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "symlink %s creation failed (%s)",
-                                rootstr, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "symlink %s creation failed",
+                                rootstr);
                         return -1;
                 }
                 break;
@@ -536,7 +538,8 @@ posix_handle_init (xlator_t *this)
                     (exportbuf.st_dev == rootbuf.st_dev))
                         return 0;
 
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        P_MSG_HANDLE_CREATE,
                         "Different dirs %s (%lld/%lld) != %s (%lld/%lld)",
                         priv->base_path, (long long) exportbuf.st_ino,
                         (long long) exportbuf.st_dev, rootstr,
@@ -578,18 +581,21 @@ posix_handle_new_trash_init (xlator_t *this, char *trash)
                 if (errno == ENOENT) {
                         ret = mkdir (trash, 0755);
                         if (ret != 0) {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "Creating directory %s failed: %s",
-                                        trash, strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_HANDLE_TRASH_CREATE,
+                                        "Creating directory %s failed",
+                                        trash);
                         }
                 } else {
-                        gf_log (this->name, GF_LOG_ERROR, "Checking for %s "
-                                "failed: %s", trash, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_HANDLE_TRASH_CREATE,
+                                "Checking for %s failed", trash);
                 }
                 break;
         case 0:
                 if (!S_ISDIR (stbuf.st_mode)) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_HANDLE_TRASH_CREATE,
                                 "Not a directory: %s", trash);
                         ret = -1;
                 }
@@ -614,8 +620,9 @@ posix_mv_old_trash_into_new_trash (xlator_t *this, char *old, char *new)
                   uuid_utoa (dest_name));
         ret = rename (old, dest_old);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_ERROR, "Not able to move "
-                        "%s -> %s (%s)", old, dest_old, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        P_MSG_HANDLE_TRASH_CREATE,
+                        "Not able to move %s -> %s ", old, dest_old);
         }
 out:
         return ret;
@@ -664,9 +671,9 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath)
 
         ret = mkdir (parpath, 0700);
         if (ret == -1 && errno != EEXIST) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "error mkdir hash-1 %s (%s)",
-                        parpath, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        P_MSG_HANDLE_CREATE,
+                        "error mkdir hash-1 %s ", parpath);
                 return -1;
         }
 
@@ -675,9 +682,9 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath)
 
         ret = mkdir (parpath, 0700);
         if (ret == -1 && errno != EEXIST) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "error mkdir hash-2 %s (%s)",
-                        parpath, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        P_MSG_HANDLE_CREATE,
+                        "error mkdir hash-2 %s ", parpath);
                 return -1;
         }
 
@@ -697,41 +704,43 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat
 
         ret = lstat (newpath, &newbuf);
         if (ret == -1 && errno != ENOENT) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "%s: %s", newpath, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HANDLE_CREATE,
+                        "%s", newpath);
                 return -1;
         }
 
         if (ret == -1 && errno == ENOENT) {
                 ret = posix_handle_mkdir_hashes (this, newpath);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "mkdir %s failed (%s)",
-                                newpath, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE, "mkdir %s failed ",
+                                newpath);
                         return -1;
                 }
 
                 ret = sys_link (oldpath, newpath);
 
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "link %s -> %s failed (%s)",
-                                oldpath, newpath, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE, "link %s -> %s"
+                                "failed ", oldpath, newpath);
                         return -1;
                 }
 
                 ret = lstat (newpath, &newbuf);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "lstat on %s failed (%s)",
-                                newpath, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "lstat on %s failed", newpath);
                         return -1;
                 }
         }
 
         if (newbuf.st_ino != oldbuf->st_ino ||
             newbuf.st_dev != oldbuf->st_dev) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_HANDLE_CREATE,
                         "mismatching ino/dev between file %s (%lld/%lld) "
                         "and handle %s (%lld/%lld)",
                         oldpath, (long long) oldbuf->st_ino, (long long) oldbuf->st_dev,
@@ -757,41 +766,43 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,
 
         ret = lstat (newpath, &newbuf);
         if (ret == -1 && errno != ENOENT) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "%s: %s", newpath, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HANDLE_CREATE, "%s", newpath);
                 return -1;
         }
 
         if (ret == -1 && errno == ENOENT) {
                 ret = posix_handle_mkdir_hashes (this, newpath);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "mkdir %s failed (%s)",
-                                newpath, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "mkdir %s failed ", newpath);
                         return -1;
                 }
 
                 ret = symlink (oldpath, newpath);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "symlink %s -> %s failed (%s)",
-                                oldpath, newpath, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "symlink %s -> %s failed",
+                                oldpath, newpath);
                         return -1;
                 }
 
                 ret = lstat (newpath, &newbuf);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "stat on %s failed (%s)",
-                                newpath, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_CREATE,
+                                "stat on %s failed ", newpath);
                         return -1;
                 }
         }
 
         ret = stat (real_path, &newbuf);
         if (ret) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "stat on %s failed (%s)", newpath, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HANDLE_CREATE,
+                        "stat on %s failed ", newpath);
                 return -1;
         }
 
@@ -800,7 +811,8 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,
 
         if (newbuf.st_ino != oldbuf->st_ino ||
             newbuf.st_dev != oldbuf->st_dev) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_HANDLE_CREATE,
                         "mismatching ino/dev between file %s (%lld/%lld) "
                         "and handle %s (%lld/%lld)",
                         oldpath, (long long) oldbuf->st_ino, (long long) oldbuf->st_dev,
@@ -825,16 +837,16 @@ posix_handle_unset_gfid (xlator_t *this, uuid_t gfid)
 
         if (ret == -1) {
                 if (errno != ENOENT) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "%s: %s", path, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HANDLE_DELETE, "%s", path);
                 }
                 goto out;
         }
 
         ret = unlink (path);
         if (ret == -1) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "unlink %s failed (%s)", path, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HANDLE_DELETE, "unlink %s failed ", path);
         }
 
 out:
@@ -856,7 +868,8 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename)
 
         MAKE_HANDLE_PATH (path, this, gfid, basename);
         if (!path) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_HANDLE_DELETE,
                         "Failed to create handle path for %s (%s)",
                         basename, uuid_utoa(gfid));
                 return -1;
@@ -865,8 +878,8 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename)
         ret = posix_istat (this, gfid, basename, &stat);
 
         if (ret == -1) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "%s: %s", path, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HANDLE_DELETE, "%s", path);
                 return -1;
         }
 
@@ -886,7 +899,8 @@ posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid,
 
         MAKE_HANDLE_PATH (newpath, this, gfid, NULL);
         if (!newpath) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_HANDLE_CREATE,
                         "Failed to create handle path (%s)", uuid_utoa(gfid));
                 return ret;
         }
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index e0b5b67..356b7b9 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -19,6 +19,7 @@
 #include <sys/types.h>
 #include "xlator.h"
 #include "gf-dirent.h"
+#include "posix-messages.h"
 
 /* From Open Group Base Specifications Issue 6 */
 #ifndef _XOPEN_PATH_MAX
@@ -50,9 +51,9 @@
                                 flags);                                 \
         if (op_ret == -1) {                                             \
                 op_errno = errno;                                       \
-                gf_log (this->name, GF_LOG_WARNING,                     \
-                        "setting xattr failed on %s: key = %s (%s)",    \
-                        path, key, strerror (op_errno));                \
+                gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_PGFID_OP, \
+                        "setting xattr failed on %s: key = %s ",        \
+                        path, key);                                     \
                 goto label;                                             \
         }                                                               \
         } while (0)
@@ -67,9 +68,10 @@
                                 SET_PGFID_XATTR (path, key, value, flags,      \
                                                  op_ret, this, label);         \
                         } else {                                               \
-                                gf_log(this->name, GF_LOG_WARNING, "getting "  \
-                                       "xattr failed on %s: key = %s (%s)",    \
-                                       path, key, strerror (op_errno));        \
+                                gf_msg (this->name, GF_LOG_WARNING, op_errno,  \
+                                       P_MSG_PGFID_OP, "getting xattr "    \
+                                       "failed on %s: key = %s ",              \
+                                       path, key);                             \
                         }                                                      \
                 }                                                              \
         } while (0)
@@ -78,9 +80,10 @@
        op_ret = sys_lremovexattr (path, key);                           \
        if (op_ret == -1) {                                              \
                op_errno = errno;                                        \
-               gf_log (this->name, GF_LOG_WARNING, "removing xattr "    \
-                       "failed on %s: key = %s (%s)", path, key,        \
-                       strerror (op_errno));                            \
+               gf_msg (this->name, GF_LOG_WARNING, op_errno,                   \
+                       P_MSG_PGFID_OP,                                     \
+                       "removing xattr failed"                                 \
+                       "on %s: key = %s", path, key);                          \
                goto label;                                              \
        }                                                                \
        } while (0)
@@ -93,9 +96,9 @@
                if (op_errno == ENOATTR || op_errno == ENODATA) {        \
                        value = 1;                                       \
                } else {                                                 \
-                       gf_log (this->name, GF_LOG_WARNING,"getting xattr " \
-                               "failed on %s: key = %s (%s)", path, key, \
-                               strerror (op_errno));                    \
+                       gf_msg (this->name, GF_LOG_WARNING, errno,       \
+                               P_MSG_PGFID_OP, "getting xattr "      \
+                               "failed on %s: key = %s ", path, key);      \
                        goto label;                                      \
                }                                                        \
        } else {                                                         \
@@ -110,8 +113,9 @@
        op_ret = sys_lgetxattr (path, key, &value, sizeof (value));  \
        if (op_ret == -1) {                                              \
                op_errno = errno;                                        \
-               gf_log (this->name, GF_LOG_WARNING, "getting xattr failed on " \
-                       "%s: key = %s (%s)", path, key, strerror (op_errno)); \
+               gf_msg (this->name, GF_LOG_WARNING, errno,               \
+                      P_MSG_PGFID_OP, "getting xattr failed on " \
+                       "%s: key = %s ", path, key);                     \
                goto label;                                              \
        } else {                                                         \
                value = ntoh32 (value);                                  \
@@ -182,7 +186,8 @@
 
 #define MAKE_INODE_HANDLE(rpath, this, loc, iatt_p) do {                \
         if (gf_uuid_is_null (loc->gfid)) {                              \
-                gf_log (this->name, GF_LOG_ERROR,                       \
+                gf_msg (this->name, GF_LOG_ERROR, 0,                    \
+                        P_MSG_INODE_HANDLE_CREATE,                      \
                         "null gfid for path %s", (loc)->path);          \
                 break;                                                  \
         }                                                               \
@@ -194,12 +199,13 @@
         errno = 0;                                                      \
         op_ret = posix_istat (this, loc->gfid, NULL, iatt_p);           \
         if (errno != ELOOP) {                                           \
-                MAKE_HANDLE_PATH (rpath, this, (loc)->gfid, NULL);        \
+                MAKE_HANDLE_PATH (rpath, this, (loc)->gfid, NULL);      \
                 if (!rpath) {                                           \
                         op_ret = -1;                                    \
-                        gf_log (this->name, GF_LOG_ERROR,               \
-                        "Failed to create inode handle "                \
-                        "for path %s", (loc)->path);                      \
+                        gf_msg (this->name, GF_LOG_ERROR, errno,        \
+                                P_MSG_INODE_HANDLE_CREATE,            \
+                                "Failed to create inode handle "        \
+                                "for path %s", (loc)->path);            \
                 }                                                       \
                 break;                                                  \
         }                                                               \
@@ -211,7 +217,7 @@
         char *__parp;                                                   \
                                                                         \
         if (gf_uuid_is_null (loc->pargfid) || !loc->name) {             \
-                gf_log (this->name, GF_LOG_ERROR,                       \
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ENTRY_HANDLE_CREATE,\
                         "null pargfid/name for path %s", loc->path);    \
                 break;                                                  \
         }                                                               \
@@ -229,9 +235,10 @@
                 MAKE_HANDLE_PATH (parp, this, loc->pargfid, NULL);      \
                 MAKE_HANDLE_PATH (entp, this, loc->pargfid, loc->name); \
                 if (!parp || !entp) {                                   \
-                        gf_log (this->name, GF_LOG_ERROR,               \
-                        "Failed to create entry handle "                \
-                        "for path %s", loc->path);                      \
+                        gf_msg (this->name, GF_LOG_ERROR, errno,        \
+                                P_MSG_ENTRY_HANDLE_CREATE,      \
+                                "Failed to create entry handle "        \
+                                "for path %s", loc->path);              \
                 }                                                       \
                 break;                                                  \
         }                                                               \
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 9018a73..e2c5eb2 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -143,11 +143,13 @@ _posix_xattr_get_set_from_backend (posix_xattr_filler_t *filler, char *key)
                                                     xattr_size);
                 if (xattr_size == -1) {
                         if (filler->real_path)
-                                gf_log (filler->this->name, GF_LOG_WARNING,
+                                gf_msg (filler->this->name, GF_LOG_WARNING, 0,
+                                        P_MSG_XATTR_FAILED,
                                         "getxattr failed. path: %s, key: %s",
                                         filler->real_path, key);
                         else
-                                gf_log (filler->this->name, GF_LOG_WARNING,
+                                gf_msg (filler->this->name, GF_LOG_WARNING, 0,
+                                        P_MSG_XATTR_FAILED,
                                         "getxattr failed. gfid: %s, key: %s",
                                         uuid_utoa (filler->fd->inode->gfid),
                                         key);
@@ -159,11 +161,11 @@ _posix_xattr_get_set_from_backend (posix_xattr_filler_t *filler, char *key)
                 ret = dict_set_bin (filler->xattr, key, value, xattr_size);
                 if (ret < 0) {
                         if (filler->real_path)
-                                gf_log (filler->this->name, GF_LOG_DEBUG,
+                                gf_msg_debug (filler->this->name, 0,
                                         "dict set failed. path: %s, key: %s",
                                         filler->real_path, key);
                         else
-                                gf_log (filler->this->name, GF_LOG_DEBUG,
+                                gf_msg_debug (filler->this->name, 0,
                                         "dict set failed. gfid: %s, key: %s",
                                         uuid_utoa (filler->fd->inode->gfid),
                                         key);
@@ -198,14 +200,15 @@ _posix_get_marker_all_contributions (posix_xattr_filler_t *filler)
                                              " with 'user_xattr' flag)");
                 } else {
                         if (filler->real_path)
-                                gf_log (THIS->name, GF_LOG_WARNING,
-                                        "listxattr failed on %s: %s",
-                                        filler->real_path, strerror (errno));
+                                gf_msg (THIS->name, GF_LOG_WARNING, errno,
+                                        P_MSG_XATTR_FAILED,
+                                        "listxattr failed on %s",
+                                        filler->real_path);
                         else
-                                gf_log (THIS->name, GF_LOG_WARNING,
-                                        "listxattr failed on %s: %s",
-                                        uuid_utoa (filler->fd->inode->gfid),
-                                        strerror (errno));
+                                gf_msg (THIS->name, GF_LOG_WARNING, errno,
+                                        P_MSG_XATTR_FAILED,
+                                        "listxattr failed on %s",
+                                        uuid_utoa (filler->fd->inode->gfid));
                 }
                 goto out;
         }
@@ -295,7 +298,8 @@ _posix_filler_get_openfd_count (posix_xattr_filler_t *filler, char *key)
 
         ret = dict_set_uint32 (filler->xattr, key, inode->fd_count);
         if (ret < 0) {
-                gf_log (filler->this->name, GF_LOG_WARNING,
+                gf_msg (filler->this->name, GF_LOG_WARNING, 0,
+                        P_MSG_DICT_SET_FAILED,
                         "Failed to set dictionary value for %s", key);
                 goto out;
         }
@@ -328,9 +332,10 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,
                 if (req_size >= filler->stbuf->ia_size) {
                         _fd = open (filler->real_path, O_RDONLY);
                         if (_fd == -1) {
-                                gf_log (filler->this->name, GF_LOG_ERROR,
-                                        "Opening file %s failed: %s",
-                                        filler->real_path, strerror (errno));
+                                gf_msg (filler->this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_XDATA_GETXATTR,
+                                        "Opening file %s failed",
+                                        filler->real_path);
                                 goto err;
                         }
 
@@ -352,26 +357,30 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,
 
                         ret = read (_fd, databuf, filler->stbuf->ia_size);
                         if (ret == -1) {
-                                gf_log (filler->this->name, GF_LOG_ERROR,
-                                        "Read on file %s failed: %s",
-                                        filler->real_path, strerror (errno));
+                                gf_msg (filler->this->name, GF_LOG_ERROR, errno,
+                                         P_MSG_XDATA_GETXATTR,
+                                        "Read on file %s failed",
+                                        filler->real_path);
                                 goto err;
                         }
 
                         ret = close (_fd);
                         _fd = -1;
                         if (ret == -1) {
-                                gf_log (filler->this->name, GF_LOG_ERROR,
-                                        "Close on file %s failed: %s",
-                                        filler->real_path, strerror (errno));
+                                gf_msg (filler->this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_XDATA_GETXATTR,
+                                        "Close on file %s failed",
+                                        filler->real_path);
                                 goto err;
                         }
 
                         ret = dict_set_bin (filler->xattr, key,
                                             databuf, filler->stbuf->ia_size);
                         if (ret < 0) {
-                                gf_log (filler->this->name, GF_LOG_ERROR,
-                                        "failed to set dict value. key: %s, path: %s",
+                                gf_msg (filler->this->name, GF_LOG_ERROR, 0,
+                                        P_MSG_XDATA_GETXATTR,
+                                        "failed to set dict value. key: %s,"
+                                        "path: %s",
                                         key, filler->real_path);
                                 goto err;
                         }
@@ -385,6 +394,16 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,
                 }
         } else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) {
                 ret = _posix_filler_get_openfd_count (filler, key);
+                loc = filler->loc;
+                if (loc) {
+                        ret = dict_set_uint32 (filler->xattr, key,
+                                               loc->inode->fd_count);
+                        if (ret < 0)
+                                gf_msg (filler->this->name, GF_LOG_WARNING, 0,
+                                        P_MSG_XDATA_GETXATTR,
+                                        "Failed to set dictionary value for %s",
+                                        key);
+                }
         } else if (!strcmp (key, GET_ANCESTRY_PATH_KEY)) {
                 /* As of now, the only consumers of POSIX_ANCESTRY_PATH attempt
                  * fetching it via path-based fops. Hence, leaving it as it is
@@ -524,7 +543,8 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename,
 
         MAKE_HANDLE_PATH (real_path, this, gfid, basename);
         if (!real_path) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, ESTALE,
+                        P_MSG_HANDLE_PATH_CREATE,
                         "Failed to create handle path for %s/%s",
                         uuid_utoa (gfid), basename ? basename : "");
                 errno = ESTALE;
@@ -537,16 +557,17 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename,
         if (ret != 0) {
                 if (ret == -1) {
                         if (errno != ENOENT && errno != ELOOP)
-                                gf_log (this->name, GF_LOG_WARNING,
-                                        "lstat failed on %s (%s)",
-                                        real_path, strerror (errno));
+                                gf_msg (this->name, GF_LOG_WARNING, errno,
+                                        P_MSG_LSTAT_FAILED,
+                                        "lstat failed on %s",
+                                        real_path);
                 } else {
                         // may be some backend filesystem issue
-                        gf_log (this->name, GF_LOG_ERROR, "lstat failed on "
-                                "%s and return value is %d instead of -1. "
-                                "Please see dmesg output to check whether the "
-                                "failure is due to backend filesystem issue",
-                                real_path, ret);
+                        gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LSTAT_FAILED,
+                                "lstat failed on %s and return value is %d "
+                                "instead of -1. Please see dmesg output to "
+                                "check whether the failure is due to backend "
+                                "filesystem issue", real_path, ret);
                         ret = -1;
                 }
                 goto out;
@@ -595,16 +616,17 @@ posix_pstat (xlator_t *this, uuid_t gfid, const char *path,
         if (ret != 0) {
                 if (ret == -1) {
                         if (errno != ENOENT)
-                                gf_log (this->name, GF_LOG_WARNING,
-                                        "lstat failed on %s (%s)",
-                                        path, strerror (errno));
+                                gf_msg (this->name, GF_LOG_WARNING, errno,
+                                        P_MSG_LSTAT_FAILED,
+                                        "lstat failed on %s",
+                                        path);
                 } else {
                         // may be some backend filesytem issue
-                        gf_log (this->name, GF_LOG_ERROR, "lstat failed on "
-                                "%s and return value is %d instead of -1. "
-                                "Please see dmesg output to check whether the "
-                                "failure is due to backend filesystem issue",
-                                path, ret);
+                        gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_LSTAT_FAILED,
+                                "lstat failed on %s and return value is %d "
+                                "instead of -1. Please see dmesg output to "
+                                "check whether the failure is due to backend "
+                                "filesystem issue", path, ret);
                         ret = -1;
                 }
                 goto out;
@@ -768,7 +790,7 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req)
 
         ret = dict_get_ptr (xattr_req, "gfid-req", &uuid_req);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "failed to get the gfid from dict for %s",
                         loc->path);
                 goto out;
@@ -776,9 +798,8 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req)
 
         ret = sys_lsetxattr (path, GFID_XATTR_KEY, uuid_req, 16, XATTR_CREATE);
         if (ret == -1) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "setting GFID on %s failed (%s)", path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_GFID_FAILED,
+                        "setting GFID on %s failed ", path);
                 goto out;
         }
         gf_uuid_copy (uuid_curr, uuid_req);
@@ -824,19 +845,20 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,
                         ret = write (file_fd, value->data, value->len);
                         if (ret == -1) {
                                 op_ret = -errno;
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "write failed while doing setxattr "
-                                        "for key %s on path %s: %s",
-                                        key, real_path, strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_SET_FILE_CONTENTS, "write failed"
+                                        "while doing setxattr for key %s on"
+                                        "path%s", key, real_path);
                                 goto out;
                         }
 
                         ret = close (file_fd);
                         if (ret == -1) {
                                 op_ret = -errno;
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "close failed on %s: %s",
-                                        real_path, strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_SET_FILE_CONTENTS,
+                                        "close failed on %s",
+                                        real_path);
                                 goto out;
                         }
                 }
@@ -847,29 +869,28 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,
 
                 if (file_fd == -1) {
                         op_ret = -errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "failed to open file %s with O_CREAT: %s",
-                                key, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_SET_FILE_CONTENTS, "failed to open file"
+                                "%s with O_CREAT", key);
                         goto out;
                 }
 
                 ret = write (file_fd, value->data, value->len);
                 if (ret == -1) {
                         op_ret = -errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "write failed on %s while setxattr with "
-                                "key %s: %s",
-                                real_path, key, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_SET_FILE_CONTENTS, "write failed on %s"
+                                "while setxattr with key %s", real_path, key);
                         goto out;
                 }
 
                 ret = close (file_fd);
                 if (ret == -1) {
                         op_ret = -errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "close failed on %s while setxattr with "
-                                "key %s: %s",
-                                real_path, key, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_SET_FILE_CONTENTS, "close failed on"
+                                " %s while setxattr with key %s",
+                                real_path, key);
                         goto out;
                 }
         }
@@ -893,7 +914,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
         MAKE_HANDLE_PATH (real_path, this, pargfid, name);
         if (!real_path) {
                 op_ret = -ESTALE;
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, ESTALE,
+                        P_MSG_XDATA_GETXATTR,
                         "Failed to create handle path for %s/%s",
                         uuid_utoa (pargfid), name);
                 goto out;
@@ -902,8 +924,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
         op_ret = posix_istat (this, pargfid, name, &stbuf);
         if (op_ret == -1) {
                 op_ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR, "lstat failed on %s: %s",
-                        real_path, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR,
+                        "lstat failed on %s", real_path);
                 goto out;
         }
 
@@ -911,8 +933,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
 
         if (file_fd == -1) {
                 op_ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR, "open failed on %s: %s",
-                        real_path, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR,
+                        "open failed on %s", real_path);
                 goto out;
         }
 
@@ -926,8 +948,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
         ret = read (file_fd, *contents, stbuf.ia_size);
         if (ret <= 0) {
                 op_ret = -1;
-                gf_log (this->name, GF_LOG_ERROR, "read on %s failed: %s",
-                        real_path, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR,
+                        "read on %s failed", real_path);
                 goto out;
         }
 
@@ -937,8 +959,8 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
         file_fd = -1;
         if (op_ret == -1) {
                 op_ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR, "close on %s failed: %s",
-                        real_path, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR,
+                        "close on %s failed", real_path);
                 goto out;
         }
 
@@ -1039,7 +1061,7 @@ void posix_dump_buffer (xlator_t *this, const char *real_path, const char *key,
                 for (index = 0; index < value->len; index++)
                         sprintf(buffer+3*index, " %02x", data[index]);
         }
-        gf_log (this->name, GF_LOG_DEBUG,
+        gf_msg_debug (this->name, 0,
                 "Dump %s: key:%s flags: %u length:%u data:%s ",
                 real_path, key, flags, value->len,
                 (log_level == GF_LOG_TRACE ? buffer : "<skipped in DEBUG>"));
@@ -1072,24 +1094,33 @@ posix_handle_pair (xlator_t *this, const char *real_path,
                         if (errno == ENOENT) {
                                 if (!posix_special_xattr (marker_xattrs,
                                                           key)) {
-                                        gf_log (this->name, GF_LOG_ERROR,
-                                                "setxattr on %s failed: %s",
-                                                real_path, strerror (errno));
+                                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                                P_MSG_XATTR_FAILED,
+                                                "setxattr on %s failed",
+                                                real_path);
                                 }
                         } else {
 
 #ifdef GF_DARWIN_HOST_OS
-                                gf_log (this->name,
-                                        ((errno == EINVAL) ?
-                                         GF_LOG_DEBUG : GF_LOG_ERROR),
-                                        "%s: key:%s flags: %u length:%d error:%s",
-                                        real_path, key, flags, value->len,
-                                        strerror (errno));
+                                if (errno == EINVAL) {
+                                        gf_msg_debug (this->name, 0, "%s: key:"
+                                                      "%s flags: %u length:%d "
+                                                      "error:%s", real_path,
+                                                      key, flags, value->len,
+                                                      strerror (errno));
+                                } else {
+                                        gf_msg (this->name, GF_LOG_ERROR,
+                                                errno, P_MSG_XATTR_FAILED,
+                                                "%s: key:%s flags: "
+                                                "%u length:%d",
+                                                real_path, key, flags,
+                                                value->len);
+
 #else /* ! DARWIN */
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "%s: key:%s flags: %u length:%d error:%s",
-                                        real_path, key, flags, value->len,
-                                        strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_XATTR_FAILED, "%s: key:%s"
+                                        "flags: %u length:%d", real_path,
+                                        key, flags, value->len);
 #endif /* DARWIN */
                         }
 
@@ -1118,21 +1149,26 @@ posix_fhandle_pair (xlator_t *this, int fd,
         if (sys_ret < 0) {
                 ret = -errno;
                 if (errno == ENOENT) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsetxattr on fd=%d failed: %s", fd,
-                                strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "fsetxattr on fd=%d"
+                                " failed", fd);
                 } else {
 
 #ifdef GF_DARWIN_HOST_OS
-                        gf_log (this->name,
-                                ((errno == EINVAL) ?
-                                 GF_LOG_DEBUG : GF_LOG_ERROR),
-                                "fd=%d: key:%s error:%s",
-                                fd, key, strerror (errno));
+                        if (errno == EINVAL) {
+                                gf_msg_debug (this->name, 0, "fd=%d: key:%s "
+                                              "error:%s", fd, key,
+                                              strerror (errno));
+                        } else {
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_XATTR_FAILED, "fd=%d: key:%s",
+                                        fd, key);
+                        }
+
 #else /* ! DARWIN */
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fd=%d: key:%s error:%s",
-                                fd, key, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "fd=%d: key:%s",
+                                fd, key);
 #endif /* DARWIN */
                 }
 
@@ -1159,14 +1195,14 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid)
         /* check that it is valid directory handle */
         size = sys_lstat (hpath, &stbuf);
         if (size < 0) {
-                gf_log (this->name, GF_LOG_DEBUG, "%s: Handle stat failed: "
+                gf_msg_debug (this->name, 0, "%s: Handle stat failed: "
                         "%s", hpath, strerror (errno));
                 goto out;
         }
 
         iatt_from_stat (&iabuf, &stbuf);
         if (iabuf.ia_nlink != 1 || !IA_ISLNK (iabuf.ia_type)) {
-                gf_log (this->name, GF_LOG_DEBUG, "%s: Handle nlink %d %d",
+                gf_msg_debug (this->name, 0, "%s: Handle nlink %d %d",
                         hpath, iabuf.ia_nlink, IA_ISLNK (iabuf.ia_type));
                 goto out;
         }
@@ -1174,7 +1210,7 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid)
         size = posix_handle_path (this, gfid, NULL, newpath, sizeof (newpath));
         if (size <= 0) {
                 if (errno == ENOENT) {
-                        gf_log (this->name, GF_LOG_DEBUG, "%s: %s", newpath,
+                        gf_msg_debug (this->name, 0, "%s: %s", newpath,
                                 strerror (ENOENT));
                         stale = _gf_true;
                 }
@@ -1183,12 +1219,12 @@ del_stale_dir_handle (xlator_t *this, uuid_t gfid)
 
         size = sys_lgetxattr (newpath, GFID_XATTR_KEY, gfid_curr, 16);
         if (size < 0 && errno == ENOENT) {
-                gf_log (this->name, GF_LOG_DEBUG, "%s: %s", newpath,
+                gf_msg_debug (this->name, 0, "%s: %s", newpath,
                         strerror (ENOENT));
                 stale = _gf_true;
         } else if (size == 16 && gf_uuid_compare (gfid, gfid_curr)) {
-                gf_log (this->name, GF_LOG_DEBUG, "%s: mismatching gfid: %s, "
-                        "at %s", hpath, uuid_utoa (gfid_curr), newpath);
+                gf_msg_debug (this->name, 0, "%s: mismatching gfid: %s, "
+                              "at %s", hpath, uuid_utoa (gfid_curr), newpath);
                 stale = _gf_true;
         }
 
@@ -1196,11 +1232,11 @@ out:
         if (stale) {
                 size = sys_unlink (hpath);
                 if (size < 0 && errno != ENOENT)
-                        gf_log (this->name, GF_LOG_ERROR, "%s: Failed to "
-                                "remove handle to %s (%s)", hpath, newpath,
-                                strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_STALE_HANDLE_REMOVE_FAILED, "%s: Failed"
+                                "to remove handle to %s", hpath, newpath);
         } else if (size == 16) {
-                gf_log (this->name, GF_LOG_DEBUG, "%s: Fresh handle for "
+                gf_msg_debug (this->name, 0, "%s: Fresh handle for "
                         "%s with gfid %s", hpath, newpath,
                         uuid_utoa (gfid_curr));
         }
@@ -1223,7 +1259,7 @@ janitor_walker (const char *fpath, const struct stat *sb,
         case S_IFCHR:
         case S_IFIFO:
         case S_IFSOCK:
-                gf_log (THIS->name, GF_LOG_TRACE,
+                gf_msg_trace (THIS->name, 0,
                         "unlinking %s", fpath);
                 unlink (fpath);
                 if (stbuf.ia_nlink == 1)
@@ -1232,7 +1268,7 @@ janitor_walker (const char *fpath, const struct stat *sb,
 
         case S_IFDIR:
                 if (ftwbuf->level) { /* don't remove top level dir */
-                        gf_log (THIS->name, GF_LOG_TRACE,
+                        gf_msg_debug (THIS->name, 0,
                                 "removing directory %s", fpath);
 
                         rmdir (fpath);
@@ -1297,8 +1333,9 @@ posix_janitor_thread_proc (void *data)
         while (1) {
                 time (&now);
                 if ((now - priv->last_landfill_check) > priv->janitor_sleep_duration) {
-                        gf_log (this->name, GF_LOG_TRACE,
-                                "janitor cleaning out %s", priv->trash_path);
+                        gf_msg_trace (this->name, 0,
+                                      "janitor cleaning out %s",
+                                      priv->trash_path);
 
                         nftw (priv->trash_path,
                               janitor_walker,
@@ -1311,12 +1348,12 @@ posix_janitor_thread_proc (void *data)
                 pfd = janitor_get_next_fd (this);
                 if (pfd) {
                         if (pfd->dir == NULL) {
-                                gf_log (this->name, GF_LOG_TRACE,
+                                gf_msg_trace (this->name, 0,
                                         "janitor: closing file fd=%d", pfd->fd);
                                 close (pfd->fd);
                         } else {
-                                gf_log (this->name, GF_LOG_TRACE,
-                                        "janitor: closing dir fd=%p", pfd->dir);
+                                gf_msg_debug (this->name, 0, "janitor: closing"
+                                              " dir fd=%p", pfd->dir);
                                 closedir (pfd->dir);
                         }
 
@@ -1343,9 +1380,9 @@ posix_spawn_janitor_thread (xlator_t *this)
                                                 posix_janitor_thread_proc, this);
 
                         if (ret < 0) {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "spawning janitor thread failed: %s",
-                                        strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_THREAD_FAILED, "spawning janitor "
+                                        "thread failed");
                                 goto unlock;
                         }
 
@@ -1537,7 +1574,8 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p)
 
         MAKE_HANDLE_PATH (real_path, this, fd->inode->gfid, NULL);
         if (!real_path) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        P_MSG_HANDLE_PATH_CREATE_FAILED,
                         "Failed to create handle path (%s)",
                         uuid_utoa (fd->inode->gfid));
                 ret = -1;
@@ -1633,16 +1671,16 @@ posix_fs_health_check (xlator_t *this)
 
         fd = open (file_path, O_CREAT|O_RDWR, 0644);
         if (fd == -1) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "open() on %s returned: %s", file_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HEALTHCHECK_FAILED,
+                        "open() on %s returned", file_path);
                 goto out;
         }
         nofbytes = write (fd, timestamp, timelen);
         if (nofbytes != timelen) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "write() on %s returned: %s", file_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HEALTHCHECK_FAILED,
+                        "write() on %s returned", file_path);
                 goto out;
         }
         /* Seek the offset to the beginning of the file, so that the offset for
@@ -1650,9 +1688,9 @@ posix_fs_health_check (xlator_t *this)
         lseek(fd, 0, SEEK_SET);
         nofbytes = read (fd, buff, timelen);
         if (nofbytes == -1) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "read() on %s returned: %s", file_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_HEALTHCHECK_FAILED,
+                        "read() on %s returned", file_path);
                 goto out;
         }
         ret = 0;
@@ -1680,7 +1718,7 @@ posix_health_check_thread_proc (void *data)
         if (interval == 0)
                 goto out;
 
-        gf_log (this->name, GF_LOG_DEBUG, "health-check thread started, "
+        gf_msg_debug (this->name, 0, "health-check thread started, "
                 "interval = %d seconds", interval);
 
         while (1) {
@@ -1697,9 +1735,10 @@ posix_health_check_thread_proc (void *data)
                 ret = posix_fs_health_check (this);
 
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "health_check on %s returned: %s",
-                                priv->base_path, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HEALTHCHECK_FAILED,
+                                "health_check on %s returned",
+                                priv->base_path);
                         goto abort;
                 }
 
@@ -1707,7 +1746,7 @@ posix_health_check_thread_proc (void *data)
         }
 
 out:
-        gf_log (this->name, GF_LOG_DEBUG, "health-check thread exiting");
+        gf_msg_debug (this->name, 0, "health-check thread exiting");
 
         LOCK (&priv->lock);
         {
@@ -1719,18 +1758,21 @@ out:
 
 abort:
         /* health-check failed */
-        gf_log (this->name, GF_LOG_EMERG, "health-check failed, going down");
+        gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED,
+                "health-check failed, going down");
         xlator_notify (this->parents->xlator, GF_EVENT_CHILD_DOWN, this);
 
         ret = sleep (30);
         if (ret == 0) {
-                gf_log (this->name, GF_LOG_EMERG, "still alive! -> SIGTERM");
+                gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED,
+                        "still alive! -> SIGTERM");
                 kill (getpid(), SIGTERM);
         }
 
         ret = sleep (30);
         if (ret == 0) {
-                gf_log (this->name, GF_LOG_EMERG, "still alive! -> SIGKILL");
+                gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED,
+                        "still alive! -> SIGKILL");
                 kill (getpid(), SIGKILL);
         }
 
@@ -1762,9 +1804,9 @@ posix_spawn_health_check_thread (xlator_t *xl)
                 if (ret < 0) {
                         priv->health_check_interval = 0;
                         priv->health_check_active = _gf_false;
-                        gf_log (xl->name, GF_LOG_ERROR,
-                                "unable to setup health-check thread: %s",
-                                strerror (errno));
+                        gf_msg (xl->name, GF_LOG_ERROR, errno,
+                                P_MSG_HEALTHCHECK_FAILED,
+                                "unable to setup health-check thread");
                         goto unlock;
                 }
 
@@ -1810,7 +1852,8 @@ posix_fsyncer_process (xlator_t *this, call_stub_t *stub, gf_boolean_t do_fsync)
 
         ret = posix_fd_ctx_get (stub->args.fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+                        P_MSG_GET_FDCTX_FAILED,
                         "could not get fdctx for fd(%s)",
                         uuid_utoa (stub->args.fd->inode->gfid));
                 call_unwind_error (stub, -1, EINVAL);
@@ -1827,7 +1870,7 @@ posix_fsyncer_process (xlator_t *this, call_stub_t *stub, gf_boolean_t do_fsync)
         }
 
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
                         "could not fstat fd(%s)",
                         uuid_utoa (stub->args.fd->inode->gfid));
                 call_unwind_error (stub, -1, errno);
@@ -1887,7 +1930,7 @@ posix_fsyncer (void *d)
 
                 usleep (priv->batch_fsync_delay_usec);
 
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "picked %d fsyncs", count);
 
                 switch (priv->batch_fsync_mode) {
diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h
new file mode 100644
index 0000000..9916aed
--- /dev/null
+++ b/xlators/storage/posix/src/posix-messages.h
@@ -0,0 +1,899 @@
+/*
+  Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+  This file is part of GlusterFS.
+
+  This file is licensed to you under your choice of the GNU Lesser
+  General Public License, version 3 or any later version (LGPLv3 or
+  later), or the GNU General Public License, version 2 (GPLv2), in all
+  cases as published by the Free Software Foundation.
+*/
+
+#ifndef _POSIX_MESSAGES_H_
+#define _POSIX_MESSAGES_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glfs-message-id.h"
+
+/*! \file posix-messages.h
+ *  \brief Psix log-message IDs and their descriptions
+ */
+
+/* NOTE: Rules for message additions
+ * 1) Each instance of a message is _better_ left with a unique message ID, even
+ *    if the message format is the same. Reasoning is that, if the message
+ *    format needs to change in one instance, the other instances are not
+ *    impacted or the new change does not change the ID of the instance being
+ *    modified.
+ * 2) Addition of a message,
+ *       - Should increment the GLFS_NUM_MESSAGES
+ *       - Append to the list of messages defined, towards the end
+ *       - Retain macro naming as glfs_msg_X (for redability across developers)
+ * NOTE: Rules for message format modifications
+ * 3) Check acorss the code if the message ID macro in question is reused
+ *    anywhere. If reused then then the modifications should ensure correctness
+ *    everywhere, or needs a new message ID as (1) above was not adhered to. If
+ *    not used anywhere, proceed with the required modification.
+ * NOTE: Rules for message deletion
+ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used
+ *    anywhere, then can be deleted, but will leave a hole by design, as
+ *    addition rules specify modification to the end of the list and not filling
+ *    holes.
+ */
+
+#define POSIX_COMP_BASE         GLFS_MSGID_COMP_POSIX
+#define GLFS_NUM_MESSAGES       104
+#define GLFS_MSGID_END          (POSIX_COMP_BASE + GLFS_NUM_MESSAGES + 1)
+/* Messaged with message IDs */
+#define glfs_msg_start_x POSIX_COMP_BASE, "Invalid: Start of messages"
+/*------------*/
+
+/*!
+ * @messageid 106001
+ * @diagnosis Operation could not be performed because the server quorum was not
+ *            met
+ * @recommendedaction Ensure that other peer nodes are online and reachable from
+ *                    the local peer node
+ */
+
+#define P_MSG_XATTR_FAILED                      (POSIX_COMP_BASE + 1)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_NULL_GFID                         (POSIX_COMP_BASE + 2)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+
+#define P_MSG_FCNTL_FAILED                      (POSIX_COMP_BASE + 3)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_READV_FAILED                      (POSIX_COMP_BASE + 4)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FSTAT_FAILED                      (POSIX_COMP_BASE + 5)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_PFD_NULL                          (POSIX_COMP_BASE + 6)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INVALID_ARGUMENT                  (POSIX_COMP_BASE + 7)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_IO_SUBMIT_FAILED                  (POSIX_COMP_BASE + 8)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_WRITEV_FAILED                     (POSIX_COMP_BASE + 9)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_IO_GETEVENTS_FAILED               (POSIX_COMP_BASE + 10)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_UNKNOWN_OP                        (POSIX_COMP_BASE + 11)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_AIO_UNAVAILABLE                   (POSIX_COMP_BASE + 12)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_IO_SETUP_FAILED                   (POSIX_COMP_BASE + 13)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_ZEROFILL_FAILED                   (POSIX_COMP_BASE + 14)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_OPENDIR_FAILED                    (POSIX_COMP_BASE + 15)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DIRFD_FAILED                      (POSIX_COMP_BASE + 16)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FD_PATH_SETTING_FAILED            (POSIX_COMP_BASE + 17)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_LSTAT_FAILED                      (POSIX_COMP_BASE + 18)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_READYLINK_FAILED                  (POSIX_COMP_BASE + 19)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_GFID_FAILED                       (POSIX_COMP_BASE + 20)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_CREATE_FAILED                     (POSIX_COMP_BASE + 21)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_MKNOD_FAILED                      (POSIX_COMP_BASE + 22)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_LCHOWN_FAILED                     (POSIX_COMP_BASE + 23)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_ACL_FAILED                        (POSIX_COMP_BASE + 24)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_MKDIR_NOT_PERMITTED               (POSIX_COMP_BASE + 25)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DIR_OF_SAME_ID                    (POSIX_COMP_BASE + 26)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_MKDIR_FAILED                      (POSIX_COMP_BASE + 27)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_CHOWN_FAILED                      (POSIX_COMP_BASE + 28)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_UNLINK_FAILED                     (POSIX_COMP_BASE + 29)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_KEY_STATUS_INFO                   (POSIX_COMP_BASE + 30)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_XATTR_STATUS                      (POSIX_COMP_BASE + 31)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_RMDIR_NOT_PERMITTED               (POSIX_COMP_BASE + 32)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_RMDIR_FAILED                      (POSIX_COMP_BASE + 33)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DIR_OPERATION_FAILED              (POSIX_COMP_BASE + 34)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SYMLINK_FAILED                    (POSIX_COMP_BASE + 35)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DIR_FOUND                         (POSIX_COMP_BASE + 36)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_LINK_FAILED                       (POSIX_COMP_BASE + 37)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_TRUNCATE_FAILED                   (POSIX_COMP_BASE + 38)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FILE_OP_FAILED                    (POSIX_COMP_BASE + 39)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_READ_FAILED                       (POSIX_COMP_BASE + 40)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DICT_SET_FAILED                   (POSIX_COMP_BASE + 41)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_STATVFS_FAILED                    (POSIX_COMP_BASE + 42)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DIR_NOT_NULL                      (POSIX_COMP_BASE + 43)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FSYNC_FAILED                      (POSIX_COMP_BASE + 44)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_CLOSE_FAILED                      (POSIX_COMP_BASE + 45)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_GETTING_FILENAME_FAILED           (POSIX_COMP_BASE + 46)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INODE_PATH_GET_FAILED             (POSIX_COMP_BASE + 47)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_GET_KEY_VALUE_FAILED              (POSIX_COMP_BASE + 48)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_CHMOD_FAILED                      (POSIX_COMP_BASE + 49)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FCHMOD_FAILED                     (POSIX_COMP_BASE + 50)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FCHOWN_FAILED                     (POSIX_COMP_BASE + 51)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_UTIMES_FAILED                     (POSIX_COMP_BASE + 52)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FUTIMES_FAILED                    (POSIX_COMP_BASE + 53)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_XATTR_NOT_REMOVED                 (POSIX_COMP_BASE + 54)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_PFD_GET_FAILED                    (POSIX_COMP_BASE + 55)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_ACCESS_FAILED                     (POSIX_COMP_BASE + 56)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_PREAD_FAILED                      (POSIX_COMP_BASE + 57)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_UUID_NULL                         (POSIX_COMP_BASE + 58)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_EXPORT_DIR_MISSING                (POSIX_COMP_BASE + 59)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SUBVOLUME_ERROR                   (POSIX_COMP_BASE + 60)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_VOLUME_DANGLING                   (POSIX_COMP_BASE + 61)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INVALID_OPTION                    (POSIX_COMP_BASE + 62)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INVALID_VOLUME_ID                 (POSIX_COMP_BASE + 63)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_VOLUME_ID_ABSENT                  (POSIX_COMP_BASE + 64)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HOSTNAME_MISSING                  (POSIX_COMP_BASE + 65)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SET_ULIMIT_FAILED                 (POSIX_COMP_BASE + 66)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SET_FILE_MAX_FAILED               (POSIX_COMP_BASE + 67)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_MAX_FILE_OPEN                     (POSIX_COMP_BASE + 68)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+
+#define P_MSG_OPEN_FAILED                       (POSIX_COMP_BASE + 69)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_LOOKUP_NOT_PERMITTED              (POSIX_COMP_BASE + 70)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_RENAME_FAILED                     (POSIX_COMP_BASE + 71)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_WRITE_FAILED                      (POSIX_COMP_BASE + 72)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FILE_FAILED                       (POSIX_COMP_BASE + 73)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_THREAD_FAILED                     (POSIX_COMP_BASE + 74)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HEALTHCHECK_FAILED                (POSIX_COMP_BASE + 75)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_GET_FDCTX_FAILED                  (POSIX_COMP_BASE + 76)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLEPATH_FAILED                 (POSIX_COMP_BASE + 77)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_IPC_NOT_HANDLE                    (POSIX_COMP_BASE + 78)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SET_XDATA_FAIL                    (POSIX_COMP_BASE + 79)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_DURABILITY_REQ_NOT_SATISFIED      (POSIX_COMP_BASE + 80)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_XATTR_NOTSUP                      (POSIX_COMP_BASE + 81)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_GFID_SET_FAILED                   (POSIX_COMP_BASE + 82)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_ACL_NOTSUP                        (POSIX_COMP_BASE + 83)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_BASEPATH_CHDIR_FAILED             (POSIX_COMP_BASE + 84)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INVALID_OPTION_VAL                (POSIX_COMP_BASE + 85)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INVALID_NODE_UUID                 (POSIX_COMP_BASE + 86)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_FSYNCER_THREAD_CREATE_FAILED      (POSIX_COMP_BASE + 87)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_GF_DIRENT_CREATE_FAILED           (POSIX_COMP_BASE + 88)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_VOLUME_ID_FETCH_FAILED            (POSIX_COMP_BASE + 89)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_UNKNOWN_ARGUMENT                  (POSIX_COMP_BASE + 90)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INODE_HANDLE_CREATE               (POSIX_COMP_BASE + 91)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_ENTRY_HANDLE_CREATE               (POSIX_COMP_BASE + 92)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_PGFID_OP                          (POSIX_COMP_BASE + 93)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_POSIX_AIO                         (POSIX_COMP_BASE + 94)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLE_CREATE_TRASH               (POSIX_COMP_BASE + 95)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLE_CREATE                     (POSIX_COMP_BASE + 96)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLE_PATH_CREATE                (POSIX_COMP_BASE + 97)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SET_FILE_CONTENTS                 (POSIX_COMP_BASE + 98)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_XDATA_GETXATTR                    (POSIX_COMP_BASE + 99)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_STALE_HANDLE_REMOVE_FAILED        (POSIX_COMP_BASE + 100)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLE_PATH_CREATE_FAILED         (POSIX_COMP_BASE + 101)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLE_TRASH_CREATE               (POSIX_COMP_BASE + 102)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_HANDLE_DELETE                     (POSIX_COMP_BASE + 103)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_READLINK_FAILED                   (POSIX_COMP_BASE + 104)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+/*------------*/
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+
+#endif /* !_GLUSTERD_MESSAGES_H_ */
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 2a1df28..a2e484e 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -53,6 +53,7 @@
 #include "hashfn.h"
 #include "posix-aio.h"
 #include "glusterfs-acl.h"
+#include "posix-messages.h"
 
 extern char *marker_xattrs[];
 #define ALIGN_SIZE 4096
@@ -118,9 +119,9 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
            should not get any gfid on it */
         if (__is_root_gfid (loc->pargfid) && loc->name
             && (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "Lookup issued on %s, which is not permitted",
-                        GF_HIDDEN_PATH);
+                gf_msg (this->name, GF_LOG_WARNING, EPERM,
+                        P_MSG_LOOKUP_NOT_PERMITTED, "Lookup issued on %s,"
+                        " which is not permitted", GF_HIDDEN_PATH);
                 op_errno = EPERM;
                 op_ret = -1;
                 goto out;
@@ -145,10 +146,10 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
 
         if (op_ret == -1) {
                 if (op_errno != ENOENT) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "lstat on %s failed: %s",
-                                real_path ? real_path : "null",
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_LSTAT_FAILED,
+                                "lstat on %s failed",
+                                real_path ? real_path : "null");
                 }
 
                 entry_ret = -1;
@@ -184,9 +185,9 @@ parent:
                 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "post-operation lstat on parent %s failed: %s",
-                                par_path, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_LSTAT_FAILED, "post-operation lstat on"
+                                " parent %s failed", par_path);
 			if (op_errno == ENOENT)
 				/* If parent directory is missing in a lookup,
 				   errno should be ESTALE (bad handle) and not
@@ -200,7 +201,8 @@ parent:
         op_ret = entry_ret;
 out:
         if (!op_ret && !gfidless && gf_uuid_is_null (buf.ia_gfid)) {
-                gf_log (this->name, GF_LOG_ERROR, "buf->ia_gfid is null for "
+                gf_msg (this->name, GF_LOG_ERROR, ENODATA, P_MSG_NULL_GFID,
+                        "buf->ia_gfid is null for "
                         "%s", (real_path) ? real_path: "");
                 op_ret = -1;
                 op_errno = ENODATA;
@@ -240,11 +242,15 @@ posix_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
 
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, (op_errno == ENOENT)?
-                        GF_LOG_DEBUG:GF_LOG_ERROR,
-                        "lstat on %s failed: %s",
-                        real_path ? real_path : "<null>",
-                        strerror (op_errno));
+                if (op_errno == ENOENT) {
+                        gf_msg_debug(this->name, 0, "lstat on %s failed: %s",
+                                     real_path ? real_path : "<null>",
+                                     strerror (op_errno));
+                } else {
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_LSTAT_FAILED, "lstat on %s failed",
+                                real_path ? real_path : "<null>");
+                }
                 goto out;
         }
         if (xdata)
@@ -272,8 +278,8 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf)
 
         ret = sys_lstat (path, &stat);
         if (ret != 0) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "lstat failed: %s (%s)", path, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_LSTAT_FAILED,
+                        "lstat failed: %s", path);
                 goto out;
         }
 
@@ -286,8 +292,7 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf)
                 /* in Linux symlinks are always in mode 0777 and no
                    such call as lchmod exists.
                 */
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "%s (%s)", path, strerror (errno));
+                gf_msg_debug (this->name, 0, "%s (%s)", path, strerror (errno));
                 if (is_symlink) {
                         ret = 0;
                         goto out;
@@ -332,8 +337,8 @@ posix_do_utimes (xlator_t *this,
 
         ret = sys_lstat (path, &stat);
         if (ret != 0) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "%s (%s)", path, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_FILE_OP_FAILED, "%s", path);
                 goto out;
         }
 
@@ -347,8 +352,8 @@ posix_do_utimes (xlator_t *this,
 
         ret = lutimes (path, tv);
         if ((ret == -1) && (errno == ENOSYS)) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "%s (%s)", path, strerror (errno));
+                gf_msg_debug (this->name, 0, "%s (%s)",
+                        path, strerror (errno));
                 if (is_symlink) {
                         ret = 0;
                         goto out;
@@ -382,9 +387,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
 
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setattr (lstat) on %s failed: %s",
-                        real_path ? real_path : "<null>", strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "setattr (lstat) on %s failed",
+                        real_path ? real_path : "<null>");
                 goto out;
         }
 
@@ -392,9 +397,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
                 op_ret = posix_do_chown (this, real_path, stbuf, valid);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "setattr (chown) on %s failed: %s", real_path,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_CHOWN_FAILED, "setattr (chown) on %s "
+                                "failed", real_path);
                         goto out;
                 }
         }
@@ -403,9 +408,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
                 op_ret = posix_do_chmod (this, real_path, stbuf);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "setattr (chmod) on %s failed: %s", real_path,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_CHMOD_FAILED,  "setattr (chmod) on %s "
+                                "failed", real_path);
                         goto out;
                 }
         }
@@ -414,9 +419,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
                 op_ret = posix_do_utimes (this, real_path, stbuf);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "setattr (utimes) on %s failed: %s", real_path,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_UTIMES_FAILED, "setattr (utimes) on %s "
+                                "failed", real_path);
                         goto out;
                 }
         }
@@ -425,9 +430,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
                 op_ret = lchown (real_path, -1, -1);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "lchown (%s, -1, -1) failed => (%s)",
-                                real_path, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_LCHOWN_FAILED, "lchown (%s, -1, -1) "
+                                "failed", real_path);
 
                         goto out;
                 }
@@ -436,9 +441,8 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->gfid, real_path, &statpost);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setattr (lstat) on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "setattr (lstat) on %s failed", real_path);
                 goto out;
         }
 
@@ -490,7 +494,8 @@ posix_do_futimes (xlator_t *this,
                   int fd,
                   struct iatt *stbuf)
 {
-        gf_log (this->name, GF_LOG_WARNING, "function not implemented fd(%d)", fd);
+        gf_msg (this->name, GF_LOG_WARNING, ENOSYS, P_MSG_UNKNOWN_OP,
+                "function not implemented fd(%d)", fd);
 
         errno = ENOSYS;
         return -1;
@@ -518,17 +523,15 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "pfd is NULL from fd=%p", fd);
+                gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
                 goto out;
         }
 
         op_ret = posix_fdstat (this, pfd->fd, &statpre);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fsetattr (fstat) failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fsetattr (fstat) failed on fd=%p", fd);
                 goto out;
         }
 
@@ -536,9 +539,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
                 op_ret = posix_do_fchown (this, pfd->fd, stbuf, valid);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsetattr (fchown) failed on fd=%p: %s",
-                                fd, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FCHOWN_FAILED, "fsetattr (fchown) failed"
+                                " on fd=%p", fd);
                         goto out;
                 }
 
@@ -548,9 +551,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
                 op_ret = posix_do_fchmod (this, pfd->fd, stbuf);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsetattr (fchmod) failed on fd=%p: %s",
-                                fd, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FCHMOD_FAILED, "fsetattr (fchmod) failed"
+                                " on fd=%p", fd);
                         goto out;
                 }
         }
@@ -559,9 +562,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
                 op_ret = posix_do_futimes (this, pfd->fd, stbuf);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsetattr (futimes) on failed fd=%p: %s", fd,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FUTIMES_FAILED, "fsetattr (futimes) on "
+                                "failed fd=%p", fd);
                         goto out;
                 }
         }
@@ -570,9 +573,10 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
                 op_ret = fchown (pfd->fd, -1, -1);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fchown (%d, -1, -1) failed => (%s)",
-                                pfd->fd, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FCHOWN_FAILED,
+                                "fchown (%d, -1, -1) failed",
+                                pfd->fd);
 
                         goto out;
                 }
@@ -581,9 +585,8 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
         op_ret = posix_fdstat (this, pfd->fd, &statpost);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fsetattr (fstat) failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fsetattr (fstat) failed on fd=%p", fd);
                 goto out;
         }
 
@@ -616,17 +619,15 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "pfd is NULL from fd=%p", fd);
+                gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
                 goto out;
         }
 
         ret = posix_fdstat (this, pfd->fd, statpre);
         if (ret == -1) {
                 ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fallocate (fstat) failed on fd=%p: %s", fd,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fallocate (fstat) failed on fd=%p", fd);
                 goto out;
         }
 
@@ -639,9 +640,8 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
         ret = posix_fdstat (this, pfd->fd, statpost);
         if (ret == -1) {
                 ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fallocate (fstat) failed on fd=%p: %s", fd,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fallocate (fstat) failed on fd=%p", fd);
                 goto out;
         }
 
@@ -701,9 +701,6 @@ _posix_do_zerofill(int fd, off_t offset, off_t len, int o_direct)
         if (o_direct) {
                 alloc_buf = _page_aligned_alloc(vect_size, &iov_base);
                 if (!alloc_buf) {
-                        gf_log ("_posix_do_zerofill", GF_LOG_DEBUG,
-                                 "memory alloc failed, vect_size %d: %s",
-                                  vect_size, strerror(errno));
                         GF_FREE(vector);
                         return -1;
                 }
@@ -768,33 +765,31 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "pfd is NULL from fd=%p", fd);
+                gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd);
                 goto out;
         }
 
         ret = posix_fdstat (this, pfd->fd, statpre);
         if (ret == -1) {
                 ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation fstat failed on fd = %p: %s", fd,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "pre-operation fstat failed on fd = %p", fd);
                 goto out;
         }
         ret = _posix_do_zerofill(pfd->fd, offset, len, pfd->flags & O_DIRECT);
         if (ret < 0) {
                 ret = -errno;
-                gf_log(this->name, GF_LOG_ERROR,
-                       "zerofill failed on fd %d length %" PRId64 " %s",
-                        pfd->fd, len, strerror(errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ZEROFILL_FAILED,
+                       "zerofill failed on fd %d length %" PRId64 ,
+                        pfd->fd, len);
                 goto out;
         }
         if (pfd->flags & (O_SYNC|O_DSYNC)) {
                 ret = fsync (pfd->fd);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsync() in writev on fd %d failed: %s",
-                        pfd->fd, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_WRITEV_FAILED, "fsync() in writev on fd"
+                                "%d failed", pfd->fd);
                         ret = -errno;
                         goto out;
                 }
@@ -803,9 +798,8 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
         ret = posix_fdstat (this, pfd->fd, statpost);
         if (ret == -1) {
                 ret = -errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post operation fstat failed on fd=%p: %s", fd,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "post operation fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -899,7 +893,8 @@ posix_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata)
          * means somebody sent one that nobody else recognized, which is an
          * error much like an uncaught exception.
          */
-        gf_log (this->name, GF_LOG_ERROR, "GF_LOG_IPC(%d) not handled", op);
+        gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_IPC_NOT_HANDLE,
+                "GF_LOG_IPC(%d) not handled", op);
         STACK_UNWIND_STRICT (ipc, frame, -1, -EOPNOTSUPP, NULL);
         return 0;
 
@@ -934,18 +929,16 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
 
         if (dir == NULL) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "opendir failed on %s: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_OPENDIR_FAILED,
+                        "opendir failed on %s", real_path);
                 goto out;
         }
 
         op_ret = dirfd (dir);
         if (op_ret < 0) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "dirfd() failed on %s: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_DIRFD_FAILED,
+                        "dirfd() failed on %s", real_path);
                 goto out;
         }
 
@@ -961,9 +954,9 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
 
         op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd);
         if (op_ret)
-                gf_log (this->name, GF_LOG_WARNING,
-                        "failed to set the fd context path=%s fd=%p",
-                        real_path, fd);
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_FD_PATH_SETTING_FAILED, "failed to set the fd"
+                        "context path=%s fd=%p", real_path, fd);
 
         op_ret = 0;
 
@@ -999,14 +992,13 @@ posix_releasedir (xlator_t *this,
 
         ret = fd_ctx_del (fd, this, &tmp_pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "pfd from fd=%p is NULL", fd);
+                gf_msg_debug (this->name, 0, "pfd from fd=%p is NULL", fd);
                 goto out;
         }
 
         pfd = (struct posix_fd *)(long)tmp_pfd;
         if (!pfd->dir) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_PFD_NULL,
                         "pfd->dir is NULL for fd=%p", fd);
                 goto out;
         }
@@ -1047,19 +1039,17 @@ posix_readlink (call_frame_t *frame, xlator_t *this,
         MAKE_INODE_HANDLE (real_path, this, loc, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lstat on %s failed: %s",
-                        loc->path ? loc->path : "<null>",
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat on %s failed",
+                        loc->path ? loc->path : "<null>");
                 goto out;
         }
 
         op_ret = sys_readlink (real_path, dest, size);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "readlink on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READYLINK_FAILED,
+                        "readlink on %s failed", real_path);
                 goto out;
         }
 
@@ -1118,9 +1108,9 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent of %s failed: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent of %s failed",
+                        real_path);
                 goto out;
         }
 
@@ -1135,9 +1125,8 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
                 dict_del (xdata, GLUSTERFS_INTERNAL_FOP_KEY);
                 op_ret = dict_get_ptr (xdata, "gfid-req", &uuid_req);
                 if (op_ret) {
-                        gf_log (this->name, GF_LOG_DEBUG,
-                                "failed to get the gfid from dict for %s",
-                                loc->path);
+                        gf_msg_debug (this->name, 0, "failed to get the gfid from "
+                                "dict for %s", loc->path);
                         goto real_op;
                 }
                 op_ret = posix_create_link_if_gfid_exists (this, uuid_req,
@@ -1163,17 +1152,17 @@ real_op:
                            doesn't work */
                         tmp_fd = creat (real_path, mode);
                         if (tmp_fd == -1) {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "create failed on %s: %s",
-                                        real_path, strerror (errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_CREATE_FAILED, "create failed on"
+                                        "%s", real_path);
                                 goto out;
                         }
                         close (tmp_fd);
                 } else {
 
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "mknod on %s failed: %s", real_path,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_MKNOD_FAILED,
+                                "mknod on %s failed", real_path);
                         goto out;
                 }
         }
@@ -1184,9 +1173,8 @@ real_op:
         op_ret = lchown (real_path, frame->root->uid, gid);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lchown on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED,
+                        "lchown on %s failed", real_path);
                 goto out;
         }
 #endif
@@ -1194,9 +1182,8 @@ real_op:
 post_op:
         op_ret = posix_acl_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting ACLs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ACL_FAILED,
+                        "setting ACLs on %s failed", real_path);
         }
 
         if (priv->update_pgfid_nlinks) {
@@ -1211,15 +1198,14 @@ post_op:
 ignore:
         op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting xattrs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_XATTR_FAILED,
+                        "setting xattrs on %s failed", real_path);
         }
 
         if (!linked) {
                 op_ret = posix_gfid_set (this, real_path, loc, xdata);
                 if (op_ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED,
                                 "setting gfid on %s failed", real_path);
                 } else {
                         gfid_set = _gf_true;
@@ -1229,18 +1215,17 @@ ignore:
         op_ret = posix_pstat (this, NULL, real_path, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "mknod on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKNOD_FAILED,
+                        "mknod on %s failed", real_path);
                 goto out;
         }
 
         op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1295,9 +1280,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
            should not get created from a user request */
         if (__is_root_gfid (loc->pargfid) &&
             (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "mkdir issued on %s, which is not permitted",
-                        GF_HIDDEN_PATH);
+                gf_msg (this->name, GF_LOG_WARNING, EPERM,
+                        P_MSG_MKDIR_NOT_PERMITTED, "mkdir issued on %s, which"
+                        "is not permitted", GF_HIDDEN_PATH);
                 op_errno = EPERM;
                 op_ret = -1;
                 goto out;
@@ -1332,11 +1317,11 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
                                 posix_handle_path (this, uuid_req, NULL,
                                                    gfid_path, size);
 
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "mkdir (%s): gfid (%s) is already associated "
-                                "with directory (%s). Hence, both directories "
-                                "will share same gfid and this can lead to "
-                                "inconsistencies.", loc->path,
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                P_MSG_DIR_OF_SAME_ID, "mkdir (%s): gfid (%s) is"
+                                "already associated with directory (%s). Hence,"
+                                "both directories will share same gfid and this"
+                                "can lead to inconsistencies.", loc->path,
                                 uuid_utoa (uuid_req), gfid_path ? gfid_path
                                 : "<NULL>");
                 }
@@ -1345,9 +1330,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1359,9 +1344,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
         op_ret = mkdir (real_path, mode);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "mkdir of %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKDIR_FAILED,
+                        "mkdir of %s failed", real_path);
                 goto out;
         }
 
@@ -1371,29 +1355,26 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
         op_ret = chown (real_path, frame->root->uid, gid);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "chown on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED,
+                        "chown on %s failed", real_path);
                 goto out;
         }
 #endif
         op_ret = posix_acl_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting ACLs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED,
+                        "setting ACLs on %s failed ", real_path);
         }
 
         op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting xattrs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED,
+                        "setting xattrs on %s failed", real_path);
         }
 
         op_ret = posix_gfid_set (this, real_path, loc, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED,
                         "setting gfid on %s failed", real_path);
         } else {
                 gfid_set = _gf_true;
@@ -1402,18 +1383,17 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, NULL, real_path, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lstat on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat on %s failed", real_path);
                 goto out;
         }
 
         op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent of %s failed: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent of %s failed",
+                        real_path);
                 goto out;
         }
 
@@ -1448,10 +1428,10 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path,
         if (stbuf && stbuf->ia_nlink == 1) {
                 ret = posix_handle_unset (this, stbuf->ia_gfid, NULL);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "unlink of gfid handle failed for path:%s with"
-                                " gfid %s with errno:%s", real_path,
-                                uuid_utoa (stbuf->ia_gfid), strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_UNLINK_FAILED, "unlink of gfid handle "
+                                "failed for path:%s with gfid %s",
+                                real_path, uuid_utoa (stbuf->ia_gfid));
                 }
         }
 
@@ -1461,9 +1441,8 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path,
                 if (op_errno)
                         *op_errno = errno;
 
-                gf_log (this->name, GF_LOG_ERROR,
-                        "unlink of %s failed: %s", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_UNLINK_FAILED,
+                        "unlink of %s failed", real_path);
                 goto err;
         }
 
@@ -1513,9 +1492,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1534,8 +1513,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
 
                 UNLOCK (&loc->inode->lock);
 
-                gf_log (this->name, GF_LOG_INFO, "open-fd-key-status: "
-                        "%"PRIu32" for %s", skip_unlink, real_path);
+                gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_KEY_STATUS_INFO,
+                        "open-fd-key-status: %"PRIu32" for %s", skip_unlink,
+                        real_path);
 
                 if (skip_unlink) {
                         op_ret = -1;
@@ -1564,8 +1544,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
 
                 UNLOCK (&loc->inode->lock);
 
-                gf_log (this->name, GF_LOG_INFO, "linkto_xattr status: "
-                        "%"PRIu32" for %s", skip_unlink, real_path);
+                gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_XATTR_STATUS,
+                        "linkto_xattr status: %"PRIu32" for %s", skip_unlink,
+                        real_path);
 
                 if (skip_unlink) {
                         op_ret = -1;
@@ -1581,9 +1562,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
                         if (fd == -1) {
                                 op_ret = -1;
                                 op_errno = errno;
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "open of %s failed: %s", real_path,
-                                        strerror (op_errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_OPEN_FAILED,
+                                        "open of %s failed", real_path);
                                 goto out;
                         }
                 }
@@ -1602,7 +1583,8 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
                 UNLOCK (&loc->inode->lock);
 
                 if (op_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING, "modification of "
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                P_MSG_XATTR_FAILED, "modification of "
                                 "parent gfid xattr failed (path:%s gfid:%s)",
                                 real_path, uuid_utoa (loc->inode->gfid));
                         if (op_errno != ENOATTR)
@@ -1620,9 +1602,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1651,9 +1633,6 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
          * all records if link count == 0*/
         if (!unwind_dict) {
                 op_ret = 0;
-                 gf_log (this->name, GF_LOG_WARNING,
-                        "Memory allocation failure while "
-                        "creating unwind_dict");
                 goto out;
         }
         /* Even if unwind_dict fails to set CTR_RESPONSE_LINK_COUNT_XDATA we
@@ -1663,7 +1642,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
         op_ret = dict_set_uint32 (unwind_dict, CTR_RESPONSE_LINK_COUNT_XDATA,
                                 stbuf.ia_nlink);
         if (op_ret == -1) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_SET_XDATA_FAIL,
                         "Failed to set CTR_RESPONSE_LINK_COUNT_XDATA");
         }
 
@@ -1714,9 +1693,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
            should not get deleted from inside process */
         if (__is_root_gfid (loc->pargfid) &&
             (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) {
-                gf_log (this->name, GF_LOG_WARNING,
-                        "rmdir issued on %s, which is not permitted",
-                        GF_HIDDEN_PATH);
+                gf_msg (this->name, GF_LOG_WARNING, EPERM,
+                        P_MSG_RMDIR_NOT_PERMITTED, "rmdir issued on %s, which"
+                        "is not permitted", GF_HIDDEN_PATH);
                 op_errno = EPERM;
                 op_ret = -1;
                 goto out;
@@ -1734,9 +1713,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1748,9 +1727,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
 
                 op_ret = mkdir (priv->trash_path, 0755);
                 if (errno != EEXIST && op_ret == -1) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "mkdir of %s failed: %s", priv->trash_path,
-                                strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_MKDIR_FAILED,
+                                "mkdir of %s failed", priv->trash_path);
                 } else {
                         sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str);
                         op_ret = rename (real_path, tmp_path);
@@ -1770,25 +1749,28 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
 
         /* No need to log a common error as ENOTEMPTY */
         if (op_ret == -1 && op_errno != ENOTEMPTY) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "rmdir of %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_RMDIR_FAILED,
+                        "rmdir of %s failed", real_path);
         }
 
         if (op_ret == -1) {
-                gf_log (this->name,
-                        (op_errno == ENOTEMPTY) ? GF_LOG_DEBUG : GF_LOG_ERROR,
-                        "%s on %s failed", (flags) ? "rename" : "rmdir",
-                        real_path);
+                if (op_errno == ENOTEMPTY) {
+                        gf_msg_debug (this->name, 0, "%s on %s failed", (flags)
+                                      ? "rename" : "rmdir", real_path);
+                } else {
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_DIR_OPERATION_FAILED, "%s on %s failed",
+                                (flags) ? "rename" : "rmdir", real_path);
+                }
                 goto out;
         }
 
         op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent of %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent of %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1843,9 +1825,9 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1857,9 +1839,9 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
 
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "symlink of %s --> %s failed: %s",
-                        real_path, linkname, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_SYMLINK_FAILED,
+                        "symlink of %s --> %s failed",
+                        real_path, linkname);
                 goto out;
         }
 
@@ -1869,17 +1851,15 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
         op_ret = lchown (real_path, frame->root->uid, gid);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lchown failed on %s: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED,
+                        "lchown failed on %s", real_path);
                 goto out;
         }
 #endif
         op_ret = posix_acl_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting ACLs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED,
+                        "setting ACLs on %s failed", real_path);
         }
 
         if (priv->update_pgfid_nlinks) {
@@ -1892,14 +1872,13 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
 ignore:
         op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting xattrs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED,
+                        "setting xattrs on %s failed ", real_path);
         }
 
         op_ret = posix_gfid_set (this, real_path, loc, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED,
                         "setting gfid on %s failed", real_path);
         } else {
                 gfid_set = _gf_true;
@@ -1908,18 +1887,17 @@ ignore:
         op_ret = posix_pstat (this, NULL, real_path, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lstat failed on %s: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat failed on %s", real_path);
                 goto out;
         }
 
         op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -1997,18 +1975,18 @@ posix_rename (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &preoldparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent %s failed: %s",
-                        par_oldpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent %s failed",
+                        par_oldpath);
                 goto out;
         }
 
         op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &prenewparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent of %s failed: %s",
-                        par_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent of %s failed",
+                        par_newpath);
                 goto out;
         }
 
@@ -2023,7 +2001,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
         }
 
         if (was_present && IA_ISDIR(stbuf.ia_type) && !newloc->inode) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, EEXIST, P_MSG_DIR_FOUND,
                         "found directory at %s while expecting ENOENT",
                         real_newpath);
                 op_ret = -1;
@@ -2033,7 +2011,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
 
         if (was_present && IA_ISDIR(stbuf.ia_type) &&
             gf_uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, EEXIST, P_MSG_DIR_FOUND,
                         "found directory %s at %s while renaming %s",
                         uuid_utoa_r (newloc->inode->gfid, olddirid),
                         real_newpath,
@@ -2063,12 +2041,17 @@ posix_rename (call_frame_t *frame, xlator_t *this,
                 op_ret = sys_rename (real_oldpath, real_newpath);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name,
-                                (op_errno == ENOTEMPTY ? GF_LOG_DEBUG
-                                 : GF_LOG_ERROR),
-                                "rename of %s to %s failed: %s",
-                                real_oldpath, real_newpath,
-                                strerror (op_errno));
+                        if (op_errno == ENOTEMPTY) {
+                                gf_msg_debug (this->name, 0, "rename of %s to"
+                                              " %s failed: %s", real_oldpath,
+                                              real_newpath,
+                                              strerror (op_errno));
+                        } else {
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_RENAME_FAILED,
+                                        "rename of %s to %s failed",
+                                        real_oldpath, real_newpath);
+                       }
 
                         if (priv->update_pgfid_nlinks
                             && !IA_ISDIR (oldloc->inode->ia_type)) {
@@ -2098,7 +2081,8 @@ unlock:
         UNLOCK (&oldloc->inode->lock);
 
         if (op_ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING, "modification of "
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_FAILED,
+                        "modification of "
                         "parent gfid xattr failed (gfid:%s)",
                         uuid_utoa (oldloc->inode->gfid));
                 goto out;
@@ -2118,27 +2102,26 @@ unlock:
         op_ret = posix_pstat (this, NULL, real_newpath, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lstat on %s failed: %s",
-                        real_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat on %s failed", real_newpath);
                 goto out;
         }
 
         op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &postoldparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent %s failed: %s",
-                        par_oldpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent %s failed",
+                        par_oldpath);
                 goto out;
         }
 
         op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postnewparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent %s failed: %s",
-                        par_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent %s failed",
+                        par_newpath);
                 goto out;
         }
 
@@ -2200,8 +2183,8 @@ posix_link (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s",
-                        par_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat failed: %s", par_newpath);
                 goto out;
         }
 
@@ -2210,9 +2193,9 @@ posix_link (call_frame_t *frame, xlator_t *this,
 
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "link %s to %s failed: %s",
-                        real_oldpath, real_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LINK_FAILED,
+                        "link %s to %s failed",
+                        real_oldpath, real_newpath);
                 goto out;
         }
 
@@ -2221,17 +2204,16 @@ posix_link (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, NULL, real_newpath, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "lstat on %s failed: %s",
-                        real_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat on %s failed", real_newpath);
                 goto out;
         }
 
         op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s",
-                        par_newpath, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat failed: %s", par_newpath);
                 goto out;
         }
 
@@ -2249,7 +2231,8 @@ posix_link (call_frame_t *frame, xlator_t *this,
                 UNLOCK (&newloc->inode->lock);
 
                 if (op_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING, "modification of "
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                P_MSG_XATTR_FAILED, "modification of "
                                 "parent gfid xattr failed (path:%s gfid:%s)",
                                 real_newpath, uuid_utoa (newloc->inode->gfid));
                         goto out;
@@ -2299,26 +2282,25 @@ posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
         MAKE_INODE_HANDLE (real_path, this, loc, &prebuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on %s failed: %s",
-                        real_path ? real_path : "<null>", strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on %s failed",
+                        real_path ? real_path : "<null>");
                 goto out;
         }
 
         op_ret = truncate (real_path, offset);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "truncate on %s failed: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED,
+                        "truncate on %s failed", real_path);
                 goto out;
         }
 
         op_ret = posix_pstat (this, loc->gfid, real_path, &postbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR, "lstat on %s failed: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "lstat on %s failed", real_path);
                 goto out;
         }
 
@@ -2382,9 +2364,9 @@ posix_create (call_frame_t *frame, xlator_t *this,
         op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "pre-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -2412,9 +2394,8 @@ posix_create (call_frame_t *frame, xlator_t *this,
         if (_fd == -1) {
                 op_errno = errno;
                 op_ret = -1;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "open on %s failed: %s", real_path,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_OPEN_FAILED,
+                        "open on %s failed", real_path);
                 goto out;
         }
 
@@ -2430,16 +2411,14 @@ posix_create (call_frame_t *frame, xlator_t *this,
         op_ret = chown (real_path, frame->root->uid, gid);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "chown on %s failed: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED,
+                        "chown on %s failed", real_path);
         }
 #endif
         op_ret = posix_acl_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting ACLs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED,
+                        "setting ACLs on %s failed", real_path);
         }
 
         if (priv->update_pgfid_nlinks) {
@@ -2452,15 +2431,14 @@ posix_create (call_frame_t *frame, xlator_t *this,
 ignore:
         op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "setting xattrs on %s failed (%s)", real_path,
-                        strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED,
+                        "setting xattrs on %s failed ", real_path);
         }
 
 fill_stat:
         op_ret = posix_gfid_set (this, real_path, loc, xdata);
         if (op_ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED,
                         "setting gfid on %s failed", real_path);
         } else {
                 gfid_set = _gf_true;
@@ -2469,17 +2447,17 @@ fill_stat:
         op_ret = posix_fdstat (this, _fd, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fstat on %d failed: %s", _fd, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fstat on %d failed", _fd);
                 goto out;
         }
 
         op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation lstat on parent %s failed: %s",
-                        par_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED,
+                        "post-operation lstat on parent %s failed",
+                        par_path);
                 goto out;
         }
 
@@ -2495,7 +2473,8 @@ fill_stat:
 
         op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd);
         if (op_ret)
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_FD_PATH_SETTING_FAILED,
                         "failed to set the fd context path=%s fd=%p",
                         real_path, fd);
 
@@ -2575,8 +2554,8 @@ posix_open (call_frame_t *frame, xlator_t *this,
         if (_fd == -1) {
                 op_ret   = -1;
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR, "open on %s, flags: %d: %s",
-                        real_path, flags, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FILE_OP_FAILED,
+                        "open on %s, flags: %d", real_path, flags);
                 goto out;
         }
 
@@ -2591,7 +2570,8 @@ posix_open (call_frame_t *frame, xlator_t *this,
 
         op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd);
         if (op_ret)
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_FD_PATH_SETTING_FAILED,
                         "failed to set the fd context path=%s fd=%p",
                         real_path, fd);
 
@@ -2643,14 +2623,15 @@ posix_readv (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto out;
         }
 
         if (!size) {
                 op_errno = EINVAL;
-                gf_log (this->name, GF_LOG_WARNING, "size=%"GF_PRI_SIZET, size);
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+                        P_MSG_INVALID_ARGUMENT, "size=%"GF_PRI_SIZET, size);
                 goto out;
         }
 
@@ -2664,9 +2645,8 @@ posix_readv (call_frame_t *frame, xlator_t *this,
         op_ret = pread (_fd, iobuf->ptr, size, offset);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "read failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READ_FAILED,
+                        "read failed on fd=%p", fd);
                 goto out;
         }
 
@@ -2691,9 +2671,8 @@ posix_readv (call_frame_t *frame, xlator_t *this,
         op_ret = posix_fdstat (this, _fd, &stbuf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "fstat failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -2818,16 +2797,17 @@ _fill_writev_xdata (fd_t *fd, dict_t *xdata, xlator_t *this, int is_append)
         ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_OPEN_FD_COUNT,
                                fd->inode->fd_count);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING, "%s: Failed to set "
-                        "dictionary value for %s", uuid_utoa (fd->inode->gfid),
-                        GLUSTERFS_OPEN_FD_COUNT);
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DICT_SET_FAILED,
+                        "%s: Failed to set dictionary value for %s",
+                        uuid_utoa (fd->inode->gfid), GLUSTERFS_OPEN_FD_COUNT);
         }
 
         ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_WRITE_IS_APPEND,
                                is_append);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING, "%s: Failed to set "
-                        "dictionary value for %s", uuid_utoa (fd->inode->gfid),
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DICT_SET_FAILED,
+                        "%s: Failed to set dictionary value for %s",
+                        uuid_utoa (fd->inode->gfid),
                         GLUSTERFS_WRITE_IS_APPEND);
         }
 out:
@@ -2863,7 +2843,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, ret, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 op_errno = -ret;
                 goto out;
@@ -2885,9 +2865,8 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
         op_ret = posix_fdstat (this, _fd, &preop);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation fstat failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "pre-operation fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -2907,8 +2886,9 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
         if (op_ret < 0) {
                 op_errno = -op_ret;
                 op_ret = -1;
-                gf_log (this->name, GF_LOG_ERROR, "write failed: offset %"PRIu64
-                        ", %s", offset, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_WRITE_FAILED,
+                        "write failed: offset %"PRIu64
+                        ",", offset);
                 goto out;
         }
 
@@ -2927,9 +2907,10 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
                 if (flags & (O_SYNC|O_DSYNC)) {
                         ret = fsync (_fd);
 			if (ret) {
-				gf_log (this->name, GF_LOG_ERROR,
-					"fsync() in writev on fd %d failed: %s",
-					_fd, strerror (errno));
+				gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_WRITEV_FAILED,
+					"fsync() in writev on fd %d failed",
+					_fd);
 				op_ret = -1;
 				op_errno = errno;
 				goto out;
@@ -2940,9 +2921,10 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
                 if (ret == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "post-operation fstat failed on fd=%p: %s",
-                                fd, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FSTAT_FAILED,
+                                "post-operation fstat failed on fd=%p",
+                                fd);
                         goto out;
                 }
         }
@@ -2991,9 +2973,8 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
 
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "statvfs failed on %s: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_STATVFS_FAILED,
+                        "statvfs failed on %s", real_path);
                 goto out;
         }
 
@@ -3030,7 +3011,7 @@ posix_flush (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL on fd=%p", fd);
                 goto out;
         }
@@ -3059,14 +3040,14 @@ posix_release (xlator_t *this, fd_t *fd)
 
         ret = fd_ctx_del (fd, this, &tmp_pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto out;
         }
         pfd = (struct posix_fd *)(long)tmp_pfd;
 
         if (pfd->dir) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DIR_NOT_NULL,
                         "pfd->dir is %p (not NULL) for file fd=%p",
                         pfd->dir, fd);
         }
@@ -3153,7 +3134,7 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd not found in fd's ctx");
                 goto out;
         }
@@ -3163,9 +3144,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
         op_ret = posix_fdstat (this, _fd, &preop);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_WARNING,
-                        "pre-operation fstat failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED,
+                        "pre-operation fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -3173,18 +3153,18 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
                 op_ret = sys_fdatasync (_fd);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fdatasync on fd=%p failed: %s",
-                                fd, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FSYNC_FAILED, "fdatasync on fd=%p"
+                                "failed:", fd);
                         goto out;
                 }
         } else {
                 op_ret = sys_fsync (_fd);
                 if (op_ret == -1) {
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsync on fd=%p failed: %s",
-                                fd, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_FSYNC_FAILED, "fsync on fd=%p "
+                                "failed", fd);
                         goto out;
                 }
         }
@@ -3192,9 +3172,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this,
         op_ret = posix_fdstat (this, _fd, &postop);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_WARNING,
-                        "post-operation fstat failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED,
+                        "post-operation fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -3449,9 +3428,8 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,
         dirp = opendir (dirpath);
         if (!dirp) {
                 *op_errno = errno;
-                gf_log (this->name, GF_LOG_WARNING,
-                        "could not opendir %s: %s", dirpath,
-                        strerror (*op_errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_OPEN_FAILED,
+                        "could not opendir %s", dirpath);
                 goto out;
         }
 
@@ -3506,8 +3484,6 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,
                                                      + 1  // ':'
                                                      + strlen (temppath) + 1 );
                                 if (!tempv) {
-                                        gf_log (this->name, GF_LOG_WARNING,
-                                                "realloc failed on path");
                                         GF_FREE (*path);
                                         op_ret = -1;
                                         *op_errno = ENOMEM;
@@ -3528,9 +3504,8 @@ out:
                 op_ret = closedir (dirp);
                 if (op_ret == -1) {
                         *op_errno = errno;
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "closedir failed: %s",
-                                strerror (*op_errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_CLOSE_FAILED, "closedir failed");
                 }
         }
 
@@ -3588,9 +3563,9 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode,
                                              " with 'user_xattr' flag)");
 
                 } else {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "listxattr failed on %s: %s",
-                                leaf_path, strerror (*op_errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_XATTR_FAILED, "listxattr failed on"
+                                "%s", leaf_path);
 
                 }
 
@@ -3620,9 +3595,8 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode,
         op_ret = sys_lstat (leaf_path, &stbuf);
         if (op_ret == -1) {
                 *op_errno = errno;
-                gf_log (this->name, GF_LOG_WARNING, "lstat failed"
-                        " on %s: %s", leaf_path,
-                        strerror (*op_errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_LSTAT_FAILED,
+                        "lstat failed on %s", leaf_path);
                 goto out;
         }
 
@@ -3637,12 +3611,9 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode,
                                         sizeof(nlink_samepgfid));
                 if (op_ret == -1) {
                         *op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "getxattr failed on "
-                                "%s: key = %s (%s)",
-                                leaf_path,
-                                key,
-                                strerror (*op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "getxattr failed on "
+                                "%s: key = %s ", leaf_path, key);
                         goto out;
                 }
 
@@ -3766,9 +3737,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                                                &file_contents);
                 if (ret < 0) {
                         op_errno = -ret;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "getting file contents failed: %s",
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_FILE_FAILED, "getting file contents"
+                                "failed");
                         goto out;
                 }
         }
@@ -3782,9 +3753,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
         if (loc->inode && name && GF_POSIX_ACL_REQUEST (name)) {
                 ret = posix_pacl_get (real_path, name, &value);
                 if (ret || !value) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "could not get acl (%s) for %s: %s", name,
-                                real_path, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_ACL_FAILED, "could not get acl (%s) for"
+                                "%s", name, real_path);
                         op_ret = -1;
                         op_errno = errno;
                         goto out;
@@ -3793,9 +3764,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 ret = dict_set_dynstr (dict, (char *)name, value);
                 if (ret < 0) {
                         GF_FREE (value);
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "could not set acl (%s) for %s in dictionary: "
-                                "(%s)", name, real_path, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_ACL_FAILED, "could not set acl (%s) for"
+                                "%s in dictionary", name, real_path);
                         op_ret = -1;
                         op_errno = errno;
                         goto out;
@@ -3813,10 +3784,16 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
 		if (ret < 0) {
 			op_ret = -1;
 			op_errno = -ret;
-			gf_log (this->name, (op_errno == ENOENT) ?
-                                GF_LOG_DEBUG : GF_LOG_WARNING,
-				"Failed to get real filename (%s, %s): %s",
-				loc->path, name, strerror (op_errno));
+                        if (op_errno == ENOENT) {
+                                gf_msg_debug (this->name, 0, "Failed to get "
+                                              "real filename (%s, %s)",
+                                              loc->path, name);
+                        } else {
+                                gf_msg (this->name, GF_LOG_WARNING, op_errno,
+                                        P_MSG_GETTING_FILENAME_FAILED,
+				        "Failed to get real filename (%s, %s):"
+                                        , loc->path, name);
+                        }
 			goto out;
 		}
 
@@ -3828,15 +3805,15 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 if (!list_empty (&loc->inode->fd_list)) {
                         ret = dict_set_uint32 (dict, (char *)name, 1);
                         if (ret < 0)
-                                gf_log (this->name, GF_LOG_WARNING,
-                                        "Failed to set dictionary value for %s",
-                                        name);
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        P_MSG_DICT_SET_FAILED, "Failed to set "
+                                        "dictionary value for %s", name);
                 } else {
                         ret = dict_set_uint32 (dict, (char *)name, 0);
                         if (ret < 0)
-                                gf_log (this->name, GF_LOG_WARNING,
-                                        "Failed to set dictionary value for %s",
-                                        name);
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        P_MSG_DICT_SET_FAILED,  "Failed to set "
+                                        "dictionary value for %s", name);
                 }
                 goto done;
         }
@@ -3862,9 +3839,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 size = strlen (dyn_rpath) + 1;
                 ret = dict_set_dynstr (dict, (char *)name, dyn_rpath);
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "could not set value (%s) in dictionary",
-                                dyn_rpath);
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                P_MSG_DICT_SET_FAILED, "could not set value"
+                                " (%s) in dictionary", dyn_rpath);
                         GF_FREE (dyn_rpath);
                 }
 
@@ -3887,9 +3864,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 ret = dict_set_dynstr (dict, GF_XATTR_NODE_UUID_KEY,
                                        dyn_rpath);
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "could not set value (%s) in dictionary",
-                                dyn_rpath);
+                        gf_msg (this->name, GF_LOG_WARNING, -ret,
+                                P_MSG_DICT_SET_FAILED, "could not set value"
+                                "(%s) in dictionary", dyn_rpath);
                         GF_FREE (dyn_rpath);
                         op_errno = -ret;
                         goto out;
@@ -3902,7 +3879,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 ret = inode_path (loc->inode, NULL, &path);
                 if (ret < 0) {
                         op_errno = -ret;
-                        gf_log (this->name, GF_LOG_WARNING, "%s: could not get "
+                        gf_msg (this->name, GF_LOG_WARNING, op_errno,
+                                P_MSG_INODE_PATH_GET_FAILED,
+                                "%s: could not get "
                                 "inode path", uuid_utoa (loc->inode->gfid));
                         goto out;
                 }
@@ -3911,9 +3890,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 ret = dict_set_dynstr (dict, GFID_TO_PATH_KEY, path);
                 if (ret < 0) {
                         op_errno = ENOMEM;
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "could not set value (%s) in dictionary",
-                                host_buf);
                         GF_FREE (path);
                         goto out;
                 }
@@ -3935,7 +3911,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
 
                 op_ret = dict_set_dynstr (dict, GET_ANCESTRY_PATH_KEY, path);
                 if (op_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING, "could not get "
+                        gf_msg (this->name, GF_LOG_WARNING, -op_ret,
+                                P_MSG_GET_KEY_VALUE_FAILED, "could not get "
                                 "value for key (%s)", GET_ANCESTRY_PATH_KEY);
                         GF_FREE (path);
                         op_errno = -op_ret;
@@ -3964,9 +3941,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 if (priv->xattr_user_namespace == XATTR_STRIP) {
                         if (strncmp(key, "user.",5) == 0) {
                                 key += 5;
-                                gf_log (this->name,
-                                        GF_LOG_DEBUG,
-                                        "getxattr for file %s"
+                                gf_msg_debug (this->name, 0, "getxattr for file %s"
                                         " stripping user key: %s -> %s",
                                         real_path, keybuffer, key);
                         }
@@ -3984,13 +3959,13 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                                                      "flag)");
                         } else if (op_errno == ENOATTR ||
                                         op_errno == ENODATA) {
-                                gf_log (this->name, GF_LOG_DEBUG,
+                                gf_msg_debug (this->name, 0,
                                         "No such attribute:%s for file %s",
                                         key, real_path);
                         } else {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "getxattr failed on %s: %s (%s)",
-                                        real_path, key, strerror (op_errno));
+                                gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                        P_MSG_XATTR_FAILED, "getxattr failed"
+                                        " on %s: %s ", real_path, key);
                         }
 
                         goto done;
@@ -4005,9 +3980,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 if (size == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR, "getxattr failed on "
-                                "%s: key = %s (%s)", real_path, key,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "getxattr failed on "
+                                "%s: key = %s", real_path, key);
                         GF_FREE (value);
                         goto out;
                 }
@@ -4015,7 +3990,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 op_ret = dict_set_dynptr (dict, key, value, size);
                 if (op_ret < 0) {
                         op_errno = -op_ret;
-                        gf_log (this->name, GF_LOG_ERROR, "dict set operation "
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_DICT_SET_FAILED, "dict set operation "
                                 "on %s for the key %s failed.", real_path, key);
                         GF_FREE (value);
                         goto out;
@@ -4036,9 +4012,10 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                                              "flag)");
                 }
                 else {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "listxattr failed on %s: %s",
-                                real_path, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED,
+                                "listxattr failed on %s",
+                                real_path);
                 }
                 goto out;
         }
@@ -4067,9 +4044,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 if (size == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR, "getxattr failed on "
-                                "%s: key = %s (%s)", real_path, keybuffer,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "getxattr failed on "
+                                "%s: key = %s ", real_path, keybuffer);
                         break;
                 }
 
@@ -4084,9 +4061,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 if (size == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR, "getxattr failed on "
-                                "%s: key = %s (%s)", real_path, keybuffer,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "getxattr failed on "
+                                "%s: key = %s ", real_path, keybuffer);
                         GF_FREE (value);
                         break;
                 }
@@ -4102,7 +4079,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
                 op_ret = dict_set_dynptr (dict, keybuffer, value, size);
                 if (op_ret < 0) {
                         op_errno = -op_ret;
-                        gf_log (this->name, GF_LOG_ERROR, "dict set operation "
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_DICT_SET_FAILED, "dict set operation "
                                 "on %s for the key %s failed.", real_path,
                                 keybuffer);
                         GF_FREE (value);
@@ -4163,7 +4141,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto out;
         }
@@ -4179,9 +4157,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
         if (name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) {
                 ret = dict_set_uint32 (dict, (char *)name, 1);
                 if (ret < 0)
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "Failed to set dictionary value for %s",
-                                name);
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                P_MSG_DICT_SET_FAILED, "Failed to set "
+                                "dictionary value for %s", name);
                 goto done;
         }
 
@@ -4211,11 +4189,15 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
                 size = sys_fgetxattr (_fd, key, NULL, 0);
                 if (size == -1) {
                         op_errno = errno;
-                        gf_log (this->name,
-                                ((errno == ENODATA || errno == ENOATTR) ?
-                                        GF_LOG_DEBUG : GF_LOG_ERROR),
-                                "fgetxattr failed on key %s (%s)", key,
-                                strerror (op_errno));
+                        if (errno == ENODATA || errno == ENOATTR) {
+                                gf_msg_debug (this->name, 0, "fgetxattr failed"
+                                              " on key %s (%s)", key,
+                                              strerror (op_errno));
+                        } else {
+                               gf_msg (this->name, GF_LOG_ERROR, errno,
+                                       P_MSG_XATTR_FAILED, "fgetxattr failed "
+                                       "on key %s", key);
+                        }
                         goto done;
                 }
 
@@ -4228,16 +4210,17 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
                 if (size == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "
-                                "fd %p for the key %s (%s)", fd, key,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "fgetxattr failed on "
+                                "fd %p for the key %s ", fd, key);
                         GF_FREE (value);
                         goto out;
                 }
                 value [size] = '\0';
                 op_ret = dict_set_dynptr (dict, key, value, size);
                 if (op_ret < 0) {
-                        gf_log (this->name, GF_LOG_ERROR, "dict set operation "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_DICT_SET_FAILED, "dict set operation "
                                 "on key %s failed", key);
                         GF_FREE (value);
                         goto out;
@@ -4256,9 +4239,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
                                              "brick with 'user_xattr' flag)");
                 }
                 else {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "listxattr failed on %p: %s",
-                                fd, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "listxattr failed on %p:",
+                                fd);
                 }
                 goto out;
         }
@@ -4285,9 +4268,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
                 if (size == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "
-                                "fd %p for the key %s (%s)", fd, key,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "fgetxattr failed on "
+                                "fd %p for the key %s ", fd, key);
                         break;
                 }
 
@@ -4303,9 +4286,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
                 if (size == -1) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "
-                                "the fd %p for the key %s (%s)", fd, key,
-                                strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "fgetxattr failed on "
+                                "the fd %p for the key %s ", fd, key);
                         GF_FREE (value);
                         break;
                 }
@@ -4314,7 +4297,8 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
 
                 op_ret = dict_set_dynptr (dict, key, value, size);
                 if (op_ret) {
-                        gf_log (this->name, GF_LOG_ERROR, "dict set operation "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_DICT_SET_FAILED, "dict set operation "
                                 "failed on key %s", key);
                         GF_FREE (value);
                         goto out;
@@ -4380,7 +4364,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto out;
         }
@@ -4408,9 +4392,10 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
                 if (op_ret < 0) {
                         op_ret = -1;
                         op_errno = errno;
-                        gf_log (this->name, GF_LOG_WARNING,
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_DURABILITY_REQ_NOT_SATISFIED,
                                 "could not satisfy durability request: "
-                                "reason (%s)", strerror (errno));
+                                "reason ");
                 }
         }
 
@@ -4455,7 +4440,7 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data)
         char *newkey = NULL;
         if (priv->xattr_user_namespace == XATTR_STRIP) {
                 gf_remove_prefix (XATTR_USER_PREFIX, key, &newkey);
-                gf_log("remove_xattr", GF_LOG_DEBUG, "key %s => %s" , key,
+                gf_msg_debug ("remove_xattr", 0, "key %s => %s" , key,
                        newkey);
                 key = newkey;
         }
@@ -4478,9 +4463,9 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data)
         if (op_ret == -1) {
                 filler->op_errno = errno;
                 if (errno != ENOATTR && errno != ENODATA && errno != EPERM)
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "removexattr failed on %s (for %s): %s",
-                                filler->real_path, key, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "removexattr failed on %s"
+                                " (for %s)", filler->real_path, key);
         }
 #ifdef GF_DARWIN_HOST_OS
         GF_FREE(newkey);
@@ -4512,14 +4497,15 @@ posix_removexattr (call_frame_t *frame, xlator_t *this,
 
 
         if (!strcmp (GFID_XATTR_KEY, name)) {
-                gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"
-                        " on gfid for file %s", real_path);
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED,
+                        "Remove xattr called on gfid for file %s", real_path);
                 op_ret = -1;
                 goto out;
         }
         if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) {
-                gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"
-                        " on volume-id for file %s", real_path);
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED,
+                        "Remove xattr called on volume-id for file %s",
+                        real_path);
                 op_ret = -1;
                 goto out;
         }
@@ -4548,9 +4534,9 @@ posix_removexattr (call_frame_t *frame, xlator_t *this,
                 op_errno = errno;
                 if (op_errno != ENOATTR && op_errno != ENODATA &&
                     op_errno != EPERM)
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "removexattr on %s (for %s): %s", real_path,
-                                name, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "removexattr on %s "
+                                "(for %s)", real_path, name);
                 goto out;
         }
 
@@ -4592,20 +4578,20 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this,
         DECLARE_OLD_FS_ID_VAR;
 
         if (!strcmp (GFID_XATTR_KEY, name)) {
-                gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"
-                        " on gfid for file");
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED,
+                        "Remove xattr called on gfid for file");
                 goto out;
         }
         if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) {
-                gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"
-                        " on volume-id for file");
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED,
+                        "Remove xattr called on volume-id for file");
                 goto out;
         }
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL from fd=%p", fd);
                 goto out;
         }
@@ -4620,9 +4606,9 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this,
                 op_errno = errno;
                 if (op_errno != ENOATTR && op_errno != ENODATA &&
                     op_errno != EPERM)
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fremovexattr (for %s): %s",
-                                name, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_XATTR_FAILED, "fremovexattr (for %s)",
+                                name);
                 goto out;
         }
 
@@ -4666,7 +4652,7 @@ posix_fsyncdir (call_frame_t *frame, xlator_t *this,
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
                 op_errno = -ret;
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
                         "pfd is NULL, fd=%p", fd);
                 goto out;
         }
@@ -4686,7 +4672,7 @@ posix_print_xattr (dict_t *this,
                    data_t *value,
                    void *data)
 {
-        gf_log ("posix", GF_LOG_DEBUG,
+        gf_msg_debug ("posix", 0,
                 "(key/val) = (%s/%d)", key, data_to_int32 (value));
 }
 
@@ -4772,13 +4758,14 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
                                    !posix_special_xattr (marker_xattrs,
                                                          k)) {
                                 if (filler->real_path)
-                                        gf_log (this->name, GF_LOG_ERROR,
-                                                "getxattr failed on %s while doing "
-                                                "xattrop: Key:%s (%s)",
-                                                filler->real_path,
-                                                k, strerror (op_errno));
+                                        gf_msg (this->name, GF_LOG_ERROR,
+                                                op_errno, P_MSG_XATTR_FAILED,
+                                                "getxattr failed on %s while "
+                                                "doing xattrop: Key:%s ",
+                                                filler->real_path, k);
                                 else
-                                        gf_log (this->name, GF_LOG_ERROR,
+                                        gf_msg (this->name, GF_LOG_ERROR,
+                                                op_errno, P_MSG_XATTR_FAILED,
                                                 "fgetxattr failed on gfid=%s "
                                                 "while doing xattrop: "
                                                 "Key:%s (%s)",
@@ -4814,11 +4801,11 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
                         break;
 
                 default:
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "Unknown xattrop type (%d) on %s. "
-                                "Please send a bug report to "
-                                "gluster-devel@gluster.org",
-                                optype, filler->real_path);
+                        gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+                                P_MSG_UNKNOWN_OP, "Unknown xattrop type (%d)"
+                                " on %s. Please send a bug report to "
+                                "gluster-devel@gluster.org", optype,
+                                filler->real_path);
                         op_ret = -1;
                         op_errno = EINVAL;
                         goto unlock;
@@ -4842,17 +4829,17 @@ unlock:
 
         if (size == -1) {
                 if (filler->real_path)
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "setxattr failed on %s while doing xattrop: "
-                                "key=%s (%s)", filler->real_path,
-                                k, strerror (op_errno));
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_XATTR_FAILED, "setxattr failed on %s "
+                                "while doing xattrop: key=%s",
+                                filler->real_path, k);
                 else
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "fsetxattr failed on gfid=%s while doing xattrop: "
-                                "key=%s (%s)",
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                P_MSG_XATTR_FAILED,
+                                "fsetxattr failed on gfid=%s while doing "
+                                "xattrop: key=%s (%s)",
                                 uuid_utoa (filler->inode->gfid),
                                 k, strerror (op_errno));
-
                 op_ret = -1;
                 goto out;
         } else {
@@ -4860,12 +4847,12 @@ unlock:
 
                 if (size != 0) {
                         if (filler->real_path)
-                                gf_log (this->name, GF_LOG_DEBUG,
+                                gf_msg_debug (this->name, 0,
                                         "dict_set_bin failed (path=%s): "
                                         "key=%s (%s)", filler->real_path,
                                         k, strerror (-size));
                         else
-                                gf_log (this->name, GF_LOG_DEBUG,
+                                gf_msg_debug (this->name, 0,
                                         "dict_set_bin failed (gfid=%s): "
                                         "key=%s (%s)",
                                         uuid_utoa (filler->inode->gfid),
@@ -4912,9 +4899,9 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
         if (fd) {
                 op_ret = posix_fd_ctx_get (fd, this, &pfd);
                 if (op_ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "failed to get pfd from fd=%p",
-                                fd);
+                        gf_msg (this->name, GF_LOG_WARNING, EBADFD,
+                                P_MSG_PFD_GET_FAILED, "failed to get pfd from"
+                                " fd=%p", fd);
                         op_errno = EBADFD;
                         goto out;
                 }
@@ -4996,8 +4983,8 @@ posix_access (call_frame_t *frame, xlator_t *this,
         op_ret = access (real_path, mask & 07);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR, "access failed on %s: %s",
-                        real_path, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACCESS_FAILED,
+                        "access failed on %s", real_path);
                 goto out;
         }
         op_ret = 0;
@@ -5035,7 +5022,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
                         "pfd is NULL, fd=%p", fd);
                 op_errno = -ret;
                 goto out;
@@ -5046,9 +5033,8 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
         op_ret = posix_fdstat (this, _fd, &preop);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "pre-operation fstat failed on fd=%p: %s", fd,
-                        strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "pre-operation fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -5056,18 +5042,16 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
 
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "ftruncate failed on fd=%p (%"PRId64": %s",
-                        fd, offset, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED,
+                        "ftruncate failed on fd=%p (%"PRId64"", fd, offset);
                 goto out;
         }
 
         op_ret = posix_fdstat (this, _fd, &postop);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR,
-                        "post-operation fstat failed on fd=%p: %s",
-                        fd, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "post-operation fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -5108,7 +5092,7 @@ posix_fstat (call_frame_t *frame, xlator_t *this,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
                         "pfd is NULL, fd=%p", fd);
                 op_errno = -ret;
                 goto out;
@@ -5119,8 +5103,8 @@ posix_fstat (call_frame_t *frame, xlator_t *this,
         op_ret = posix_fdstat (this, _fd, &buf);
         if (op_ret == -1) {
                 op_errno = errno;
-                gf_log (this->name, GF_LOG_ERROR, "fstat failed on fd=%p: %s",
-                        fd, strerror (op_errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED,
+                        "fstat failed on fd=%p", fd);
                 goto out;
         }
 
@@ -5235,7 +5219,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
                         "pfd is NULL, fd=%p", fd);
                 count = -1;
                 errno = -ret;
@@ -5268,7 +5252,8 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
                 seekdir (dir, off);
 #ifndef GF_LINUX_HOST_OS
                 if ((u_long)telldir(dir) != off && off != pfd->dir_eof) {
-                        gf_log (THIS->name, GF_LOG_ERROR,
+                        gf_msg (THIS->name, GF_LOG_ERROR, EINVAL,
+                                P_MSG_DIR_OPERATION_FAILED,
                                 "seekdir(0x%llx) failed on dir=%p: "
                                 "Invalid argument (offset reused from "
                                 "another DIR * structure?)", off, dir);
@@ -5283,9 +5268,9 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
                 in_case = (u_long)telldir (dir);
 
                 if (in_case == -1) {
-                        gf_log (THIS->name, GF_LOG_ERROR,
-                                "telldir failed on dir=%p: %s",
-                                dir, strerror (errno));
+                        gf_msg (THIS->name, GF_LOG_ERROR, errno,
+                                P_MSG_DIR_OPERATION_FAILED,
+                                "telldir failed on dir=%p", dir);
                         goto out;
                 }
 
@@ -5295,9 +5280,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
 
                 if (!entry) {
                         if (errno == EBADF) {
-                                gf_log (THIS->name, GF_LOG_WARNING,
-                                        "readdir failed on dir=%p: %s",
-                                        dir, strerror (errno));
+                                gf_msg (THIS->name, GF_LOG_WARNING, errno,
+                                        P_MSG_DIR_OPERATION_FAILED,
+                                        "readdir failed on dir=%p",
+                                        dir);
                                 goto out;
                         }
                         break;
@@ -5342,7 +5328,8 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
 #ifndef GF_LINUX_HOST_OS
                         if ((u_long)telldir(dir) != in_case &&
                             in_case != pfd->dir_eof) {
-                                gf_log (THIS->name, GF_LOG_ERROR,
+                                gf_msg (THIS->name, GF_LOG_ERROR, EINVAL,
+                                        P_MSG_DIR_OPERATION_FAILED,
                                         "seekdir(0x%llx) failed on dir=%p: "
                                         "Invalid argument (offset reused from "
                                         "another DIR * structure?)",
@@ -5358,9 +5345,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
                 this_entry = gf_dirent_for_name (entry->d_name);
 
                 if (!this_entry) {
-                        gf_log (THIS->name, GF_LOG_ERROR,
-                                "could not create gf_dirent for entry %s: (%s)",
-                                entry->d_name, strerror (errno));
+                        gf_msg (THIS->name, GF_LOG_ERROR, errno,
+                                P_MSG_GF_DIRENT_CREATE_FAILED,
+                                "could not create "
+                                "gf_dirent for entry %s", entry->d_name);
                         goto out;
                 }
                 /*
@@ -5403,7 +5391,8 @@ posix_entry_xattr_fill (xlator_t *this, inode_t *inode,
 
         MAKE_HANDLE_PATH (entry_path, this, fd->inode->gfid, name);
         if (!entry_path) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        P_MSG_HANDLE_CREATE,
                         "Failed to create handle path for %s/%s",
                         uuid_utoa (fd->inode->gfid), name);
 
@@ -5500,7 +5489,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
                         "pfd is NULL, fd=%p", fd);
                 op_errno = -ret;
                 goto out;
@@ -5509,7 +5498,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
         dir = pfd->dir;
 
         if (!dir) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL, P_MSG_PFD_NULL,
                         "dir is NULL for fd=%p", fd);
                 op_errno = EINVAL;
                 goto out;
@@ -5663,7 +5652,7 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this,
 
         ret = posix_fd_ctx_get (fd, this, &pfd);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL,
                         "pfd is NULL, fd=%p", fd);
                 op_errno = -ret;
                 goto out;
@@ -5678,9 +5667,10 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this,
 
                 ret = pread (_fd, buf, len, offset);
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "pread of %d bytes returned %d (%s)",
-                                len, ret, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_PREAD_FAILED,
+                                "pread of %d bytes returned %d ",
+                                len, ret);
 
                         op_errno = errno;
                 }
@@ -5740,8 +5730,6 @@ mem_acct_init (xlator_t *this)
         ret = xlator_mem_acct_init (this, gf_posix_mt_end + 1);
 
         if (ret != 0) {
-                gf_log(this->name, GF_LOG_ERROR, "Memory accounting init"
-                       "failed");
                 return ret;
         }
 
@@ -5759,9 +5747,10 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid)
 
 	ret = sys_lstat (priv->base_path, &st);
 	if (ret) {
-		gf_log (this->name, GF_LOG_ERROR, "Failed to stat "
-			"brick path %s (%s)",
-			priv->base_path, strerror (errno));
+		gf_msg (this->name, GF_LOG_ERROR, errno,
+                        P_MSG_DIR_OPERATION_FAILED, "Failed to stat "
+			"brick path %s",
+			priv->base_path);
 		return ret;
 	}
 
@@ -5771,9 +5760,9 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid)
 
         ret = sys_chown (priv->base_path, uid, gid);
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "Failed to set "
-                        "uid/gid for brick path %s, %s",
-                        priv->base_path, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        P_MSG_DIR_OPERATION_FAILED, "Failed to set uid/gid for"
+                        " brick path %s", priv->base_path);
 
         return ret;
 }
@@ -5820,7 +5809,7 @@ int
 reconfigure (xlator_t *this, dict_t *options)
 {
 	int                   ret = -1;
-	struct posix_private *priv = NULL;
+struct posix_private *priv = NULL;
         int32_t               uid = -1;
         int32_t               gid = -1;
 	char                 *batch_fsync_mode_str = NULL;
@@ -5839,8 +5828,8 @@ reconfigure (xlator_t *this, dict_t *options)
 			  options, str, out);
 
 	if (set_batch_fsync_mode (priv, batch_fsync_mode_str) != 0) {
-		gf_log (this->name, GF_LOG_ERROR, "Unknown mode string: %s",
-			batch_fsync_mode_str);
+		gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT,
+                        "Unknown mode string: %s", batch_fsync_mode_str);
 		goto out;
 	}
 
@@ -5852,7 +5841,8 @@ reconfigure (xlator_t *this, dict_t *options)
                           options, str, out);
 
         if (set_xattr_user_namespace_mode (priv, xattr_user_namespace_mode_str) != 0) {
-                gf_log (this->name, GF_LOG_ERROR, "Unknown xattr user namespace mode string: %s",
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_UNKNOWN_ARGUMENT,
+                        "Unknown xattr user namespace mode string: %s",
                         xattr_user_namespace_mode_str);
                 goto out;
         }
@@ -5874,10 +5864,10 @@ reconfigure (xlator_t *this, dict_t *options)
                           options, bool, out);
 
         if (priv->node_uuid_pathinfo &&
-            (gf_uuid_is_null (priv->glusterd_uuid))) {
-                    gf_log (this->name, GF_LOG_INFO,
-                            "glusterd uuid is NULL, pathinfo xattr would"
-                            " fallback to <hostname>:<export>");
+                        (gf_uuid_is_null (priv->glusterd_uuid))) {
+                gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL,
+                        "glusterd uuid is NULL, pathinfo xattr would"
+                        " fallback to <hostname>:<export>");
         }
 
         GF_OPTION_RECONF ("health-check-interval", priv->health_check_interval,
@@ -5918,19 +5908,20 @@ init (xlator_t *this)
         dir_data = dict_get (this->options, "directory");
 
         if (this->children) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, 0, P_MSG_SUBVOLUME_ERROR,
                         "FATAL: storage/posix cannot have subvolumes");
                 ret = -1;
                 goto out;
         }
 
         if (!this->parents) {
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_VOLUME_DANGLING,
                         "Volume is dangling. Please check the volume file.");
         }
 
         if (!dir_data) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, 0,
+                        P_MSG_EXPORT_DIR_MISSING,
                         "Export directory not specified in volume file.");
                 ret = -1;
                 goto out;
@@ -5941,7 +5932,7 @@ init (xlator_t *this)
         /* Check whether the specified directory exists, if not log it. */
         op_ret = stat (dir_data->data, &buf);
         if ((op_ret != 0) || !S_ISDIR (buf.st_mode)) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED,
                         "Directory '%s' doesn't exist, exiting.",
                         dir_data->data);
                 ret = -1;
@@ -5959,25 +5950,29 @@ init (xlator_t *this)
                 if (tmp_data) {
                         if (gf_string2boolean (tmp_data->data,
                                                &tmp_bool) == -1) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        P_MSG_INVALID_OPTION,
                                         "wrong option provided for key "
                                         "\"mandate-attribute\"");
                                 ret = -1;
                                 goto out;
                         }
                         if (!tmp_bool) {
-                                gf_log (this->name, GF_LOG_WARNING,
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        P_MSG_XATTR_NOTSUP,
                                         "Extended attribute not supported, "
                                         "starting as per option");
                         } else {
-                                gf_log (this->name, GF_LOG_CRITICAL,
+                                gf_msg (this->name, GF_LOG_CRITICAL, 0,
+                                        P_MSG_XATTR_NOTSUP,
                                         "Extended attribute not supported, "
                                         "exiting.");
                                 ret = -1;
                                 goto out;
                         }
                 } else {
-                        gf_log (this->name, GF_LOG_CRITICAL,
+                        gf_msg (this->name, GF_LOG_CRITICAL, 0,
+                                P_MSG_XATTR_NOTSUP,
                                 "Extended attribute not supported, exiting.");
                         ret = -1;
                         goto out;
@@ -5988,9 +5983,10 @@ init (xlator_t *this)
         if (tmp_data) {
                 op_ret = gf_uuid_parse (tmp_data->data, dict_uuid);
                 if (op_ret < 0) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "wrong volume-id (%s) set in volume file",
-                                tmp_data->data);
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_INVALID_VOLUME_ID,
+                                "wrong volume-id (%s) set"
+                                " in volume file", tmp_data->data);
                         ret = -1;
                         goto out;
                 }
@@ -5998,7 +5994,8 @@ init (xlator_t *this)
                                       "trusted.glusterfs.volume-id", old_uuid, 16);
                 if (size == 16) {
                         if (gf_uuid_compare (old_uuid, dict_uuid)) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        P_MSG_INVALID_VOLUME_ID,
                                         "mismatching volume-id (%s) received. "
                                         "already is a part of volume %s ",
                                         tmp_data->data, uuid_utoa (old_uuid));
@@ -6007,7 +6004,8 @@ init (xlator_t *this)
                         }
                 } else if ((size == -1) &&
                            (errno == ENODATA || errno == ENOATTR)) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        P_MSG_VOLUME_ID_ABSENT,
                                         "Extended attribute trusted.glusterfs."
                                         "volume-id is absent");
                                 ret = -1;
@@ -6016,14 +6014,16 @@ init (xlator_t *this)
                 }  else if ((size == -1) && (errno != ENODATA) &&
                             (errno != ENOATTR)) {
                         /* Wrong 'volume-id' is set, it should be error */
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "%s: failed to fetch volume-id (%s)",
-                                dir_data->data, strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_VOLUME_ID_FETCH_FAILED,
+                                "%s: failed to fetch volume-id",
+                                dir_data->data);
                         ret = -1;
                         goto out;
                 } else {
                         ret = -1;
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_VOLUME_ID_FETCH_FAILED,
                                 "failed to fetch proper volume id from export");
                         goto out;
                 }
@@ -6034,7 +6034,8 @@ init (xlator_t *this)
         size = sys_lgetxattr (dir_data->data, "trusted.gfid", gfid, 16);
         if (size == 16) {
                 if (!__is_root_gfid (gfid)) {
-                        gf_log (this->name, GF_LOG_WARNING,
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_GFID_SET_FAILED,
                                 "%s: gfid (%s) is not that of glusterfs '/' ",
                                 dir_data->data, uuid_utoa (gfid));
                         ret = -1;
@@ -6042,7 +6043,8 @@ init (xlator_t *this)
                 }
         } else if (size != -1) {
                 /* Wrong 'gfid' is set, it should be error */
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_GFID_SET_FAILED,
                         "%s: wrong value set as gfid",
                         dir_data->data);
                 ret = -1;
@@ -6050,9 +6052,10 @@ init (xlator_t *this)
         } else if ((size == -1) && (errno != ENODATA) &&
                    (errno != ENOATTR)) {
                 /* Wrong 'gfid' is set, it should be error */
-                gf_log (this->name, GF_LOG_WARNING,
-                        "%s: failed to fetch gfid (%s)",
-                        dir_data->data, strerror (errno));
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_GFID_SET_FAILED,
+                        "%s: failed to fetch gfid",
+                        dir_data->data);
                 ret = -1;
                 goto out;
         } else {
@@ -6060,9 +6063,10 @@ init (xlator_t *this)
                 size = sys_lsetxattr (dir_data->data, "trusted.gfid", rootgfid,
                                      16, XATTR_CREATE);
                 if (size == -1) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "%s: failed to set gfid (%s)",
-                                dir_data->data, strerror (errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                P_MSG_GFID_SET_FAILED,
+                                "%s: failed to set gfid",
+                                dir_data->data);
                         ret = -1;
                         goto out;
                 }
@@ -6071,7 +6075,8 @@ init (xlator_t *this)
         size = sys_lgetxattr (dir_data->data, POSIX_ACL_ACCESS_XATTR,
                               NULL, 0);
         if ((size < 0) && (errno == ENOTSUP))
-                gf_log (this->name, GF_LOG_WARNING,
+                gf_msg (this->name, GF_LOG_WARNING, errno,
+                        P_MSG_ACL_NOTSUP,
                         "Posix access control list is not supported.");
 
         ret = 0;
@@ -6099,7 +6104,8 @@ init (xlator_t *this)
             _XOPEN_PATH_MAX + _private->base_path_length > _private->path_max) {
                 ret = chdir(_private->base_path);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_BASEPATH_CHDIR_FAILED,
                                 "chdir() to \"%s\" failed",
                                 _private->base_path);
                         goto out;
@@ -6130,8 +6136,9 @@ init (xlator_t *this)
                 }
                 ret = gethostname (_private->hostname, 256);
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_WARNING,
-                                "could not find hostname (%s)", strerror (errno));
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_HOSTNAME_MISSING,
+                                "could not find hostname ");
                 }
         }
 
@@ -6141,13 +6148,14 @@ init (xlator_t *this)
                 if (gf_string2boolean (tmp_data->data,
                                        &_private->export_statfs) == -1) {
                         ret = -1;
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_INVALID_OPTION_VAL,
                                 "'export-statfs-size' takes only boolean "
                                 "options");
                         goto out;
                 }
                 if (!_private->export_statfs)
-                        gf_log (this->name, GF_LOG_DEBUG,
+                        gf_msg_debug (this->name, 0,
                                 "'statfs()' returns dummy size");
         }
 
@@ -6157,14 +6165,14 @@ init (xlator_t *this)
                 if (gf_string2boolean (tmp_data->data,
                                        &_private->background_unlink) == -1) {
                         ret = -1;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "'background-unlink' takes only boolean "
-                                "options");
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_INVALID_OPTION_VAL, "'background-unlink'"
+                                " takes only boolean options");
                         goto out;
                 }
 
                 if (_private->background_unlink)
-                        gf_log (this->name, GF_LOG_DEBUG,
+                        gf_msg_debug (this->name, 0,
                                 "unlinks will be performed in background");
         }
 
@@ -6173,14 +6181,14 @@ init (xlator_t *this)
                 if (gf_string2boolean (tmp_data->data,
                                        &_private->o_direct) == -1) {
                         ret = -1;
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_INVALID_OPTION_VAL,
                                 "wrong option provided for 'o-direct'");
                         goto out;
                 }
                 if (_private->o_direct)
-                        gf_log (this->name, GF_LOG_DEBUG,
-                                "o-direct mode is enabled (O_DIRECT "
-                                "for every open)");
+                        gf_msg_debug (this->name, 0, "o-direct mode is enabled"
+                                      " (O_DIRECT for every open)");
         }
 
         tmp_data = dict_get (this->options, "update-link-count-parent");
@@ -6188,29 +6196,31 @@ init (xlator_t *this)
                 if (gf_string2boolean (tmp_data->data,
                                        &_private->update_pgfid_nlinks) == -1) {
                         ret = -1;
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "wrong value provided for "
-                                "'update-link-count-parent'");
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                P_MSG_INVALID_OPTION, "wrong value provided "
+                                "for 'update-link-count-parent'");
                         goto out;
                 }
                 if (_private->update_pgfid_nlinks)
-                        gf_log (this->name, GF_LOG_DEBUG,
-                                "update-link-count-parent is enabled. Thus for each "
-                                "file an extended attribute representing the "
-                                "number of hardlinks for that file within the "
-                                "same parent directory is set.");
+                        gf_msg_debug (this->name, 0, "update-link-count-parent"
+                                      " is enabled. Thus for each file an "
+                                      "extended attribute representing the "
+                                      "number of hardlinks for that file "
+                                      "within the same parent directory is"
+                                      " set.");
         }
 
         ret = dict_get_str (this->options, "glusterd-uuid", &guuid);
         if (!ret) {
                 if (gf_uuid_parse (guuid, _private->glusterd_uuid))
-                        gf_log (this->name, GF_LOG_WARNING, "Cannot parse "
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                P_MSG_INVALID_NODE_UUID, "Cannot parse "
                                 "glusterd (node) UUID, node-uuid xattr "
                                 "request would return - \"No such attribute\"");
         } else {
-                gf_log (this->name, GF_LOG_DEBUG, "No glusterd (node) UUID "
-                        "passed - node-uuid xattr request will return "
-                        "\"No such attribute\"");
+                gf_msg_debug (this->name, 0, "No glusterd (node) UUID passed -"
+                              " node-uuid xattr request will return \"No such"
+                              " attribute\"");
         }
         ret = 0;
 
@@ -6219,9 +6229,8 @@ init (xlator_t *this)
         dict_ret = dict_get_int32 (this->options, "janitor-sleep-duration",
                                    &janitor_sleep);
         if (dict_ret == 0) {
-                gf_log (this->name, GF_LOG_DEBUG,
-                        "Setting janitor sleep duration to %d.",
-                        janitor_sleep);
+                gf_msg_debug (this->name, 0, "Setting janitor sleep duration "
+                              "to %d.", janitor_sleep);
 
                 _private->janitor_sleep_duration = janitor_sleep;
         }
@@ -6231,7 +6240,7 @@ init (xlator_t *this)
         _private->mount_lock = opendir (dir_data->data);
         if (!_private->mount_lock) {
                 ret = -1;
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED,
                         "Could not lock brick directory");
                 goto out;
         }
@@ -6242,22 +6251,23 @@ init (xlator_t *this)
                 lim.rlim_max = 1048576;
 
                 if (setrlimit (RLIMIT_NOFILE, &lim) == -1) {
-                        gf_log (this->name, GF_LOG_WARNING,
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                P_MSG_SET_ULIMIT_FAILED,
                                 "Failed to set 'ulimit -n "
-                                " 1048576': %s", strerror(errno));
+                                " 1048576'");
                         lim.rlim_cur = 65536;
                         lim.rlim_max = 65536;
 
                         if (setrlimit (RLIMIT_NOFILE, &lim) == -1) {
-                                gf_log (this->name, GF_LOG_WARNING,
+                                gf_msg (this->name, GF_LOG_WARNING, errno,
+                                        P_MSG_SET_FILE_MAX_FAILED,
                                         "Failed to set maximum allowed open "
-                                        "file descriptors to 64k: %s",
-                                        strerror(errno));
+                                        "file descriptors to 64k");
                         }
                         else {
-                                gf_log (this->name, GF_LOG_INFO,
-                                        "Maximum allowed open file descriptors "
-                                        "set to 65536");
+                                gf_msg (this->name, GF_LOG_INFO, 0,
+                                        P_MSG_MAX_FILE_OPEN, "Maximum allowed "
+                                        "open file descriptors set to 65536");
                         }
                 }
         }
@@ -6266,7 +6276,7 @@ init (xlator_t *this)
 
         op_ret = posix_handle_init (this);
         if (op_ret == -1) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE,
                         "Posix handle setup failed");
                 ret = -1;
                 goto out;
@@ -6274,7 +6284,7 @@ init (xlator_t *this)
 
         op_ret = posix_handle_trash_init (this);
         if (op_ret < 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE_TRASH,
                         "Posix landfill setup failed");
                 ret = -1;
                 goto out;
@@ -6294,7 +6304,7 @@ init (xlator_t *this)
 		op_ret = posix_aio_on (this);
 
 		if (op_ret == -1) {
-			gf_log (this->name, GF_LOG_ERROR,
+			gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_POSIX_AIO,
 				"Posix AIO init failed");
 			ret = -1;
 			goto out;
@@ -6305,7 +6315,7 @@ init (xlator_t *this)
                         _private->node_uuid_pathinfo, bool, out);
         if (_private->node_uuid_pathinfo &&
             (gf_uuid_is_null (_private->glusterd_uuid))) {
-                        gf_log (this->name, GF_LOG_INFO,
+                        gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL,
                                 "glusterd uuid is NULL, pathinfo xattr would"
                                 " fallback to <hostname>:<export>");
         }
@@ -6328,16 +6338,17 @@ init (xlator_t *this)
 
 	ret = gf_thread_create (&_private->fsyncer, NULL, posix_fsyncer, this);
 	if (ret) {
-		gf_log (this->name, GF_LOG_ERROR, "fsyncer thread"
-			" creation failed (%s)", strerror (errno));
+		gf_msg (this->name, GF_LOG_ERROR, errno,
+                        P_MSG_FSYNCER_THREAD_CREATE_FAILED,
+                        "fsyncer thread creation failed");
 		goto out;
 	}
 
 	GF_OPTION_INIT ("batch-fsync-mode", batch_fsync_mode_str, str, out);
 
 	if (set_batch_fsync_mode (_private, batch_fsync_mode_str) != 0) {
-		gf_log (this->name, GF_LOG_ERROR, "Unknown mode string: %s",
-			batch_fsync_mode_str);
+		gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT,
+                        "Unknown mode string: %s", batch_fsync_mode_str);
 		goto out;
 	}
 
@@ -6350,7 +6361,7 @@ init (xlator_t *this)
 
         if (set_xattr_user_namespace_mode (_private,
                                            xattr_user_namespace_mode_str) != 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT,
                         "Unknown xattr user namespace mode string: %s",
                         xattr_user_namespace_mode_str);
                 goto out;
@@ -6376,7 +6387,6 @@ fini (xlator_t *this)
         GF_FREE (priv);
         return;
 }
-
 struct xlator_dumpops dumpops = {
         .priv    = posix_priv,
         .inode   = posix_inode,
-- 
1.7.1