|
Packit Service |
e080da |
#!/bin/bash
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
. $(dirname $0)/../include.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../volume.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../nfs.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../fileio.rc
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
cleanup;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
QDD=$(dirname $0)/quota
|
|
Packit Service |
e080da |
# compile the test write program and run it
|
|
Packit Service |
e080da |
build_tester $(dirname $0)/quota.c -o $QDD
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TESTS_EXPECTED_IN_LOOP=16
|
|
Packit Service |
e080da |
TEST glusterd
|
|
Packit Service |
e080da |
TEST pidof glusterd
|
|
Packit Service |
e080da |
TEST $CLI volume info;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume create $V0 $H0:$B0/brick1;
|
|
Packit Service |
e080da |
EXPECT 'Created' volinfo_field $V0 'Status';
|
|
Packit Service |
e080da |
TEST $CLI volume set $V0 nfs.disable false
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# The test makes use of inode-lru-limit to hit a scenario, where we
|
|
Packit Service |
e080da |
# find an inode whose ancestry is not there. Following is the
|
|
Packit Service |
e080da |
# hypothesis (which is confirmed by seeing logs indicating that
|
|
Packit Service |
e080da |
# codepath has been executed, but not through a good understanding of
|
|
Packit Service |
e080da |
# NFS internals).
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# At the end of an fop, the reference count of an inode would be
|
|
Packit Service |
e080da |
# zero. The inode (and its ancestry) persists in memory only
|
|
Packit Service |
e080da |
# because of non-zero lookup count. These looked up inodes are put
|
|
Packit Service |
e080da |
# in an lru queue of size 1 (here). So, there can be at most one
|
|
Packit Service |
e080da |
# such inode in memory.
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# NFS Server makes use of anonymous fds. So, if it cannot find
|
|
Packit Service |
e080da |
# valid fd, it does a nameless lookup. This gives us an inode
|
|
Packit Service |
e080da |
# whose ancestry is NULL. When a write happens on this inode,
|
|
Packit Service |
e080da |
# quota-enforcer/marker finds a NULL ancestry and asks
|
|
Packit Service |
e080da |
# storage/posix to build it.
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume set $V0 network.inode-lru-limit 1
|
|
Packit Service |
e080da |
TEST $CLI volume set $V0 performance.nfs.write-behind off
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume start $V0;
|
|
Packit Service |
e080da |
EXPECT 'Started' volinfo_field $V0 'Status';
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 enable
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage / 1
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 soft-timeout 0
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 hard-timeout 0
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available;
|
|
Packit Service |
e080da |
TEST mount_nfs $H0:/$V0 $N0 noac,soft,nolock,vers=3;
|
|
Packit Service |
e080da |
deep=/0/1/2/3/4/5/6/7/8/9
|
|
Packit Service |
e080da |
TEST mkdir -p $N0/$deep
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST touch $N0/$deep/file1 $N0/$deep/file2 $N0/$deep/file3 $N0/$deep/file4
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST fd_open 3 'w' "$N0/$deep/file1"
|
|
Packit Service |
e080da |
TEST fd_open 4 'w' "$N0/$deep/file2"
|
|
Packit Service |
e080da |
TEST fd_open 5 'w' "$N0/$deep/file3"
|
|
Packit Service |
e080da |
TEST fd_open 6 'w' "$N0/$deep/file4"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# consume all quota
|
|
Packit Service |
e080da |
echo "Hello" > $N0/$deep/new_file_1
|
|
Packit Service |
e080da |
echo "World" >> $N0/$deep/new_file_1
|
|
Packit Service |
e080da |
echo 1 >> $N0/$deep/new_file_1
|
|
Packit Service |
e080da |
echo 2 >> $N0/$deep/new_file_1
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# Try to create a 1M file which should fail
|
|
Packit Service |
e080da |
TEST ! $QDD $N0/$deep/new_file_2 256 4
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# At the end of each fop in server, reference count of the
|
|
Packit Service |
e080da |
# inode associated with each of the file above drops to zero and hence
|
|
Packit Service |
e080da |
# put into lru queue. Since lru-limit is set to 1, an fop next file
|
|
Packit Service |
e080da |
# will displace the current inode from itable. This will ensure that
|
|
Packit Service |
e080da |
# when writes happens on same fd, fd resolution results in
|
|
Packit Service |
e080da |
# nameless lookup from server and quota_writev encounters an fd
|
|
Packit Service |
e080da |
# associated with an inode whose parent is not present in itable.
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
for j in $(seq 1 2); do
|
|
Packit Service |
e080da |
for i in $(seq 3 6); do
|
|
Packit Service |
e080da |
# failing writes indicate that we are enforcing quota set on /
|
|
Packit Service |
e080da |
# even with anonymous fds.
|
|
Packit Service |
e080da |
TEST_IN_LOOP ! fd_write $i "content"
|
|
Packit Service |
e080da |
TEST_IN_LOOP sync
|
|
Packit Service |
e080da |
done
|
|
Packit Service |
e080da |
done
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
exec 3>&-
|
|
Packit Service |
e080da |
exec 4>&-
|
|
Packit Service |
e080da |
exec 5>&-
|
|
Packit Service |
e080da |
exec 6>&-
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
$CLI volume statedump $V0 all
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# This is ugly, but there seems to be a latent race between other actions and
|
|
Packit Service |
e080da |
# stopping the volume. The visible symptom is that "umount -l" (run from
|
|
Packit Service |
e080da |
# gf_umount_lazy in glusterd) hangs. This happens pretty consistently with the
|
|
Packit Service |
e080da |
# new mem-pool code, though it's not really anything to do with memory pools -
|
|
Packit Service |
e080da |
# just with changed timing. Adding the sleep here makes it work consistently.
|
|
Packit Service |
e080da |
#
|
|
Packit Service |
e080da |
# If anyone else wants to debug the race condition, feel free.
|
|
Packit Service |
e080da |
sleep 3
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume stop $V0
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
rm -f $QDD
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
cleanup;
|
|
Packit Service |
e080da |
#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
|