Blob Blame History Raw
From b2a0656b409cf867073c961fa4103bc59966a059 Mon Sep 17 00:00:00 2001
From: Ashish Pandey <aspandey@redhat.com>
Date: Mon, 3 Sep 2018 14:01:23 +0530
Subject: [PATCH 367/385] cluster/ec: Improve logging for some critical error
 messages

>Change-Id: I037e52a3467467b81a1ba5416317870864060d4d
>updates: bz#1615703
>Signed-off-by: Ashish Pandey <aspandey@redhat.com>

upstream patch: https://review.gluster.org/#/c/glusterfs/+/21061/

BUG: 1625622
Change-Id: I037e52a3467467b81a1ba5416317870864060d4d
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/149671
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 xlators/cluster/ec/src/ec-common.c | 66 ++++++++++++++++++++++++++++++--------
 xlators/cluster/ec/src/ec-data.c   |  1 +
 xlators/cluster/ec/src/ec-types.h  |  2 ++
 3 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index b74bce0..6d0eb62 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -587,6 +587,42 @@ ec_internal_op (ec_fop_data_t *fop)
         return _gf_false;
 }
 
+char *
+ec_msg_str (ec_fop_data_t *fop)
+{
+    loc_t    *loc1 = NULL;
+    loc_t    *loc2 = NULL;
+    char     gfid1[64] = {0};
+    char     gfid2[64] = {0};
+
+    if (fop->errstr)
+        return fop->errstr;
+
+    if (!fop->use_fd) {
+        loc1 = &fop->loc[0];
+        loc2 = &fop->loc[1];
+
+        if (fop->id == GF_FOP_RENAME) {
+                gf_asprintf(&fop->errstr,
+                            "FOP : '%s' failed on '%s' and '%s' with gfids "
+                            "%s and %s respectively", ec_fop_name (fop->id),
+                            loc1->path, loc2->path,
+                            uuid_utoa_r (loc1->gfid, gfid1),
+                            uuid_utoa_r (loc2->gfid, gfid2));
+        } else {
+                gf_asprintf(&fop->errstr,
+                            "FOP : '%s' failed on '%s' with gfid %s",
+                            ec_fop_name (fop->id),
+                            loc1->path, uuid_utoa_r (loc1->gfid, gfid1));
+        }
+    } else {
+        gf_asprintf(&fop->errstr, "FOP : '%s' failed on gfid %s",
+                    ec_fop_name (fop->id),
+                    uuid_utoa_r (fop->fd->inode->gfid, gfid1));
+    }
+    return fop->errstr;
+}
+
 int32_t ec_child_select(ec_fop_data_t * fop)
 {
     ec_t * ec = fop->xl->private;
@@ -607,9 +643,8 @@ int32_t ec_child_select(ec_fop_data_t * fop)
         gf_msg (fop->xl->name, GF_LOG_WARNING, 0,
                 EC_MSG_OP_EXEC_UNAVAIL,
                 "Executing operation with "
-                "some subvolumes unavailable "
-                "(%lX)", fop->mask & ~ec->xl_up);
-
+                "some subvolumes unavailable. (%lX). %s ",
+                fop->mask & ~ec->xl_up, ec_msg_str(fop));
         fop->mask &= ec->xl_up;
     }
 
@@ -650,8 +685,8 @@ int32_t ec_child_select(ec_fop_data_t * fop)
                 EC_MSG_CHILDS_INSUFFICIENT,
                 "Insufficient available children "
                 "for this request (have %d, need "
-                "%d)", num, fop->minimum);
-
+                "%d). %s",
+                num, fop->minimum, ec_msg_str(fop));
         return 0;
     }
 
@@ -1122,7 +1157,6 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
     gf_boolean_t release = _gf_false;
     uint64_t provided_flags = 0;
     uint64_t dirty[EC_VERSION_SIZE] = {0, 0};
