summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glusterfsd/src/glusterfsd-messages.h2
-rw-r--r--libglusterfs/src/glfs-message-id.h1
-rw-r--r--xlators/storage/posix/src/Makefile.am3
-rw-r--r--xlators/storage/posix/src/posix-aio.c76
-rw-r--r--xlators/storage/posix/src/posix-handle.c178
-rw-r--r--xlators/storage/posix/src/posix-handle.h53
-rw-r--r--xlators/storage/posix/src/posix-helpers.c323
-rw-r--r--xlators/storage/posix/src/posix-messages.h899
-rw-r--r--xlators/storage/posix/src/posix.c1228
9 files changed, 1872 insertions, 891 deletions
diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h
index 1e47380f4cc..9c6196c1d44 100644
--- a/glusterfsd/src/glusterfsd-messages.h
+++ b/glusterfsd/src/glusterfsd-messages.h
@@ -36,7 +36,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 58c123a66d6..745ad8b32ad 100644
--- a/libglusterfs/src/glfs-message-id.h
+++ b/libglusterfs/src/glfs-message-id.h
@@ -60,6 +60,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 509b0524921..9dd89e71826 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 1818da6e34c..44824943fe4 100644
--- a/xlators/storage/posix/src/posix-aio.c
+++ b/xlators/storage/posix/src/posix-aio.c
@@ -11,6 +11,7 @@
#include "glusterfs.h"
#include "posix.h"
#include <sys/uio.h>
+#include "posix-messages.h"
#ifdef HAVE_LIBAIO
#include <libaio.h>
@@ -50,9 +51,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);
}
}
@@ -96,11 +97,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;
}
@@ -108,9 +109,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;
}
@@ -177,7 +177,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;
}
@@ -185,7 +185,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;
}
@@ -227,9 +228,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;
}
@@ -269,10 +271,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;
}
@@ -281,9 +283,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;
}
@@ -334,7 +335,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;
}
@@ -366,9 +367,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;
}
@@ -383,9 +383,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;
}
@@ -423,7 +425,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;
@@ -445,7 +448,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;
@@ -467,7 +471,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;
@@ -475,9 +479,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;
}
@@ -536,7 +541,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;
@@ -545,7 +550,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;
@@ -556,9 +561,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 9ebb2069f96..bc010a9cc65 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -20,6 +20,7 @@
#include "posix.h"
#include "xlator.h"
#include "syscall.h"
+#include "posix-messages.h"
#include "compat-errno.h"
@@ -67,12 +68,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);
@@ -147,9 +144,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;
}
@@ -240,9 +237,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;
}
@@ -259,14 +256,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;
@@ -277,7 +274,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;
@@ -287,7 +284,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;
@@ -296,7 +293,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;
@@ -456,7 +453,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;
}
@@ -472,21 +470,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;
@@ -504,25 +505,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;
@@ -531,7 +533,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,
@@ -573,18 +576,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;
}
@@ -609,8 +615,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;
@@ -659,9 +666,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;
}
@@ -670,9 +677,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;
}
@@ -692,41 +699,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,
@@ -752,41 +761,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;
}
@@ -795,7 +806,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,
@@ -820,16 +832,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:
@@ -851,7 +863,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;
@@ -860,8 +873,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;
}
@@ -881,7 +894,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 d73ff9e655a..c26e301d5af 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -14,6 +14,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
@@ -45,9 +46,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)
@@ -62,9 +63,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)
@@ -73,9 +75,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)
@@ -88,9 +91,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 { \
@@ -105,8 +108,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); \
@@ -177,7 +181,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; \
} \
@@ -189,12 +194,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; \
} \
@@ -206,7 +212,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; \
} \
@@ -224,9 +230,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 4bfb9bbf29b..36a334bd127 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -138,11 +138,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);
@@ -154,11 +156,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);
@@ -193,14 +195,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;
}
@@ -290,7 +293,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;
}
@@ -323,9 +327,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;
}
@@ -347,26 +352,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;
}
@@ -380,6 +389,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
@@ -519,7 +538,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;
@@ -532,16 +552,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;
@@ -590,16 +611,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;
@@ -763,7 +785,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;
@@ -771,9 +793,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);
@@ -819,19 +840,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;
}
}
@@ -842,29 +864,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;
}
}
@@ -888,7 +909,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;
@@ -897,8 +919,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;
}
@@ -906,8 +928,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;
}
@@ -921,8 +943,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;
}
@@ -932,8 +954,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;
}
@@ -1034,7 +1056,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>"));
@@ -1067,24 +1089,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 */
}
@@ -1113,21 +1144,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 */
}
@@ -1154,14 +1190,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;
}
@@ -1169,7 +1205,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;
}
@@ -1178,12 +1214,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;
}
@@ -1191,11 +1227,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));
}
@@ -1218,7 +1254,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)
@@ -1227,7 +1263,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);
@@ -1292,8 +1328,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,
@@ -1306,12 +1343,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);
}
@@ -1338,9 +1375,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;
}
@@ -1532,7 +1569,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;
@@ -1628,16 +1666,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
@@ -1645,9 +1683,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;
@@ -1675,7 +1713,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) {
@@ -1692,9 +1730,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;
}
@@ -1702,7 +1741,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);
{
@@ -1714,18 +1753,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);
}
@@ -1757,9 +1799,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;
}
@@ -1805,7 +1847,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);
@@ -1822,7 +1865,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);
@@ -1882,7 +1925,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 00000000000..9916aed92cd
--- /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 6d3be0cdc69..73295eb72af 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -48,6 +48,7 @@
#include "hashfn.h"
#include "posix-aio.h"
#include "glusterfs-acl.h"
+#include "posix-messages.h"
extern char *marker_xattrs[];
#define ALIGN_SIZE 4096
@@ -113,9 +114,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;
@@ -140,10 +141,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;
@@ -179,9 +180,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
@@ -195,7 +196,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;
@@ -235,11 +237,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)
@@ -267,8 +273,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;
}
@@ -281,8 +287,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;
@@ -327,8 +332,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;
}
@@ -342,8 +347,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;
@@ -377,9 +382,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;
}
@@ -387,9 +392,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;
}
}
@@ -398,9 +403,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;
}
}
@@ -409,9 +414,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;
}
}
@@ -420,9 +425,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;
}
@@ -431,9 +436,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;
}
@@ -485,7 +489,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;
@@ -513,17 +518,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;
}
@@ -531,9 +534,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;
}
@@ -543,9 +546,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;
}
}
@@ -554,9 +557,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;
}
}
@@ -565,9 +568,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;
}
@@ -576,9 +580,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;
}
@@ -611,17 +614,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;
}
@@ -634,9 +635,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;
}
@@ -696,9 +696,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;
}
@@ -763,33 +760,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;
}
@@ -798,9 +793,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;
}
@@ -894,7 +888,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;
@@ -929,18 +924,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;
}
@@ -956,9 +949,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;
@@ -994,14 +987,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;
}
@@ -1042,19 +1034,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;
}
@@ -1113,9 +1103,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;
}
@@ -1130,9 +1120,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,
@@ -1158,17 +1147,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;
}
}
@@ -1179,9 +1168,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
@@ -1189,9 +1177,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) {
@@ -1206,15 +1193,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;
@@ -1224,18 +1210,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;
}
@@ -1290,9 +1275,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;
@@ -1327,11 +1312,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>");
}
@@ -1340,9 +1325,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;
}
@@ -1354,9 +1339,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;
}
@@ -1366,29 +1350,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;
@@ -1397,18 +1378,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;
}
@@ -1443,10 +1423,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));
}
}
@@ -1456,9 +1436,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;
}
@@ -1508,9 +1487,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;
}
@@ -1529,8 +1508,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;
@@ -1559,8 +1539,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;
@@ -1576,9 +1557,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;
}
}
@@ -1597,7 +1578,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)
@@ -1615,9 +1597,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;
}
@@ -1646,9 +1628,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
@@ -1658,7 +1637,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");
}
@@ -1709,9 +1688,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;
@@ -1729,9 +1708,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;
}
@@ -1743,9 +1722,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);
@@ -1765,25 +1744,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;
}
@@ -1838,9 +1820,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;
}
@@ -1852,9 +1834,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;
}
@@ -1864,17 +1846,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) {
@@ -1887,14 +1867,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;
@@ -1903,18 +1882,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;
}
@@ -1992,18 +1970,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;
}
@@ -2018,7 +1996,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;
@@ -2028,7 +2006,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,
@@ -2058,12 +2036,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)) {
@@ -2093,7 +2076,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;
@@ -2113,27 +2097,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;
}
@@ -2195,8 +2178,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;
}
@@ -2205,9 +2188,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;
}
@@ -2216,17 +2199,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;
}
@@ -2244,7 +2226,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;
@@ -2294,26 +2277,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;
}
@@ -2377,9 +2359,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;
}
@@ -2407,9 +2389,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;
}
@@ -2425,16 +2406,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) {
@@ -2447,15 +2426,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;
@@ -2464,17 +2442,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;
}
@@ -2490,7 +2468,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);
@@ -2570,8 +2549,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;
}
@@ -2586,7 +2565,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);
@@ -2638,14 +2618,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;
}
@@ -2659,9 +2640,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;
}
@@ -2686,9 +2666,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;
}
@@ -2813,16 +2792,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:
@@ -2858,7 +2838,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;
@@ -2880,9 +2860,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;
}
@@ -2902,8 +2881,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;
}
@@ -2922,9 +2902,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;
@@ -2935,9 +2916,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;
}
}
@@ -2986,9 +2968,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;
}
@@ -3025,7 +3006,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;
}
@@ -3054,14 +3035,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);
}
@@ -3148,7 +3129,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;
}
@@ -3158,9 +3139,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;
}
@@ -3168,18 +3148,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;
}
}
@@ -3187,9 +3167,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;
}
@@ -3444,9 +3423,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;
}
@@ -3501,8 +3479,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;
@@ -3523,9 +3499,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");
}
}
@@ -3583,9 +3558,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);
}
@@ -3615,9 +3590,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;
}
@@ -3632,12 +3606,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;
}
@@ -3761,9 +3732,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;
}
}
@@ -3777,9 +3748,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;
@@ -3788,9 +3759,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;
@@ -3808,10 +3779,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;
}
@@ -3823,15 +3800,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;
}
@@ -3857,9 +3834,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);
}
@@ -3882,9 +3859,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;
@@ -3897,7 +3874,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;
}
@@ -3906,9 +3885,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;
}
@@ -3930,7 +3906,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;
@@ -3959,9 +3936,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);
}
@@ -3979,13 +3954,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;
@@ -4000,9 +3975,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;
}
@@ -4010,7 +3985,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;
@@ -4031,9 +4007,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;
}
@@ -4062,9 +4039,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;
}
@@ -4079,9 +4056,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;
}
@@ -4097,7 +4074,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);
@@ -4158,7 +4136,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;
}
@@ -4174,9 +4152,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;
}
@@ -4206,11 +4184,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;
}
@@ -4223,16 +4205,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;
@@ -4251,9 +4234,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;
}
@@ -4280,9 +4263,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;
}
@@ -4298,9 +4281,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;
}
@@ -4309,7 +4292,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;
@@ -4375,7 +4359,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;
}
@@ -4403,9 +4387,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 ");
}
}
@@ -4450,7 +4435,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;
}
@@ -4473,9 +4458,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);
@@ -4507,14 +4492,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;
}
@@ -4543,9 +4529,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;
}
@@ -4587,20 +4573,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;
}
@@ -4615,9 +4601,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;
}
@@ -4661,7 +4647,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;
}
@@ -4681,7 +4667,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));
}
@@ -4767,13 +4753,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)",
@@ -4809,11 +4796,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;
@@ -4837,17 +4824,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 {
@@ -4855,12 +4842,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),
@@ -4907,9 +4894,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;
}
@@ -4991,8 +4978,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;
@@ -5030,7 +5017,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;
@@ -5041,9 +5028,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;
}
@@ -5051,18 +5037,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;
}
@@ -5103,7 +5087,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;
@@ -5114,8 +5098,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;
}
@@ -5230,7 +5214,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;
@@ -5263,7 +5247,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);
@@ -5278,9 +5263,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;
}
@@ -5290,9 +5275,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;
@@ -5337,7 +5323,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?)",
@@ -5353,9 +5340,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;
}
/*
@@ -5398,7 +5386,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);
@@ -5495,7 +5484,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;
@@ -5504,7 +5493,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;
@@ -5658,7 +5647,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;
@@ -5673,9 +5662,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;
}
@@ -5735,8 +5725,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;
}
@@ -5754,9 +5742,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;
}
@@ -5766,9 +5755,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;
}
@@ -5815,7 +5804,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;
@@ -5834,8 +5823,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;
}
@@ -5847,7 +5836,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;
}
@@ -5869,10 +5859,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,
@@ -5913,19 +5903,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;
@@ -5936,7 +5927,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;
@@ -5954,25 +5945,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;
@@ -5983,9 +5978,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;
}
@@ -5993,7 +5989,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));
@@ -6002,7 +5999,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;
@@ -6011,14 +6009,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;
}
@@ -6029,7 +6029,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;
@@ -6037,7 +6038,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;
@@ -6045,9 +6047,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 {
@@ -6055,9 +6058,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;
}
@@ -6066,7 +6070,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;
@@ -6094,7 +6099,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;
@@ -6125,8 +6131,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 ");
}
}
@@ -6136,13 +6143,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");
}
@@ -6152,14 +6160,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");
}
@@ -6168,14 +6176,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");
@@ -6183,29 +6191,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;
@@ -6214,9 +6224,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;
}
@@ -6226,7 +6235,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;
}
@@ -6237,22 +6246,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");
}
}
}
@@ -6261,7 +6271,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;
@@ -6269,7 +6279,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;
@@ -6289,7 +6299,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;
@@ -6300,7 +6310,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>");
}
@@ -6323,16 +6333,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;
}
@@ -6345,7 +6356,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;
@@ -6371,7 +6382,6 @@ fini (xlator_t *this)
GF_FREE (priv);
return;
}
-
struct xlator_dumpops dumpops = {
.priv = posix_priv,
.inode = posix_inode,