NetBSD Problem Report #48426

From oster@cs.usask.ca  Fri Dec  6 20:35:54 2013
Return-Path: <oster@cs.usask.ca>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 816A1A63E0
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  6 Dec 2013 20:35:54 +0000 (UTC)
Message-Id: <20131206203323.5963787D35@mickey.usask.ca>
Date: Fri,  6 Dec 2013 14:33:23 -0600 (CST)
From: oster@netbsd.org
Reply-To: oster@netbsd.org
To: gnats-bugs@gnats.NetBSD.org
Subject: nfsstat shows negative counts
X-Send-Pr-Version: 3.95

>Number:         48426
>Category:       kern
>Synopsis:       nfsstat shows negative counts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 06 20:40:00 +0000 2013
>Closed-Date:    Wed Jul 16 06:32:00 +0000 2014
>Last-Modified:  Wed Jul 16 06:32:00 +0000 2014
>Originator:     Greg Oster
>Release:        NetBSD 6.1.2
>Organization:
>Environment:


System: NetBSD mickey 6.1.2 NetBSD 6.1.2 (QUAD) #0: Thu Sep 26 15:35:44 CST 2013 oster@quad:/u1/builds/build242/src/obj/amd64/u1/builds/build242/src/sys/arch/amd64/compile/QUAD amd64
Architecture: x86_64
Machine: amd64
>Description:

nfsstat shows negative count values.  For example:

Client Info:
RPC Counts: (176595266 calls)
      null         getattr         setattr          lookup          access
         0  0%    96191690 54%      694127  0%    28335421 16%     5543767  3%
  readlink            read           write          create           mkdir
      1348  0%     2769302  1%    26090532 14%      666888  0%       15792  0%
   symlink           mknod          remove           rmdir          rename
       615  0%           2  0%      281455  0%       15681  0%      446339  0%
      link         readdir     readdirplus          fsstat          fsinfo
      6326  0%      666711  0%           0  0%    13574917  7%           5  0%
  pathconf          commit
     36406  0%     1257942  0%
RPC Info:
   timeout         invalid      unexpected         retries        requests
         1               0               2              17       176595266
Cache Info:
 attrcache     lookupcache            read           write        readlink
-153914704 293%   269765890 90%  -841091842 100%    40898680 71%    18241964 99%
   readdir     direofcache
   5236935 90%     1339656 65%

Server Info:
RPC Counts: (1 call)
      null         getattr         setattr          lookup          access
         1 100%           0  0%           0  0%           0  0%           0  0%
  readlink            read           write          create           mkdir
         0  0%           0  0%           0  0%           0  0%           0  0%
   symlink           mknod          remove           rmdir          rename
         0  0%           0  0%           0  0%           0  0%           0  0%
      link         readdir     readdirplus          fsstat          fsinfo
         0  0%           0  0%           0  0%           0  0%           0  0%
  pathconf          commit
         0  0%           0  0%
Server Errors:
RPC errors          faults
         0               0
Server Cache Stats:
inprogress            idem        non-idem          misses
         0               0               0               1
Server Write Gathering:
    writes       write RPC       OPs saved
         0               0               0  0%


>How-To-Repeat:

	Run /usr/bin/nfsstat on a NetBSD 6.1.2 NFS client that has
been doing a fair bit of activity.  It is expected that this problem
exists in -current as well, but my test box needs to transfer a lot
more data before the counters overflow and that can be confirmed.

>Fix:

	As David Holland suggests, making 'struct nfsstats' use
something larger than integers for counters would be a good first
step.


>Release-Note:

