3604df
From 81a1c4cdcfe5a20edf760fcb857e9d5297c322dd Mon Sep 17 00:00:00 2001
3604df
From: Pranith Kumar K <pkarampu@redhat.com>
3604df
Date: Thu, 4 Aug 2016 00:41:16 +0530
3604df
Subject: [PATCH 107/141] cluster/ec: Do multi-threaded self-heal
3604df
3604df
 >BUG: 1368451
3604df
 >Change-Id: I5d6b91d714ad6906dc478a401e614115c89a8fbb
3604df
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
3604df
 >Reviewed-on: http://review.gluster.org/15083
3604df
 >Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
 >Reviewed-by: Ashish Pandey <aspandey@redhat.com>
3604df
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
3604df
BUG: 1375465
3604df
Change-Id: Iad998614f659fd988fe41a2103cfc4af993aa8a2
3604df
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/87213
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
Tested-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 xlators/cluster/afr/src/afr.c                   |    6 ++--
3604df
 xlators/cluster/ec/src/ec-heald.c               |   14 +++++++++++-
3604df
 xlators/cluster/ec/src/ec-heald.h               |    2 +
3604df
 xlators/cluster/ec/src/ec.c                     |   25 +++++++++++++++++++++++
3604df
 xlators/mgmt/glusterd/src/glusterd-volume-set.c |   10 +++++++++
3604df
 5 files changed, 52 insertions(+), 5 deletions(-)
3604df
3604df
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
3604df
index d38d59c..c30e7ec 100644
3604df
--- a/xlators/cluster/afr/src/afr.c
3604df
+++ b/xlators/cluster/afr/src/afr.c
3604df
@@ -896,9 +896,9 @@ struct volume_options options[] = {
3604df
           .min   = 1,
3604df
           .max   = 64,
3604df
           .default_value = "1",
3604df
-           .description = "Maximum number of threads SHD can use per local "
3604df
-                          "brick.  This can substantially lower heal times, "
3604df
-                          "but can also crush your bricks if you don't have "
3604df
+           .description = "Maximum number of parallel heals SHD can do per "
3604df
+                          "local brick. This can substantially lower heal times"
3604df
+                          ", but can also crush your bricks if you don't have "
3604df
                           "the storage hardware to support this."
3604df
         },
3604df
         { .key   = {"shd-wait-qlength"},
3604df
diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c
3604df
index 0f63ab1..9860f10 100644
3604df
--- a/xlators/cluster/ec/src/ec-heald.c
3604df
+++ b/xlators/cluster/ec/src/ec-heald.c
3604df
@@ -240,6 +240,7 @@ ec_shd_index_sweep (struct subvol_healer *healer)
3604df
         ec_t          *ec     = NULL;
3604df
         int           ret     = 0;
3604df
         xlator_t      *subvol = NULL;
3604df
+        dict_t        *xdata  = NULL;
3604df
 
3604df
         ec = healer->this->private;
3604df
         subvol = ec->xl_list[healer->subvol];
3604df
@@ -252,9 +253,18 @@ ec_shd_index_sweep (struct subvol_healer *healer)
3604df
                 goto out;
3604df
         }
3604df
 
3604df
-        ret = syncop_dir_scan (subvol, &loc, GF_CLIENT_PID_SELF_HEALD,
3604df
-                               healer, ec_shd_index_heal);
3604df
+        xdata = dict_new ();
3604df
+        if (!xdata || dict_set_int32 (xdata, "get-gfid-type", 1)) {
3604df
+                ret = -ENOMEM;
3604df
+                goto out;
3604df
+        }
3604df
+
3604df
+        ret = syncop_mt_dir_scan (NULL, subvol, &loc, GF_CLIENT_PID_SELF_HEALD,
3604df
+                                  healer, ec_shd_index_heal, xdata,
3604df
+                                  ec->shd.max_threads, ec->shd.wait_qlength);
3604df
 out:
