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