21ab4e
From c176aec07bed30c2aa8f327272e1f02be545ae43 Mon Sep 17 00:00:00 2001
21ab4e
From: Poornima G <pgurusid@redhat.com>
21ab4e
Date: Fri, 19 May 2017 11:09:13 +0530
21ab4e
Subject: [PATCH 464/473] rda, glusterd: Change the max of rda-cache-limit to
21ab4e
 INFINITY
21ab4e
21ab4e
Issue:
21ab4e
The max value of rda-cache-limit is 1GB before this patch.
21ab4e
When parallel-readdir is enabled, there will be many instances of
21ab4e
readdir-ahead, hence the rda-cache-limit depends on the number of
21ab4e
instances. Eg: On a volume with distribute count 4, rda-cache-limit
21ab4e
when parallel-readdir is enabled, will be 4GB instead of 1GB.
21ab4e
Consider a followinf sequence of operations:
21ab4e
- Enable parallel readdir
21ab4e
- Set rda-cache-limit to lets say 3GB
21ab4e
- Disable parallel-readdir, this results in one instance of readdir-ahead
21ab4e
  and the rda-cache-limit will be back to 1GB, but the current value is 3GB
21ab4e
  and hence the mount will stop working as 3GB > max 1GB.
21ab4e
21ab4e
Solution:
21ab4e
To fix this, we can limit the cache to 1GB even when parallel-readdir
21ab4e
is enabled. But there is no necessity to limit the cache to 1GB, it
21ab4e
can be increased if the system has enough resources. Hence getting rid
21ab4e
of the rda-cache-limit max value is more apt. If we just change the
21ab4e
rda-cache-limit max to INFINITY, we will render older(<3.11) clients
21ab4e
broken, when the rda-cache-limit is set to > 1GB (as the older clients
21ab4e
still expect a value < 1GB). To safely change the max value of
21ab4e
rda-cache-limit to INFINITY, add a check in glusted to verify all
21ab4e
the clients are > 3.11 if the value exceeds 1GB.
21ab4e
21ab4e
>Reviewed-on: https://review.gluster.org/17338
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Signed-off-by: Poornima G <pgurusid@redhat.com>
21ab4e
Change-Id: Id0cdda3b053287b659c7bf511b13db2e45b92032
21ab4e
BUG: 1438245
21ab4e
Signed-off-by: Poornima G <pgurusid@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106815
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 tests/bugs/readdir-ahead/bug-1439640.t             |  2 +-
21ab4e
 tests/bugs/readdir-ahead/bug-1446516.t             | 21 +++++++++++++++
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volume-set.c    | 31 ++++++++++++++++++++++
21ab4e
 .../performance/readdir-ahead/src/readdir-ahead.c  |  3 ++-
21ab4e
 4 files changed, 55 insertions(+), 2 deletions(-)
21ab4e
 create mode 100755 tests/bugs/readdir-ahead/bug-1446516.t
21ab4e
21ab4e
diff --git a/tests/bugs/readdir-ahead/bug-1439640.t b/tests/bugs/readdir-ahead/bug-1439640.t
21ab4e
index cfa5d1f..cc6c829 100755
21ab4e
--- a/tests/bugs/readdir-ahead/bug-1439640.t
21ab4e
+++ b/tests/bugs/readdir-ahead/bug-1439640.t
21ab4e
@@ -27,4 +27,4 @@ TEST ! $CLI volume set $V0 rda-request-size 87adh
21ab4e
 TEST $CLI volume set $V0 rda-cache-limit 10MB
21ab4e
 TEST $CLI volume set $V0 rda-request-size 128KB
21ab4e
 
