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