887953
From b2a0656b409cf867073c961fa4103bc59966a059 Mon Sep 17 00:00:00 2001
887953
From: Ashish Pandey <aspandey@redhat.com>
887953
Date: Mon, 3 Sep 2018 14:01:23 +0530
887953
Subject: [PATCH 367/385] cluster/ec: Improve logging for some critical error
887953
 messages
887953
887953
>Change-Id: I037e52a3467467b81a1ba5416317870864060d4d
887953
>updates: bz#1615703
887953
>Signed-off-by: Ashish Pandey <aspandey@redhat.com>
887953
887953
upstream patch: https://review.gluster.org/#/c/glusterfs/+/21061/
887953
887953
BUG: 1625622
887953
Change-Id: I037e52a3467467b81a1ba5416317870864060d4d
887953
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/149671
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
887953
---
887953
 xlators/cluster/ec/src/ec-common.c | 66 ++++++++++++++++++++++++++++++--------
887953
 xlators/cluster/ec/src/ec-data.c   |  1 +
887953
 xlators/cluster/ec/src/ec-types.h  |  2 ++
887953
 3 files changed, 55 insertions(+), 14 deletions(-)
887953
887953
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
887953
index b74bce0..6d0eb62 100644
887953
--- a/xlators/cluster/ec/src/ec-common.c
887953
+++ b/xlators/cluster/ec/src/ec-common.c
887953
@@ -587,6 +587,42 @@ ec_internal_op (ec_fop_data_t *fop)
887953
         return _gf_false;
887953
 }
887953
 
887953
+char *
887953
+ec_msg_str (ec_fop_data_t *fop)
887953
+{
887953
+    loc_t    *loc1 = NULL;
887953
+    loc_t    *loc2 = NULL;
887953
+    char     gfid1[64] = {0};
887953
+    char     gfid2[64] = {0};
887953
+
887953
+    if (fop->errstr)
887953
+        return fop->errstr;
887953
+
887953
+    if (!fop->use_fd) {
887953
+        loc1 = &fop->loc[0];
887953
+        loc2 = &fop->loc[1];
887953
+
887953
+        if (fop->id == GF_FOP_RENAME) {
887953
+                gf_asprintf(&fop->errstr,
887953
+                            "FOP : '%s' failed on '%s' and '%s' with gfids "
887953
+                            "%s and %s respectively", ec_fop_name (fop->id),
887953
+                            loc1->path, loc2->path,
887953
+                            uuid_utoa_r (loc1->gfid, gfid1),
887953
+                            uuid_utoa_r (loc2->gfid, gfid2));
887953
+        } else {
887953
+                gf_asprintf(&fop->errstr,
887953
+                            "FOP : '%s' failed on '%s' with gfid %s",
887953
+                            ec_fop_name (fop->id),
887953
+                            loc1->path, uuid_utoa_r (loc1->gfid, gfid1));
887953
+        }
887953
+    } else {
887953
+        gf_asprintf(&fop->errstr, "FOP : '%s' failed on gfid %s",
887953
+                    ec_fop_name (fop->id),
887953
+                    uuid_utoa_r (fop->fd->inode->gfid, gfid1));
887953
+    }
887953
+    return fop->errstr;
887953
+}
887953
+
887953
 int32_t ec_child_select(ec_fop_data_t * fop)
887953
 {
887953
     ec_t * ec = fop->xl->private;
887953
@@ -607,9 +643,8 @@ int32_t ec_child_select(ec_fop_data_t * fop)
887953
         gf_msg (fop->xl->name, GF_LOG_WARNING, 0,
887953
                 EC_MSG_OP_EXEC_UNAVAIL,
887953
                 "Executing operation with "
887953
-                "some subvolumes unavailable "
887953
-                "(%lX)", fop->mask & ~ec->xl_up);
887953
-
887953
+                "some subvolumes unavailable. (%lX). %s ",
887953
+                fop->mask & ~ec->xl_up, ec_msg_str(fop));
887953
         fop->mask &= ec->xl_up;
887953
     }
887953
 
887953
@@ -650,8 +685,8 @@ int32_t ec_child_select(ec_fop_data_t * fop)
887953
                 EC_MSG_CHILDS_INSUFFICIENT,
887953
                 "Insufficient available children "
887953
                 "for this request (have %d, need "
887953
-                "%d)", num, fop->minimum);
887953
-
887953
+                "%d). %s",
887953
+                num, fop->minimum, ec_msg_str(fop));
887953
         return 0;
887953
     }
887953
 
887953
@@ -1122,7 +1157,6 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
887953
     gf_boolean_t release = _gf_false;
887953
     uint64_t provided_flags = 0;
887953
     uint64_t dirty[EC_VERSION_SIZE] = {0, 0};
