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