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