21ab4e
From 6d108a367e32ffdcdf092a802370d601c3ee65d4 Mon Sep 17 00:00:00 2001
21ab4e
From: Poornima G <pgurusid@redhat.com>
21ab4e
Date: Thu, 8 Dec 2016 16:48:55 +0530
21ab4e
Subject: [PATCH 358/361] glusterd: Change the volfile to have readdir-ahead as
21ab4e
 a child of dht
21ab4e
21ab4e
As mentioned in feature page http://review.gluster.org/#/c/16090/
21ab4e
readdir-ahead will be optionally placed below dht.
21ab4e
21ab4e
There are two options:
21ab4e
1. performance.readdir-ahead
21ab4e
2. performance.parallel-readdir
21ab4e
21ab4e
If only option is enabled, then readdir ahead is placed at its
21ab4e
original place as an ancestor of dht. If both the options 1 and 2
21ab4e
are enabled then readdir ahead is placed as a child of dht.
21ab4e
21ab4e
Also changes have been made to retain the rebalance, quotad,
21ab4e
snapd vol files to remain unchanged.
21ab4e
21ab4e
mainline:
21ab4e
> BUG: 1401812
21ab4e
> Reviewed-on: http://review.gluster.org/16072
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
21ab4e
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
(cherry picked from commit 716756e73e13c73031a88b6aa6749299ea809cf2)
21ab4e
21ab4e
BUG: 1427096
21ab4e
Change-Id: I0adf0b476fcbf91251f5a2fee2241786a3d8255a
21ab4e
Signed-off-by: Poornima G <pgurusid@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/101418
21ab4e
Tested-by: Milind Changire <mchangir@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/mgmt/glusterd/src/glusterd-utils.c      | 16 ----------
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volgen.c     | 40 +++++++++++++++++++++++++
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volgen.h     | 10 +++++++
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volume-set.c | 21 +++++++++++--
21ab4e
 4 files changed, 69 insertions(+), 18 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
index eee2224..4e15603 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
@@ -11354,22 +11354,6 @@ glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option)
21ab4e
                  * }
21ab4e
                  * */
21ab4e
 
21ab4e
-                /* readdir-ahead needs to be enabled for new volumes with
21ab4e
-                 * >= gluster version 3.7
21ab4e
-                 */
21ab4e
-                if (!option || !strcmp ("performance.readdir-ahead", option)) {
21ab4e
-                        ret = dict_set_dynstr_with_alloc (volinfo->dict,
21ab4e
-                                        "performance.readdir-ahead", "on");
21ab4e
-                        if (ret) {
21ab4e
-                                gf_msg (this->name, GF_LOG_ERROR, errno,
21ab4e
-                                        GD_MSG_DICT_SET_FAILED,
21ab4e
-                                        "Failed to set option "
21ab4e
-                                        "'performance.readdir-ahead' on volume "
21ab4e
-                                        "%s", volinfo->volname);
21ab4e
-                                goto out;
21ab4e
-                        }
21ab4e
-                }
21ab4e
-
21ab4e
                 /* Option 'features.quota-deem-statfs' should not be turned off
21ab4e
                  * with 'gluster volume reset <VOLNAME>', since quota features
21ab4e
                  * can be reset only with 'gluster volume quota <VOLNAME>
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
21ab4e
index 1b53e7c..abebd10 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
21ab4e
@@ -2541,6 +2541,12 @@ perfxl_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
21ab4e
         if (!strcmp (vme->key, "performance.client-io-threads") &&
21ab4e
             (GF_CLUSTER_TYPE_STRIPE_REPLICATE == volinfo->type ||
21ab4e
              GF_CLUSTER_TYPE_REPLICATE == volinfo->type))
21ab4e
+
21ab4e
+        /* if VKEY_READDIR_AHEAD is enabled and parallel readdir is
21ab4e
+         * not enabled then load readdir-ahead here else it will be
21ab4e
+         * loaded as a child of dht */
21ab4e
+        if (!strcmp (vme->key, VKEY_READDIR_AHEAD) &&
21ab4e
+            glusterd_volinfo_get_boolean (volinfo, VKEY_PARALLEL_READDIR))
21ab4e
                 return 0;
