256ebe
From ba1460a4fee0c41c7d7f7a2043bae37f7e751259 Mon Sep 17 00:00:00 2001
256ebe
From: Ravishankar N <ravishankar@redhat.com>
256ebe
Date: Fri, 15 Mar 2019 19:31:03 +0530
256ebe
Subject: [PATCH 108/124] afr: add client-pid to all gf_event() calls
256ebe
256ebe
client-pid for glustershd is GF_CLIENT_PID_SELF_HEALD
256ebe
client-pid for glfsheal is GF_CLIENT_PID_GLFS_HEALD
256ebe
256ebe
Patch on upstream master: https://review.gluster.org/#/c/glusterfs/+/22369/
256ebe
BUG: 1676495
256ebe
Change-Id: Ib3a863af160ff48c822a5e6b0c27c575c9887470
256ebe
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/166460
256ebe
Tested-by: RHGS Build Bot <nigelb@redhat.com>
256ebe
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
256ebe
---
256ebe
 heal/src/glfs-heal.c                             |  6 ++++++
256ebe
 xlators/cluster/afr/src/afr-common.c             | 12 ++++++++----
256ebe
 xlators/cluster/afr/src/afr-self-heal-common.c   | 11 +++++++----
256ebe
 xlators/cluster/afr/src/afr-self-heal-data.c     |  4 +++-
256ebe
 xlators/cluster/afr/src/afr-self-heal-entry.c    |  5 +++--
256ebe
 xlators/cluster/afr/src/afr-self-heal-metadata.c |  4 +++-
256ebe
 xlators/cluster/afr/src/afr-self-heal-name.c     |  7 ++++---
256ebe
 xlators/mgmt/glusterd/src/glusterd-shd-svc.c     | 10 ++++++++++
256ebe
 8 files changed, 44 insertions(+), 15 deletions(-)
256ebe
256ebe
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
256ebe
index 6030de3..7e37e47 100644
256ebe
--- a/heal/src/glfs-heal.c
256ebe
+++ b/heal/src/glfs-heal.c
256ebe
@@ -1688,6 +1688,12 @@ main(int argc, char **argv)
256ebe
         goto out;
256ebe
     }
256ebe
 
256ebe
+    ret = glfs_setfspid(fs, GF_CLIENT_PID_GLFS_HEAL);
256ebe
+    if (ret) {
256ebe
+        printf("Setting client pid failed, %s\n", strerror(errno));
256ebe
+        goto out;
256ebe
+    }
256ebe
+
256ebe
     ret = glfs_init(fs);
256ebe
     if (ret < 0) {
256ebe
         ret = -errno;
256ebe
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
256ebe
index 47a5d3a..3690b84 100644
256ebe
--- a/xlators/cluster/afr/src/afr-common.c
256ebe
+++ b/xlators/cluster/afr/src/afr-common.c
256ebe
@@ -5233,7 +5233,8 @@ __afr_handle_child_up_event(xlator_t *this, xlator_t *child_xlator,
256ebe
                "Subvolume '%s' came back up; "
256ebe
                "going online.",
256ebe
                child_xlator->name);
256ebe
-        gf_event(EVENT_AFR_SUBVOL_UP, "subvol=%s", this->name);
256ebe
+        gf_event(EVENT_AFR_SUBVOL_UP, "client-pid=%d; subvol=%s",
256ebe
+                 this->ctx->cmd_args.client_pid, this->name);
256ebe
     } else {
256ebe
         *event = GF_EVENT_SOME_DESCENDENT_UP;
256ebe
     }
256ebe
@@ -5310,7 +5311,8 @@ __afr_handle_child_down_event(xlator_t *this, xlator_t *child_xlator, int idx,
256ebe
                "All subvolumes are down. Going "
256ebe
                "offline until at least one of them "
256ebe
                "comes back up.");
256ebe
-        gf_event(EVENT_AFR_SUBVOLS_DOWN, "subvol=%s", this->name);
256ebe
+        gf_event(EVENT_AFR_SUBVOLS_DOWN, "client-pid=%d; subvol=%s",
256ebe
+                 this->ctx->cmd_args.client_pid, this->name);
256ebe
     } else {
256ebe
         *event = GF_EVENT_SOME_DESCENDENT_DOWN;
256ebe
     }