887953
-
887953
     lock = parent_link->lock;
887953
     parent = parent_link->fop;
887953
     ctx = lock->ctx;
887953
@@ -1139,11 +1173,11 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
887953
                     list_add_tail(&link->fop->cbk_list, &list);
887953
         }
887953
     }
887953
-
887953
     if (op_ret < 0) {
887953
         gf_msg (this->name, GF_LOG_WARNING, op_errno,
887953
                 EC_MSG_SIZE_VERS_GET_FAIL,
887953
-                "Failed to get size and version");
887953
+                "Failed to get size and version :  %s",
887953
+                ec_msg_str(fop));
887953
 
887953
         goto unlock;
887953
     }
887953
@@ -1155,7 +1189,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
887953
             if (op_errno != 0) {
887953
                 gf_msg (this->name, GF_LOG_ERROR, op_errno,
887953
                         EC_MSG_VER_XATTR_GET_FAIL,
887953
-                        "Unable to get version xattr");
887953
+                        "Unable to get version xattr. %s",
887953
+                        ec_msg_str(fop));
887953
                 goto unlock;
887953
             }
887953
             ctx->post_version[0] += ctx->pre_version[0];
887953
@@ -1171,7 +1206,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
887953
                     if (lock->loc.inode->ia_type == IA_IFREG) {
887953
                         gf_msg (this->name, GF_LOG_ERROR, op_errno,
887953
                                 EC_MSG_SIZE_XATTR_GET_FAIL,
887953
-                                "Unable to get size xattr");
887953
+                                "Unable to get size xattr. %s",
887953
+                                ec_msg_str(fop));
887953
                         goto unlock;
887953
                     }
887953
                 } else {
887953
@@ -1187,7 +1223,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie,
887953
                         (op_errno != ENODATA)) {
887953
                         gf_msg (this->name, GF_LOG_ERROR, op_errno,
887953
                                 EC_MSG_CONFIG_XATTR_GET_FAIL,
887953
-                                "Unable to get config xattr");
887953
+                                "Unable to get config xattr. %s",
887953
+                                ec_msg_str(fop));
887953
 
887953
                         goto unlock;
887953
                     }
887953
@@ -2168,7 +2205,8 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie,
887953
     if (op_ret < 0) {
887953
         gf_msg(fop->xl->name, fop_log_level (fop->id, op_errno), op_errno,
887953
                EC_MSG_SIZE_VERS_UPDATE_FAIL,
887953
-               "Failed to update version and size");
887953
+               "Failed to update version and size. %s",
887953
+                ec_msg_str(fop));
887953
     } else {
887953
         fop->parent->good &= fop->good;
887953
 
887953
@@ -2213,7 +2251,6 @@ ec_update_size_version(ec_lock_link_t *link, uint64_t *version,
887953
     ec_inode_t *ctx;
887953
     dict_t *dict = NULL;
887953
     uintptr_t   update_on = 0;
887953
-
887953
     int32_t err = -ENOMEM;
887953
 
887953
     fop = link->fop;
887953
@@ -2294,7 +2331,8 @@ out:
887953
     ec_fop_set_error(fop, -err);
887953
 
887953
     gf_msg (fop->xl->name, GF_LOG_ERROR, -err, EC_MSG_SIZE_VERS_UPDATE_FAIL,
887953
-            "Unable to update version and size");
887953
+               "Unable to update version and size. %s",
887953
+                ec_msg_str(fop));
887953
 
887953
     if (lock->unlock_now) {
887953
         ec_unlock_lock(fop->data);
887953
diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c
887953
index 54c708a..b3b72d5 100644
887953
--- a/xlators/cluster/ec/src/ec-data.c
887953
+++ b/xlators/cluster/ec/src/ec-data.c
887953
@@ -286,6 +286,7 @@ void ec_fop_data_release(ec_fop_data_t * fop)
887953
         GF_FREE(fop->str[1]);
887953
         loc_wipe(&fop->loc[0]);
887953
         loc_wipe(&fop->loc[1]);
887953
+        GF_FREE(fop->errstr);
887953
 
887953
         ec_resume_parent(fop, fop->error);
887953
 
887953
diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h
887953
index f6e2cd9..9176dde 100644
887953
--- a/xlators/cluster/ec/src/ec-types.h
887953
+++ b/xlators/cluster/ec/src/ec-types.h
887953
@@ -347,6 +347,8 @@ struct _ec_fop_data {
887953
     struct iovec      *vector;
887953
     struct iobref     *buffers;
887953
     gf_seek_what_t     seek;
887953
+    char              *errstr;    /*String of fop name, path and gfid
887953
+                                   to be used in gf_msg. */
887953
 };
887953
 
887953
 struct _ec_cbk_data {
887953
-- 
887953
1.8.3.1
887953