74096c
From 2e6a5e504e66bc95208420e4882e453a53ac9ea2 Mon Sep 17 00:00:00 2001
74096c
From: schaffung <ssivakum@redhat.com>
74096c
Date: Mon, 2 Nov 2020 11:18:01 +0530
74096c
Subject: [PATCH 485/511] cli-rpc: conditional init of global quota rpc (#1578)
74096c
74096c
Issue: It is seem that the initialization of rpc to
74096c
connect with quotad is done in every glusterfs cli command,
74096c
irrespective of whether the quota feature is enabled or disabled.
74096c
This seems to be an overkill.
74096c
74096c
Code change: The file /var/run/quotad/quotad.pid is present
74096c
signals that quotad is enabled. Hence we can put a conditional
74096c
check for seeing when this file exists and if it doesn't we
74096c
just skip over the initialization of the global quotad rpc.
74096c
74096c
This will go on to reduce the extra rpc calls and operations
74096c
being performed in the kernel space.
74096c
74096c
>Fixes: #1577
74096c
>Change-Id: Icb69d35330f76ce95626f59af75a12726eb620ff
74096c
>Signed-off-by: srijan-sivakumar <ssivakumar@redhat.com>
74096c
Upstream Patch : https://github.com/gluster/glusterfs/pull/1578
74096c
74096c
BUG: 1885966
74096c
Change-Id: Icb69d35330f76ce95626f59af75a12726eb620ff
74096c
Signed-off-by: Srijan Sivakumar <ssivakum@redhat.com>
74096c
Reviewed-on: https://code.engineering.redhat.com/gerrit/220371
74096c
Tested-by: RHGS Build Bot <nigelb@redhat.com>
74096c
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
74096c
---
74096c
 cli/src/cli.c | 18 +++++++++++++-----
74096c
 cli/src/cli.h |  3 +++
74096c
 2 files changed, 16 insertions(+), 5 deletions(-)
74096c
74096c
diff --git a/cli/src/cli.c b/cli/src/cli.c
74096c
index 99a16a0..a76c5a2 100644
74096c
--- a/cli/src/cli.c
74096c
+++ b/cli/src/cli.c
74096c
@@ -64,8 +64,7 @@
74096c
 extern int connected;
74096c
 /* using argp for command line parsing */
74096c
 
74096c
-const char *argp_program_version =
74096c
-    PACKAGE_NAME" "PACKAGE_VERSION;
74096c
+const char *argp_program_version = PACKAGE_NAME " " PACKAGE_VERSION;
74096c
 const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
74096c
 
74096c
 struct rpc_clnt *global_quotad_rpc;
74096c
@@ -840,9 +839,18 @@ main(int argc, char *argv[])
74096c
     if (!global_rpc)
74096c
         goto out;
74096c
 
74096c
-    global_quotad_rpc = cli_quotad_clnt_rpc_init();
74096c
-    if (!global_quotad_rpc)
74096c
-        goto out;
74096c
+    /*
74096c
+     * Now, one doesn't need to initialize global rpc
74096c
+     * for quota unless and until quota is enabled.
74096c
+     * So why not put a check to save all the rpc related
74096c
+     * ops here.
74096c
+     */
74096c
+    ret = sys_access(QUOTAD_PID_PATH, F_OK);
74096c
+    if (!ret) {
74096c
+        global_quotad_rpc = cli_quotad_clnt_rpc_init();
74096c
+        if (!global_quotad_rpc)
74096c
+            goto out;
74096c
+    }
74096c
 
74096c
     ret = cli_cmds_register(&state);
74096c
     if (ret)
74096c
diff --git a/cli/src/cli.h b/cli/src/cli.h
74096c
index 37e4d9d..c30ae9c 100644
74096c
--- a/cli/src/cli.h
74096c
+++ b/cli/src/cli.h
74096c
@@ -30,6 +30,9 @@
74096c
 #define CLI_TAB_LENGTH 8
74096c
 #define CLI_BRICK_STATUS_LINE_LEN 78
74096c
 
74096c
+// Quotad pid path.
74096c
+#define QUOTAD_PID_PATH "/var/run/gluster/quotad/quotad.pid"
74096c
+
74096c
 /* Geo-rep command positional arguments' index  */
74096c
 #define GEO_REP_CMD_INDEX 1
74096c
 #define GEO_REP_CMD_CONFIG_INDEX 4
74096c
-- 
74096c
1.8.3.1
74096c