256ebe
@@ -5585,12 +5587,14 @@ afr_notify(xlator_t *this, int32_t event, void *data, void *data2)
256ebe
         if (!had_quorum && has_quorum) {
256ebe
             gf_msg(this->name, GF_LOG_INFO, 0, AFR_MSG_QUORUM_MET,
256ebe
                    "Client-quorum is met");
256ebe
-            gf_event(EVENT_AFR_QUORUM_MET, "subvol=%s", this->name);
256ebe
+            gf_event(EVENT_AFR_QUORUM_MET, "client-pid=%d; subvol=%s",
256ebe
+                     this->ctx->cmd_args.client_pid, this->name);
256ebe
         }
256ebe
         if (had_quorum && !has_quorum) {
256ebe
             gf_msg(this->name, GF_LOG_WARNING, 0, AFR_MSG_QUORUM_FAIL,
256ebe
                    "Client-quorum is not met");
256ebe
-            gf_event(EVENT_AFR_QUORUM_FAIL, "subvol=%s", this->name);
256ebe
+            gf_event(EVENT_AFR_QUORUM_FAIL, "client-pid=%d; subvol=%s",
256ebe
+                     this->ctx->cmd_args.client_pid, this->name);
256ebe
         }
256ebe
     }
256ebe
 
256ebe
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
256ebe
index 2268761..595bed4 100644
256ebe
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
256ebe
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
256ebe
@@ -383,11 +383,12 @@ out:
256ebe
                uuid_utoa_r(replies[src_idx].poststat.ia_gfid, g2),
256ebe
                priv->children[src_idx]->name);
256ebe
         gf_event(EVENT_AFR_SPLIT_BRAIN,
256ebe
+                 "client-pid=%d;"
256ebe
                  "subvol=%s;type=gfid;file="
256ebe
                  "<gfid:%s>/%s>;count=2;child-%d=%s;gfid-%d=%s;"
256ebe
                  "child-%d=%s;gfid-%d=%s",
256ebe
-                 this->name, uuid_utoa(pargfid), bname, child_idx,
256ebe
-                 priv->children[child_idx]->name, child_idx,
256ebe
+                 this->ctx->cmd_args.client_pid, this->name, uuid_utoa(pargfid),
256ebe
+                 bname, child_idx, priv->children[child_idx]->name, child_idx,
256ebe
                  uuid_utoa_r(replies[child_idx].poststat.ia_gfid, g1), src_idx,
256ebe
                  priv->children[src_idx]->name, src_idx,
256ebe
                  uuid_utoa_r(replies[src_idx].poststat.ia_gfid, g2));
256ebe
@@ -2296,11 +2297,13 @@ afr_selfheal_unlocked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
256ebe
                    priv->children[i]->name,
256ebe
                    uuid_utoa(replies[i].poststat.ia_gfid));
256ebe
             gf_event(EVENT_AFR_SPLIT_BRAIN,
256ebe
+                     "client-pid=%d;"
256ebe
                      "subvol=%s;"
256ebe
                      "type=file;gfid=%s;"
256ebe
                      "ia_type-%d=%s;ia_type-%d=%s",
256ebe
-                     this->name, uuid_utoa(replies[i].poststat.ia_gfid),
256ebe
-                     first_idx, gf_inode_type_to_str(first.ia_type), i,
256ebe
+                     this->ctx->cmd_args.client_pid, this->name,
256ebe
+                     uuid_utoa(replies[i].poststat.ia_gfid), first_idx,
256ebe
+                     gf_inode_type_to_str(first.ia_type), i,
256ebe
                      gf_inode_type_to_str(replies[i].poststat.ia_type));
256ebe
             ret = -EIO;
256ebe
             goto out;
256ebe
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
256ebe
index d9a0ee3..18a0334 100644
256ebe
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
256ebe
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
256ebe
@@ -537,9 +537,11 @@ __afr_selfheal_data_finalize_source(
256ebe
             replies, AFR_DATA_TRANSACTION);
256ebe
         if (source < 0) {
256ebe
             gf_event(EVENT_AFR_SPLIT_BRAIN,
256ebe
+                     "client-pid=%d;"
256ebe
                      "subvol=%s;type=data;"
256ebe
                      "file=%s",
256ebe
-                     this->name, uuid_utoa(inode->gfid));
256ebe
+                     this->ctx->cmd_args.client_pid, this->name,
256ebe
+                     uuid_utoa(inode->gfid));
256ebe
             return -EIO;
256ebe
         }
256ebe
 
256ebe
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
256ebe
index b23ed6a..fc09b4c 100644
256ebe
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
256ebe
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
256ebe
@@ -269,11 +269,12 @@ afr_selfheal_detect_gfid_and_type_mismatch(xlator_t *this,
256ebe
                    gf_inode_type_to_str(replies[src_idx].poststat.ia_type),
256ebe
                    priv->children[src_idx]->name);
