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