glusterfs
1#!/bin/bash
2
3. $(dirname $0)/../include.rc4. $(dirname $0)/../volume.rc5. $(dirname $0)/../nfs.rc6. $(dirname $0)/../fileio.rc7
8#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST
9
10cleanup;11
12TESTS_EXPECTED_IN_LOOP=1613TEST glusterd
14TEST pidof glusterd
15TEST $CLI volume info;16
17TEST $CLI volume create $V0 $H0:$B0/brick1;18EXPECT 'Created' volinfo_field $V0 'Status';19TEST $CLI volume set $V0 nfs.disable false20
21# The test makes use of inode-lru-limit to hit a scenario, where we
22# find an inode whose ancestry is not there. Following is the
23# hypothesis (which is confirmed by seeing logs indicating that
24# codepath has been executed, but not through a good understanding of
25# NFS internals).
26
27# At the end of an fop, the reference count of an inode would be
28# zero. The inode (and its ancestry) persists in memory only
29# because of non-zero lookup count. These looked up inodes are put
30# in an lru queue of size 1 (here). So, there can be at most one
31# such inode in memory.
32
33# NFS Server makes use of anonymous fds. So, if it cannot find
34# valid fd, it does a nameless lookup. This gives us an inode
35# whose ancestry is NULL. When a write happens on this inode,
36# quota-enforcer/marker finds a NULL ancestry and asks
37# storage/posix to build it.
38
39TEST $CLI volume set $V0 network.inode-lru-limit 140TEST $CLI volume set $V0 performance.nfs.write-behind off41
42TEST $CLI volume start $V0;43EXPECT 'Started' volinfo_field $V0 'Status';44
45## Enable bitrot
46TEST $CLI volume bitrot $V0 enable;47
48## Wait for gluster nfs to come up
49EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available50
51TEST mount_nfs $H0:/$V0 $N0;52deep=/0/1/2/3/4/5/6/7/8/953TEST mkdir -p $N0/$deep54
55TEST touch $N0/$deep/file1 $N0/$deep/file2 $N0/$deep/file3 $N0/$deep/file456
57TEST fd_open 3 'w' "$N0/$deep/file1"58TEST fd_open 4 'w' "$N0/$deep/file2"59TEST fd_open 5 'w' "$N0/$deep/file3"60TEST fd_open 6 'w' "$N0/$deep/file4"61
62# consume all quota
63echo "Hello" > $N0/$deep/new_file_164echo "World" >> $N0/$deep/new_file_165echo 1 >> $N0/$deep/new_file_166echo 2 >> $N0/$deep/new_file_167
68
69# At the end of each fop in server, reference count of the
70# inode associated with each of the file above drops to zero and hence
71# put into lru queue. Since lru-limit is set to 1, an fop next file
72# will displace the current inode from itable. This will ensure that
73# when writes happens on same fd, fd resolution results in
74# nameless lookup from server and encounters an fd
75# associated with an inode whose parent is not present in itable.
76
77for j in $(seq 1 2); do78for i in $(seq 3 6); do79TEST_IN_LOOP fd_write $i "content"80TEST_IN_LOOP sync81done82done
83
84exec 3>&-85exec 4>&-86exec 5>&-87exec 6>&-88
89$CLI volume statedump $V0 all90
91EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N092
93TEST $CLI volume stop $V094
95cleanup;96