256ebe
             gf_event(EVENT_AFR_SPLIT_BRAIN,
256ebe
+                     "client-pid=%d;"
256ebe
                      "subvol=%s;type=file;"
256ebe
                      "file=<gfid:%s>/%s>;count=2;child-%d=%s;type-"
256ebe
                      "%d=%s;child-%d=%s;type-%d=%s",
256ebe
-                     this->name, uuid_utoa(pargfid), bname, i,
256ebe
-                     priv->children[i]->name, i,
256ebe
+                     this->ctx->cmd_args.client_pid, this->name,
256ebe
+                     uuid_utoa(pargfid), bname, i, priv->children[i]->name, i,
256ebe
                      gf_inode_type_to_str(replies[i].poststat.ia_type), src_idx,
256ebe
                      priv->children[src_idx]->name, src_idx,
256ebe
                      gf_inode_type_to_str(replies[src_idx].poststat.ia_type));
256ebe
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
256ebe
index a661fcb..ba43341 100644
256ebe
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
256ebe
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
256ebe
@@ -242,9 +242,11 @@ __afr_selfheal_metadata_finalize_source(call_frame_t *frame, xlator_t *this,
256ebe
 
256ebe
         if (!priv->metadata_splitbrain_forced_heal) {
256ebe
             gf_event(EVENT_AFR_SPLIT_BRAIN,
256ebe
+                     "client-pid=%d;"
256ebe
                      "subvol=%s;"
256ebe
                      "type=metadata;file=%s",
256ebe
-                     this->name, uuid_utoa(inode->gfid));
256ebe
+                     this->ctx->cmd_args.client_pid, this->name,
256ebe
+                     uuid_utoa(inode->gfid));
256ebe
             return -EIO;
256ebe
         }
256ebe
 
256ebe
diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c
256ebe
index c4df5d4..36640b5 100644
256ebe
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
256ebe
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
256ebe
@@ -222,13 +222,14 @@ afr_selfheal_name_type_mismatch_check(xlator_t *this, struct afr_reply *replies,
256ebe
                        gf_inode_type_to_str(inode_type),
256ebe
                        priv->children[type_idx]->name);
256ebe
                 gf_event(EVENT_AFR_SPLIT_BRAIN,
256ebe
+                         "client-pid=%d;"
256ebe
                          "subvol=%s;type=file;"
256ebe
                          "file=<gfid:%s>/%s;count=2;"
256ebe
                          "child-%d=%s;type-%d=%s;child-%d=%s;"
256ebe
                          "type-%d=%s",
256ebe
-                         this->name, uuid_utoa(pargfid), bname, i,
256ebe
-                         priv->children[i]->name, i,
256ebe
-                         gf_inode_type_to_str(inode_type1), type_idx,
256ebe
+                         this->ctx->cmd_args.client_pid, this->name,
256ebe
+                         uuid_utoa(pargfid), bname, i, priv->children[i]->name,
256ebe
+                         i, gf_inode_type_to_str(inode_type1), type_idx,
256ebe
                          priv->children[type_idx]->name, type_idx,
256ebe
                          gf_inode_type_to_str(inode_type));
256ebe
                 return -EIO;
256ebe
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
256ebe
index 04a4b2e..19eca9f 100644
256ebe
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
256ebe
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
256ebe
@@ -324,6 +324,7 @@ glusterd_new_shd_svc_start(glusterd_svc_t *svc, int flags)
256ebe
 {
256ebe
     int ret = -1;
256ebe
     char glusterd_uuid_option[PATH_MAX] = {0};
256ebe
+    char client_pid[32] = {0};
256ebe
     dict_t *cmdline = NULL;
256ebe
 
256ebe
     cmdline = dict_new();
256ebe
@@ -335,6 +336,15 @@ glusterd_new_shd_svc_start(glusterd_svc_t *svc, int flags)
256ebe
     if (ret < 0)
256ebe
         goto out;
256ebe
 
256ebe
+    ret = snprintf(client_pid, sizeof(client_pid), "--client-pid=%d",
256ebe
+                   GF_CLIENT_PID_SELF_HEALD);
256ebe
+    if (ret < 0)
256ebe
+        goto out;
256ebe
+
256ebe
+    ret = dict_set_str(cmdline, "arg", client_pid);
256ebe
+    if (ret < 0)
256ebe
+        goto out;
256ebe
+
256ebe
     /* Pass cmdline arguments as key-value pair. The key is merely
256ebe
      * a carrier and is not used. Since dictionary follows LIFO the value
256ebe
      * should be put in reverse order*/
256ebe
-- 
256ebe
1.8.3.1
256ebe