1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2016-2018 Oracle and/or its affiliates. All Rights Reserved. 4# Copyright (c) International Business Machines Corp., 2001 5 6TST_TESTFUNC="do_test" 7TST_NEEDS_CMDS="nfsstat" 8 9get_calls() 10{ 11 local name=$1 12 local field=$2 13 local nfs_f=$3 14 local calls= 15 local opt= 16 [ "$name" = "rpc" ] && opt="r" || opt="n" 17 18 if tst_net_use_netns || [ "$nfs_f" = "nfs" ]; then 19 calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)" 20 ROD nfsstat -c$opt | grep -q "$calls" 21 echo "$calls" 22 return 23 fi 24 25 calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \ 26 cut -d' ' -f$field) 27 tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls" 28 echo "$calls" 29} 30 31# PURPOSE: Performs simple copies and removes to verify statistic 32# tracking using the 'nfsstat' command and /proc/net/rpc 33do_test() 34{ 35 tst_res TINFO "checking RPC calls for server/client" 36 37 local server_calls="$(get_calls rpc 2 nfsd)" 38 local client_calls="$(get_calls rpc 2 nfs)" 39 40 tst_res TINFO "calls $server_calls/$client_calls" 41 42 tst_res TINFO "Checking for tracking of RPC calls for server/client" 43 cat /proc/cpuinfo > nfsstat01.tmp 44 45 local new_server_calls="$(get_calls rpc 2 nfsd)" 46 local new_client_calls="$(get_calls rpc 2 nfs)" 47 tst_res TINFO "new calls $new_server_calls/$new_client_calls" 48 49 if [ "$new_server_calls" -le "$server_calls" ]; then 50 tst_res TFAIL "server RPC calls not increased" 51 else 52 tst_res TPASS "server RPC calls increased" 53 fi 54 55 if [ "$new_client_calls" -le "$client_calls" ]; then 56 tst_res TFAIL "client RPC calls not increased" 57 else 58 tst_res TPASS "client RPC calls increased" 59 fi 60 61 tst_res TINFO "checking NFS calls for server/client" 62 local field= 63 case $VERSION in 64 2) field=13 65 ;; 66 *) field=15 67 ;; 68 esac 69 70 server_calls="$(get_calls proc$VERSION $field nfsd)" 71 client_calls="$(get_calls proc$VERSION $field nfs)" 72 tst_res TINFO "calls $server_calls/$client_calls" 73 74 tst_res TINFO "Checking for tracking of NFS calls for server/client" 75 rm -f nfsstat01.tmp 76 77 new_server_calls="$(get_calls proc$VERSION $field nfsd)" 78 new_client_calls="$(get_calls proc$VERSION $field nfs)" 79 tst_res TINFO "new calls $new_server_calls/$new_client_calls" 80 81 if [ "$new_server_calls" -le "$server_calls" ]; then 82 tst_res TFAIL "server NFS calls not increased" 83 else 84 tst_res TPASS "server NFS calls increased" 85 fi 86 87 if [ "$new_client_calls" -le "$client_calls" ]; then 88 tst_res TFAIL "client NFS calls not increased" 89 else 90 tst_res TPASS "client NFS calls increased" 91 fi 92} 93 94. nfs_lib.sh 95tst_run 96