>Audit-Trail:
From: Dimitris Karagkasidis <dimitris@gatoni.gr>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/48426
Date: Thu, 24 Apr 2014 10:23:47 +0200

 This is a multi-part message in MIME format.
 --------------070904040207080408090901
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 Converting the signed integers to unsigned in `struct nfsstats` is the
 first thing that pops in mind. This would both solve the presentation
 issue in /usr/bin/nfsstat and would also be "theoretically" correct,
 since there is no need to store negative values in NFS stat counters.

 IMHO it doesn't makes sense to increase the size of `struct nfsstats`
 and potentially introduce issues to other parts of the code, just so
 the NFS stat counters wrap at values higher than 4294967295?


 Index: nfs.h
 ===================================================================
 RCS file: /cvsroot/src/sys/nfs/nfs.h,v
 retrieving revision 1.73
 diff -u -r1.73 nfs.h
 --- nfs.h	1 Mar 2013 18:26:10 -0000	1.73
 +++ nfs.h	23 Apr 2014 23:14:57 -0000
 @@ -238,39 +238,39 @@
    * Stats structure
    */
   struct nfsstats {
 -	int	attrcache_hits;
 -	int	attrcache_misses;
 -	int	lookupcache_hits;
 -	int	lookupcache_misses;
 -	int	direofcache_hits;
 -	int	direofcache_misses;
 -	int	biocache_reads;
 -	int	read_bios;
 -	int	read_physios;
 -	int	biocache_writes;
 -	int	write_bios;
 -	int	write_physios;
 -	int	biocache_readlinks;
 -	int	readlink_bios;
 -	int	biocache_readdirs;
 -	int	readdir_bios;
 -	int	rpccnt[NFSSTATS_NPROCS];
 -	int	rpcretries;
 -	int	srvrpccnt[NFSSTATS_NPROCS];
 -	int	srvrpc_errs;
 -	int	srv_errs;
 -	int	rpcrequests;
 -	int	rpctimeouts;
 -	int	rpcunexpected;
 -	int	rpcinvalid;
 -	int	srvcache_inproghits;
 -	int	srvcache_idemdonehits;
 -	int	srvcache_nonidemdonehits;
 -	int	srvcache_misses;
 -	int	__srvnqnfs_leases;	/* unused */
 -	int	__srvnqnfs_maxleases;	/* unused */
 -	int	__srvnqnfs_getleases;	/* unused */
 -	int	srvvop_writes;
 +	unsigned int	attrcache_hits;
 +	unsigned int	attrcache_misses;
 +	unsigned int	lookupcache_hits;
 +	unsigned int	lookupcache_misses;
 +	unsigned int	direofcache_hits;
 +	unsigned int	direofcache_misses;
 +	unsigned int	biocache_reads;
 +	unsigned int	read_bios;
 +	unsigned int	read_physios;
 +	unsigned int	biocache_writes;
 +	unsigned int	write_bios;
 +	unsigned int	write_physios;
 +	unsigned int	biocache_readlinks;
 +	unsigned int	readlink_bios;
 +	unsigned int	biocache_readdirs;
 +	unsigned int	readdir_bios;
 +	unsigned int	rpccnt[NFSSTATS_NPROCS];
 +	unsigned int	rpcretries;
 +	unsigned int	srvrpccnt[NFSSTATS_NPROCS];
 +	unsigned int	srvrpc_errs;
 +	unsigned int	srv_errs;
 +	unsigned int	rpcrequests;
 +	unsigned int	rpctimeouts;
 +	unsigned int	rpcunexpected;
 +	unsigned int	rpcinvalid;
 +	unsigned int	srvcache_inproghits;
 +	unsigned int	srvcache_idemdonehits;
 +	unsigned int	srvcache_nonidemdonehits;
 +	unsigned int	srvcache_misses;
 +	unsigned int	__srvnqnfs_leases;	/* unused */
 +	unsigned int	__srvnqnfs_maxleases;	/* unused */
 +	unsigned int	__srvnqnfs_getleases;	/* unused */
 +	unsigned int	srvvop_writes;
   };

   /*



 --------------070904040207080408090901
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit

 <html>
   <head>

     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   </head>
   <body bgcolor="#FFFFFF" text="#000000">
     <meta http-equiv="content-type" content="text/html;
       charset=ISO-8859-1">
     <pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap;">Converting the signed integers to unsigned in `struct nfsstats` is the
 first thing that pops in mind. This would both solve the presentation
 issue in /usr/bin/nfsstat and would also be "theoretically" correct,
 since there is no need to store negative values in NFS stat counters.

 IMHO it doesn't makes sense to increase the size of `struct nfsstats`
 and potentially introduce issues to other parts of the code, just so
 the NFS stat counters wrap at values higher than 4294967295?


 Index: nfs.h
 ===================================================================
 RCS file: /cvsroot/src/sys/nfs/nfs.h,v
 retrieving revision 1.73
 diff -u -r1.73 nfs.h
 --- nfs.h	1 Mar 2013 18:26:10 -0000	1.73
 +++ nfs.h	23 Apr 2014 23:14:57 -0000
 @@ -238,39 +238,39 @@
   * Stats structure
   */
  struct nfsstats {
 -	int	attrcache_hits;
 -	int	attrcache_misses;
 -	int	lookupcache_hits;
 -	int	lookupcache_misses;
 -	int	direofcache_hits;
 -	int	direofcache_misses;
 -	int	biocache_reads;
 -	int	read_bios;
 -	int	read_physios;
 -	int	biocache_writes;
 -	int	write_bios;
 -	int	write_physios;
 -	int	biocache_readlinks;
 -	int	readlink_bios;
 -	int	biocache_readdirs;
 -	int	readdir_bios;
 -	int	rpccnt[NFSSTATS_NPROCS];
 -	int	rpcretries;
 -	int	srvrpccnt[NFSSTATS_NPROCS];
 -	int	srvrpc_errs;
 -	int	srv_errs;
 -	int	rpcrequests;
 -	int	rpctimeouts;
 -	int	rpcunexpected;
 -	int	rpcinvalid;
 -	int	srvcache_inproghits;
 -	int	srvcache_idemdonehits;
 -	int	srvcache_nonidemdonehits;
 -	int	srvcache_misses;
 -	int	__srvnqnfs_leases;	/* unused */
 -	int	__srvnqnfs_maxleases;	/* unused */
 -	int	__srvnqnfs_getleases;	/* unused */
 -	int	srvvop_writes;
 +	unsigned int	attrcache_hits;
 +	unsigned int	attrcache_misses;
 +	unsigned int	lookupcache_hits;
 +	unsigned int	lookupcache_misses;
 +	unsigned int	direofcache_hits;
 +	unsigned int	direofcache_misses;
 +	unsigned int	biocache_reads;
 +	unsigned int	read_bios;
 +	unsigned int	read_physios;
 +	unsigned int	biocache_writes;
 +	unsigned int	write_bios;
 +	unsigned int	write_physios;
 +	unsigned int	biocache_readlinks;
 +	unsigned int	readlink_bios;
 +	unsigned int	biocache_readdirs;
 +	unsigned int	readdir_bios;
 +	unsigned int	rpccnt[NFSSTATS_NPROCS];
 +	unsigned int	rpcretries;
 +	unsigned int	srvrpccnt[NFSSTATS_NPROCS];
 +	unsigned int	srvrpc_errs;
 +	unsigned int	srv_errs;
 +	unsigned int	rpcrequests;
 +	unsigned int	rpctimeouts;
 +	unsigned int	rpcunexpected;
 +	unsigned int	rpcinvalid;
 +	unsigned int	srvcache_inproghits;
 +	unsigned int	srvcache_idemdonehits;
 +	unsigned int	srvcache_nonidemdonehits;
 +	unsigned int	srvcache_misses;
 +	unsigned int	__srvnqnfs_leases;	/* unused */
 +	unsigned int	__srvnqnfs_maxleases;	/* unused */
 +	unsigned int	__srvnqnfs_getleases;	/* unused */
 +	unsigned int	srvvop_writes;
  };

  /*
 </pre>
     <br class="Apple-interchange-newline">
   </body>
 </html>

 --------------070904040207080408090901--

From: Dimitris Karagkasidis <dimitris@gatoni.gr>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/48426
Date: Thu, 24 Apr 2014 20:12:36 +0200

 This is a multi-part message in MIME format.
 --------------020808060203020807030806
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 After some more investigation and talks on #netbsd-code, I have come to
 conclusion that making signed integers unsgined in `struct nfsstats` will
 not entirely solve the issue. The problem lies entirely in the presentation
 layer of /usr/bin/nfsstat.

 /usr/bin/nfsstats is using the "d" converstion specifier when printing
 the counter values to stdout. According to printf(3), the "d" conversion
 specifier is converting any arguments to signed decimal, even if the
 argument was declared as unsigned.

 In order to reproduce the issue while avoiding the generation of excessive
 NFS usage, I wrote the following kernel module that manually sets the
 counters in `struct nfsstats` to arbitrary values:

 ---
 /*
   * repr_nfsstats.c
   * PoC to reproduce kern/48426
   */
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <nfs/rpcv2.h>
 #include <nfs/nfs.h>

 MODULE(MODULE_CLASS_MISC, repr_nfsstats, NULL);

 extern struct nfsstats nfsstats;

 void
 set_nfsstats(int value)
 {
      int i;

      for (i = 0; i < NFSSTATS_NPROCS; i++) {
          nfsstats.rpccnt[i] = value;
          nfsstats.srvrpccnt[i] = value;
      }

      nfsstats.attrcache_hits = value;
      nfsstats.attrcache_misses = value;
      nfsstats.lookupcache_hits = value;
      nfsstats.lookupcache_misses = value;
      nfsstats.direofcache_hits = value;
      nfsstats.direofcache_misses = value;
      nfsstats.biocache_reads = value;
      nfsstats.read_bios = value;
      nfsstats.read_physios = value;
      nfsstats.biocache_writes = value;
      nfsstats.write_bios = value;
      nfsstats.write_physios = value;
      nfsstats.biocache_readlinks = value;
      nfsstats.readlink_bios = value;
      nfsstats.biocache_readdirs = value;
      nfsstats.readdir_bios = value;
      nfsstats.rpcretries = value;
      nfsstats.srvrpc_errs = value;
      nfsstats.srv_errs = value;
      nfsstats.rpcrequests = value;
      nfsstats.rpctimeouts = value;
      nfsstats.rpcunexpected = value;
      nfsstats.rpcinvalid = value;
      nfsstats.srvcache_inproghits = value;
      nfsstats.srvcache_idemdonehits = value;
      nfsstats.srvcache_nonidemdonehits = value;
      nfsstats.srvcache_misses = value;
      nfsstats.__srvnqnfs_leases = value;
      nfsstats.__srvnqnfs_maxleases = value;
      nfsstats.__srvnqnfs_getleases = value;
      nfsstats.srvvop_writes = value;
 }

 int
 repr_nfsstats_modcmd(modcmd_t cmd, void *data)
 {
      switch(cmd) {
      case MODULE_CMD_INIT:
          // Set counters to LONG_MAX+1
          set_nfsstats(2147483648);
          break;
      case MODULE_CMD_FINI:
          set_nfsstats(0);
          break;
      case MODULE_CMD_STAT:
          return ENOTTY;
          break;
      default:
          return ENOTTY;
      }
      return (0);
 }
 ---

 These are the results before and after loading the module:

 ---
 netbsd# /usr/bin/nfsstat
 Client Info:
 RPC Counts: (0 calls)
        null         getattr         setattr          lookup          access
           0  0%           0  0%           0  0%           0  0%           0  0%
    readlink            read           write          create           mkdir
           0  0%           0  0%           0  0%           0  0%           0  0%
     symlink           mknod          remove           rmdir          rename
           0  0%           0  0%           0  0%           0  0%           0  0%
        link         readdir     readdirplus          fsstat          fsinfo
           0  0%           0  0%           0  0%           0  0%           0  0%
    pathconf          commit
           0  0%           0  0%
 RPC Info:
     timeout         invalid      unexpected         retries        requests
           0               0               0               0               0
 Cache Info:
   attrcache     lookupcache            read           write        readlink
           0  0%           0  0%           0  0%           0  0%           0  0%
     readdir     direofcache
           0  0%           0  0%

 Server Info:
 RPC Counts: (0 calls)
        null         getattr         setattr          lookup          access
           0  0%           0  0%           0  0%           0  0%           0  0%
    readlink            read           write          create           mkdir
           0  0%           0  0%           0  0%           0  0%           0  0%
     symlink           mknod          remove           rmdir          rename
           0  0%           0  0%           0  0%           0  0%           0  0%
        link         readdir     readdirplus          fsstat          fsinfo
           0  0%           0  0%           0  0%           0  0%           0  0%
    pathconf          commit
           0  0%           0  0%
 Server Errors:
 RPC errors          faults
           0               0
 Server Cache Stats:
 inprogress            idem        non-idem          misses
           0               0               0               0
 Server Write Gathering:
      writes       write RPC       OPs saved
           0               0               0  0%
 netbsd# modload ./repr_nfsstats.kmod
 netbsd# /usr/bin/nfsstat
 Client Info:
 RPC Counts: (-49392123904 calls)
        null         getattr         setattr          lookup          access
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
    readlink            read           write          create           mkdir
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
     symlink           mknod          remove           rmdir          rename
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
        link         readdir     readdirplus          fsstat          fsinfo
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
    pathconf          commit
 -2147483648  4%  -2147483648  4%
 RPC Info:
     timeout         invalid      unexpected         retries        requests
 -2147483648     -2147483648     -2147483648     -2147483648     -2147483648
 Cache Info:
   attrcache     lookupcache            read           write        readlink
 -2147483648  0%  -2147483648  0%           0  0%           0  0%           0  0%
     readdir     direofcache
           0  0%  -2147483648  0%

 Server Info:
 RPC Counts: (-49392123904 calls)
        null         getattr         setattr          lookup          access
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
    readlink            read           write          create           mkdir
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
     symlink           mknod          remove           rmdir          rename
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
        link         readdir     readdirplus          fsstat          fsinfo
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
    pathconf          commit
 -2147483648  4%  -2147483648  4%
 Server Errors:
 RPC errors          faults
 -2147483648     -2147483648
 Server Cache Stats:
 inprogress            idem        non-idem          misses
 -2147483648     -2147483648     -2147483648     -2147483648
 Server Write Gathering:
      writes       write RPC       OPs saved
 -2147483648     -2147483648               0  0%
 ---

 By changing "d" conversion specifier to "u", nfsstat counters will never
 be negative. These are the results of nfsstat after the application of the
 patch listed in the bottom of this PR:

 ---
 netbsd# ./nfsstat
 Client Info:
 RPC Counts: (18446744024317427712 calls)
        null         getattr         setattr          lookup          access
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
    readlink            read           write          create           mkdir
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
     symlink           mknod          remove           rmdir          rename
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
        link         readdir     readdirplus          fsstat          fsinfo
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
    pathconf          commit
 2147483648  4%  2147483648  4%
 RPC Info:
     timeout         invalid      unexpected         retries        requests
 2147483648      2147483648      2147483648      2147483648      2147483648
 Cache Info:
   attrcache     lookupcache            read           write        readlink
 2147483648  0%  2147483648  0%           0  0%           0  0%           0  0%
     readdir     direofcache
           0  0%  2147483648  0%

 Server Info:
 RPC Counts: (18446744024317427712 calls)
        null         getattr         setattr          lookup          access
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
    readlink            read           write          create           mkdir
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
     symlink           mknod          remove           rmdir          rename
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
        link         readdir     readdirplus          fsstat          fsinfo
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
    pathconf          commit
 2147483648  4%  2147483648  4%
 Server Errors:
 RPC errors          faults
 2147483648      2147483648
 Server Cache Stats:
 inprogress            idem        non-idem          misses
 2147483648      2147483648      2147483648      2147483648
 Server Write Gathering:
      writes       write RPC       OPs saved
 2147483648      2147483648               0  0%
 ---

 This is my suggested patch to resolve the issue:

 Index: nfsstat.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/nfsstat/nfsstat.c,v
 retrieving revision 1.24
 diff -u -r1.24 nfsstat.c
 --- nfsstat.c	6 Sep 2011 18:19:58 -0000	1.24
 +++ nfsstat.c	24 Apr 2014 17:48:26 -0000
 @@ -217,13 +217,13 @@
   		for (i = 0; i < NFS_NPROCS; i++)
   			total += nfsstats.rpccnt[i];
   		printf("Client Info:\n");
 -		printf("RPC Counts: (%lld call%s)\n", (long long)total,
 +		printf("RPC Counts: (%llu call%s)\n", (long long)total,
   		    total == 1 ? "" : "s");

   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "null", "getattr", "setattr", "lookup", "access");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_NULL]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_GETATTR]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_SETATTR]),
 @@ -232,7 +232,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "readlink", "read", "write", "create", "mkdir");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READLINK]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READ]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_WRITE]),
 @@ -241,7 +241,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "symlink", "mknod", "remove", "rmdir", "rename");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_SYMLINK]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_MKNOD]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_REMOVE]),
 @@ -250,7 +250,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "link", "readdir", "readdirplus", "fsstat", "fsinfo");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_LINK]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READDIR]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READDIRPLUS]),
 @@ -258,14 +258,14 @@
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_FSINFO]));
   		printf("%10s  %14s\n",
   		    "pathconf", "commit");
 -		printf("%10d %2d%%  %10d %2d%%\n",
 +		printf("%10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_PATHCONF]),
   		    RPCSTAT(nfsstats.rpccnt[NFSPROC_COMMIT]));

   		printf("RPC Info:\n");
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "timeout", "invalid", "unexpected", "retries", "requests");
 -		printf("%10d  %14d  %14d  %14d  %14d\n",
 +		printf("%10u  %14u  %14u  %14u  %14u\n",
   		    nfsstats.rpctimeouts,
   		    nfsstats.rpcinvalid,
   		    nfsstats.rpcunexpected,
 @@ -276,7 +276,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "attrcache", "lookupcache", "read", "write", "readlink");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    NUMPCT(nfsstats.attrcache_hits,
   			nfsstats.attrcache_misses),
   		    NUMPCT(nfsstats.lookupcache_hits,
 @@ -289,7 +289,7 @@
   			nfsstats.readlink_bios));
   		printf("%10s  %14s\n",
   		    "readdir", "direofcache");
 -		printf("%10d %2d%%  %10d %2d%%\n",
 +		printf("%10u %2u%%  %10u %2u%%\n",
   		    NUMPCT(nfsstats.biocache_readdirs - nfsstats.readdir_bios,
   			nfsstats.readdir_bios),
   		    NUMPCT(nfsstats.direofcache_hits,
 @@ -304,13 +304,13 @@
   		for (i = 0; i < NFS_NPROCS; i++)
   			total += nfsstats.srvrpccnt[i];
   		printf("Server Info:\n");
 -		printf("RPC Counts: (%lld call%s)\n", (long long)total,
 +		printf("RPC Counts: (%llu call%s)\n", (long long)total,
   		    total == 1 ? "" : "s");

   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "null", "getattr", "setattr", "lookup", "access");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_NULL]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_GETATTR]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_SETATTR]),
 @@ -319,7 +319,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "readlink", "read", "write", "create", "mkdir");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READLINK]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READ]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_WRITE]),
 @@ -328,7 +328,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "symlink", "mknod", "remove", "rmdir", "rename");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_SYMLINK]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_MKNOD]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_REMOVE]),
 @@ -337,7 +337,7 @@
   		printf("%10s  %14s  %14s  %14s  %14s\n",
   		    "link", "readdir", "readdirplus", "fsstat", "fsinfo");
   		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_LINK]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READDIR]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READDIRPLUS]),
 @@ -345,20 +345,20 @@
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_FSINFO]));
   		printf("%10s  %14s\n",
   		    "pathconf", "commit");
 -		printf("%10d %2d%%  %10d %2d%%\n",
 +		printf("%10u %2u%%  %10u %2u%%\n",
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_PATHCONF]),
   		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_COMMIT]));

   		printf("Server Errors:\n");
   		printf("%10s  %14s\n",
   		    "RPC errors", "faults");
 -		printf("%10d  %14d\n",
 +		printf("%10u  %14u\n",
   		    nfsstats.srvrpc_errs,
   		    nfsstats.srv_errs);
   		printf("Server Cache Stats:\n");
   		printf("%10s  %14s  %14s  %14s\n",
   		    "inprogress", "idem", "non-idem", "misses");
 -		printf("%10d  %14d  %14d  %14d\n",
 +		printf("%10u  %14u  %14u  %14u\n",
   		    nfsstats.srvcache_inproghits,
   		    nfsstats.srvcache_idemdonehits,
   		    nfsstats.srvcache_nonidemdonehits,
 @@ -366,7 +366,7 @@
   		printf("Server Write Gathering:\n");
   		printf("%10s  %14s  %14s\n",
   		    "writes", "write RPC", "OPs saved");
 -		printf("%10d  %14d  %14d %2d%%\n",
 +		printf("%10u  %14u  %14u %2u%%\n",
   		    nfsstats.srvvop_writes,
   		    nfsstats.srvrpccnt[NFSPROC_WRITE],
   		    NUMPCT(
 @@ -422,14 +422,14 @@
   		if (printall || clientinfo) {
   			printf("Client:");
   			for (i = 0; i < NSHORTPROC; i++)
 -				printf(" %7d",
 +				printf(" %7u",
   				    current.client[i] - last.client[i]);
   			printf("\n");
   		}
   		if (printall || serverinfo) {
   			printf("Server:");
   			for (i = 0; i < NSHORTPROC; i++)
 -				printf(" %7d",
 +				printf(" %7u",
   				    current.server[i] - last.server[i]);
   			printf("\n");
   		}



 --------------020808060203020807030806
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit

 <html>
   <head>

     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   </head>
   <body bgcolor="#FFFFFF" text="#000000">
     <meta http-equiv="content-type" content="text/html;
       charset=ISO-8859-1">
     <pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap;">After some more investigation and talks on #netbsd-code, I have come to
 conclusion that making signed integers unsgined in `struct nfsstats` will
 not entirely solve the issue. The problem lies entirely in the presentation
 layer of /usr/bin/nfsstat.

 /usr/bin/nfsstats is using the "d" converstion specifier when printing
 the counter values to stdout. According to printf(3), the "d" conversion
 specifier is converting any arguments to signed decimal, even if the
 argument was declared as unsigned.

 In order to reproduce the issue while avoiding the generation of excessive
 NFS usage, I wrote the following kernel module that manually sets the
 counters in `struct nfsstats` to arbitrary values:

 ---
 /*
  * repr_nfsstats.c
  * PoC to reproduce kern/48426
  */
 #include &lt;sys/param.h&gt;
 #include &lt;sys/kernel.h&gt;
 #include &lt;sys/module.h&gt;
 #include &lt;nfs/rpcv2.h&gt;
 #include &lt;nfs/nfs.h&gt;

 MODULE(MODULE_CLASS_MISC, repr_nfsstats, NULL);

 extern struct nfsstats nfsstats;

 void
 set_nfsstats(int value)
 {
     int i;

     for (i = 0; i &lt; NFSSTATS_NPROCS; i++) {
         nfsstats.rpccnt[i] = value;
         nfsstats.srvrpccnt[i] = value;
     }

     nfsstats.attrcache_hits = value;
     nfsstats.attrcache_misses = value;
     nfsstats.lookupcache_hits = value;
     nfsstats.lookupcache_misses = value;
     nfsstats.direofcache_hits = value;
     nfsstats.direofcache_misses = value;
     nfsstats.biocache_reads = value;
     nfsstats.read_bios = value;
     nfsstats.read_physios = value;
     nfsstats.biocache_writes = value;
     nfsstats.write_bios = value;
     nfsstats.write_physios = value;
     nfsstats.biocache_readlinks = value;
     nfsstats.readlink_bios = value;
     nfsstats.biocache_readdirs = value;
     nfsstats.readdir_bios = value;
     nfsstats.rpcretries = value;
     nfsstats.srvrpc_errs = value;
     nfsstats.srv_errs = value;
     nfsstats.rpcrequests = value;
     nfsstats.rpctimeouts = value;
     nfsstats.rpcunexpected = value;
     nfsstats.rpcinvalid = value;
     nfsstats.srvcache_inproghits = value;
     nfsstats.srvcache_idemdonehits = value;
     nfsstats.srvcache_nonidemdonehits = value;
     nfsstats.srvcache_misses = value;
     nfsstats.__srvnqnfs_leases = value;
     nfsstats.__srvnqnfs_maxleases = value;
     nfsstats.__srvnqnfs_getleases = value;
     nfsstats.srvvop_writes = value;
 }

 int
 repr_nfsstats_modcmd(modcmd_t cmd, void *data)
 {
     switch(cmd) {
     case MODULE_CMD_INIT:
         // Set counters to LONG_MAX+1
         set_nfsstats(2147483648);
         break;
     case MODULE_CMD_FINI:
         set_nfsstats(0);
         break;
     case MODULE_CMD_STAT:
         return ENOTTY;
         break;
     default:
         return ENOTTY;
     }
     return (0);
 }
 ---

 These are the results before and after loading the module:

 ---
 netbsd# /usr/bin/nfsstat
 Client Info:
 RPC Counts: (0 calls)
       null         getattr         setattr          lookup          access
          0  0%           0  0%           0  0%           0  0%           0  0%
   readlink            read           write          create           mkdir
          0  0%           0  0%           0  0%           0  0%           0  0%
    symlink           mknod          remove           rmdir          rename
          0  0%           0  0%           0  0%           0  0%           0  0%
       link         readdir     readdirplus          fsstat          fsinfo
          0  0%           0  0%           0  0%           0  0%           0  0%
   pathconf          commit
          0  0%           0  0%
 RPC Info:
    timeout         invalid      unexpected         retries        requests
          0               0               0               0               0
 Cache Info:
  attrcache     lookupcache            read           write        readlink
          0  0%           0  0%           0  0%           0  0%           0  0%
    readdir     direofcache
          0  0%           0  0%

 Server Info:
 RPC Counts: (0 calls)
       null         getattr         setattr          lookup          access
          0  0%           0  0%           0  0%           0  0%           0  0%
   readlink            read           write          create           mkdir
          0  0%           0  0%           0  0%           0  0%           0  0%
    symlink           mknod          remove           rmdir          rename
          0  0%           0  0%           0  0%           0  0%           0  0%
       link         readdir     readdirplus          fsstat          fsinfo
          0  0%           0  0%           0  0%           0  0%           0  0%
   pathconf          commit
          0  0%           0  0%
 Server Errors:
 RPC errors          faults
          0               0
 Server Cache Stats:
 inprogress            idem        non-idem          misses
          0               0               0               0
 Server Write Gathering:
     writes       write RPC       OPs saved
          0               0               0  0%
 netbsd# modload ./repr_nfsstats.kmod 
 netbsd# /usr/bin/nfsstat
 Client Info:
 RPC Counts: (-49392123904 calls)
       null         getattr         setattr          lookup          access
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
   readlink            read           write          create           mkdir
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
    symlink           mknod          remove           rmdir          rename
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
       link         readdir     readdirplus          fsstat          fsinfo
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
   pathconf          commit
 -2147483648  4%  -2147483648  4%
 RPC Info:
    timeout         invalid      unexpected         retries        requests
 -2147483648     -2147483648     -2147483648     -2147483648     -2147483648
 Cache Info:
  attrcache     lookupcache            read           write        readlink
 -2147483648  0%  -2147483648  0%           0  0%           0  0%           0  0%
    readdir     direofcache
          0  0%  -2147483648  0%

 Server Info:
 RPC Counts: (-49392123904 calls)
       null         getattr         setattr          lookup          access
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
   readlink            read           write          create           mkdir
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
    symlink           mknod          remove           rmdir          rename
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
       link         readdir     readdirplus          fsstat          fsinfo
 -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%  -2147483648  4%
   pathconf          commit
 -2147483648  4%  -2147483648  4%
 Server Errors:
 RPC errors          faults
 -2147483648     -2147483648
 Server Cache Stats:
 inprogress            idem        non-idem          misses
 -2147483648     -2147483648     -2147483648     -2147483648
 Server Write Gathering:
     writes       write RPC       OPs saved
 -2147483648     -2147483648               0  0%
 ---

 By changing "d" conversion specifier to "u", nfsstat counters will never
 be negative. These are the results of nfsstat after the application of the
 patch listed in the bottom of this PR:

 ---
 netbsd# ./nfsstat
 Client Info:
 RPC Counts: (18446744024317427712 calls)
       null         getattr         setattr          lookup          access
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
   readlink            read           write          create           mkdir
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
    symlink           mknod          remove           rmdir          rename
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
       link         readdir     readdirplus          fsstat          fsinfo
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
   pathconf          commit
 2147483648  4%  2147483648  4%
 RPC Info:
    timeout         invalid      unexpected         retries        requests
 2147483648      2147483648      2147483648      2147483648      2147483648
 Cache Info:
  attrcache     lookupcache            read           write        readlink
 2147483648  0%  2147483648  0%           0  0%           0  0%           0  0%
    readdir     direofcache
          0  0%  2147483648  0%

 Server Info:
 RPC Counts: (18446744024317427712 calls)
       null         getattr         setattr          lookup          access
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
   readlink            read           write          create           mkdir
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
    symlink           mknod          remove           rmdir          rename
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
       link         readdir     readdirplus          fsstat          fsinfo
 2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%  2147483648  4%
   pathconf          commit
 2147483648  4%  2147483648  4%
 Server Errors:
 RPC errors          faults
 2147483648      2147483648
 Server Cache Stats:
 inprogress            idem        non-idem          misses
 2147483648      2147483648      2147483648      2147483648
 Server Write Gathering:
     writes       write RPC       OPs saved
 2147483648      2147483648               0  0%
 ---

 This is my suggested patch to resolve the issue:

 Index: nfsstat.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/nfsstat/nfsstat.c,v
 retrieving revision 1.24
 diff -u -r1.24 nfsstat.c
 --- nfsstat.c	6 Sep 2011 18:19:58 -0000	1.24
 +++ nfsstat.c	24 Apr 2014 17:48:26 -0000
 @@ -217,13 +217,13 @@
  		for (i = 0; i &lt; NFS_NPROCS; i++)
  			total += nfsstats.rpccnt[i];
  		printf("Client <a class="moz-txt-link-freetext" href="Info:\n">Info:\n</a>");
 -		printf("RPC Counts: (%lld call%s)\n", (long long)total,
 +		printf("RPC Counts: (%llu call%s)\n", (long long)total,
  		    total == 1 ? "" : "s");

  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "null", "getattr", "setattr", "lookup", "access");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_NULL]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_GETATTR]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_SETATTR]),
 @@ -232,7 +232,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "readlink", "read", "write", "create", "mkdir");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READLINK]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READ]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_WRITE]),
 @@ -241,7 +241,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "symlink", "mknod", "remove", "rmdir", "rename");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_SYMLINK]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_MKNOD]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_REMOVE]),
 @@ -250,7 +250,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "link", "readdir", "readdirplus", "fsstat", "fsinfo");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_LINK]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READDIR]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_READDIRPLUS]),
 @@ -258,14 +258,14 @@
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_FSINFO]));
  		printf("%10s  %14s\n",
  		    "pathconf", "commit");
 -		printf("%10d %2d%%  %10d %2d%%\n",
 +		printf("%10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_PATHCONF]),
  		    RPCSTAT(nfsstats.rpccnt[NFSPROC_COMMIT]));

  		printf("RPC <a class="moz-txt-link-freetext" href="Info:\n">Info:\n</a>");
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "timeout", "invalid", "unexpected", "retries", "requests");
 -		printf("%10d  %14d  %14d  %14d  %14d\n",
 +		printf("%10u  %14u  %14u  %14u  %14u\n",
  		    nfsstats.rpctimeouts,
  		    nfsstats.rpcinvalid,
  		    nfsstats.rpcunexpected,
 @@ -276,7 +276,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "attrcache", "lookupcache", "read", "write", "readlink");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    NUMPCT(nfsstats.attrcache_hits,
  			nfsstats.attrcache_misses),
  		    NUMPCT(nfsstats.lookupcache_hits,
 @@ -289,7 +289,7 @@
  			nfsstats.readlink_bios));
  		printf("%10s  %14s\n",
  		    "readdir", "direofcache");
 -		printf("%10d %2d%%  %10d %2d%%\n",
 +		printf("%10u %2u%%  %10u %2u%%\n",
  		    NUMPCT(nfsstats.biocache_readdirs - nfsstats.readdir_bios,
  			nfsstats.readdir_bios),
  		    NUMPCT(nfsstats.direofcache_hits,
 @@ -304,13 +304,13 @@
  		for (i = 0; i &lt; NFS_NPROCS; i++)
  			total += nfsstats.srvrpccnt[i];
  		printf("Server <a class="moz-txt-link-freetext" href="Info:\n">Info:\n</a>");
 -		printf("RPC Counts: (%lld call%s)\n", (long long)total,
 +		printf("RPC Counts: (%llu call%s)\n", (long long)total,
  		    total == 1 ? "" : "s");

  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "null", "getattr", "setattr", "lookup", "access");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_NULL]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_GETATTR]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_SETATTR]),
 @@ -319,7 +319,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "readlink", "read", "write", "create", "mkdir");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READLINK]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READ]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_WRITE]),
 @@ -328,7 +328,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "symlink", "mknod", "remove", "rmdir", "rename");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_SYMLINK]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_MKNOD]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_REMOVE]),
 @@ -337,7 +337,7 @@
  		printf("%10s  %14s  %14s  %14s  %14s\n",
  		    "link", "readdir", "readdirplus", "fsstat", "fsinfo");
  		printf(
 -	    "%10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%  %10d %2d%%\n",
 +	    "%10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_LINK]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READDIR]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_READDIRPLUS]),
 @@ -345,20 +345,20 @@
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_FSINFO]));
  		printf("%10s  %14s\n",
  		    "pathconf", "commit");
 -		printf("%10d %2d%%  %10d %2d%%\n",
 +		printf("%10u %2u%%  %10u %2u%%\n",
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_PATHCONF]),
  		    RPCSTAT(nfsstats.srvrpccnt[NFSPROC_COMMIT]));

  		printf("Server Errors:\n");
  		printf("%10s  %14s\n",
  		    "RPC errors", "faults");
 -		printf("%10d  %14d\n",
 +		printf("%10u  %14u\n",
  		    nfsstats.srvrpc_errs,
  		    nfsstats.srv_errs);
  		printf("Server Cache Stats:\n");
  		printf("%10s  %14s  %14s  %14s\n",
  		    "inprogress", "idem", "non-idem", "misses");
 -		printf("%10d  %14d  %14d  %14d\n",
 +		printf("%10u  %14u  %14u  %14u\n",
  		    nfsstats.srvcache_inproghits,
  		    nfsstats.srvcache_idemdonehits,
  		    nfsstats.srvcache_nonidemdonehits,
 @@ -366,7 +366,7 @@
  		printf("Server Write Gathering:\n");
  		printf("%10s  %14s  %14s\n",
  		    "writes", "write RPC", "OPs saved");
 -		printf("%10d  %14d  %14d %2d%%\n",
 +		printf("%10u  %14u  %14u %2u%%\n",
  		    nfsstats.srvvop_writes,
  		    nfsstats.srvrpccnt[NFSPROC_WRITE],
  		    NUMPCT(
 @@ -422,14 +422,14 @@
  		if (printall || clientinfo) {
  			printf("Client:");
  			for (i = 0; i &lt; NSHORTPROC; i++)
 -				printf(" %7d",
 +				printf(" %7u",
  				    current.client[i] - last.client[i]);
  			printf("\n");
  		}
  		if (printall || serverinfo) {
  			printf("Server:");
  			for (i = 0; i &lt; NSHORTPROC; i++)
 -				printf(" %7d",
 +				printf(" %7u",
  				    current.server[i] - last.server[i]);
  			printf("\n");
  		}
 </pre>
     <br class="Apple-interchange-newline">
   </body>
 </html>

 --------------020808060203020807030806--

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48426 CVS commit: src/usr.bin/nfsstat
Date: Thu, 24 Apr 2014 14:40:36 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu Apr 24 18:40:36 UTC 2014

 Modified Files:
 	src/usr.bin/nfsstat: nfsstat.c

 Log Message:
 PR/48426: Dimitris Karagkasidis: Make nfsstat use unsigned numbers.


 To generate a diff of this commit:
 cvs rdiff -u -r1.24 -r1.25 src/usr.bin/nfsstat/nfsstat.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48426 CVS commit: src/sys/nfs
Date: Thu, 24 Apr 2014 14:43:02 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu Apr 24 18:43:02 UTC 2014

 Modified Files:
 	src/sys/nfs: nfs.h

 Log Message:
 PR/48426: Dimitris Karagkasidis: Convert to sized, unsigned types.
 Ideally we could use uint64_t, but for compatibility and performance
 we don't (for now)


 To generate a diff of this commit:
 cvs rdiff -u -r1.73 -r1.74 src/sys/nfs/nfs.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 13 Jul 2014 04:17:22 +0000
State-Changed-Why:
Christos committed it; ok to close?


From: Greg Oster <oster@cs.usask.ca>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/48426 (nfsstat shows negative counts)
Date: Tue, 15 Jul 2014 20:59:45 -0600

 On Sun, 13 Jul 2014 04:17:22 +0000 (UTC)
 dholland@NetBSD.org wrote:

 > Synopsis: nfsstat shows negative counts
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dholland@NetBSD.org
 > State-Changed-When: Sun, 13 Jul 2014 04:17:22 +0000
 > State-Changed-Why:
 > Christos committed it; ok to close?

 Yes.  Fix sounds fine to me.  Thanks Dimitris, Christos!

 Later...

 Greg Oster

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 16 Jul 2014 06:32:00 +0000
State-Changed-Why:
Approved by submitter.

(if anyone wants this fix in -6, let me or Christos know)


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.