nfsstat01 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. TST_TESTFUNC="do_test"
  6. TST_NEEDS_CMDS="nfsstat"
  7. . nfs_lib.sh
  8. get_calls()
  9. {
  10. local name=$1
  11. local field=$2
  12. local nfs_f=$3
  13. local calls=
  14. local opt=
  15. [ "$name" = "rpc" ] && opt="r" || opt="n"
  16. if [ -n "$LTP_NETNS" -o "$nfs_f" = "nfs" ]; then
  17. calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)"
  18. ROD nfsstat -c$opt | grep -q "$calls"
  19. echo "$calls"
  20. return
  21. fi
  22. calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \
  23. cut -d' ' -f$field)
  24. tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls"
  25. echo "$calls"
  26. }
  27. # PURPOSE: Performs simple copies and removes to verify statistic
  28. # tracking using the 'nfsstat' command and /proc/net/rpc
  29. do_test()
  30. {
  31. tst_res TINFO "checking RPC calls for server/client"
  32. local server_calls="$(get_calls rpc 2 nfsd)"
  33. local client_calls="$(get_calls rpc 2 nfs)"
  34. tst_res TINFO "calls $server_calls/$client_calls"
  35. tst_res TINFO "Checking for tracking of RPC calls for server/client"
  36. cat /proc/cpuinfo > nfsstat01.tmp
  37. local new_server_calls="$(get_calls rpc 2 nfsd)"
  38. local new_client_calls="$(get_calls rpc 2 nfs)"
  39. tst_res TINFO "new calls $new_server_calls/$new_client_calls"
  40. if [ "$new_server_calls" -le "$server_calls" ]; then
  41. tst_res TFAIL "server RPC calls not increased"
  42. else
  43. tst_res TPASS "server RPC calls increased"
  44. fi
  45. if [ "$new_client_calls" -le "$client_calls" ]; then
  46. tst_res TFAIL "client RPC calls not increased"
  47. else
  48. tst_res TPASS "client RPC calls increased"
  49. fi
  50. tst_res TINFO "checking NFS calls for server/client"
  51. local field=
  52. case $VERSION in
  53. 2) field=13
  54. ;;
  55. *) field=15
  56. ;;
  57. esac
  58. server_calls="$(get_calls proc$VERSION $field nfsd)"
  59. client_calls="$(get_calls proc$VERSION $field nfs)"
  60. tst_res TINFO "calls $server_calls/$client_calls"
  61. tst_res TINFO "Checking for tracking of NFS calls for server/client"
  62. rm -f nfsstat01.tmp
  63. new_server_calls="$(get_calls proc$VERSION $field nfsd)"
  64. new_client_calls="$(get_calls proc$VERSION $field nfs)"
  65. tst_res TINFO "new calls $new_server_calls/$new_client_calls"
  66. if [ "$new_server_calls" -le "$server_calls" ]; then
  67. tst_res TFAIL "server NFS calls not increased"
  68. else
  69. tst_res TPASS "server NFS calls increased"
  70. fi
  71. if [ "$new_client_calls" -le "$client_calls" ]; then
  72. tst_res TFAIL "client NFS calls not increased"
  73. else
  74. tst_res TPASS "client NFS calls increased"
  75. fi
  76. }
  77. tst_run