diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2013-02-18 13:16:39 -0500 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-02-18 20:50:48 -0800 |
commit | 59ac567c8b5ebf20b573ecf250e13f841e817dbd (patch) | |
tree | b16dd6c33140c1ec571145b64bae574e9be0c76d /tests | |
parent | 6ff25bc98193fd39e25acfce8e3b2f3b3d80a9c8 (diff) |
distribute: add hash-name-regex option
This is to support the common "write to temp file then rename" idiom. In our
case this causes us to create a linkfile during the rename in (N-1)/N cases,
with a significant impact on performance e.g. for UFO which uses this idiom.
This patch allows the user to specify up to two regular expressions that
separate the permanent and transient parts of a temp-file name:
rsync-hash-regex reimplements the existing RSYNC_FRIENDLY_NAME
pattern where the temporary name for EXAMPLE is .EXAMPLE.suffix
extra-hash-regex can be used for a second pattern, active concurrently,
and can include alternatives via the POSIX extended-regex syntax
Change-Id: Ic1a6ed19324bc31fefe91ee34b8478877a9c5d2c
BUG: 912564
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/4116
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/bugs/bug-912564.t | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/bugs/bug-912564.t b/tests/bugs/bug-912564.t new file mode 100755 index 00000000000..b24268fbc9b --- /dev/null +++ b/tests/bugs/bug-912564.t @@ -0,0 +1,92 @@ +#!/bin/bash + +# Test that the rsync and "extra" regexes cause rename-in-place without +# creating linkfiles, when they're supposed to. Without the regex we'd have a +# 1/4 chance of each file being assigned to the right place, so with 16 files +# we have a 1/2^32 chance of getting the correct result by accident. + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +function count_linkfiles { + local i + local count=0 + for i in $(seq $2 $3); do + x=$(find $1$i -perm -1000 | wc -l) + # Divide by two because of the .glusterfs links. + count=$((count+x/2)) + done + echo $count +} + +# This function only exists to get around quoting difficulties in TEST. +function set_regex { + $CLI volume set $1 cluster.extra-hash-regex '^foo(.+)bar$' +} + +cleanup; + +TEST glusterd +TEST pidof glusterd + +mkdir -p $H0:$B0/${V0}0 +mkdir -p $H0:$B0/${V0}1 +mkdir -p $H0:$B0/${V0}2 +mkdir -p $H0:$B0/${V0}3 + +# Create and start a volume. +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 \ + $H0:$B0/${V0}2 $H0:$B0/${V0}3 +TEST $CLI volume start $V0 +EXPECT_WITHIN 15 'Started' volinfo_field $V0 'Status'; + +# Mount it. +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +# Make sure the rsync regex works, by verifying that no linkfiles are +# created. +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf .%s.%d $fn $RANDOM) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -eq "0" ] + +# Make sure that linkfiles *are* created for normal files. +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf foo%sbar $fn) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -ne "0" ] + +# Make sure that setting an extra regex suppresses the linkfiles. +TEST set_regex $V0 +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf foo%sbar $fn) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -eq "0" ] + +# Re-test the rsync regex, to make sure the extra one didn't break it. +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf .%s.%d $fn $RANDOM) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -eq "0" ] + +cleanup |