12a457
From 3008985af3ee25b8be7b6bc95302a867698c597e Mon Sep 17 00:00:00 2001
12a457
From: Ashish Pandey <aspandey@redhat.com>
12a457
Date: Fri, 4 Mar 2016 13:05:09 +0530
12a457
Subject: [PATCH 38/80] cluster/ec: Provide an option to enable/disable eager lock
12a457
12a457
Problem: If a fop takes lock, and completes its operation,
12a457
it waits for 1 second before releasing the lock. However,
12a457
If ec find any lock contention within this time period,
12a457
it release the lock immediately before time expires. As we
12a457
take lock on first brick, for few operations, like read, it
12a457
might happen that discovery of lock contention might take
12a457
long time and can degrades the performance.
12a457
12a457
Solution: Provide an option to enable/disable eager lock.
12a457
If eager lock is disabled, lock will be released as soon
12a457
as fop completes.
12a457
12a457
gluster v set <VOLUME NAME> disperse.eager-lock on
12a457
gluster v set <VOLUME NAME> disperse.eager-lock off
12a457
12a457
master -
12a457
http://review.gluster.org/#/c/13605/
12a457
release-3.7 -
12a457
http://review.gluster.org/#/c/13773/
12a457
12a457
Change-Id: I000985a787eba3c190fdcd5981dfbf04e64af166
12a457
BUG: 1320412
12a457
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/70536
12a457
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
12a457
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
12a457
---
12a457
 libglusterfs/src/globals.h                      |    2 ++
12a457
 tests/bugs/replicate/bug-1297695.t              |    2 +-
12a457
 tests/bugs/replicate/bug-821056.t               |    2 +-
12a457
 tests/bugs/replicate/bug-921231.t               |    4 ++--
12a457
 tests/bugs/replicate/bug-966018.t               |    2 +-
12a457
 tests/bugs/replicate/bug-976800.t               |    2 +-
12a457
 tests/bugs/replicate/bug-979365.t               |    2 +-
12a457
 xlators/cluster/ec/src/ec-common.c              |    9 ++++++---
12a457
 xlators/cluster/ec/src/ec.c                     |    9 +++++++++
12a457
 xlators/cluster/ec/src/ec.h                     |    1 +
12a457
 xlators/mgmt/glusterd/src/glusterd-volume-set.c |    5 +++++
12a457
 11 files changed, 30 insertions(+), 10 deletions(-)
12a457
12a457
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h
12a457
index cc23b6c..ad0aef8 100644
12a457
--- a/libglusterfs/src/globals.h
12a457
+++ b/libglusterfs/src/globals.h
12a457
@@ -72,6 +72,8 @@
12a457
 
12a457
 #define GD_OP_VERSION_3_7_7    30707 /* Op-version for GlusterFS 3.7.7 */
12a457
 
12a457
+#define GD_OP_VERSION_3_7_10    30710 /* Op-version for GlusterFS 3.7.10 */
12a457
+
12a457
 #include "xlator.h"
12a457
 
12a457
 /* THIS */
12a457
diff --git a/tests/bugs/replicate/bug-1297695.t b/tests/bugs/replicate/bug-1297695.t
12a457
index e0f4316..d5c1a21 100644
12a457
--- a/tests/bugs/replicate/bug-1297695.t
12a457
+++ b/tests/bugs/replicate/bug-1297695.t
12a457
@@ -13,7 +13,7 @@ TEST glusterd
12a457
 TEST pidof glusterd
12a457
 TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1
12a457
 
12a457
-TEST $CLI volume set $V0 eager-lock on
12a457
+TEST $CLI volume set $V0 cluster.eager-lock on
12a457
 TEST $CLI volume set $V0 post-op-delay-secs 3
12a457
 TEST $CLI volume set $V0 cluster.entry-self-heal off
12a457
 TEST $CLI volume set $V0 cluster.data-self-heal off
12a457
diff --git a/tests/bugs/replicate/bug-821056.t b/tests/bugs/replicate/bug-821056.t
12a457
index 02a9c78..a163300 100644
12a457
--- a/tests/bugs/replicate/bug-821056.t
12a457
+++ b/tests/bugs/replicate/bug-821056.t
12a457
@@ -8,7 +8,7 @@ TEST glusterd
12a457
 TEST pidof glusterd
12a457
 
12a457
 TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
12a457
-TEST $CLI volume set $V0 eager-lock off
12a457
+TEST $CLI volume set $V0 cluster.eager-lock off
12a457
 TEST $CLI volume set $V0 cluster.self-heal-daemon off
