Whamcloud - gitweb
LU-19098 hsm: don't print progname twice with lhsmtool
[fs/lustre-release.git] / lustre / tests / parallel-scale-nfs.sh
1 #!/bin/bash
2
3 NFSVERSION=${1:-"3"}
4
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
9         init_test_env "$@"
10 else
11         . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
12
13 fi
14
15 init_logging
16
17 racer=$LUSTRE/tests/racer/racer.sh
18 . $LUSTRE/tests/setup-nfs.sh
19
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}
26
27 [ -z "$NFS_CLIENTS" ] &&
28         skip_env "need at least two nodes: nfs server and nfs client"
29
30 [ "$NFSVERSION" = "4" ] && cl_mnt_opt="${MOUNT_OPTS:+$MOUNT_OPTS,}32bitapi" ||
31         cl_mnt_opt=""
32
33 check_and_setup_lustre
34 $LFS df
35 TESTDIR=$NFS_CLIMNTPT/d0.$(basename $0 .sh)
36 mkdir -p $TESTDIR
37 $LFS setstripe -c -1 $TESTDIR
38
39 # first unmount all the lustre clients
40 cleanup_mount $MOUNT
41
42 cleanup_exit () {
43         trap 0
44         cleanup
45         check_and_cleanup_lustre
46         exit
47 }
48
49 cleanup () {
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"
59 }
60
61 trap cleanup_exit EXIT SIGHUP SIGINT
62
63 zconf_mount $LUSTRE_CLIENT_NFSSRV $NFS_SRVMNTPT "$cl_mnt_opt" ||
64         error "mount lustre on $LUSTRE_CLIENT_NFSSRV failed"
65
66 # setup the nfs
67 setup_nfs "$LUSTRE_CLIENT_NFSSRV" "$NFS_SRVMNTPT" "$NFS_CLIENTS" \
68                 "$NFS_CLIMNTPT" "$NFSVERSION" || \
69         error false "setup nfs failed!"
70
71 NFSCLIENT=true
72 FAIL_ON_ERROR=false
73
74 # common setup
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//,/ })
79
80 # compilbench
81 # Run short iteration in nfs mode
82 cbench_IDIRS=${cbench_IDIRS:-2}
83 cbench_RUNS=${cbench_RUNS:-2}
84
85 # metabench
86 # Run quick in nfs mode
87 mbench_NFILES=${mbench_NFILES:-10000}
88
89 # connectathon
90 [ "$SLOW" = "no" ] && cnt_NRUN=2
91
92 # IOR
93 ior_DURATION=${ior_DURATION:-30}
94
95 # source the common file after all parameters are set to take affect
96 . $LUSTRE/tests/functions.sh
97
98 build_test_filter
99
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
103
104 test_1() {
105         local src_file=/tmp/testfile.txt
106         local dst_file=$TESTDIR/$tfile
107         local native_file=$MOUNT/${dst_file#$NFS_CLIMNTPT}
108         local mode=644
109         local got
110         local ver
111
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"
115
116         touch $src_file
117         chmod $mode $src_file
118
119         cp -p $src_file $dst_file || error "copy  $src_file->$dst_file failed"
120
121         stat $dst_file
122         got="$(stat -c %a $dst_file)"
123         [[ "$got" == "$mode" ]] || error "permissions mismatch on '$dst_file'"
124
125         local xattr=system.posix_acl_access
126         local lustre_xattrs=$(do_node $LUSTRE_CLIENT_NFSSRV \
127                 "getfattr -d -m - -e hex $native_file")
128
129         echo $lustre_xattrs
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'"
134
135         [[ "$lustre_xattrs" =~ "$xattr" ]] &&
136                 error "found unexpected $xattr in '$native_file'"
137
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'"
141
142         rm -f $src_file $dst_file
143 }
144 run_test 1 "test copy with attributes"
145
146 mod_strings()
147 {
148         local node=$1
149         local mod=$2
150
151         local args=($(do_node $node "cat /sys/module/$mod/sections/__ksymtab /sys/module/$mod/coresize"))
152
153         [[ $((args[1])) > 0 ]] || return
154
155         local min=$((0x7fffffffffffffff))
156         while read line; do
157                 local as=($line)
158
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)
162
163         do_node $node "od --strings -A none -j $((ofs+min)) -N ${args[1]} /proc/kcore"
164 }
165
166 test_2() {
167         local mp1file=$TESTDIR/file1
168         local tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
169         local mp2file=$tmpdir/${mp1file#$NFS_CLIMNTPT}
170
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()"
175
176         mount -v -t nfs -o nfsvers=$NFSVERSION,async \
177                 $LUSTRE_CLIENT_NFSSRV:$NFS_SRVMNTPT $tmpdir ||\
178                 error "Nfs 2nd mount($tmpdir) error"
179
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'
184
185         touch $mp1file
186         local i=0
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"
191                 sleep 1
192         done | flocks_test 6 $mp1file &
193         local pid=$!
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)"
203                 }
204                 sleep 1
205         done
206         kill -9 $pid
207         wait
208
209         umount $tmpdir
210         rm -rf $tmpdir || true
211 }
212 run_test 2 "fcntl getlk on nfs shouldn't cause refcount underflow"
213
214 test_compilebench() {
215         if [[ "$TESTSUITE" =~ "parallel-scale-nfs" ]]; then
216                 skip "LU-12957 and LU-13068: compilebench for $TESTSUITE"
217         fi
218
219         run_compilebench $TESTDIR
220 }
221 run_test compilebench "compilebench"
222
223 test_metabench() {
224         run_metabench $TESTDIR $NFS_CLIMNTPT
225 }
226 run_test metabench "metabench"
227
228 test_connectathon() {
229         run_connectathon $TESTDIR
230 }
231 run_test connectathon "connectathon"
232
233 test_iorssf() {
234         run_ior "ssf" $TESTDIR $NFS_SRVMNTPT
235 }
236 run_test iorssf "iorssf"
237
238 test_iorfpp() {
239         run_ior "fpp" $TESTDIR $NFS_SRVMNTPT
240 }
241 run_test iorfpp "iorfpp"
242
243 test_racer_on_nfs() {
244         local racer_params="MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT LFS=$LFS"
245
246         do_nodes $CLIENTS "$racer_params $racer $TESTDIR"
247 }
248 run_test racer_on_nfs "racer on NFS client"
249
250 complete_test $SECONDS
251 exit_status