diff options
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 1228 |
1 files changed, 619 insertions, 609 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 2a1df28040c..a2e484e4f8c 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -53,6 +53,7 @@ #include "hashfn.h" #include "posix-aio.h" #include "glusterfs-acl.h" +#include "posix-messages.h" extern char *marker_xattrs[]; #define ALIGN_SIZE 4096 @@ -118,9 +119,9 @@ posix_lookup (call_frame_t *frame, xlator_t *this, should not get any gfid on it */ if (__is_root_gfid (loc->pargfid) && loc->name && (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { - gf_log (this->name, GF_LOG_WARNING, - "Lookup issued on %s, which is not permitted", - GF_HIDDEN_PATH); + gf_msg (this->name, GF_LOG_WARNING, EPERM, + P_MSG_LOOKUP_NOT_PERMITTED, "Lookup issued on %s," + " which is not permitted", GF_HIDDEN_PATH); op_errno = EPERM; op_ret = -1; goto out; @@ -145,10 +146,10 @@ posix_lookup (call_frame_t *frame, xlator_t *this, if (op_ret == -1) { if (op_errno != ENOENT) { - gf_log (this->name, GF_LOG_ERROR, - "lstat on %s failed: %s", - real_path ? real_path : "null", - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_LSTAT_FAILED, + "lstat on %s failed", + real_path ? real_path : "null"); } entry_ret = -1; @@ -184,9 +185,9 @@ parent: op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_LSTAT_FAILED, "post-operation lstat on" + " parent %s failed", par_path); if (op_errno == ENOENT) /* If parent directory is missing in a lookup, errno should be ESTALE (bad handle) and not @@ -200,7 +201,8 @@ parent: op_ret = entry_ret; out: if (!op_ret && !gfidless && gf_uuid_is_null (buf.ia_gfid)) { - gf_log (this->name, GF_LOG_ERROR, "buf->ia_gfid is null for " + gf_msg (this->name, GF_LOG_ERROR, ENODATA, P_MSG_NULL_GFID, + "buf->ia_gfid is null for " "%s", (real_path) ? real_path: ""); op_ret = -1; op_errno = ENODATA; @@ -240,11 +242,15 @@ posix_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (op_ret == -1) { op_errno = errno; - gf_log (this->name, (op_errno == ENOENT)? - GF_LOG_DEBUG:GF_LOG_ERROR, - "lstat on %s failed: %s", - real_path ? real_path : "<null>", - strerror (op_errno)); + if (op_errno == ENOENT) { + gf_msg_debug(this->name, 0, "lstat on %s failed: %s", + real_path ? real_path : "<null>", + strerror (op_errno)); + } else { + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_LSTAT_FAILED, "lstat on %s failed", + real_path ? real_path : "<null>"); + } goto out; } if (xdata) @@ -272,8 +278,8 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf) ret = sys_lstat (path, &stat); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "lstat failed: %s (%s)", path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_LSTAT_FAILED, + "lstat failed: %s", path); goto out; } @@ -286,8 +292,7 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf) /* in Linux symlinks are always in mode 0777 and no such call as lchmod exists. */ - gf_log (this->name, GF_LOG_DEBUG, - "%s (%s)", path, strerror (errno)); + gf_msg_debug (this->name, 0, "%s (%s)", path, strerror (errno)); if (is_symlink) { ret = 0; goto out; @@ -332,8 +337,8 @@ posix_do_utimes (xlator_t *this, ret = sys_lstat (path, &stat); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "%s (%s)", path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_FILE_OP_FAILED, "%s", path); goto out; } @@ -347,8 +352,8 @@ posix_do_utimes (xlator_t *this, ret = lutimes (path, tv); if ((ret == -1) && (errno == ENOSYS)) { - gf_log (this->name, GF_LOG_DEBUG, - "%s (%s)", path, strerror (errno)); + gf_msg_debug (this->name, 0, "%s (%s)", + path, strerror (errno)); if (is_symlink) { ret = 0; goto out; @@ -382,9 +387,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "setattr (lstat) on %s failed: %s", - real_path ? real_path : "<null>", strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "setattr (lstat) on %s failed", + real_path ? real_path : "<null>"); goto out; } @@ -392,9 +397,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, op_ret = posix_do_chown (this, real_path, stbuf, valid); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "setattr (chown) on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_CHOWN_FAILED, "setattr (chown) on %s " + "failed", real_path); goto out; } } @@ -403,9 +408,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, op_ret = posix_do_chmod (this, real_path, stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "setattr (chmod) on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_CHMOD_FAILED, "setattr (chmod) on %s " + "failed", real_path); goto out; } } @@ -414,9 +419,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, op_ret = posix_do_utimes (this, real_path, stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "setattr (utimes) on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_UTIMES_FAILED, "setattr (utimes) on %s " + "failed", real_path); goto out; } } @@ -425,9 +430,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, op_ret = lchown (real_path, -1, -1); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lchown (%s, -1, -1) failed => (%s)", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_LCHOWN_FAILED, "lchown (%s, -1, -1) " + "failed", real_path); goto out; } @@ -436,9 +441,8 @@ posix_setattr (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->gfid, real_path, &statpost); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "setattr (lstat) on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "setattr (lstat) on %s failed", real_path); goto out; } @@ -490,7 +494,8 @@ posix_do_futimes (xlator_t *this, int fd, struct iatt *stbuf) { - gf_log (this->name, GF_LOG_WARNING, "function not implemented fd(%d)", fd); + gf_msg (this->name, GF_LOG_WARNING, ENOSYS, P_MSG_UNKNOWN_OP, + "function not implemented fd(%d)", fd); errno = ENOSYS; return -1; @@ -518,17 +523,15 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_DEBUG, - "pfd is NULL from fd=%p", fd); + gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd); goto out; } op_ret = posix_fdstat (this, pfd->fd, &statpre); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fsetattr (fstat) failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fsetattr (fstat) failed on fd=%p", fd); goto out; } @@ -536,9 +539,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, op_ret = posix_do_fchown (this, pfd->fd, stbuf, valid); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fsetattr (fchown) failed on fd=%p: %s", - fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FCHOWN_FAILED, "fsetattr (fchown) failed" + " on fd=%p", fd); goto out; } @@ -548,9 +551,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, op_ret = posix_do_fchmod (this, pfd->fd, stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fsetattr (fchmod) failed on fd=%p: %s", - fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FCHMOD_FAILED, "fsetattr (fchmod) failed" + " on fd=%p", fd); goto out; } } @@ -559,9 +562,9 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, op_ret = posix_do_futimes (this, pfd->fd, stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fsetattr (futimes) on failed fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FUTIMES_FAILED, "fsetattr (futimes) on " + "failed fd=%p", fd); goto out; } } @@ -570,9 +573,10 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, op_ret = fchown (pfd->fd, -1, -1); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fchown (%d, -1, -1) failed => (%s)", - pfd->fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FCHOWN_FAILED, + "fchown (%d, -1, -1) failed", + pfd->fd); goto out; } @@ -581,9 +585,8 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this, op_ret = posix_fdstat (this, pfd->fd, &statpost); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fsetattr (fstat) failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fsetattr (fstat) failed on fd=%p", fd); goto out; } @@ -616,17 +619,15 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "pfd is NULL from fd=%p", fd); + gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd); goto out; } ret = posix_fdstat (this, pfd->fd, statpre); if (ret == -1) { ret = -errno; - gf_log (this->name, GF_LOG_ERROR, - "fallocate (fstat) failed on fd=%p: %s", fd, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fallocate (fstat) failed on fd=%p", fd); goto out; } @@ -639,9 +640,8 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, ret = posix_fdstat (this, pfd->fd, statpost); if (ret == -1) { ret = -errno; - gf_log (this->name, GF_LOG_ERROR, - "fallocate (fstat) failed on fd=%p: %s", fd, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fallocate (fstat) failed on fd=%p", fd); goto out; } @@ -701,9 +701,6 @@ _posix_do_zerofill(int fd, off_t offset, off_t len, int o_direct) if (o_direct) { alloc_buf = _page_aligned_alloc(vect_size, &iov_base); if (!alloc_buf) { - gf_log ("_posix_do_zerofill", GF_LOG_DEBUG, - "memory alloc failed, vect_size %d: %s", - vect_size, strerror(errno)); GF_FREE(vector); return -1; } @@ -768,33 +765,31 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "pfd is NULL from fd=%p", fd); + gf_msg_debug (this->name, 0, "pfd is NULL from fd=%p", fd); goto out; } ret = posix_fdstat (this, pfd->fd, statpre); if (ret == -1) { ret = -errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation fstat failed on fd = %p: %s", fd, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "pre-operation fstat failed on fd = %p", fd); goto out; } ret = _posix_do_zerofill(pfd->fd, offset, len, pfd->flags & O_DIRECT); if (ret < 0) { ret = -errno; - gf_log(this->name, GF_LOG_ERROR, - "zerofill failed on fd %d length %" PRId64 " %s", - pfd->fd, len, strerror(errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ZEROFILL_FAILED, + "zerofill failed on fd %d length %" PRId64 , + pfd->fd, len); goto out; } if (pfd->flags & (O_SYNC|O_DSYNC)) { ret = fsync (pfd->fd); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "fsync() in writev on fd %d failed: %s", - pfd->fd, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_WRITEV_FAILED, "fsync() in writev on fd" + "%d failed", pfd->fd); ret = -errno; goto out; } @@ -803,9 +798,8 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, ret = posix_fdstat (this, pfd->fd, statpost); if (ret == -1) { ret = -errno; - gf_log (this->name, GF_LOG_ERROR, - "post operation fstat failed on fd=%p: %s", fd, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "post operation fstat failed on fd=%p", fd); goto out; } @@ -899,7 +893,8 @@ posix_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) * means somebody sent one that nobody else recognized, which is an * error much like an uncaught exception. */ - gf_log (this->name, GF_LOG_ERROR, "GF_LOG_IPC(%d) not handled", op); + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_IPC_NOT_HANDLE, + "GF_LOG_IPC(%d) not handled", op); STACK_UNWIND_STRICT (ipc, frame, -1, -EOPNOTSUPP, NULL); return 0; @@ -934,18 +929,16 @@ posix_opendir (call_frame_t *frame, xlator_t *this, if (dir == NULL) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "opendir failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_OPENDIR_FAILED, + "opendir failed on %s", real_path); goto out; } op_ret = dirfd (dir); if (op_ret < 0) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "dirfd() failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_DIRFD_FAILED, + "dirfd() failed on %s", real_path); goto out; } @@ -961,9 +954,9 @@ posix_opendir (call_frame_t *frame, xlator_t *this, op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd); if (op_ret) - gf_log (this->name, GF_LOG_WARNING, - "failed to set the fd context path=%s fd=%p", - real_path, fd); + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_FD_PATH_SETTING_FAILED, "failed to set the fd" + "context path=%s fd=%p", real_path, fd); op_ret = 0; @@ -999,14 +992,13 @@ posix_releasedir (xlator_t *this, ret = fd_ctx_del (fd, this, &tmp_pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_DEBUG, - "pfd from fd=%p is NULL", fd); + gf_msg_debug (this->name, 0, "pfd from fd=%p is NULL", fd); goto out; } pfd = (struct posix_fd *)(long)tmp_pfd; if (!pfd->dir) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_PFD_NULL, "pfd->dir is NULL for fd=%p", fd); goto out; } @@ -1047,19 +1039,17 @@ posix_readlink (call_frame_t *frame, xlator_t *this, MAKE_INODE_HANDLE (real_path, this, loc, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lstat on %s failed: %s", - loc->path ? loc->path : "<null>", - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat on %s failed", + loc->path ? loc->path : "<null>"); goto out; } op_ret = sys_readlink (real_path, dest, size); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "readlink on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READYLINK_FAILED, + "readlink on %s failed", real_path); goto out; } @@ -1118,9 +1108,9 @@ posix_mknod (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent of %s failed: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent of %s failed", + real_path); goto out; } @@ -1135,9 +1125,8 @@ posix_mknod (call_frame_t *frame, xlator_t *this, dict_del (xdata, GLUSTERFS_INTERNAL_FOP_KEY); op_ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (op_ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get the gfid from dict for %s", - loc->path); + gf_msg_debug (this->name, 0, "failed to get the gfid from " + "dict for %s", loc->path); goto real_op; } op_ret = posix_create_link_if_gfid_exists (this, uuid_req, @@ -1163,17 +1152,17 @@ real_op: doesn't work */ tmp_fd = creat (real_path, mode); if (tmp_fd == -1) { - gf_log (this->name, GF_LOG_ERROR, - "create failed on %s: %s", - real_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_CREATE_FAILED, "create failed on" + "%s", real_path); goto out; } close (tmp_fd); } else { - gf_log (this->name, GF_LOG_ERROR, - "mknod on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_MKNOD_FAILED, + "mknod on %s failed", real_path); goto out; } } @@ -1184,9 +1173,8 @@ real_op: op_ret = lchown (real_path, frame->root->uid, gid); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lchown on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED, + "lchown on %s failed", real_path); goto out; } #endif @@ -1194,9 +1182,8 @@ real_op: post_op: op_ret = posix_acl_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting ACLs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ACL_FAILED, + "setting ACLs on %s failed", real_path); } if (priv->update_pgfid_nlinks) { @@ -1211,15 +1198,14 @@ post_op: ignore: op_ret = posix_entry_create_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting xattrs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_XATTR_FAILED, + "setting xattrs on %s failed", real_path); } if (!linked) { op_ret = posix_gfid_set (this, real_path, loc, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, "setting gfid on %s failed", real_path); } else { gfid_set = _gf_true; @@ -1229,18 +1215,17 @@ ignore: op_ret = posix_pstat (this, NULL, real_path, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "mknod on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKNOD_FAILED, + "mknod on %s failed", real_path); goto out; } op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent %s failed", + par_path); goto out; } @@ -1295,9 +1280,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, should not get created from a user request */ if (__is_root_gfid (loc->pargfid) && (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { - gf_log (this->name, GF_LOG_WARNING, - "mkdir issued on %s, which is not permitted", - GF_HIDDEN_PATH); + gf_msg (this->name, GF_LOG_WARNING, EPERM, + P_MSG_MKDIR_NOT_PERMITTED, "mkdir issued on %s, which" + "is not permitted", GF_HIDDEN_PATH); op_errno = EPERM; op_ret = -1; goto out; @@ -1332,11 +1317,11 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, posix_handle_path (this, uuid_req, NULL, gfid_path, size); - gf_log (this->name, GF_LOG_WARNING, - "mkdir (%s): gfid (%s) is already associated " - "with directory (%s). Hence, both directories " - "will share same gfid and this can lead to " - "inconsistencies.", loc->path, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_DIR_OF_SAME_ID, "mkdir (%s): gfid (%s) is" + "already associated with directory (%s). Hence," + "both directories will share same gfid and this" + "can lead to inconsistencies.", loc->path, uuid_utoa (uuid_req), gfid_path ? gfid_path : "<NULL>"); } @@ -1345,9 +1330,9 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent %s failed", + par_path); goto out; } @@ -1359,9 +1344,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, op_ret = mkdir (real_path, mode); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "mkdir of %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKDIR_FAILED, + "mkdir of %s failed", real_path); goto out; } @@ -1371,29 +1355,26 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, op_ret = chown (real_path, frame->root->uid, gid); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "chown on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED, + "chown on %s failed", real_path); goto out; } #endif op_ret = posix_acl_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting ACLs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED, + "setting ACLs on %s failed ", real_path); } op_ret = posix_entry_create_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting xattrs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, + "setting xattrs on %s failed", real_path); } op_ret = posix_gfid_set (this, real_path, loc, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, "setting gfid on %s failed", real_path); } else { gfid_set = _gf_true; @@ -1402,18 +1383,17 @@ posix_mkdir (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, NULL, real_path, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lstat on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat on %s failed", real_path); goto out; } op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent of %s failed: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent of %s failed", + real_path); goto out; } @@ -1448,10 +1428,10 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path, if (stbuf && stbuf->ia_nlink == 1) { ret = posix_handle_unset (this, stbuf->ia_gfid, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "unlink of gfid handle failed for path:%s with" - " gfid %s with errno:%s", real_path, - uuid_utoa (stbuf->ia_gfid), strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_UNLINK_FAILED, "unlink of gfid handle " + "failed for path:%s with gfid %s", + real_path, uuid_utoa (stbuf->ia_gfid)); } } @@ -1461,9 +1441,8 @@ posix_unlink_gfid_handle_and_entry (xlator_t *this, const char *real_path, if (op_errno) *op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "unlink of %s failed: %s", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_UNLINK_FAILED, + "unlink of %s failed", real_path); goto err; } @@ -1513,9 +1492,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent %s failed", + par_path); goto out; } @@ -1534,8 +1513,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, UNLOCK (&loc->inode->lock); - gf_log (this->name, GF_LOG_INFO, "open-fd-key-status: " - "%"PRIu32" for %s", skip_unlink, real_path); + gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_KEY_STATUS_INFO, + "open-fd-key-status: %"PRIu32" for %s", skip_unlink, + real_path); if (skip_unlink) { op_ret = -1; @@ -1564,8 +1544,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, UNLOCK (&loc->inode->lock); - gf_log (this->name, GF_LOG_INFO, "linkto_xattr status: " - "%"PRIu32" for %s", skip_unlink, real_path); + gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_XATTR_STATUS, + "linkto_xattr status: %"PRIu32" for %s", skip_unlink, + real_path); if (skip_unlink) { op_ret = -1; @@ -1581,9 +1562,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, if (fd == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "open of %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_OPEN_FAILED, + "open of %s failed", real_path); goto out; } } @@ -1602,7 +1583,8 @@ posix_unlink (call_frame_t *frame, xlator_t *this, UNLOCK (&loc->inode->lock); if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, "modification of " + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_XATTR_FAILED, "modification of " "parent gfid xattr failed (path:%s gfid:%s)", real_path, uuid_utoa (loc->inode->gfid)); if (op_errno != ENOATTR) @@ -1620,9 +1602,9 @@ posix_unlink (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent %s failed", + par_path); goto out; } @@ -1651,9 +1633,6 @@ posix_unlink (call_frame_t *frame, xlator_t *this, * all records if link count == 0*/ if (!unwind_dict) { op_ret = 0; - gf_log (this->name, GF_LOG_WARNING, - "Memory allocation failure while " - "creating unwind_dict"); goto out; } /* Even if unwind_dict fails to set CTR_RESPONSE_LINK_COUNT_XDATA we @@ -1663,7 +1642,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this, op_ret = dict_set_uint32 (unwind_dict, CTR_RESPONSE_LINK_COUNT_XDATA, stbuf.ia_nlink); if (op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_SET_XDATA_FAIL, "Failed to set CTR_RESPONSE_LINK_COUNT_XDATA"); } @@ -1714,9 +1693,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, should not get deleted from inside process */ if (__is_root_gfid (loc->pargfid) && (strcmp (loc->name, GF_HIDDEN_PATH) == 0)) { - gf_log (this->name, GF_LOG_WARNING, - "rmdir issued on %s, which is not permitted", - GF_HIDDEN_PATH); + gf_msg (this->name, GF_LOG_WARNING, EPERM, + P_MSG_RMDIR_NOT_PERMITTED, "rmdir issued on %s, which" + "is not permitted", GF_HIDDEN_PATH); op_errno = EPERM; op_ret = -1; goto out; @@ -1734,9 +1713,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent %s failed", + par_path); goto out; } @@ -1748,9 +1727,9 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, op_ret = mkdir (priv->trash_path, 0755); if (errno != EEXIST && op_ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "mkdir of %s failed: %s", priv->trash_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_MKDIR_FAILED, + "mkdir of %s failed", priv->trash_path); } else { sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str); op_ret = rename (real_path, tmp_path); @@ -1770,25 +1749,28 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, /* No need to log a common error as ENOTEMPTY */ if (op_ret == -1 && op_errno != ENOTEMPTY) { - gf_log (this->name, GF_LOG_ERROR, - "rmdir of %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_RMDIR_FAILED, + "rmdir of %s failed", real_path); } if (op_ret == -1) { - gf_log (this->name, - (op_errno == ENOTEMPTY) ? GF_LOG_DEBUG : GF_LOG_ERROR, - "%s on %s failed", (flags) ? "rename" : "rmdir", - real_path); + if (op_errno == ENOTEMPTY) { + gf_msg_debug (this->name, 0, "%s on %s failed", (flags) + ? "rename" : "rmdir", real_path); + } else { + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_DIR_OPERATION_FAILED, "%s on %s failed", + (flags) ? "rename" : "rmdir", real_path); + } goto out; } op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent of %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent of %s failed", + par_path); goto out; } @@ -1843,9 +1825,9 @@ posix_symlink (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent %s failed", + par_path); goto out; } @@ -1857,9 +1839,9 @@ posix_symlink (call_frame_t *frame, xlator_t *this, if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "symlink of %s --> %s failed: %s", - real_path, linkname, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_SYMLINK_FAILED, + "symlink of %s --> %s failed", + real_path, linkname); goto out; } @@ -1869,17 +1851,15 @@ posix_symlink (call_frame_t *frame, xlator_t *this, op_ret = lchown (real_path, frame->root->uid, gid); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lchown failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED, + "lchown failed on %s", real_path); goto out; } #endif op_ret = posix_acl_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting ACLs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED, + "setting ACLs on %s failed", real_path); } if (priv->update_pgfid_nlinks) { @@ -1892,14 +1872,13 @@ posix_symlink (call_frame_t *frame, xlator_t *this, ignore: op_ret = posix_entry_create_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting xattrs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, + "setting xattrs on %s failed ", real_path); } op_ret = posix_gfid_set (this, real_path, loc, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, "setting gfid on %s failed", real_path); } else { gfid_set = _gf_true; @@ -1908,18 +1887,17 @@ ignore: op_ret = posix_pstat (this, NULL, real_path, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lstat failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat failed on %s", real_path); goto out; } op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent %s failed", + par_path); goto out; } @@ -1997,18 +1975,18 @@ posix_rename (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &preoldparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent %s failed: %s", - par_oldpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent %s failed", + par_oldpath); goto out; } op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &prenewparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent of %s failed: %s", - par_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent of %s failed", + par_newpath); goto out; } @@ -2023,7 +2001,7 @@ posix_rename (call_frame_t *frame, xlator_t *this, } if (was_present && IA_ISDIR(stbuf.ia_type) && !newloc->inode) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, EEXIST, P_MSG_DIR_FOUND, "found directory at %s while expecting ENOENT", real_newpath); op_ret = -1; @@ -2033,7 +2011,7 @@ posix_rename (call_frame_t *frame, xlator_t *this, if (was_present && IA_ISDIR(stbuf.ia_type) && gf_uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, EEXIST, P_MSG_DIR_FOUND, "found directory %s at %s while renaming %s", uuid_utoa_r (newloc->inode->gfid, olddirid), real_newpath, @@ -2063,12 +2041,17 @@ posix_rename (call_frame_t *frame, xlator_t *this, op_ret = sys_rename (real_oldpath, real_newpath); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, - (op_errno == ENOTEMPTY ? GF_LOG_DEBUG - : GF_LOG_ERROR), - "rename of %s to %s failed: %s", - real_oldpath, real_newpath, - strerror (op_errno)); + if (op_errno == ENOTEMPTY) { + gf_msg_debug (this->name, 0, "rename of %s to" + " %s failed: %s", real_oldpath, + real_newpath, + strerror (op_errno)); + } else { + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_RENAME_FAILED, + "rename of %s to %s failed", + real_oldpath, real_newpath); + } if (priv->update_pgfid_nlinks && !IA_ISDIR (oldloc->inode->ia_type)) { @@ -2098,7 +2081,8 @@ unlock: UNLOCK (&oldloc->inode->lock); if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, "modification of " + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_FAILED, + "modification of " "parent gfid xattr failed (gfid:%s)", uuid_utoa (oldloc->inode->gfid)); goto out; @@ -2118,27 +2102,26 @@ unlock: op_ret = posix_pstat (this, NULL, real_newpath, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lstat on %s failed: %s", - real_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat on %s failed", real_newpath); goto out; } op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &postoldparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_oldpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent %s failed", + par_oldpath); goto out; } op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postnewparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent %s failed", + par_newpath); goto out; } @@ -2200,8 +2183,8 @@ posix_link (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s", - par_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat failed: %s", par_newpath); goto out; } @@ -2210,9 +2193,9 @@ posix_link (call_frame_t *frame, xlator_t *this, if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "link %s to %s failed: %s", - real_oldpath, real_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LINK_FAILED, + "link %s to %s failed", + real_oldpath, real_newpath); goto out; } @@ -2221,17 +2204,16 @@ posix_link (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, NULL, real_newpath, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "lstat on %s failed: %s", - real_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat on %s failed", real_newpath); goto out; } op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s", - par_newpath, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat failed: %s", par_newpath); goto out; } @@ -2249,7 +2231,8 @@ posix_link (call_frame_t *frame, xlator_t *this, UNLOCK (&newloc->inode->lock); if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, "modification of " + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_XATTR_FAILED, "modification of " "parent gfid xattr failed (path:%s gfid:%s)", real_newpath, uuid_utoa (newloc->inode->gfid)); goto out; @@ -2299,26 +2282,25 @@ posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, MAKE_INODE_HANDLE (real_path, this, loc, &prebuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on %s failed: %s", - real_path ? real_path : "<null>", strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on %s failed", + real_path ? real_path : "<null>"); goto out; } op_ret = truncate (real_path, offset); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "truncate on %s failed: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED, + "truncate on %s failed", real_path); goto out; } op_ret = posix_pstat (this, loc->gfid, real_path, &postbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "lstat on %s failed: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "lstat on %s failed", real_path); goto out; } @@ -2382,9 +2364,9 @@ posix_create (call_frame_t *frame, xlator_t *this, op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "pre-operation lstat on parent %s failed", + par_path); goto out; } @@ -2412,9 +2394,8 @@ posix_create (call_frame_t *frame, xlator_t *this, if (_fd == -1) { op_errno = errno; op_ret = -1; - gf_log (this->name, GF_LOG_ERROR, - "open on %s failed: %s", real_path, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_OPEN_FAILED, + "open on %s failed", real_path); goto out; } @@ -2430,16 +2411,14 @@ posix_create (call_frame_t *frame, xlator_t *this, op_ret = chown (real_path, frame->root->uid, gid); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "chown on %s failed: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED, + "chown on %s failed", real_path); } #endif op_ret = posix_acl_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting ACLs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACL_FAILED, + "setting ACLs on %s failed", real_path); } if (priv->update_pgfid_nlinks) { @@ -2452,15 +2431,14 @@ posix_create (call_frame_t *frame, xlator_t *this, ignore: op_ret = posix_entry_create_xattr_set (this, real_path, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, - "setting xattrs on %s failed (%s)", real_path, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, + "setting xattrs on %s failed ", real_path); } fill_stat: op_ret = posix_gfid_set (this, real_path, loc, xdata); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_GFID_FAILED, "setting gfid on %s failed", real_path); } else { gfid_set = _gf_true; @@ -2469,17 +2447,17 @@ fill_stat: op_ret = posix_fdstat (this, _fd, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fstat on %d failed: %s", _fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fstat on %d failed", _fd); goto out; } op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation lstat on parent %s failed: %s", - par_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, + "post-operation lstat on parent %s failed", + par_path); goto out; } @@ -2495,7 +2473,8 @@ fill_stat: op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd); if (op_ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_FD_PATH_SETTING_FAILED, "failed to set the fd context path=%s fd=%p", real_path, fd); @@ -2575,8 +2554,8 @@ posix_open (call_frame_t *frame, xlator_t *this, if (_fd == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "open on %s, flags: %d: %s", - real_path, flags, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FILE_OP_FAILED, + "open on %s, flags: %d", real_path, flags); goto out; } @@ -2591,7 +2570,8 @@ posix_open (call_frame_t *frame, xlator_t *this, op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd); if (op_ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_FD_PATH_SETTING_FAILED, "failed to set the fd context path=%s fd=%p", real_path, fd); @@ -2643,14 +2623,15 @@ posix_readv (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd is NULL from fd=%p", fd); goto out; } if (!size) { op_errno = EINVAL; - gf_log (this->name, GF_LOG_WARNING, "size=%"GF_PRI_SIZET, size); + gf_msg (this->name, GF_LOG_WARNING, EINVAL, + P_MSG_INVALID_ARGUMENT, "size=%"GF_PRI_SIZET, size); goto out; } @@ -2664,9 +2645,8 @@ posix_readv (call_frame_t *frame, xlator_t *this, op_ret = pread (_fd, iobuf->ptr, size, offset); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "read failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READ_FAILED, + "read failed on fd=%p", fd); goto out; } @@ -2691,9 +2671,8 @@ posix_readv (call_frame_t *frame, xlator_t *this, op_ret = posix_fdstat (this, _fd, &stbuf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fstat failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fstat failed on fd=%p", fd); goto out; } @@ -2818,16 +2797,17 @@ _fill_writev_xdata (fd_t *fd, dict_t *xdata, xlator_t *this, int is_append) ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_OPEN_FD_COUNT, fd->inode->fd_count); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, "%s: Failed to set " - "dictionary value for %s", uuid_utoa (fd->inode->gfid), - GLUSTERFS_OPEN_FD_COUNT); + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DICT_SET_FAILED, + "%s: Failed to set dictionary value for %s", + uuid_utoa (fd->inode->gfid), GLUSTERFS_OPEN_FD_COUNT); } ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_WRITE_IS_APPEND, is_append); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, "%s: Failed to set " - "dictionary value for %s", uuid_utoa (fd->inode->gfid), + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DICT_SET_FAILED, + "%s: Failed to set dictionary value for %s", + uuid_utoa (fd->inode->gfid), GLUSTERFS_WRITE_IS_APPEND); } out: @@ -2863,7 +2843,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, ret, P_MSG_PFD_NULL, "pfd is NULL from fd=%p", fd); op_errno = -ret; goto out; @@ -2885,9 +2865,8 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, op_ret = posix_fdstat (this, _fd, &preop); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation fstat failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "pre-operation fstat failed on fd=%p", fd); goto out; } @@ -2907,8 +2886,9 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, if (op_ret < 0) { op_errno = -op_ret; op_ret = -1; - gf_log (this->name, GF_LOG_ERROR, "write failed: offset %"PRIu64 - ", %s", offset, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, P_MSG_WRITE_FAILED, + "write failed: offset %"PRIu64 + ",", offset); goto out; } @@ -2927,9 +2907,10 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, if (flags & (O_SYNC|O_DSYNC)) { ret = fsync (_fd); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "fsync() in writev on fd %d failed: %s", - _fd, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_WRITEV_FAILED, + "fsync() in writev on fd %d failed", + _fd); op_ret = -1; op_errno = errno; goto out; @@ -2940,9 +2921,10 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, if (ret == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation fstat failed on fd=%p: %s", - fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FSTAT_FAILED, + "post-operation fstat failed on fd=%p", + fd); goto out; } } @@ -2991,9 +2973,8 @@ posix_statfs (call_frame_t *frame, xlator_t *this, if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "statvfs failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_STATVFS_FAILED, + "statvfs failed on %s", real_path); goto out; } @@ -3030,7 +3011,7 @@ posix_flush (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd is NULL on fd=%p", fd); goto out; } @@ -3059,14 +3040,14 @@ posix_release (xlator_t *this, fd_t *fd) ret = fd_ctx_del (fd, this, &tmp_pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_PFD_NULL, "pfd is NULL from fd=%p", fd); goto out; } pfd = (struct posix_fd *)(long)tmp_pfd; if (pfd->dir) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_DIR_NOT_NULL, "pfd->dir is %p (not NULL) for file fd=%p", pfd->dir, fd); } @@ -3153,7 +3134,7 @@ posix_fsync (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd not found in fd's ctx"); goto out; } @@ -3163,9 +3144,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this, op_ret = posix_fdstat (this, _fd, &preop); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_WARNING, - "pre-operation fstat failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED, + "pre-operation fstat failed on fd=%p", fd); goto out; } @@ -3173,18 +3153,18 @@ posix_fsync (call_frame_t *frame, xlator_t *this, op_ret = sys_fdatasync (_fd); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fdatasync on fd=%p failed: %s", - fd, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FSYNC_FAILED, "fdatasync on fd=%p" + "failed:", fd); goto out; } } else { op_ret = sys_fsync (_fd); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "fsync on fd=%p failed: %s", - fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FSYNC_FAILED, "fsync on fd=%p " + "failed", fd); goto out; } } @@ -3192,9 +3172,8 @@ posix_fsync (call_frame_t *frame, xlator_t *this, op_ret = posix_fdstat (this, _fd, &postop); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_WARNING, - "post-operation fstat failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_FSTAT_FAILED, + "post-operation fstat failed on fd=%p", fd); goto out; } @@ -3449,9 +3428,8 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, dirp = opendir (dirpath); if (!dirp) { *op_errno = errno; - gf_log (this->name, GF_LOG_WARNING, - "could not opendir %s: %s", dirpath, - strerror (*op_errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_OPEN_FAILED, + "could not opendir %s", dirpath); goto out; } @@ -3506,8 +3484,6 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode, + 1 // ':' + strlen (temppath) + 1 ); if (!tempv) { - gf_log (this->name, GF_LOG_WARNING, - "realloc failed on path"); GF_FREE (*path); op_ret = -1; *op_errno = ENOMEM; @@ -3528,9 +3504,8 @@ out: op_ret = closedir (dirp); if (op_ret == -1) { *op_errno = errno; - gf_log (this->name, GF_LOG_WARNING, - "closedir failed: %s", - strerror (*op_errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_CLOSE_FAILED, "closedir failed"); } } @@ -3588,9 +3563,9 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, " with 'user_xattr' flag)"); } else { - gf_log (this->name, GF_LOG_WARNING, - "listxattr failed on %s: %s", - leaf_path, strerror (*op_errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_XATTR_FAILED, "listxattr failed on" + "%s", leaf_path); } @@ -3620,9 +3595,8 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, op_ret = sys_lstat (leaf_path, &stbuf); if (op_ret == -1) { *op_errno = errno; - gf_log (this->name, GF_LOG_WARNING, "lstat failed" - " on %s: %s", leaf_path, - strerror (*op_errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_LSTAT_FAILED, + "lstat failed on %s", leaf_path); goto out; } @@ -3637,12 +3611,9 @@ posix_get_ancestry_non_directory (xlator_t *this, inode_t *leaf_inode, sizeof(nlink_samepgfid)); if (op_ret == -1) { *op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "getxattr failed on " - "%s: key = %s (%s)", - leaf_path, - key, - strerror (*op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "getxattr failed on " + "%s: key = %s ", leaf_path, key); goto out; } @@ -3766,9 +3737,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, &file_contents); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_ERROR, - "getting file contents failed: %s", - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_FILE_FAILED, "getting file contents" + "failed"); goto out; } } @@ -3782,9 +3753,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (loc->inode && name && GF_POSIX_ACL_REQUEST (name)) { ret = posix_pacl_get (real_path, name, &value); if (ret || !value) { - gf_log (this->name, GF_LOG_WARNING, - "could not get acl (%s) for %s: %s", name, - real_path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_ACL_FAILED, "could not get acl (%s) for" + "%s", name, real_path); op_ret = -1; op_errno = errno; goto out; @@ -3793,9 +3764,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, ret = dict_set_dynstr (dict, (char *)name, value); if (ret < 0) { GF_FREE (value); - gf_log (this->name, GF_LOG_WARNING, - "could not set acl (%s) for %s in dictionary: " - "(%s)", name, real_path, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_ACL_FAILED, "could not set acl (%s) for" + "%s in dictionary", name, real_path); op_ret = -1; op_errno = errno; goto out; @@ -3813,10 +3784,16 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (ret < 0) { op_ret = -1; op_errno = -ret; - gf_log (this->name, (op_errno == ENOENT) ? - GF_LOG_DEBUG : GF_LOG_WARNING, - "Failed to get real filename (%s, %s): %s", - loc->path, name, strerror (op_errno)); + if (op_errno == ENOENT) { + gf_msg_debug (this->name, 0, "Failed to get " + "real filename (%s, %s)", + loc->path, name); + } else { + gf_msg (this->name, GF_LOG_WARNING, op_errno, + P_MSG_GETTING_FILENAME_FAILED, + "Failed to get real filename (%s, %s):" + , loc->path, name); + } goto out; } @@ -3828,15 +3805,15 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (!list_empty (&loc->inode->fd_list)) { ret = dict_set_uint32 (dict, (char *)name, 1); if (ret < 0) - gf_log (this->name, GF_LOG_WARNING, - "Failed to set dictionary value for %s", - name); + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, "Failed to set " + "dictionary value for %s", name); } else { ret = dict_set_uint32 (dict, (char *)name, 0); if (ret < 0) - gf_log (this->name, GF_LOG_WARNING, - "Failed to set dictionary value for %s", - name); + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, "Failed to set " + "dictionary value for %s", name); } goto done; } @@ -3862,9 +3839,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, size = strlen (dyn_rpath) + 1; ret = dict_set_dynstr (dict, (char *)name, dyn_rpath); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "could not set value (%s) in dictionary", - dyn_rpath); + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, "could not set value" + " (%s) in dictionary", dyn_rpath); GF_FREE (dyn_rpath); } @@ -3887,9 +3864,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, ret = dict_set_dynstr (dict, GF_XATTR_NODE_UUID_KEY, dyn_rpath); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "could not set value (%s) in dictionary", - dyn_rpath); + gf_msg (this->name, GF_LOG_WARNING, -ret, + P_MSG_DICT_SET_FAILED, "could not set value" + "(%s) in dictionary", dyn_rpath); GF_FREE (dyn_rpath); op_errno = -ret; goto out; @@ -3902,7 +3879,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, ret = inode_path (loc->inode, NULL, &path); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, "%s: could not get " + gf_msg (this->name, GF_LOG_WARNING, op_errno, + P_MSG_INODE_PATH_GET_FAILED, + "%s: could not get " "inode path", uuid_utoa (loc->inode->gfid)); goto out; } @@ -3911,9 +3890,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, ret = dict_set_dynstr (dict, GFID_TO_PATH_KEY, path); if (ret < 0) { op_errno = ENOMEM; - gf_log (this->name, GF_LOG_WARNING, - "could not set value (%s) in dictionary", - host_buf); GF_FREE (path); goto out; } @@ -3935,7 +3911,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, op_ret = dict_set_dynstr (dict, GET_ANCESTRY_PATH_KEY, path); if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, "could not get " + gf_msg (this->name, GF_LOG_WARNING, -op_ret, + P_MSG_GET_KEY_VALUE_FAILED, "could not get " "value for key (%s)", GET_ANCESTRY_PATH_KEY); GF_FREE (path); op_errno = -op_ret; @@ -3964,9 +3941,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (priv->xattr_user_namespace == XATTR_STRIP) { if (strncmp(key, "user.",5) == 0) { key += 5; - gf_log (this->name, - GF_LOG_DEBUG, - "getxattr for file %s" + gf_msg_debug (this->name, 0, "getxattr for file %s" " stripping user key: %s -> %s", real_path, keybuffer, key); } @@ -3984,13 +3959,13 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, "flag)"); } else if (op_errno == ENOATTR || op_errno == ENODATA) { - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "No such attribute:%s for file %s", key, real_path); } else { - gf_log (this->name, GF_LOG_ERROR, - "getxattr failed on %s: %s (%s)", - real_path, key, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_XATTR_FAILED, "getxattr failed" + " on %s: %s ", real_path, key); } goto done; @@ -4005,9 +3980,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (size == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "getxattr failed on " - "%s: key = %s (%s)", real_path, key, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "getxattr failed on " + "%s: key = %s", real_path, key); GF_FREE (value); goto out; } @@ -4015,7 +3990,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, op_ret = dict_set_dynptr (dict, key, value, size); if (op_ret < 0) { op_errno = -op_ret; - gf_log (this->name, GF_LOG_ERROR, "dict set operation " + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_DICT_SET_FAILED, "dict set operation " "on %s for the key %s failed.", real_path, key); GF_FREE (value); goto out; @@ -4036,9 +4012,10 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, "flag)"); } else { - gf_log (this->name, GF_LOG_ERROR, - "listxattr failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, + "listxattr failed on %s", + real_path); } goto out; } @@ -4067,9 +4044,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (size == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "getxattr failed on " - "%s: key = %s (%s)", real_path, keybuffer, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "getxattr failed on " + "%s: key = %s ", real_path, keybuffer); break; } @@ -4084,9 +4061,9 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, if (size == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "getxattr failed on " - "%s: key = %s (%s)", real_path, keybuffer, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "getxattr failed on " + "%s: key = %s ", real_path, keybuffer); GF_FREE (value); break; } @@ -4102,7 +4079,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, op_ret = dict_set_dynptr (dict, keybuffer, value, size); if (op_ret < 0) { op_errno = -op_ret; - gf_log (this->name, GF_LOG_ERROR, "dict set operation " + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_DICT_SET_FAILED, "dict set operation " "on %s for the key %s failed.", real_path, keybuffer); GF_FREE (value); @@ -4163,7 +4141,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd is NULL from fd=%p", fd); goto out; } @@ -4179,9 +4157,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, if (name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) { ret = dict_set_uint32 (dict, (char *)name, 1); if (ret < 0) - gf_log (this->name, GF_LOG_WARNING, - "Failed to set dictionary value for %s", - name); + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, "Failed to set " + "dictionary value for %s", name); goto done; } @@ -4211,11 +4189,15 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, size = sys_fgetxattr (_fd, key, NULL, 0); if (size == -1) { op_errno = errno; - gf_log (this->name, - ((errno == ENODATA || errno == ENOATTR) ? - GF_LOG_DEBUG : GF_LOG_ERROR), - "fgetxattr failed on key %s (%s)", key, - strerror (op_errno)); + if (errno == ENODATA || errno == ENOATTR) { + gf_msg_debug (this->name, 0, "fgetxattr failed" + " on key %s (%s)", key, + strerror (op_errno)); + } else { + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "fgetxattr failed " + "on key %s", key); + } goto done; } @@ -4228,16 +4210,17 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, if (size == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on " - "fd %p for the key %s (%s)", fd, key, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "fgetxattr failed on " + "fd %p for the key %s ", fd, key); GF_FREE (value); goto out; } value [size] = '\0'; op_ret = dict_set_dynptr (dict, key, value, size); if (op_ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "dict set operation " + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_DICT_SET_FAILED, "dict set operation " "on key %s failed", key); GF_FREE (value); goto out; @@ -4256,9 +4239,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, "brick with 'user_xattr' flag)"); } else { - gf_log (this->name, GF_LOG_ERROR, - "listxattr failed on %p: %s", - fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "listxattr failed on %p:", + fd); } goto out; } @@ -4285,9 +4268,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, if (size == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on " - "fd %p for the key %s (%s)", fd, key, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "fgetxattr failed on " + "fd %p for the key %s ", fd, key); break; } @@ -4303,9 +4286,9 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, if (size == -1) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on " - "the fd %p for the key %s (%s)", fd, key, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "fgetxattr failed on " + "the fd %p for the key %s ", fd, key); GF_FREE (value); break; } @@ -4314,7 +4297,8 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this, op_ret = dict_set_dynptr (dict, key, value, size); if (op_ret) { - gf_log (this->name, GF_LOG_ERROR, "dict set operation " + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_DICT_SET_FAILED, "dict set operation " "failed on key %s", key); GF_FREE (value); goto out; @@ -4380,7 +4364,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd is NULL from fd=%p", fd); goto out; } @@ -4408,9 +4392,10 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this, if (op_ret < 0) { op_ret = -1; op_errno = errno; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_DURABILITY_REQ_NOT_SATISFIED, "could not satisfy durability request: " - "reason (%s)", strerror (errno)); + "reason "); } } @@ -4455,7 +4440,7 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data) char *newkey = NULL; if (priv->xattr_user_namespace == XATTR_STRIP) { gf_remove_prefix (XATTR_USER_PREFIX, key, &newkey); - gf_log("remove_xattr", GF_LOG_DEBUG, "key %s => %s" , key, + gf_msg_debug ("remove_xattr", 0, "key %s => %s" , key, newkey); key = newkey; } @@ -4478,9 +4463,9 @@ _posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data) if (op_ret == -1) { filler->op_errno = errno; if (errno != ENOATTR && errno != ENODATA && errno != EPERM) - gf_log (this->name, GF_LOG_ERROR, - "removexattr failed on %s (for %s): %s", - filler->real_path, key, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "removexattr failed on %s" + " (for %s)", filler->real_path, key); } #ifdef GF_DARWIN_HOST_OS GF_FREE(newkey); @@ -4512,14 +4497,15 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, if (!strcmp (GFID_XATTR_KEY, name)) { - gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" - " on gfid for file %s", real_path); + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, + "Remove xattr called on gfid for file %s", real_path); op_ret = -1; goto out; } if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) { - gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" - " on volume-id for file %s", real_path); + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, + "Remove xattr called on volume-id for file %s", + real_path); op_ret = -1; goto out; } @@ -4548,9 +4534,9 @@ posix_removexattr (call_frame_t *frame, xlator_t *this, op_errno = errno; if (op_errno != ENOATTR && op_errno != ENODATA && op_errno != EPERM) - gf_log (this->name, GF_LOG_ERROR, - "removexattr on %s (for %s): %s", real_path, - name, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "removexattr on %s " + "(for %s)", real_path, name); goto out; } @@ -4592,20 +4578,20 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, DECLARE_OLD_FS_ID_VAR; if (!strcmp (GFID_XATTR_KEY, name)) { - gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" - " on gfid for file"); + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, + "Remove xattr called on gfid for file"); goto out; } if (!strcmp (GF_XATTR_VOL_ID_KEY, name)) { - gf_log (this->name, GF_LOG_WARNING, "Remove xattr called" - " on volume-id for file"); + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOT_REMOVED, + "Remove xattr called on volume-id for file"); goto out; } ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd is NULL from fd=%p", fd); goto out; } @@ -4620,9 +4606,9 @@ posix_fremovexattr (call_frame_t *frame, xlator_t *this, op_errno = errno; if (op_errno != ENOATTR && op_errno != ENODATA && op_errno != EPERM) - gf_log (this->name, GF_LOG_ERROR, - "fremovexattr (for %s): %s", - name, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_XATTR_FAILED, "fremovexattr (for %s)", + name); goto out; } @@ -4666,7 +4652,7 @@ posix_fsyncdir (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { op_errno = -ret; - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL, "pfd is NULL, fd=%p", fd); goto out; } @@ -4686,7 +4672,7 @@ posix_print_xattr (dict_t *this, data_t *value, void *data) { - gf_log ("posix", GF_LOG_DEBUG, + gf_msg_debug ("posix", 0, "(key/val) = (%s/%d)", key, data_to_int32 (value)); } @@ -4772,13 +4758,14 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, !posix_special_xattr (marker_xattrs, k)) { if (filler->real_path) - gf_log (this->name, GF_LOG_ERROR, - "getxattr failed on %s while doing " - "xattrop: Key:%s (%s)", - filler->real_path, - k, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, + op_errno, P_MSG_XATTR_FAILED, + "getxattr failed on %s while " + "doing xattrop: Key:%s ", + filler->real_path, k); else - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, + op_errno, P_MSG_XATTR_FAILED, "fgetxattr failed on gfid=%s " "while doing xattrop: " "Key:%s (%s)", @@ -4814,11 +4801,11 @@ _posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v, break; default: - gf_log (this->name, GF_LOG_ERROR, - "Unknown xattrop type (%d) on %s. " - "Please send a bug report to " - "gluster-devel@gluster.org", - optype, filler->real_path); + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + P_MSG_UNKNOWN_OP, "Unknown xattrop type (%d)" + " on %s. Please send a bug report to " + "gluster-devel@gluster.org", optype, + filler->real_path); op_ret = -1; op_errno = EINVAL; goto unlock; @@ -4842,17 +4829,17 @@ unlock: if (size == -1) { if (filler->real_path) - gf_log (this->name, GF_LOG_ERROR, - "setxattr failed on %s while doing xattrop: " - "key=%s (%s)", filler->real_path, - k, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_XATTR_FAILED, "setxattr failed on %s " + "while doing xattrop: key=%s", + filler->real_path, k); else - gf_log (this->name, GF_LOG_ERROR, - "fsetxattr failed on gfid=%s while doing xattrop: " - "key=%s (%s)", + gf_msg (this->name, GF_LOG_ERROR, op_errno, + P_MSG_XATTR_FAILED, + "fsetxattr failed on gfid=%s while doing " + "xattrop: key=%s (%s)", uuid_utoa (filler->inode->gfid), k, strerror (op_errno)); - op_ret = -1; goto out; } else { @@ -4860,12 +4847,12 @@ unlock: if (size != 0) { if (filler->real_path) - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "dict_set_bin failed (path=%s): " "key=%s (%s)", filler->real_path, k, strerror (-size)); else - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "dict_set_bin failed (gfid=%s): " "key=%s (%s)", uuid_utoa (filler->inode->gfid), @@ -4912,9 +4899,9 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, if (fd) { op_ret = posix_fd_ctx_get (fd, this, &pfd); if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "failed to get pfd from fd=%p", - fd); + gf_msg (this->name, GF_LOG_WARNING, EBADFD, + P_MSG_PFD_GET_FAILED, "failed to get pfd from" + " fd=%p", fd); op_errno = EBADFD; goto out; } @@ -4996,8 +4983,8 @@ posix_access (call_frame_t *frame, xlator_t *this, op_ret = access (real_path, mask & 07); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "access failed on %s: %s", - real_path, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACCESS_FAILED, + "access failed on %s", real_path); goto out; } op_ret = 0; @@ -5035,7 +5022,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, "pfd is NULL, fd=%p", fd); op_errno = -ret; goto out; @@ -5046,9 +5033,8 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this, op_ret = posix_fdstat (this, _fd, &preop); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "pre-operation fstat failed on fd=%p: %s", fd, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "pre-operation fstat failed on fd=%p", fd); goto out; } @@ -5056,18 +5042,16 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this, if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "ftruncate failed on fd=%p (%"PRId64": %s", - fd, offset, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED, + "ftruncate failed on fd=%p (%"PRId64"", fd, offset); goto out; } op_ret = posix_fdstat (this, _fd, &postop); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, - "post-operation fstat failed on fd=%p: %s", - fd, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "post-operation fstat failed on fd=%p", fd); goto out; } @@ -5108,7 +5092,7 @@ posix_fstat (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, "pfd is NULL, fd=%p", fd); op_errno = -ret; goto out; @@ -5119,8 +5103,8 @@ posix_fstat (call_frame_t *frame, xlator_t *this, op_ret = posix_fdstat (this, _fd, &buf); if (op_ret == -1) { op_errno = errno; - gf_log (this->name, GF_LOG_ERROR, "fstat failed on fd=%p: %s", - fd, strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_FSTAT_FAILED, + "fstat failed on fd=%p", fd); goto out; } @@ -5235,7 +5219,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, "pfd is NULL, fd=%p", fd); count = -1; errno = -ret; @@ -5268,7 +5252,8 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, seekdir (dir, off); #ifndef GF_LINUX_HOST_OS if ((u_long)telldir(dir) != off && off != pfd->dir_eof) { - gf_log (THIS->name, GF_LOG_ERROR, + gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, + P_MSG_DIR_OPERATION_FAILED, "seekdir(0x%llx) failed on dir=%p: " "Invalid argument (offset reused from " "another DIR * structure?)", off, dir); @@ -5283,9 +5268,9 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, in_case = (u_long)telldir (dir); if (in_case == -1) { - gf_log (THIS->name, GF_LOG_ERROR, - "telldir failed on dir=%p: %s", - dir, strerror (errno)); + gf_msg (THIS->name, GF_LOG_ERROR, errno, + P_MSG_DIR_OPERATION_FAILED, + "telldir failed on dir=%p", dir); goto out; } @@ -5295,9 +5280,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, if (!entry) { if (errno == EBADF) { - gf_log (THIS->name, GF_LOG_WARNING, - "readdir failed on dir=%p: %s", - dir, strerror (errno)); + gf_msg (THIS->name, GF_LOG_WARNING, errno, + P_MSG_DIR_OPERATION_FAILED, + "readdir failed on dir=%p", + dir); goto out; } break; @@ -5342,7 +5328,8 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, #ifndef GF_LINUX_HOST_OS if ((u_long)telldir(dir) != in_case && in_case != pfd->dir_eof) { - gf_log (THIS->name, GF_LOG_ERROR, + gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, + P_MSG_DIR_OPERATION_FAILED, "seekdir(0x%llx) failed on dir=%p: " "Invalid argument (offset reused from " "another DIR * structure?)", @@ -5358,9 +5345,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size, this_entry = gf_dirent_for_name (entry->d_name); if (!this_entry) { - gf_log (THIS->name, GF_LOG_ERROR, - "could not create gf_dirent for entry %s: (%s)", - entry->d_name, strerror (errno)); + gf_msg (THIS->name, GF_LOG_ERROR, errno, + P_MSG_GF_DIRENT_CREATE_FAILED, + "could not create " + "gf_dirent for entry %s", entry->d_name); goto out; } /* @@ -5403,7 +5391,8 @@ posix_entry_xattr_fill (xlator_t *this, inode_t *inode, MAKE_HANDLE_PATH (entry_path, this, fd->inode->gfid, name); if (!entry_path) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_HANDLE_CREATE, "Failed to create handle path for %s/%s", uuid_utoa (fd->inode->gfid), name); @@ -5500,7 +5489,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, "pfd is NULL, fd=%p", fd); op_errno = -ret; goto out; @@ -5509,7 +5498,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this, dir = pfd->dir; if (!dir) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, EINVAL, P_MSG_PFD_NULL, "dir is NULL for fd=%p", fd); op_errno = EINVAL; goto out; @@ -5663,7 +5652,7 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this, ret = posix_fd_ctx_get (fd, this, &pfd); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, -ret, P_MSG_PFD_NULL, "pfd is NULL, fd=%p", fd); op_errno = -ret; goto out; @@ -5678,9 +5667,10 @@ posix_rchecksum (call_frame_t *frame, xlator_t *this, ret = pread (_fd, buf, len, offset); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "pread of %d bytes returned %d (%s)", - len, ret, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_PREAD_FAILED, + "pread of %d bytes returned %d ", + len, ret); op_errno = errno; } @@ -5740,8 +5730,6 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_posix_mt_end + 1); if (ret != 0) { - gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" - "failed"); return ret; } @@ -5759,9 +5747,10 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid) ret = sys_lstat (priv->base_path, &st); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to stat " - "brick path %s (%s)", - priv->base_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_DIR_OPERATION_FAILED, "Failed to stat " + "brick path %s", + priv->base_path); return ret; } @@ -5771,9 +5760,9 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid) ret = sys_chown (priv->base_path, uid, gid); if (ret) - gf_log (this->name, GF_LOG_ERROR, "Failed to set " - "uid/gid for brick path %s, %s", - priv->base_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_DIR_OPERATION_FAILED, "Failed to set uid/gid for" + " brick path %s", priv->base_path); return ret; } @@ -5820,7 +5809,7 @@ int reconfigure (xlator_t *this, dict_t *options) { int ret = -1; - struct posix_private *priv = NULL; +struct posix_private *priv = NULL; int32_t uid = -1; int32_t gid = -1; char *batch_fsync_mode_str = NULL; @@ -5839,8 +5828,8 @@ reconfigure (xlator_t *this, dict_t *options) options, str, out); if (set_batch_fsync_mode (priv, batch_fsync_mode_str) != 0) { - gf_log (this->name, GF_LOG_ERROR, "Unknown mode string: %s", - batch_fsync_mode_str); + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, + "Unknown mode string: %s", batch_fsync_mode_str); goto out; } @@ -5852,7 +5841,8 @@ reconfigure (xlator_t *this, dict_t *options) options, str, out); if (set_xattr_user_namespace_mode (priv, xattr_user_namespace_mode_str) != 0) { - gf_log (this->name, GF_LOG_ERROR, "Unknown xattr user namespace mode string: %s", + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_UNKNOWN_ARGUMENT, + "Unknown xattr user namespace mode string: %s", xattr_user_namespace_mode_str); goto out; } @@ -5874,10 +5864,10 @@ reconfigure (xlator_t *this, dict_t *options) options, bool, out); if (priv->node_uuid_pathinfo && - (gf_uuid_is_null (priv->glusterd_uuid))) { - gf_log (this->name, GF_LOG_INFO, - "glusterd uuid is NULL, pathinfo xattr would" - " fallback to <hostname>:<export>"); + (gf_uuid_is_null (priv->glusterd_uuid))) { + gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL, + "glusterd uuid is NULL, pathinfo xattr would" + " fallback to <hostname>:<export>"); } GF_OPTION_RECONF ("health-check-interval", priv->health_check_interval, @@ -5918,19 +5908,20 @@ init (xlator_t *this) dir_data = dict_get (this->options, "directory"); if (this->children) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, P_MSG_SUBVOLUME_ERROR, "FATAL: storage/posix cannot have subvolumes"); ret = -1; goto out; } if (!this->parents) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_VOLUME_DANGLING, "Volume is dangling. Please check the volume file."); } if (!dir_data) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + P_MSG_EXPORT_DIR_MISSING, "Export directory not specified in volume file."); ret = -1; goto out; @@ -5941,7 +5932,7 @@ init (xlator_t *this) /* Check whether the specified directory exists, if not log it. */ op_ret = stat (dir_data->data, &buf); if ((op_ret != 0) || !S_ISDIR (buf.st_mode)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, "Directory '%s' doesn't exist, exiting.", dir_data->data); ret = -1; @@ -5959,25 +5950,29 @@ init (xlator_t *this) if (tmp_data) { if (gf_string2boolean (tmp_data->data, &tmp_bool) == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_OPTION, "wrong option provided for key " "\"mandate-attribute\""); ret = -1; goto out; } if (!tmp_bool) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_XATTR_NOTSUP, "Extended attribute not supported, " "starting as per option"); } else { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + P_MSG_XATTR_NOTSUP, "Extended attribute not supported, " "exiting."); ret = -1; goto out; } } else { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + P_MSG_XATTR_NOTSUP, "Extended attribute not supported, exiting."); ret = -1; goto out; @@ -5988,9 +5983,10 @@ init (xlator_t *this) if (tmp_data) { op_ret = gf_uuid_parse (tmp_data->data, dict_uuid); if (op_ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "wrong volume-id (%s) set in volume file", - tmp_data->data); + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_VOLUME_ID, + "wrong volume-id (%s) set" + " in volume file", tmp_data->data); ret = -1; goto out; } @@ -5998,7 +5994,8 @@ init (xlator_t *this) "trusted.glusterfs.volume-id", old_uuid, 16); if (size == 16) { if (gf_uuid_compare (old_uuid, dict_uuid)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_VOLUME_ID, "mismatching volume-id (%s) received. " "already is a part of volume %s ", tmp_data->data, uuid_utoa (old_uuid)); @@ -6007,7 +6004,8 @@ init (xlator_t *this) } } else if ((size == -1) && (errno == ENODATA || errno == ENOATTR)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_VOLUME_ID_ABSENT, "Extended attribute trusted.glusterfs." "volume-id is absent"); ret = -1; @@ -6016,14 +6014,16 @@ init (xlator_t *this) } else if ((size == -1) && (errno != ENODATA) && (errno != ENOATTR)) { /* Wrong 'volume-id' is set, it should be error */ - gf_log (this->name, GF_LOG_WARNING, - "%s: failed to fetch volume-id (%s)", - dir_data->data, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_VOLUME_ID_FETCH_FAILED, + "%s: failed to fetch volume-id", + dir_data->data); ret = -1; goto out; } else { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_VOLUME_ID_FETCH_FAILED, "failed to fetch proper volume id from export"); goto out; } @@ -6034,7 +6034,8 @@ init (xlator_t *this) size = sys_lgetxattr (dir_data->data, "trusted.gfid", gfid, 16); if (size == 16) { if (!__is_root_gfid (gfid)) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_GFID_SET_FAILED, "%s: gfid (%s) is not that of glusterfs '/' ", dir_data->data, uuid_utoa (gfid)); ret = -1; @@ -6042,7 +6043,8 @@ init (xlator_t *this) } } else if (size != -1) { /* Wrong 'gfid' is set, it should be error */ - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_GFID_SET_FAILED, "%s: wrong value set as gfid", dir_data->data); ret = -1; @@ -6050,9 +6052,10 @@ init (xlator_t *this) } else if ((size == -1) && (errno != ENODATA) && (errno != ENOATTR)) { /* Wrong 'gfid' is set, it should be error */ - gf_log (this->name, GF_LOG_WARNING, - "%s: failed to fetch gfid (%s)", - dir_data->data, strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_GFID_SET_FAILED, + "%s: failed to fetch gfid", + dir_data->data); ret = -1; goto out; } else { @@ -6060,9 +6063,10 @@ init (xlator_t *this) size = sys_lsetxattr (dir_data->data, "trusted.gfid", rootgfid, 16, XATTR_CREATE); if (size == -1) { - gf_log (this->name, GF_LOG_ERROR, - "%s: failed to set gfid (%s)", - dir_data->data, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_GFID_SET_FAILED, + "%s: failed to set gfid", + dir_data->data); ret = -1; goto out; } @@ -6071,7 +6075,8 @@ init (xlator_t *this) size = sys_lgetxattr (dir_data->data, POSIX_ACL_ACCESS_XATTR, NULL, 0); if ((size < 0) && (errno == ENOTSUP)) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_ACL_NOTSUP, "Posix access control list is not supported."); ret = 0; @@ -6099,7 +6104,8 @@ init (xlator_t *this) _XOPEN_PATH_MAX + _private->base_path_length > _private->path_max) { ret = chdir(_private->base_path); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_BASEPATH_CHDIR_FAILED, "chdir() to \"%s\" failed", _private->base_path); goto out; @@ -6130,8 +6136,9 @@ init (xlator_t *this) } ret = gethostname (_private->hostname, 256); if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "could not find hostname (%s)", strerror (errno)); + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_HOSTNAME_MISSING, + "could not find hostname "); } } @@ -6141,13 +6148,14 @@ init (xlator_t *this) if (gf_string2boolean (tmp_data->data, &_private->export_statfs) == -1) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_OPTION_VAL, "'export-statfs-size' takes only boolean " "options"); goto out; } if (!_private->export_statfs) - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "'statfs()' returns dummy size"); } @@ -6157,14 +6165,14 @@ init (xlator_t *this) if (gf_string2boolean (tmp_data->data, &_private->background_unlink) == -1) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, - "'background-unlink' takes only boolean " - "options"); + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_OPTION_VAL, "'background-unlink'" + " takes only boolean options"); goto out; } if (_private->background_unlink) - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "unlinks will be performed in background"); } @@ -6173,14 +6181,14 @@ init (xlator_t *this) if (gf_string2boolean (tmp_data->data, &_private->o_direct) == -1) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_OPTION_VAL, "wrong option provided for 'o-direct'"); goto out; } if (_private->o_direct) - gf_log (this->name, GF_LOG_DEBUG, - "o-direct mode is enabled (O_DIRECT " - "for every open)"); + gf_msg_debug (this->name, 0, "o-direct mode is enabled" + " (O_DIRECT for every open)"); } tmp_data = dict_get (this->options, "update-link-count-parent"); @@ -6188,29 +6196,31 @@ init (xlator_t *this) if (gf_string2boolean (tmp_data->data, &_private->update_pgfid_nlinks) == -1) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, - "wrong value provided for " - "'update-link-count-parent'"); + gf_msg (this->name, GF_LOG_ERROR, 0, + P_MSG_INVALID_OPTION, "wrong value provided " + "for 'update-link-count-parent'"); goto out; } if (_private->update_pgfid_nlinks) - gf_log (this->name, GF_LOG_DEBUG, - "update-link-count-parent is enabled. Thus for each " - "file an extended attribute representing the " - "number of hardlinks for that file within the " - "same parent directory is set."); + gf_msg_debug (this->name, 0, "update-link-count-parent" + " is enabled. Thus for each file an " + "extended attribute representing the " + "number of hardlinks for that file " + "within the same parent directory is" + " set."); } ret = dict_get_str (this->options, "glusterd-uuid", &guuid); if (!ret) { if (gf_uuid_parse (guuid, _private->glusterd_uuid)) - gf_log (this->name, GF_LOG_WARNING, "Cannot parse " + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_INVALID_NODE_UUID, "Cannot parse " "glusterd (node) UUID, node-uuid xattr " "request would return - \"No such attribute\""); } else { - gf_log (this->name, GF_LOG_DEBUG, "No glusterd (node) UUID " - "passed - node-uuid xattr request will return " - "\"No such attribute\""); + gf_msg_debug (this->name, 0, "No glusterd (node) UUID passed -" + " node-uuid xattr request will return \"No such" + " attribute\""); } ret = 0; @@ -6219,9 +6229,8 @@ init (xlator_t *this) dict_ret = dict_get_int32 (this->options, "janitor-sleep-duration", &janitor_sleep); if (dict_ret == 0) { - gf_log (this->name, GF_LOG_DEBUG, - "Setting janitor sleep duration to %d.", - janitor_sleep); + gf_msg_debug (this->name, 0, "Setting janitor sleep duration " + "to %d.", janitor_sleep); _private->janitor_sleep_duration = janitor_sleep; } @@ -6231,7 +6240,7 @@ init (xlator_t *this) _private->mount_lock = opendir (dir_data->data); if (!_private->mount_lock) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, "Could not lock brick directory"); goto out; } @@ -6242,22 +6251,23 @@ init (xlator_t *this) lim.rlim_max = 1048576; if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_SET_ULIMIT_FAILED, "Failed to set 'ulimit -n " - " 1048576': %s", strerror(errno)); + " 1048576'"); lim.rlim_cur = 65536; lim.rlim_max = 65536; if (setrlimit (RLIMIT_NOFILE, &lim) == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_SET_FILE_MAX_FAILED, "Failed to set maximum allowed open " - "file descriptors to 64k: %s", - strerror(errno)); + "file descriptors to 64k"); } else { - gf_log (this->name, GF_LOG_INFO, - "Maximum allowed open file descriptors " - "set to 65536"); + gf_msg (this->name, GF_LOG_INFO, 0, + P_MSG_MAX_FILE_OPEN, "Maximum allowed " + "open file descriptors set to 65536"); } } } @@ -6266,7 +6276,7 @@ init (xlator_t *this) op_ret = posix_handle_init (this); if (op_ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE, "Posix handle setup failed"); ret = -1; goto out; @@ -6274,7 +6284,7 @@ init (xlator_t *this) op_ret = posix_handle_trash_init (this); if (op_ret < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE_TRASH, "Posix landfill setup failed"); ret = -1; goto out; @@ -6294,7 +6304,7 @@ init (xlator_t *this) op_ret = posix_aio_on (this); if (op_ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_POSIX_AIO, "Posix AIO init failed"); ret = -1; goto out; @@ -6305,7 +6315,7 @@ init (xlator_t *this) _private->node_uuid_pathinfo, bool, out); if (_private->node_uuid_pathinfo && (gf_uuid_is_null (_private->glusterd_uuid))) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"); } @@ -6328,16 +6338,17 @@ init (xlator_t *this) ret = gf_thread_create (&_private->fsyncer, NULL, posix_fsyncer, this); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "fsyncer thread" - " creation failed (%s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_FSYNCER_THREAD_CREATE_FAILED, + "fsyncer thread creation failed"); goto out; } GF_OPTION_INIT ("batch-fsync-mode", batch_fsync_mode_str, str, out); if (set_batch_fsync_mode (_private, batch_fsync_mode_str) != 0) { - gf_log (this->name, GF_LOG_ERROR, "Unknown mode string: %s", - batch_fsync_mode_str); + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, + "Unknown mode string: %s", batch_fsync_mode_str); goto out; } @@ -6350,7 +6361,7 @@ init (xlator_t *this) if (set_xattr_user_namespace_mode (_private, xattr_user_namespace_mode_str) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, "Unknown xattr user namespace mode string: %s", xattr_user_namespace_mode_str); goto out; @@ -6376,7 +6387,6 @@ fini (xlator_t *this) GF_FREE (priv); return; } - struct xlator_dumpops dumpops = { .priv = posix_priv, .inode = posix_inode, |