-
     lock = parent_link->lock;
     parent = parent_link->fop;
     ctx = lock->ctx;
@@ -1139,11 +1173,11 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
                     list_add_tail(&link->fop->cbk_list, &list);
         }
     }
-
     if (op_ret < 0) {
         gf_msg (this->name, GF_LOG_WARNING, op_errno,
                 EC_MSG_SIZE_VERS_GET_FAIL,
-                "Failed to get size and version");
+                "Failed to get size and version :  %s",
+                ec_msg_str(fop));
 
         goto unlock;
     }
@@ -1155,7 +1189,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
             if (op_errno != 0) {
                 gf_msg (this->name, GF_LOG_ERROR, op_errno,
                         EC_MSG_VER_XATTR_GET_FAIL,
-                        "Unable to get version xattr");
+                        "Unable to get version xattr. %s",
+                        ec_msg_str(fop));
                 goto unlock;
             }
             ctx->post_version[0] += ctx->pre_version[0];
@@ -1171,7 +1206,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
                     if (lock->loc.inode->ia_type == IA_IFREG) {
                         gf_msg (this->name, GF_LOG_ERROR, op_errno,
                                 EC_MSG_SIZE_XATTR_GET_FAIL,
-                                "Unable to get size xattr");
+                                "Unable to get size xattr. %s",
+                                ec_msg_str(fop));
                         goto unlock;
                     }
                 } else {
@@ -1187,7 +1223,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
                         (op_errno != ENODATA)) {
                         gf_msg (this->name, GF_LOG_ERROR, op_errno,
                                 EC_MSG_CONFIG_XATTR_GET_FAIL,
-                                "Unable to get config xattr");
+                                "Unable to get config xattr. %s",
+                                ec_msg_str(fop));
 
                         goto unlock;
                     }
@@ -2168,7 +2205,8 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie,
     if (op_ret < 0) {
         gf_msg(fop->xl->name, fop_log_level (fop->id, op_errno), op_errno,
                EC_MSG_SIZE_VERS_UPDATE_FAIL,
-               "Failed to update version and size");
+               "Failed to update version and size. %s",
+                ec_msg_str(fop));
     } else {
         fop->parent->good &= fop->good;
 
@@ -2213,7 +2251,6 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version,
     ec_inode_t *ctx;
     dict_t *dict = NULL;
     uintptr_t   update_on = 0;
-
     int32_t err = -ENOMEM;
 
     fop = link->fop;
@@ -2294,7 +2331,8 @@ out:
     ec_fop_set_error(fop, -err);
 
     gf_msg (fop->xl->name, GF_LOG_ERROR, -err, EC_MSG_SIZE_VERS_UPDATE_FAIL,
-            "Unable to update version and size");
+               "Unable to update version and size. %s",
+                ec_msg_str(fop));
 
     if (lock->unlock_now) {
         ec_unlock_lock(fop->data);
diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c
index 54c708a..b3b72d5 100644
--- a/xlators/cluster/ec/src/ec-data.c
+++ b/xlators/cluster/ec/src/ec-data.c
@@ -286,6 +286,7 @@ void ec_fop_data_release(ec_fop_data_t * fop)
         GF_FREE(fop->str[1]);
         loc_wipe(&fop->loc[0]);
         loc_wipe(&fop->loc[1]);
+        GF_FREE(fop->errstr);
 
         ec_resume_parent(fop, fop->error);
 
diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h
index f6e2cd9..9176dde 100644
--- a/xlators/cluster/ec/src/ec-types.h
+++ b/xlators/cluster/ec/src/ec-types.h
@@ -347,6 +347,8 @@ struct _ec_fop_data {
     struct iovec      *vector;
     struct iobref     *buffers;
     gf_seek_what_t     seek;
+    char              *errstr;    /*String of fop name, path and gfid
+                                   to be used in gf_msg. */
 };
 
 struct _ec_cbk_data {
-- 
1.8.3.1