3604df
+        if (xdata)
3604df
+                dict_unref (xdata);
3604df
         loc_wipe (&loc;;
3604df
 
3604df
         return ret;
3604df
diff --git a/xlators/cluster/ec/src/ec-heald.h b/xlators/cluster/ec/src/ec-heald.h
3604df
index 0f27a8e..0929044 100644
3604df
--- a/xlators/cluster/ec/src/ec-heald.h
3604df
+++ b/xlators/cluster/ec/src/ec-heald.h
3604df
@@ -34,6 +34,8 @@ struct _ec_self_heald {
3604df
         gf_boolean_t            iamshd;
3604df
         gf_boolean_t            enabled;
3604df
         int                     timeout;
3604df
+        uint32_t                max_threads;
3604df
+        uint32_t                wait_qlength;
3604df
         struct subvol_healer   *index_healers;
3604df
         struct subvol_healer   *full_healers;
3604df
 };
3604df
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
3604df
index 7e295ca..587ea63 100644
3604df
--- a/xlators/cluster/ec/src/ec.c
3604df
+++ b/xlators/cluster/ec/src/ec.c
3604df
@@ -275,6 +275,10 @@ reconfigure (xlator_t *this, dict_t *options)
3604df
         GF_OPTION_RECONF ("read-policy", read_policy, options, str, failed);
3604df
         if (ec_assign_read_policy (ec, read_policy))
3604df
                 goto failed;
3604df
+        GF_OPTION_RECONF ("shd-max-threads", ec->shd.max_threads,
3604df
+                          options, uint32, failed);
3604df
+        GF_OPTION_RECONF ("shd-wait-qlength", ec->shd.wait_qlength,
3604df
+                          options, uint32, failed);
3604df
 
3604df
         return 0;
3604df
 failed:
3604df
@@ -616,6 +620,9 @@ init (xlator_t *this)
3604df
     if (ec_assign_read_policy (ec, read_policy))
3604df
             goto failed;
3604df
 
3604df
+    GF_OPTION_INIT ("shd-max-threads", ec->shd.max_threads, uint32, failed);
3604df
+    GF_OPTION_INIT ("shd-wait-qlength", ec->shd.wait_qlength, uint32, failed);
3604df
+
3604df
     this->itable = inode_table_new (EC_SHD_INODE_LRU_LIMIT, this);
3604df
     if (!this->itable)
3604df
             goto failed;
3604df
@@ -1365,5 +1372,23 @@ struct volume_options options[] =
3604df
               " subvolume using round-robin algo. 'gfid-hash' selects read"
3604df
               " subvolume based on hash of the gfid of that file/directory.",
3604df
     },
3604df
+    { .key   = {"shd-max-threads"},
3604df
+      .type  = GF_OPTION_TYPE_INT,
3604df
+      .min   = 1,
3604df
+      .max   = 64,
3604df
+      .default_value = "1",
3604df
+      .description = "Maximum number of parallel heals SHD can do per local "
3604df
+                      "brick.  This can substantially lower heal times, "
3604df
+                      "but can also crush your bricks if you don't have "
3604df
+                      "the storage hardware to support this."
3604df
+    },
3604df
+    { .key   = {"shd-wait-qlength"},
3604df
+      .type  = GF_OPTION_TYPE_INT,
3604df
+      .min   = 1,
3604df
+      .max   = 655536,
3604df
+      .default_value = "1024",
3604df
+      .description = "This option can be used to control number of heals"
3604df
+                     " that can wait in SHD per subvolume"
3604df
+    },
3604df
     { }
3604df
 };
3604df
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
3604df
index bd9b21b..8978709 100644
3604df
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
3604df
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
3604df
@@ -2977,6 +2977,16 @@ struct volopt_map_entry glusterd_volopt_map[] = {
3604df
           .op_version = GD_OP_VERSION_3_8_4,
3604df
           .flags      = OPT_FLAG_CLIENT_OPT
3604df
         },
3604df
+        { .key        = "disperse.shd-max-threads",
3604df
+          .voltype    = "cluster/disperse",
3604df
+          .op_version = GD_OP_VERSION_3_9_0,
3604df
+          .flags      = OPT_FLAG_CLIENT_OPT
3604df
+        },
3604df
+        { .key        = "disperse.shd-wait-qlength",
3604df
+          .voltype    = "cluster/disperse",
3604df
+          .op_version = GD_OP_VERSION_3_9_0,
3604df
+          .flags      = OPT_FLAG_CLIENT_OPT
3604df
+        },
3604df
         { .key         = NULL
3604df
         }
3604df
 };
3604df
-- 
3604df
1.7.1
3604df