12a457
 TEST $CLI volume set $V0 performance.quick-read off
12a457
 TEST $CLI volume set $V0 performance.open-behind off
12a457
diff --git a/tests/bugs/replicate/bug-921231.t b/tests/bugs/replicate/bug-921231.t
12a457
index 93c642b..8150461 100644
12a457
--- a/tests/bugs/replicate/bug-921231.t
12a457
+++ b/tests/bugs/replicate/bug-921231.t
12a457
@@ -3,7 +3,7 @@
12a457
 . $(dirname $0)/../../include.rc
12a457
 . $(dirname $0)/../../volume.rc
12a457
 
12a457
-# This test writes to same file with 2 fds and tests that eager-lock is not
12a457
+# This test writes to same file with 2 fds and tests that cluster.eager-lock is not
12a457
 # causing extra delay because of post-op-delay-secs
12a457
 cleanup;
12a457
 
12a457
@@ -14,7 +14,7 @@ function write_to_file {
12a457
 TEST glusterd
12a457
 TEST pidof glusterd
12a457
 TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1
12a457
-TEST $CLI volume set $V0 eager-lock on
12a457
+TEST $CLI volume set $V0 cluster.eager-lock on
12a457
 TEST $CLI volume set $V0 post-op-delay-secs 3
12a457
 TEST $CLI volume set $V0 client-log-level DEBUG
12a457
 TEST $CLI volume start $V0
12a457
diff --git a/tests/bugs/replicate/bug-966018.t b/tests/bugs/replicate/bug-966018.t
12a457
index be4d0b9..ec3beb1 100644
12a457
--- a/tests/bugs/replicate/bug-966018.t
12a457
+++ b/tests/bugs/replicate/bug-966018.t
12a457
@@ -4,7 +4,7 @@
12a457
 . $(dirname $0)/../../volume.rc
12a457
 . $(dirname $0)/../../nfs.rc
12a457
 
12a457
-#This tests if eager-lock blocks metadata operations on nfs/fuse mounts.
12a457
+#This tests if cluster.eager-lock blocks metadata operations on nfs/fuse mounts.
12a457
 #If it is not woken up, INODELK from the next command waits
12a457
 #for post-op-delay secs.
12a457
 
12a457
diff --git a/tests/bugs/replicate/bug-976800.t b/tests/bugs/replicate/bug-976800.t
12a457
index 8311734..27f8b27 100644
12a457
--- a/tests/bugs/replicate/bug-976800.t
12a457
+++ b/tests/bugs/replicate/bug-976800.t
12a457
@@ -20,7 +20,7 @@ TEST glusterd
12a457
 TEST pidof glusterd
12a457
 TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
12a457
 TEST $CLI volume set $V0 ensure-durability off
12a457
-TEST $CLI volume set $V0 eager-lock off
12a457
+TEST $CLI volume set $V0 cluster.eager-lock off
12a457
 TEST $CLI volume set $V0 flush-behind off
12a457
 TEST $CLI volume start $V0
12a457
 TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0
12a457
diff --git a/tests/bugs/replicate/bug-979365.t b/tests/bugs/replicate/bug-979365.t
12a457
index b1396c2..c09c7d5 100755
12a457
--- a/tests/bugs/replicate/bug-979365.t
12a457
+++ b/tests/bugs/replicate/bug-979365.t
12a457
@@ -15,7 +15,7 @@ TEST glusterd
12a457
 TEST pidof glusterd
12a457
 TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
12a457
 TEST $CLI volume set $V0 ensure-durability on
12a457
-TEST $CLI volume set $V0 eager-lock off
12a457
+TEST $CLI volume set $V0 cluster.eager-lock off
12a457
 TEST $CLI volume start $V0
12a457
 TEST $CLI volume profile $V0 start
12a457
 TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
12a457
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
12a457
index 8c6ff78..de0e597 100644
12a457
--- a/xlators/cluster/ec/src/ec-common.c
12a457
+++ b/xlators/cluster/ec/src/ec-common.c
12a457
@@ -2034,11 +2034,13 @@ void ec_flush_size_version(ec_fop_data_t *fop)
12a457
 void ec_lock_reuse(ec_fop_data_t *fop)
12a457
 {
12a457
     ec_cbk_data_t *cbk;
12a457
+    ec_t *ec = NULL;
12a457
     int32_t i, count;
12a457
     gf_boolean_t release = _gf_false;
12a457
-
12a457
+    ec = fop->xl->private;
12a457
     cbk = fop->answer;
12a457
-    if (cbk != NULL) {
12a457
+
12a457
+    if (ec->eager_lock && cbk != NULL) {
12a457
         if (cbk->xdata != NULL) {
12a457
             if ((dict_get_int32(cbk->xdata, GLUSTERFS_INODELK_COUNT,
12a457
                                 &count) == 0) && (count > 1)) {
12a457
@@ -2050,7 +2052,8 @@ void ec_lock_reuse(ec_fop_data_t *fop)
12a457
             }
12a457
         }
12a457
     } else {
12a457
-        /* If we haven't get an answer with enough quorum, we always release
12a457
+        /* If eager lock is disabled or If we haven't get
12a457
+         * an answer with enough quorum, we always release
12a457
          * the lock. */
12a457
         release = _gf_true;
12a457
     }
12a457
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
12a457
index e8acc23..3133962 100644
12a457
--- a/xlators/cluster/ec/src/ec.c
12a457
+++ b/xlators/cluster/ec/src/ec.c
12a457
@@ -261,6 +261,8 @@ reconfigure (xlator_t *this, dict_t *options)
12a457
                           failed);
12a457
         GF_OPTION_RECONF ("iam-self-heal-daemon", ec->shd.iamshd, options,
12a457
                           bool, failed);
12a457
+        GF_OPTION_RECONF ("eager-lock", ec->eager_lock, options,
12a457
+                          bool, failed);
12a457
         GF_OPTION_RECONF ("background-heals", background_heals, options,
12a457
                           uint32, failed);
12a457
         GF_OPTION_RECONF ("heal-wait-qlength", heal_wait_qlen, options,
12a457
@@ -599,6 +601,7 @@ init (xlator_t *this)
12a457
     ec_method_initialize();
12a457
     GF_OPTION_INIT ("self-heal-daemon", ec->shd.enabled, bool, failed);
12a457
     GF_OPTION_INIT ("iam-self-heal-daemon", ec->shd.iamshd, bool, failed);
12a457
+    GF_OPTION_INIT ("eager-lock", ec->eager_lock, bool, failed);
12a457
     GF_OPTION_INIT ("background-heals", ec->background_heals, uint32, failed);
12a457
     GF_OPTION_INIT ("heal-wait-qlength", ec->heal_wait_qlen, uint32, failed);
12a457
     ec_configure_background_heal_opts (ec, ec->background_heals,
12a457
@@ -1309,6 +1312,12 @@ struct volume_options options[] =
12a457
                      "translator is running as part of self-heal-daemon "
12a457
                      "or not."
12a457
     },
12a457
+    { .key = {"eager-lock"},
12a457
+      .type = GF_OPTION_TYPE_BOOL,
12a457
+      .default_value = "on",
12a457
+      .description = "This option will enable/diable eager lock for"
12a457
+                     "disperse volume "
12a457
+    },
12a457
     { .key = {"background-heals"},
12a457
       .type = GF_OPTION_TYPE_INT,
12a457
       .min = 0,/*Disabling background heals*/
12a457
diff --git a/xlators/cluster/ec/src/ec.h b/xlators/cluster/ec/src/ec.h
12a457
index 480125e..49af5c2 100644
12a457
--- a/xlators/cluster/ec/src/ec.h
12a457
+++ b/xlators/cluster/ec/src/ec.h
12a457
@@ -54,6 +54,7 @@ struct _ec
12a457
     gf_lock_t         lock;
12a457
     gf_timer_t *      timer;
12a457
     gf_boolean_t      shutdown;
12a457
+    gf_boolean_t      eager_lock;
12a457
     uint32_t          background_heals;
12a457
     uint32_t          heal_wait_qlen;
12a457
     struct list_head  pending_fops;
12a457
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
12a457
index ec99c8a..f5746c8 100644
12a457
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
12a457
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
12a457
@@ -1080,6 +1080,11 @@ struct volopt_map_entry glusterd_volopt_map[] = {
12a457
           .op_version = 1,
12a457
           .flags      = OPT_FLAG_CLIENT_OPT
12a457
         },
12a457
+        { .key        = "disperse.eager-lock",
12a457
+          .voltype    = "cluster/disperse",
12a457
+          .op_version = GD_OP_VERSION_3_7_10,
12a457
+          .flags      = OPT_FLAG_CLIENT_OPT
12a457
+        },
12a457
         { .key        = "cluster.quorum-type",
12a457
           .voltype    = "cluster/replicate",
12a457
           .option     = "quorum-type",
12a457
-- 
12a457
1.7.1
12a457