5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
7 # only call init_test_env if this script is called directly
8 if [[ -z "$TESTSUITE" || "$TESTSUITE" = "$(basename $0 .sh)" ]]; then
11 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 racer=$LUSTRE/tests/racer/racer.sh
18 . $LUSTRE/tests/setup-nfs.sh
20 # lustre client used as nfs server (default is mds node)
21 LUSTRE_CLIENT_NFSSRV=${LUSTRE_CLIENT_NFSSRV:-$(facet_active_host $SINGLEMDS)}
22 NFS_SRVMNTPT=${NFS_SRVMNTPT:-$MOUNT}
23 NFS_CLIENTS=${NFS_CLIENTS:-$CLIENTS}
24 NFS_CLIENTS=$(exclude_items_from_list $NFS_CLIENTS $LUSTRE_CLIENT_NFSSRV)
25 NFS_CLIMNTPT=${NFS_CLIMNTPT:-$MOUNT}
27 [ -z "$NFS_CLIENTS" ] &&
28 skip_env "need at least two nodes: nfs server and nfs client"
30 [ "$NFSVERSION" = "4" ] && cl_mnt_opt="${MOUNT_OPTS:+$MOUNT_OPTS,}32bitapi" ||
33 check_and_setup_lustre
35 TESTDIR=$NFS_CLIMNTPT/d0.$(basename $0 .sh)
37 $LFS setstripe -c -1 $TESTDIR
39 # first unmount all the lustre clients
45 check_and_cleanup_lustre
50 cleanup_nfs "$LUSTRE_CLIENT_NFSSRV" "$NFS_SRVMNTPT" \
51 "$NFS_CLIENTS" "$NFS_CLIMNTPT" || \
52 error_noexit false "failed to cleanup nfs"
53 zconf_umount $LUSTRE_CLIENT_NFSSRV $NFS_SRVMNTPT force ||
54 error_noexit false "failed to umount lustre on"\
55 "$LUSTRE_CLIENT_NFSSRV"
56 # restore lustre mount
57 restore_mount $MOUNT ||
58 error_noexit false "failed to mount lustre"
61 trap cleanup_exit EXIT SIGHUP SIGINT
63 zconf_mount $LUSTRE_CLIENT_NFSSRV $NFS_SRVMNTPT "$cl_mnt_opt" ||
64 error "mount lustre on $LUSTRE_CLIENT_NFSSRV failed"
67 setup_nfs "$LUSTRE_CLIENT_NFSSRV" "$NFS_SRVMNTPT" "$NFS_CLIENTS" \
68 "$NFS_CLIMNTPT" "$NFSVERSION" || \
69 error false "setup nfs failed!"
75 clients=${NFS_CLIENTS:-$HOSTNAME}
76 generate_machine_file $clients $MACHINEFILE ||
77 error "Failed to generate machine file"
78 num_clients=$(get_node_count ${clients//,/ })
81 # Run short iteration in nfs mode
82 cbench_IDIRS=${cbench_IDIRS:-2}
83 cbench_RUNS=${cbench_RUNS:-2}
86 # Run quick in nfs mode
87 mbench_NFILES=${mbench_NFILES:-10000}
90 [ "$SLOW" = "no" ] && cnt_NRUN=2
93 ior_DURATION=${ior_DURATION:-30}
95 # source the common file after all parameters are set to take affect
96 . $LUSTRE/tests/functions.sh
100 get_mpiuser_id $MPI_USER
101 MPI_RUNAS=${MPI_RUNAS:-"runas -u $MPI_USER_UID -g $MPI_USER_GID"}
102 $GSS_KRB5 && refresh_krb5_tgt $MPI_USER_UID $MPI_USER_GID $MPI_RUNAS
105 local src_file=/tmp/testfile.txt
106 local dst_file=$TESTDIR/$tfile
107 local native_file=$MOUNT/${dst_file#$NFS_CLIMNTPT}
112 ver=$(version_code $(lustre_build_version_node $LUSTRE_CLIENT_NFSSRV))
113 (( $ver >= $(version_code v2_15_90-11-g75f55f99a3) )) ||
114 skip "Need lustre client version of nfs server (MDS1 by default) >= 2.15.91 for NFS ACL handling fix"
117 chmod $mode $src_file
119 cp -p $src_file $dst_file || error "copy $src_file->$dst_file failed"
122 got="$(stat -c %a $dst_file)"
123 [[ "$got" == "$mode" ]] || error "permissions mismatch on '$dst_file'"
125 local xattr=system.posix_acl_access
126 local lustre_xattrs=$(do_node $LUSTRE_CLIENT_NFSSRV \
127 "getfattr -d -m - -e hex $native_file")
130 # If this fails then the mountpoint is non-Lustre or does
131 # not exist because we failed to find a native mountpoint
132 [[ "$lustre_xattrs" =~ "trusted.link" ]] ||
133 error "no trusted.link xattr in '$native_file'"
135 [[ "$lustre_xattrs" =~ "$xattr" ]] &&
136 error "found unexpected $xattr in '$native_file'"
138 do_node $LUSTRE_CLIENT_NFSSRV "stat $native_file"
139 got=$(do_node $LUSTRE_CLIENT_NFSSRV "stat -c %a $native_file")
140 [[ "$got" == "$mode" ]] || error "permission mismatch on '$native_file'"
142 rm -f $src_file $dst_file
144 run_test 1 "test copy with attributes"
151 local args=($(do_node $node "cat /sys/module/$mod/sections/__ksymtab /sys/module/$mod/coresize"))
153 [[ $((args[1])) > 0 ]] || return
155 local min=$((0x7fffffffffffffff))
159 val=$((${args[0]}-${as[2]}))
160 (($val > 0 && $min > $val)) && ofs=${as[1]} && min=$val
161 done <<< $(do_node $node "readelf -l /proc/kcore" | grep LOAD)
163 do_node $node "od --strings -A none -j $((ofs+min)) -N ${args[1]} /proc/kcore"
167 local mp1file=$TESTDIR/file1
168 local tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
169 local mp2file=$tmpdir/${mp1file#$NFS_CLIMNTPT}
171 # Skip without fixing patch
172 mod_strings $LUSTRE_CLIENT_NFSSRV lustre |
173 grep 'Invoke locks_copy_lock for NFSv3' ||
174 skip "NFSv3 server missing locks_copy_lock()"
176 mount -v -t nfs -o nfsvers=$NFSVERSION,async \
177 $LUSTRE_CLIENT_NFSSRV:$NFS_SRVMNTPT $tmpdir ||\
178 error "Nfs 2nd mount($tmpdir) error"
180 local owc=$(do_node $LUSTRE_CLIENT_NFSSRV \
181 "dmesg | grep -v 'DEBUG MARKER:' | grep -c 'refcount_t: underflow; use-after-free'")
182 (( $owc > 0 )) && do_node $LUSTRE_CLIENT_NFSSRV \
183 'echo 1 > /sys/kernel/debug/clear_warn_once'
187 for ((i=1; i<=10; i++)) do
188 [ $i -eq 10 ] && echo "P100"
189 echo "R$((i * 2)),10"
190 echo "W$((i * 100)),100"
192 done | flocks_test 6 $mp1file &
194 for ((i = 0; i < 5; )); do
195 echo "T0" | flocks_test 6 $mp2file |\
196 grep 'R2,26;W100,900.' && i=$((i + 1))
197 local nwc=$(do_node $LUSTRE_CLIENT_NFSSRV \
198 "dmesg | grep -v 'DEBUG MARKER:' | grep -c 'refcount_t: underflow; use-after-free'")
199 (( $owc >= $nwc )) || {
200 do_node $LUSTRE_CLIENT_NFSSRV \
201 "dmesg | grep -1 'refcount_t: underflow; use-after-free'"
202 error "Failed (owc:$owc < nwc:$nwc)"
210 rm -rf $tmpdir || true
212 run_test 2 "fcntl getlk on nfs shouldn't cause refcount underflow"
214 test_compilebench() {
215 if [[ "$TESTSUITE" =~ "parallel-scale-nfs" ]]; then
216 skip "LU-12957 and LU-13068: compilebench for $TESTSUITE"
219 run_compilebench $TESTDIR
221 run_test compilebench "compilebench"
224 run_metabench $TESTDIR $NFS_CLIMNTPT
226 run_test metabench "metabench"
228 test_connectathon() {
229 run_connectathon $TESTDIR
231 run_test connectathon "connectathon"
234 run_ior "ssf" $TESTDIR $NFS_SRVMNTPT
236 run_test iorssf "iorssf"
239 run_ior "fpp" $TESTDIR $NFS_SRVMNTPT
241 run_test iorfpp "iorfpp"
243 test_racer_on_nfs() {
244 local racer_params="MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT LFS=$LFS"
246 do_nodes $CLIENTS "$racer_params $racer $TESTDIR"
248 run_test racer_on_nfs "racer on NFS client"
250 complete_test $SECONDS