Blob Blame History Raw
From 81a1c4cdcfe5a20edf760fcb857e9d5297c322dd Mon Sep 17 00:00:00 2001
From: Pranith Kumar K <pkarampu@redhat.com>
Date: Thu, 4 Aug 2016 00:41:16 +0530
Subject: [PATCH 107/141] cluster/ec: Do multi-threaded self-heal

 >BUG: 1368451
 >Change-Id: I5d6b91d714ad6906dc478a401e614115c89a8fbb
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
 >Reviewed-on: http://review.gluster.org/15083
 >Smoke: Gluster Build System <jenkins@build.gluster.org>
 >Reviewed-by: Ashish Pandey <aspandey@redhat.com>
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

BUG: 1375465
Change-Id: Iad998614f659fd988fe41a2103cfc4af993aa8a2
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/87213
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/afr/src/afr.c                   |    6 ++--
 xlators/cluster/ec/src/ec-heald.c               |   14 +++++++++++-
 xlators/cluster/ec/src/ec-heald.h               |    2 +
 xlators/cluster/ec/src/ec.c                     |   25 +++++++++++++++++++++++
 xlators/mgmt/glusterd/src/glusterd-volume-set.c |   10 +++++++++
 5 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index d38d59c..c30e7ec 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -896,9 +896,9 @@ struct volume_options options[] = {
           .min   = 1,
           .max   = 64,
           .default_value = "1",
-           .description = "Maximum number of threads SHD can use per local "
-                          "brick.  This can substantially lower heal times, "
-                          "but can also crush your bricks if you don't have "
+           .description = "Maximum number of parallel heals SHD can do per "
+                          "local brick. This can substantially lower heal times"
+                          ", but can also crush your bricks if you don't have "
                           "the storage hardware to support this."
         },
         { .key   = {"shd-wait-qlength"},
diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c
index 0f63ab1..9860f10 100644
--- a/xlators/cluster/ec/src/ec-heald.c
+++ b/xlators/cluster/ec/src/ec-heald.c
@@ -240,6 +240,7 @@ ec_shd_index_sweep (struct subvol_healer *healer)
         ec_t          *ec     = NULL;
         int           ret     = 0;
         xlator_t      *subvol = NULL;
+        dict_t        *xdata  = NULL;
 
         ec = healer->this->private;
         subvol = ec->xl_list[healer->subvol];
@@ -252,9 +253,18 @@ ec_shd_index_sweep (struct subvol_healer *healer)
                 goto out;
         }
 
-        ret = syncop_dir_scan (subvol, &loc, GF_CLIENT_PID_SELF_HEALD,
-                               healer, ec_shd_index_heal);
+        xdata = dict_new ();
+        if (!xdata || dict_set_int32 (xdata, "get-gfid-type", 1)) {
+                ret = -ENOMEM;
+                goto out;
+        }
+
+        ret = syncop_mt_dir_scan (NULL, subvol, &loc, GF_CLIENT_PID_SELF_HEALD,
+                                  healer, ec_shd_index_heal, xdata,
+                                  ec->shd.max_threads, ec->shd.wait_qlength);
 out:
+        if (xdata)
+                dict_unref (xdata);
         loc_wipe (&loc);
 
         return ret;
diff --git a/xlators/cluster/ec/src/ec-heald.h b/xlators/cluster/ec/src/ec-heald.h
index 0f27a8e..0929044 100644
--- a/xlators/cluster/ec/src/ec-heald.h
+++ b/xlators/cluster/ec/src/ec-heald.h
@@ -34,6 +34,8 @@ struct _ec_self_heald {
         gf_boolean_t            iamshd;
         gf_boolean_t            enabled;
         int                     timeout;
+        uint32_t                max_threads;
+        uint32_t                wait_qlength;
         struct subvol_healer   *index_healers;
         struct subvol_healer   *full_healers;
 };
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 7e295ca..587ea63 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -275,6 +275,10 @@ reconfigure (xlator_t *this, dict_t *options)
         GF_OPTION_RECONF ("read-policy", read_policy, options, str, failed);
         if (ec_assign_read_policy (ec, read_policy))
                 goto failed;
+        GF_OPTION_RECONF ("shd-max-threads", ec->shd.max_threads,
+                          options, uint32, failed);
+        GF_OPTION_RECONF ("shd-wait-qlength", ec->shd.wait_qlength,
+                          options, uint32, failed);
 
         return 0;
 failed:
@@ -616,6 +620,9 @@ init (xlator_t *this)
     if (ec_assign_read_policy (ec, read_policy))
             goto failed;
 
+    GF_OPTION_INIT ("shd-max-threads", ec->shd.max_threads, uint32, failed);
+    GF_OPTION_INIT ("shd-wait-qlength", ec->shd.wait_qlength, uint32, failed);
+
     this->itable = inode_table_new (EC_SHD_INODE_LRU_LIMIT, this);
     if (!this->itable)
             goto failed;
@@ -1365,5 +1372,23 @@ struct volume_options options[] =
               " subvolume using round-robin algo. 'gfid-hash' selects read"
               " subvolume based on hash of the gfid of that file/directory.",
     },
+    { .key   = {"shd-max-threads"},
+      .type  = GF_OPTION_TYPE_INT,
+      .min   = 1,
+      .max   = 64,
+      .default_value = "1",
+      .description = "Maximum number of parallel heals SHD can do per local "
+                      "brick.  This can substantially lower heal times, "
+                      "but can also crush your bricks if you don't have "
+                      "the storage hardware to support this."
+    },
+    { .key   = {"shd-wait-qlength"},
+      .type  = GF_OPTION_TYPE_INT,
+      .min   = 1,
+      .max   = 655536,
+      .default_value = "1024",
+      .description = "This option can be used to control number of heals"
+                     " that can wait in SHD per subvolume"
+    },
     { }
 };
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index bd9b21b..8978709 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -2977,6 +2977,16 @@ struct volopt_map_entry glusterd_volopt_map[] = {
           .op_version = GD_OP_VERSION_3_8_4,
           .flags      = OPT_FLAG_CLIENT_OPT
         },
+        { .key        = "disperse.shd-max-threads",
+          .voltype    = "cluster/disperse",
+          .op_version = GD_OP_VERSION_3_9_0,
+          .flags      = OPT_FLAG_CLIENT_OPT
+        },
+        { .key        = "disperse.shd-wait-qlength",
+          .voltype    = "cluster/disperse",
+          .op_version = GD_OP_VERSION_3_9_0,
+          .flags      = OPT_FLAG_CLIENT_OPT
+        },
         { .key         = NULL
         }
 };
-- 
1.7.1