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 type="lhost" 15 local calls opt 16 17 [ "$name" = "rpc" ] && opt="r" || opt="n" 18 ! tst_net_use_netns && [ "$nfs_f" != "nfs" ] && type="rhost" 19 20 if [ "$type" = "lhost" ]; then 21 calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)" 22 ROD nfsstat -c$opt | grep -q "$calls" 23 else 24 calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \ 25 cut -d' ' -f$field) 26 tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls" 27 fi 28 29 if ! tst_is_int "$calls"; then 30 if [ "$type" = "lhost" ]; then 31 tst_res TINFO "lhost /proc/net/rpc/$nfs_f" 32 cat /proc/net/rpc/$nfs_f >&2 33 else 34 tst_res TINFO "rhost /proc/net/rpc/$nfs_f" 35 tst_rhost_run -c "cat /proc/net/rpc/$nfs_f" >&2 36 fi 37 38 tst_res TWARN "get_calls: failed to get integer value (args: $@)" 39 fi 40 41 echo "$calls" 42} 43 44# PURPOSE: Performs simple copies and removes to verify statistic 45# tracking using the 'nfsstat' command and /proc/net/rpc 46do_test() 47{ 48 local client_calls server_calls new_server_calls new_client_calls 49 local client_field server_field 50 local client_v=$VERSION server_v=$VERSION 51 52 tst_res TINFO "checking RPC calls for server/client" 53 54 server_calls="$(get_calls rpc 2 nfsd)" 55 client_calls="$(get_calls rpc 2 nfs)" 56 57 tst_res TINFO "calls $server_calls/$client_calls" 58 59 tst_res TINFO "Checking for tracking of RPC calls for server/client" 60 cat /proc/cpuinfo > nfsstat01.tmp 61 62 new_server_calls="$(get_calls rpc 2 nfsd)" 63 new_client_calls="$(get_calls rpc 2 nfs)" 64 tst_res TINFO "new calls $new_server_calls/$new_client_calls" 65 66 if [ "$new_server_calls" -le "$server_calls" ]; then 67 tst_res TFAIL "server RPC calls not increased" 68 else 69 tst_res TPASS "server RPC calls increased" 70 fi 71 72 if [ "$new_client_calls" -le "$client_calls" ]; then 73 tst_res TFAIL "client RPC calls not increased" 74 else 75 tst_res TPASS "client RPC calls increased" 76 fi 77 78 tst_res TINFO "checking NFS calls for server/client" 79 case $VERSION in 80 2) client_field=13 server_field=13 81 ;; 82 3) client_field=15 server_field=15 83 ;; 84 4*) client_field=24 server_field=31 client_v=4 server_v=4ops 85 ;; 86 esac 87 88 server_calls="$(get_calls proc$server_v $server_field nfsd)" 89 client_calls="$(get_calls proc$client_v $client_field nfs)" 90 tst_res TINFO "calls $server_calls/$client_calls" 91 92 tst_res TINFO "Checking for tracking of NFS calls for server/client" 93 rm -f nfsstat01.tmp 94 95 new_server_calls="$(get_calls proc$server_v $server_field nfsd)" 96 new_client_calls="$(get_calls proc$client_v $client_field nfs)" 97 tst_res TINFO "new calls $new_server_calls/$new_client_calls" 98 99 if [ "$new_server_calls" -le "$server_calls" ]; then 100 tst_res TFAIL "server NFS calls not increased" 101 else 102 tst_res TPASS "server NFS calls increased" 103 fi 104 105 if [ "$new_client_calls" -le "$client_calls" ]; then 106 tst_res TFAIL "client NFS calls not increased" 107 else 108 tst_res TPASS "client NFS calls increased" 109 fi 110} 111 112. nfs_lib.sh 113tst_run 114