diff options
author | Xavier Hernandez <xhernandez@datalab.es> | 2016-06-15 14:42:19 +0200 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2018-01-16 10:37:22 +0000 |
commit | 7ba7a4b27d124f4ee16fe4776a4670cd5b0160c4 (patch) | |
tree | 73cca7226576b7ce3e480dc991aa70b9cc7cab07 /tests | |
parent | 3e9a9c029fac359477fb26d9cc7803749ba038b2 (diff) |
locks: added inodelk/entrylk contention upcall notifications
The locks xlator now is able to send a contention notification to
the current owner of the lock.
This is only a notification that can be used to improve performance
of some client side operations that might benefit from extended
duration of lock ownership. Nothing is done if the lock owner decides
to ignore the message and to not release the lock. For forced
release of acquired resources, leases must be used.
Change-Id: I7f1ad32a0b4b445505b09908a050080ad848f8e0
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic/ec/lock-contention.t | 62 | ||||
-rw-r--r-- | tests/volume.rc | 12 |
2 files changed, 70 insertions, 4 deletions
diff --git a/tests/basic/ec/lock-contention.t b/tests/basic/ec/lock-contention.t new file mode 100644 index 00000000000..8f86cee16ad --- /dev/null +++ b/tests/basic/ec/lock-contention.t @@ -0,0 +1,62 @@ +#!/bin/bash + +# This test verifies that when 'lock-notify-contention' option is enabled, +# locks xlator actually sends an upcall notification that causes the acquired +# lock from one client to be released before it's supposed to when another +# client accesses the file. + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +function elapsed_time() { + local start="`date +%s`" + + if [[ "test" == `cat "$1"` ]]; then + echo "$((`date +%s` - ${start}))" + fi +} + +cleanup + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 disperse 3 redundancy 1 $H0:$B0/${V0}{0..2} +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 performance.write-behind off +TEST $CLI volume set $V0 performance.quick-read off +TEST $CLI volume set $V0 performance.read-ahead off +TEST $CLI volume set $V0 performance.io-cache off +TEST $CLI volume set $V0 features.locks-notify-contention off +TEST $CLI volume set $V0 disperse.eager-lock on +TEST $CLI volume set $V0 disperse.eager-lock-timeout 6 +TEST $CLI volume set $V0 disperse.other-eager-lock on +TEST $CLI volume set $V0 disperse.other-eager-lock-timeout 6 +TEST $CLI volume start $V0 + +TEST $GFS --direct-io-mode=yes --volfile-id=/$V0 --volfile-server=$H0 $M0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 $M0 + +TEST $GFS --direct-io-mode=yes --volfile-id=/$V0 --volfile-server=$H0 $M1 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0 $M1 + +TEST $(echo "test" >$M0/file) + +# With locks-notify-contention set to off, accessing the file from another +# client should take 6 seconds. Checking against 3 seconds to be safe. +elapsed="$(elapsed_time $M1/file)" +TEST [[ ${elapsed} -ge 3 ]] + +elapsed="$(elapsed_time $M0/file)" +TEST [[ ${elapsed} -ge 3 ]] + +TEST $CLI volume set $V0 features.locks-notify-contention on + +# With locks-notify-contention set to on, accessing the file from another +# client should be fast. Checking against 3 seconds to be safe. +elapsed="$(elapsed_time $M1/file)" +TEST [[ ${elapsed} -le 3 ]] + +elapsed="$(elapsed_time $M0/file)" +TEST [[ ${elapsed} -le 3 ]] + +cleanup diff --git a/tests/volume.rc b/tests/volume.rc index 3a48b43d2e0..3ee83624058 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -93,7 +93,8 @@ function remove_brick_status_completed_field { function get_mount_process_pid { local vol=$1 - ps auxww | grep glusterfs | grep -E "volfile-id[ =]/?$vol " | awk '{print $2}' | head -1 + local mnt=$2 + ps auxww | grep glusterfs | grep -E "volfile-id[ =]/?$vol .*$mnt" | awk '{print $2}' | head -1 } function get_nfs_pid () @@ -126,7 +127,8 @@ function generate_statedump { function generate_mount_statedump { local vol=$1 - generate_statedump $(get_mount_process_pid $vol) + local mnt=$2 + generate_statedump $(get_mount_process_pid $vol $mnt) } function cleanup_mount_statedump { @@ -205,14 +207,16 @@ function ec_child_up_status { local vol=$1 local dist_id=$2 local brick_id=$(($3 + 1)) - local mask=$(ec_get_info $vol $dist_id "childs_up_mask" $(generate_mount_statedump $vol)) + local mnt=$4 + local mask=$(ec_get_info $vol $dist_id "childs_up_mask" $(generate_mount_statedump $vol $mnt)) echo "${mask: -$brick_id:1}" } function ec_child_up_count { local vol=$1 local dist_id=$2 - ec_get_info $vol $dist_id "childs_up" $(generate_mount_statedump $vol) + local mnt=$3 + ec_get_info $vol $dist_id "childs_up" $(generate_mount_statedump $vol $mnt) } function ec_child_up_status_shd { |