21ab4e
-#cleanup;
21ab4e
+cleanup;
21ab4e
diff --git a/tests/bugs/readdir-ahead/bug-1446516.t b/tests/bugs/readdir-ahead/bug-1446516.t
21ab4e
new file mode 100755
21ab4e
index 0000000..2bf6520
21ab4e
--- /dev/null
21ab4e
+++ b/tests/bugs/readdir-ahead/bug-1446516.t
21ab4e
@@ -0,0 +1,21 @@
21ab4e
+#!/bin/bash
21ab4e
+
21ab4e
+. $(dirname $0)/../../include.rc
21ab4e
+. $(dirname $0)/../../volume.rc
21ab4e
+
21ab4e
+cleanup;
21ab4e
+
21ab4e
+TEST glusterd
21ab4e
+
21ab4e
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1..4}
21ab4e
+TEST $CLI volume start $V0
21ab4e
+
21ab4e
+TEST $CLI volume set $V0 parallel-readdir on
21ab4e
+
21ab4e
+TEST $CLI volume set $V0 rda-cache-limit 4GB
21ab4e
+
21ab4e
+TEST $CLI volume set $V0 parallel-readdir off
21ab4e
+
21ab4e
+TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0
21ab4e
+
21ab4e
+cleanup;
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
index 8d464d0..dd3f4fd 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
21ab4e
@@ -966,6 +966,36 @@ out:
21ab4e
 
21ab4e
 
21ab4e
 static int
21ab4e
+validate_rda_cache_limit (glusterd_volinfo_t *volinfo, dict_t *dict,
21ab4e
+                          char *key, char *value, char **op_errstr)
21ab4e
+{
21ab4e
+        int          ret             = 0;
21ab4e
+        uint64_t     rda_cache_size  = 0;
21ab4e
+
21ab4e
+        ret = gf_string2bytesize_uint64 (value, &rda_cache_size);
21ab4e
+        if (ret < 0)
21ab4e
+                goto out;
21ab4e
+
21ab4e
+        if (rda_cache_size <= (1 * GF_UNIT_GB))
21ab4e
+                goto out;
21ab4e
+
21ab4e
+        /* With release 3.11 the max value of rda_cache_limit is changed from
21ab4e
+         * 1GB to INFINITY. If there are clients older than 3.11 and the value
21ab4e
+         * of rda-cache-limit is set to > 1GB, the older clients will stop
21ab4e
+         * working. Hence if a user is setting rda-cache-limit to > 1GB
21ab4e
+         * ensure that all the clients are 3.11 or greater.
21ab4e
+         */
21ab4e
+        ret = glusterd_check_client_op_version_support (volinfo->volname,
21ab4e
+                                                        GD_OP_VERSION_3_11_0,
21ab4e
+                                                        op_errstr);
21ab4e
+out:
21ab4e
+        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
21ab4e
+
21ab4e
+        return ret;
21ab4e
+}
21ab4e
+
21ab4e
+
21ab4e
+static int
21ab4e
 validate_worm_period (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
21ab4e
                char *value, char **op_errstr)
21ab4e
 {
21ab4e
@@ -3114,6 +3144,7 @@ struct volopt_map_entry glusterd_volopt_map[] = {
21ab4e
           .type        = DOC,
21ab4e
           .flags       = OPT_FLAG_CLIENT_OPT,
21ab4e
           .op_version  = GD_OP_VERSION_3_9_1,
21ab4e
+          .validate_fn = validate_rda_cache_limit
21ab4e
         },
21ab4e
         { .key         = "performance.nl-cache-positive-entry",
21ab4e
           .voltype     = "performance/nl-cache",
21ab4e
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c
21ab4e
index 2ffcf25..4e7f2b9 100644
21ab4e
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c
21ab4e
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c
21ab4e
@@ -23,6 +23,7 @@
21ab4e
  * preloads on the directory.
21ab4e
  */
21ab4e
 
21ab4e
+#include <math.h>
21ab4e
 #include "glusterfs.h"
21ab4e
 #include "xlator.h"
21ab4e
 #include "call-stub.h"
21ab4e
@@ -739,7 +740,7 @@ struct volume_options options[] = {
21ab4e
         { .key = {"rda-cache-limit"},
21ab4e
           .type = GF_OPTION_TYPE_SIZET,
21ab4e
           .min = 0,
21ab4e
-          .max = 1 * GF_UNIT_GB,
21ab4e
+          .max = INFINITY,
21ab4e
           .default_value = "10MB",
21ab4e
           .description = "maximum size of cache consumed by readdir-ahead "
21ab4e
                          "xlator. This value is global and total memory "
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e