21ab4e
 
21ab4e
         if (volgen_graph_add (graph, vme->voltype, volinfo->volname))
21ab4e
@@ -3291,6 +3297,30 @@ out:
21ab4e
 }
21ab4e
 
21ab4e
 static int
21ab4e
+volgen_graph_build_readdir_ahead (volgen_graph_t *graph,
21ab4e
+                                  glusterd_volinfo_t *volinfo,
21ab4e
+                                  size_t child_count)
21ab4e
+{
21ab4e
+        int32_t                 clusters                 = 0;
21ab4e
+
21ab4e
+        if (graph->type == GF_REBALANCED ||
21ab4e
+            graph->type == GF_QUOTAD ||
21ab4e
+            graph->type == GF_SNAPD ||
21ab4e
+            !glusterd_volinfo_get_boolean (volinfo, VKEY_PARALLEL_READDIR) ||
21ab4e
+            !glusterd_volinfo_get_boolean (volinfo, VKEY_READDIR_AHEAD))
21ab4e
+                goto out;
21ab4e
+
21ab4e
+        clusters = volgen_link_bricks_from_list_tail (graph,
21ab4e
+                                                      volinfo,
21ab4e
+                                                      "performance/readdir-ahead",
21ab4e
+                                                      "%s-readdir-ahead-%d",
21ab4e
+                                                      child_count,
21ab4e
+                                                      1);
21ab4e
+out:
21ab4e
+        return clusters;
21ab4e
+}
21ab4e
+
21ab4e
+static int
21ab4e
 volgen_graph_build_dht_cluster (volgen_graph_t *graph,
21ab4e
                                 glusterd_volinfo_t *volinfo, size_t child_count,
21ab4e
                                 gf_boolean_t is_quotad)
21ab4e
@@ -3546,6 +3576,11 @@ build_distribute:
21ab4e
                 else
21ab4e
                         strcat (volinfo->volname, "-cold");
21ab4e
         }
21ab4e
+        clusters = volgen_graph_build_readdir_ahead (graph, volinfo,
21ab4e
+                                                     dist_count);
21ab4e
+        if (clusters < 0)
21ab4e
+                goto out;
21ab4e
+
21ab4e
         ret = volgen_graph_build_dht_cluster (graph, volinfo,
21ab4e
                                               dist_count, is_quotad);
21ab4e
         if (volinfo->tier_info.hot_brick_count)
