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