3
. $(dirname $0)/../include.rc
4
. $(dirname $0)/../volume.rc
5
. $(dirname $0)/../dht.rc
10
for i in $(seq 1 $NFILES); do
11
touch $(printf $M0/dir/file%02d $i)
17
for i in $(seq 1 $NFILES); do
18
if [ -f $(printf $M0/dir/file%02d $i) ]; then
22
echo "found $found files" > /dev/tty
26
wait_for_rebalance () {
28
tmp=$(rebalance_completed)
29
if [ $tmp -eq 1 ]; then
38
cmd="getfattr --absolute-names --only-values -n trusted.glusterfs.dht"
39
$cmd $1 | od -tx1 -An | tr -d ' '
43
cmd="getfattr --absolute-names --only-values -n trusted.glusterfs.dht"
44
$cmd $1 | od -tx1 -An | awk '{printf("%s%s%s%s\n", $1, $2, $3, $4);}'
53
TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}
54
EXPECT "$V0" volinfo_field $V0 'Volume Name'
55
EXPECT 'Created' volinfo_field $V0 'Status'
57
TEST $CLI volume set $V0 cluster.lookup-optimize ON
59
TEST $CLI volume start $V0
60
EXPECT 'Started' volinfo_field $V0 'Status'
62
# Create some files for later tests.
63
TEST $GFS -s $H0 --volfile-id $V0 $M0
66
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
68
# Add a brick and do the fix-layout part of rebalance to update directory layouts
69
# (including their directory commit hashes).
70
TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
71
EXPECT '3' brick_count $V0
72
TEST $CLI volume rebalance $V0 fix-layout start
73
TEST wait_for_rebalance
75
# Now for the sneaky part. *Undo* the part of rebalance that updated the volume
76
# commit hash, forcing a false match between that and the directory commit hashes.
77
TEST setfattr -x trusted.glusterfs.dht.commithash $B0/${V0}1
78
TEST setfattr -x trusted.glusterfs.dht.commithash $B0/${V0}2
79
TEST setfattr -x trusted.glusterfs.dht.commithash $B0/${V0}3
81
# Mount and check that we do *not* see all of the files. This indicates that we
82
# correctly skipped the broadcast lookup that would have found them.
83
TEST $GFS -s $H0 --volfile-id $V0 $M0
84
TEST [ $(count_files) -ne 100 ]
85
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
87
# Do the fix-layout again to generate a new volume commit hash.
88
TEST $CLI volume rebalance $V0 fix-layout start
89
TEST wait_for_rebalance
91
# Mount and check that we *do* see all of the files. This indicates that we saw
92
# the mismatch and did the broadcast lookup this time.
93
TEST $GFS -s $H0 --volfile-id $V0 $M0
94
TEST [ $(count_files) -eq 100 ]
95
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
97
# Do a *full* rebalance and verify that the directory commit hash changed.
98
old_val=$(get_xattr $B0/${V0}1/dir)
99
TEST $CLI volume rebalance $V0 start
100
TEST wait_for_rebalance
101
new_val=$(get_xattr $B0/${V0}1/dir)
102
TEST [ ! x"$old_val" = x"$new_val" ]
104
# Force an anomoly on an existing layout and heal it
105
## The healed layout should not carry a commit-hash (or should carry 1 in the
107
TEST setfattr -x trusted.glusterfs.dht $B0/${V0}1/dir
108
TEST $GFS -s $H0 --volfile-id $V0 $M0
110
new_hash=$(get_xattr_hash $B0/${V0}1/dir)
111
TEST [ x"$new_hash" = x"00000001" ]
112
new_hash=$(get_xattr_hash $B0/${V0}2/dir)
113
TEST [ x"$new_hash" = x"00000001" ]
115
# Unset the option and check that newly created directories get 1 in the
117
TEST $CLI volume set $V0 cluster.lookup-optimize off
119
new_hash=$(get_xattr_hash $B0/${V0}1/dir1)
120
TEST [ x"$new_hash" = x"00000001" ]
121
new_hash=$(get_xattr_hash $B0/${V0}2/dir1)
122
TEST [ x"$new_hash" = x"00000001" ]