21ab4e
@@ -4565,6 +4600,8 @@ build_rebalance_volfile (glusterd_volinfo_t *volinfo, char *filepath,
21ab4e
 
21ab4e
         this = THIS;
21ab4e
 
21ab4e
+        graph.type = GF_REBALANCED;
21ab4e
+
21ab4e
         if (volinfo->brick_count <= volinfo->dist_leaf_count) {
21ab4e
                 /*
21ab4e
                  * Volume is not a distribute volume or
21ab4e
@@ -5003,6 +5040,8 @@ build_quotad_graph (volgen_graph_t *graph, dict_t *mod_dict)
21ab4e
         priv = this->private;
21ab4e
         GF_ASSERT (priv);
21ab4e
 
21ab4e
+        graph->type = GF_QUOTAD;
21ab4e
+
21ab4e
         set_dict = dict_new ();
21ab4e
         if (!set_dict) {
21ab4e
                 ret = -ENOMEM;
21ab4e
@@ -5851,6 +5890,7 @@ glusterd_snapdsvc_create_volfile (glusterd_volinfo_t *volinfo)
21ab4e
         int             ret                     = -1;
21ab4e
         char            filename [PATH_MAX]     = {0,};
21ab4e
 
21ab4e
+        graph.type = GF_SNAPD;
21ab4e
         glusterd_svc_build_snapd_volfile (volinfo, filename, PATH_MAX);
21ab4e
 
21ab4e
         ret = glusterd_snapdsvc_generate_volfile (&graph, volinfo);
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
21ab4e
index f901773..bbf40b5 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
21ab4e
@@ -32,6 +32,8 @@
21ab4e
 #define VKEY_FEATURES_TRASH       "features.trash"
21ab4e
 #define VKEY_FEATURES_BITROT      "features.bitrot"
21ab4e
 #define VKEY_FEATURES_SCRUB       "features.scrub"
21ab4e
+#define VKEY_PARALLEL_READDIR     "performance.parallel-readdir"
21ab4e
+#define VKEY_READDIR_AHEAD        "performance.readdir-ahead"
21ab4e
 
21ab4e
 #define AUTH_ALLOW_MAP_KEY "auth.allow"
21ab4e
 #define AUTH_REJECT_MAP_KEY "auth.reject"
21ab4e
@@ -55,9 +57,17 @@ typedef enum {
21ab4e
         GF_CLIENT_OTHER
21ab4e
 } glusterd_client_type_t;
21ab4e
 
21ab4e
+/* It indicates the type of volfile that the graph is built for */
21ab4e
+typedef enum {
21ab4e
+        GF_REBALANCED = 1,
21ab4e
+        GF_QUOTAD,
21ab4e
+        GF_SNAPD,
21ab4e
+} glusterd_graph_type_t;
21ab4e
+
21ab4e
 struct volgen_graph {
21ab4e
         char **errstr;
21ab4e
         glusterfs_graph_t graph;
21ab4e
+        glusterd_graph_type_t type;
21ab4e
 };
21ab4e
 typedef struct volgen_graph volgen_graph_t;
21ab4e
 
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
index 2898b4a..a2ef7c9 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
@@ -1864,12 +1864,11 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
         { .key         = "performance.readdir-ahead",
21ab4e
           .voltype     = "performance/readdir-ahead",
21ab4e
           .option      = "!perf",
21ab4e
-          .value       = "off",
21ab4e
+          .value       = "on",
21ab4e
           .op_version  = GD_OP_VERSION_RHS_3_0,
21ab4e
           .description = "enable/disable readdir-ahead translator in the volume.",
21ab4e
           .flags       = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT
21ab4e
         },
21ab4e
-
21ab4e
         { .key         = "performance.io-cache",
21ab4e
           .voltype     = "performance/io-cache",
21ab4e
           .option      = "!perf",
21ab4e
@@ -3012,6 +3011,24 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
           .op_version = GD_OP_VERSION_3_9_0,
21ab4e
           .flags      = OPT_FLAG_CLIENT_OPT
21ab4e
         },
21ab4e
+        { .key        = "cluster.use-compound-fops",
21ab4e
+          .voltype    = "cluster/replicate",
21ab4e
+          .value      = "off",
21ab4e
+          .type       = DOC,
21ab4e
+          .op_version = GD_OP_VERSION_3_8_4,
21ab4e
+          .flags      = OPT_FLAG_CLIENT_OPT
21ab4e
+        },
21ab4e
+        { .key         = "performance.parallel-readdir",
21ab4e
+          .voltype     = "performance/readdir-ahead",
21ab4e
+          .option      = "parallel-readdir",
21ab4e
+          .value       = "off",
21ab4e
+          .type        = DOC,
21ab4e
+          .op_version  = GD_OP_VERSION_3_10_0,
21ab4e
+          .description = "If this option is enabled, the readdir operation is "
21ab4e
+                         "performed parallely on all the bricks, thus improving"
21ab4e
+                         " the performance of readdir. Note that the performance"
21ab4e
+                         "improvement is higher in large clusters"
21ab4e
+        },
21ab4e
 	{ .key         = "performance.rda-request-size",
21ab4e
 	  .voltype     = "performance/readdir-ahead",
21ab4e
           .option      = "rda-request-size",
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e