From 5fff385333db750561ffd026af09e52a8c8c16e6 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 21 Oct 2014 16:18:16 +0530 Subject: logs: Do selective logging for errnos Backport of http://review.gluster.org/8918 http://review.gluster.org/8955 Problem: Just after replace-brick the mount logs are filled with ENOENT/ESTALE warning logs because the file is yet to be self-healed now that the brick is new. Fix: Do conditional logging for the logs. ENOENT/ESTALE will be logged at lower log level. Only when debug logs are enabled, these logs will be written to the logfile. BUG: 1155073 Change-Id: Icf06f2fc4f2f91e199de24a88bcb0ce9b8955ebd Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/8960 Reviewed-by: Krutika Dhananjay Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- libglusterfs/src/common-utils.c | 36 +++++++++++++++++++++++++++ libglusterfs/src/common-utils.h | 2 ++ xlators/cluster/afr/src/afr-open.c | 7 +++--- xlators/protocol/client/src/client-rpc-fops.c | 30 +++++++++++++--------- xlators/protocol/server/src/server-rpc-fops.c | 35 -------------------------- 5 files changed, 60 insertions(+), 50 deletions(-) diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index d5df2b2fedf..5424fbfb7d0 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -37,6 +37,7 @@ #include #endif +#include "compat-errno.h" #include "logging.h" #include "common-utils.h" #include "revision.h" @@ -3215,3 +3216,38 @@ dht_is_linkfile (struct iatt *buf, dict_t *dict) return linkfile_key_found; } +gf_loglevel_t +fop_log_level (glusterfs_fop_t fop, int op_errno) +{ + //if gfid doesn't exist ESTALE comes + if (op_errno == ENOENT || op_errno == ESTALE) + return GF_LOG_DEBUG; + + if ((fop == GF_FOP_ENTRYLK) || + (fop == GF_FOP_FENTRYLK)|| + (fop == GF_FOP_FINODELK)|| + (fop == GF_FOP_INODELK) || + (fop == GF_FOP_LK)) { + //if non-blocking lock fails EAGAIN comes + //if locks xlator is not loaded ENOSYS comes + if (op_errno == EAGAIN || op_errno == ENOSYS) + return GF_LOG_DEBUG; + } + + if ((fop == GF_FOP_GETXATTR) || + (fop == GF_FOP_FGETXATTR)) { + if (op_errno == ENOTSUP || op_errno == ENODATA) + return GF_LOG_DEBUG; + } + + if ((fop == GF_FOP_SETXATTR) || + (fop == GF_FOP_FSETXATTR)|| + (fop == GF_FOP_REMOVEXATTR)|| + (fop == GF_FOP_FREMOVEXATTR)) { + if (op_errno == ENOTSUP) + return GF_LOG_DEBUG; + } + + return GF_LOG_ERROR; +} + diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 28b2836c925..26574a41ad4 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -628,4 +628,6 @@ struct _dict; inline gf_boolean_t dht_is_linkfile (struct iatt *buf, struct _dict *dict); +gf_loglevel_t +fop_log_level (glusterfs_fop_t fop, int op_errno); #endif /* _COMMON_UTILS_H */ diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c index 9404b6e847b..ccfd655eebb 100644 --- a/xlators/cluster/afr/src/afr-open.c +++ b/xlators/cluster/afr/src/afr-open.c @@ -264,9 +264,10 @@ afr_openfd_fix_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, "successfully on subvolume %s", local->loc.path, priv->children[child_index]->name); } else { - gf_log (this->name, GF_LOG_ERROR, "Failed to open %s " - "on subvolume %s", local->loc.path, - priv->children[child_index]->name); + gf_log (this->name, fop_log_level (GF_FOP_OPEN, op_errno), + "Failed to open %s on subvolume %s [%s]", + local->loc.path, priv->children[child_index]->name, + strerror (op_errno)); } fd_ctx = afr_fd_ctx_get (local->fd, this); diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 3c014915ef5..50d15ec5fdc 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -458,7 +458,8 @@ client3_3_open_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_log (this->name, fop_log_level (GF_FOP_OPEN, + gf_error_to_errno (rsp.op_errno)), "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), local->loc.path, loc_gfid_utoa (&local->loc)); @@ -923,7 +924,8 @@ client3_3_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_log (this->name, fop_log_level (GF_FOP_FLUSH, + gf_error_to_errno (rsp.op_errno)), "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } @@ -1524,9 +1526,10 @@ client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, rsp.op_errno, out); out: - if ((rsp.op_ret == -1) && - (EAGAIN != gf_error_to_errno (rsp.op_errno))) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + if (rsp.op_ret == -1) { + gf_log (this->name, fop_log_level (GF_FOP_INODELK, + gf_error_to_errno (rsp.op_errno)), + "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (inodelk, frame, rsp.op_ret, @@ -1574,9 +1577,10 @@ client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, rsp.op_errno, out); out: - if ((rsp.op_ret == -1) && - (EAGAIN != gf_error_to_errno (rsp.op_errno))) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + if (rsp.op_ret == -1) { + gf_log (this->name, fop_log_level (GF_FOP_FINODELK, + gf_error_to_errno (rsp.op_errno)), + "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } else if (rsp.op_ret == 0) { if (local->attempt_reopen) @@ -1626,9 +1630,10 @@ client3_3_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, rsp.op_errno, out); out: - if ((rsp.op_ret == -1) && - (EAGAIN != gf_error_to_errno (rsp.op_errno))) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + if (rsp.op_ret == -1) { + gf_log (this->name, fop_log_level (GF_FOP_ENTRYLK, + gf_error_to_errno (rsp.op_errno)), + "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } @@ -2684,7 +2689,8 @@ client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_log (this->name, fop_log_level (GF_FOP_OPENDIR, + gf_error_to_errno (rsp.op_errno)), "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), local->loc.path, loc_gfid_utoa (&local->loc)); diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index d69d51f4d08..227552793ef 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -30,41 +30,6 @@ ret = RPCSVC_ACTOR_ERROR; \ } while (0) -static gf_loglevel_t -fop_log_level (glusterfs_fop_t fop, int op_errno) -{ - //if gfid doesn't exist ESTALE comes - if (op_errno == ENOENT || op_errno == ESTALE) - return GF_LOG_DEBUG; - - if ((fop == GF_FOP_ENTRYLK) || - (fop == GF_FOP_FENTRYLK)|| - (fop == GF_FOP_FINODELK)|| - (fop == GF_FOP_INODELK) || - (fop == GF_FOP_LK)) { - //if non-blocking lock fails EAGAIN comes - //if locks xlator is not loaded ENOSYS comes - if (op_errno == EAGAIN || op_errno == ENOSYS) - return GF_LOG_DEBUG; - } - - if ((fop == GF_FOP_GETXATTR) || - (fop == GF_FOP_FGETXATTR)) { - if (op_errno == ENOTSUP || op_errno == ENODATA) - return GF_LOG_DEBUG; - } - - if ((fop == GF_FOP_SETXATTR) || - (fop == GF_FOP_FSETXATTR)|| - (fop == GF_FOP_REMOVEXATTR)|| - (fop == GF_FOP_FREMOVEXATTR)) { - if (op_errno == ENOTSUP) - return GF_LOG_DEBUG; - } - - return GF_LOG_ERROR; -} - /* Callback function section */ int server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, -- cgit