256ebe
From ff8a74250209f4279f67dd89c3e57b2289a1b7d1 Mon Sep 17 00:00:00 2001
256ebe
From: Xavi Hernandez <xhernandez@redhat.com>
256ebe
Date: Thu, 9 May 2019 11:07:18 +0200
256ebe
Subject: [PATCH 144/169] cluster/ec: honor contention notifications for
256ebe
 partially acquired locks
256ebe
256ebe
EC was ignoring lock contention notifications received while a lock was
256ebe
being acquired. When a lock is partially acquired (some bricks have
256ebe
granted the lock but some others not yet) we can receive notifications
256ebe
from acquired bricks, which should be honored, since we may not receive
256ebe
more notifications after that.
256ebe
256ebe
Since EC was ignoring them, once the lock was acquired, it was not
256ebe
released until the eager-lock timeout, causing unnecessary delays on
256ebe
other clients.
256ebe
256ebe
This fix takes into consideration the notifications received before
256ebe
having completed the full lock acquisition. After that, the lock will
256ebe
be releaed as soon as possible.
256ebe
256ebe
Upstream patch:
256ebe
> BUG: 1708156
256ebe
> Upstream patch link: https://review.gluster.org/c/glusterfs/+/22690
256ebe
> Change-Id: I2a306dbdb29fb557dcab7788a258bd75d826cc12
256ebe
> Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
256ebe
256ebe
Fixes: bz#1703455
256ebe
Change-Id: I2a306dbdb29fb557dcab7788a258bd75d826cc12
256ebe
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/171525
256ebe
Tested-by: RHGS Build Bot <nigelb@redhat.com>
256ebe
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
256ebe
---
256ebe
 ...or-inodelk-contention-notify-on-partial-locks.t | 54 ++++++++++++++++++++++
256ebe
 xlators/cluster/ec/src/ec-common.c                 |  2 +-
256ebe
 2 files changed, 55 insertions(+), 1 deletion(-)
256ebe
 create mode 100644 tests/bugs/ec/bug-1708156-honor-inodelk-contention-notify-on-partial-locks.t
256ebe
256ebe
diff --git a/tests/bugs/ec/bug-1708156-honor-inodelk-contention-notify-on-partial-locks.t b/tests/bugs/ec/bug-1708156-honor-inodelk-contention-notify-on-partial-locks.t
256ebe
new file mode 100644
256ebe
index 0000000..67fdb18
256ebe
--- /dev/null
256ebe
+++ b/tests/bugs/ec/bug-1708156-honor-inodelk-contention-notify-on-partial-locks.t
256ebe
@@ -0,0 +1,54 @@
256ebe
+#!/bin/bash
256ebe
+
256ebe
+. $(dirname $0)/../../include.rc
256ebe
+. $(dirname $0)/../../volume.rc
256ebe
+
256ebe
+function do_ls() {
256ebe
+    local dir="${1}"
256ebe
+    local i
256ebe
+
256ebe
+    for i in {1..50}; do
256ebe
+        ls -l $M0/${dir} >/dev/null &
256ebe
+        ls -l $M1/${dir} >/dev/null &
256ebe
+        ls -l $M2/${dir} >/dev/null &
256ebe
+        ls -l $M3/${dir} >/dev/null &
256ebe
+    done
256ebe
+    wait
256ebe
+}
256ebe
+
256ebe
+function measure_time() {
256ebe
+    {
256ebe
+        LC_ALL=C
256ebe
+        time -p "${@}"
256ebe
+    } 2>&1 | awk '/^real/ { print $2 * 1000 }'
256ebe
+}
256ebe
+
256ebe
+cleanup
256ebe
+
256ebe
+TEST glusterd
256ebe
+TEST pidof glusterd
256ebe
+TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5}
256ebe
+
256ebe
+TEST $CLI volume set $V0 disperse.eager-lock on
256ebe
+TEST $CLI volume set $V0 disperse.other-eager-lock on
256ebe
+TEST $CLI volume set $V0 features.locks-notify-contention on
256ebe
+TEST $CLI volume set $V0 disperse.eager-lock-timeout 10
256ebe
+TEST $CLI volume set $V0 disperse.other-eager-lock-timeout 10
256ebe
+
256ebe
+TEST $CLI volume start $V0
256ebe
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
256ebe
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M1
256ebe
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M2
256ebe
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M3
256ebe
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 $M0
256ebe
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 $M1
256ebe
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 $M2
256ebe
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 $M3
256ebe
+TEST mkdir $M0/dir
256ebe
+TEST touch $M0/dir/file.{1..10}
256ebe
+
256ebe
+# Run multiple 'ls' concurrently from multiple clients so that they collide and
256ebe
+# cause partial locks.
256ebe
+TEST [[ $(measure_time do_ls dir) -lt 10000 ]]
256ebe
+
256ebe
+cleanup
256ebe
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
256ebe
index b1ba5e9..e85aa8b 100644
256ebe
--- a/xlators/cluster/ec/src/ec-common.c
256ebe
+++ b/xlators/cluster/ec/src/ec-common.c
256ebe
@@ -2497,7 +2497,7 @@ ec_lock_release(ec_t *ec, inode_t *inode)
256ebe
         goto done;
256ebe
     }
256ebe
     lock = ctx->inode_lock;
256ebe
-    if ((lock == NULL) || !lock->acquired || lock->release) {
256ebe
+    if ((lock == NULL) || lock->release) {
256ebe
         goto done;
256ebe
     }
256ebe
 
256ebe
-- 
256ebe
1.8.3.1
256ebe