Change nfsstat client statistics to report actual RPC counts

From: John Baldwin <jhb_at_freebsd.org>
Date: Tue, 28 Jan 2014 15:45:30 -0500
I had always assumed that when you ran 'nfsstat -c 1' you saw counts of actual 
RPCs sent over the wire (similar to how 'netstat 1' show actual packets / 
bytes, 'iostat 1' shows actual disk transactions / bytes, etc.).  I was 
surprised to find that 'nfsstat -c' does not show actual RPC counts.  Instead, 
it shows theoretical RPC counts as if the client did no caching at all.  (This 
would be akin to 'iostat 1' showing a disk transaction for every read() system 
call).  In general when I'm using 'nfsstat -c 1', I'm using it to get a 
summary of what the NFS client is actually sending over the wire, not the 
theoretical numbers.  To that end, I have a patch to change nfsstat back to 
reporting raw RPC count deltas instead of theoretical deltas.  (It used to 
report raw RPC counts back before 4.0.)  If you are curious about the 
effectiveness of the client side caches, that data can still be obtained via 
the existing '-W' flag.

Index: nfsstat.c
===================================================================
--- nfsstat.c	(revision 261241)
+++ nfsstat.c	(working copy)
_at__at_ -604,14 +604,15 _at__at_
 		if (clientOnly) {
 		    printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
 			((clientOnly && serverOnly) ? "Client:" : ""),
-			DELTA(attrcache_hits) + DELTA(attrcache_misses),
-			DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
-			DELTA(biocache_readlinks),
-			DELTA(biocache_reads),
-			DELTA(biocache_writes),
-			nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME],
-			DELTA(accesscache_hits) + DELTA(accesscache_misses),
-			DELTA(biocache_readdirs)
+			DELTA(rpccnt[NFSPROC_GETATTR]),
+			DELTA(rpccnt[NFSPROC_LOOKUP]),
+			DELTA(rpccnt[NFSPROC_READLINK]),
+			DELTA(rpccnt[NFSPROC_READ]),
+			DELTA(rpccnt[NFSPROC_WRITE]),
+			DELTA(rpccnt[NFSPROC_RENAME]),
+			DELTA(rpccnt[NFSPROC_ACCESS]),
+			DELTA(rpccnt[NFSPROC_READDIR]) +
+			DELTA(rpccnt[NFSPROC_READDIRPLUS])
 		    );
 		    if (widemode) {
 			    printf(" %s %s %s %s %s %s",
_at__at_ -993,15 +994,15 _at__at_
 		if (clientOnly) {
 		    printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
 			((clientOnly && serverOnly) ? "Client:" : ""),
-			DELTA(attrcache_hits) + DELTA(attrcache_misses),
-			DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
-			DELTA(biocache_readlinks),
-			DELTA(biocache_reads),
-			DELTA(biocache_writes),
-			nfsstats.rpccnt[NFSPROC_RENAME] -
-			lastst.rpccnt[NFSPROC_RENAME],
-			DELTA(accesscache_hits) + DELTA(accesscache_misses),
-			DELTA(biocache_readdirs)
+			DELTA(rpccnt[NFSPROC_GETATTR]),
+			DELTA(rpccnt[NFSPROC_LOOKUP]),
+			DELTA(rpccnt[NFSPROC_READLINK]),
+			DELTA(rpccnt[NFSPROC_READ]),
+			DELTA(rpccnt[NFSPROC_WRITE]),
+			DELTA(rpccnt[NFSPROC_RENAME]),
+			DELTA(rpccnt[NFSPROC_ACCESS]),
+			DELTA(rpccnt[NFSPROC_READDIR]) +
+			DELTA(rpccnt[NFSPROC_READDIRPLUS])
 		    );
 		    if (widemode) {
 			    printf(" %s %s %s %s %s %s",


-- 
John Baldwin
Received on Tue Jan 28 2014 - 19:45:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:46 UTC