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