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