Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Nov 2003 14:37:21 +0000
From:      Peter Edwards <peter.edwards@openet-telecom.com>
To:        ticso@cicely.de
Cc:        Kris Kennaway <kris@obsecurity.org>
Subject:   Re: Who needs these silly statfs changes...
Message-ID:  <3FB4E8A1.6090402@openet-telecom.com>
In-Reply-To: <20031113131057.GD22887@cicely12.cicely.de>
References:  <20031113020400.GA44619@xor.obsecurity.org> <20031113074425.GC39616@cirb503493.alcatel.com.au> <20031113085418.GA47995@xor.obsecurity.org> <20031113131057.GD22887@cicely12.cicely.de>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------010306020905030705080501
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Bernd Walter wrote:

>On Thu, Nov 13, 2003 at 12:54:18AM -0800, Kris Kennaway wrote:
>  
>
>>On Thu, Nov 13, 2003 at 06:44:25PM +1100, Peter Jeremy wrote:
>>    
>>
>>>On Wed, Nov 12, 2003 at 06:04:00PM -0800, Kris Kennaway wrote:
>>>      
>>>
>>>>...my sparc machine reports that my i386 nfs server has 15 exabytes of
>>>>free space!
>>>>
>>>>enigma# df -k
>>>>Filesystem  1K-blocks     Used             Avail Capacity  Mounted on
>>>>rot13:/mnt2  56595176 54032286 18014398507517260     0%    /rot13/mnt2
>>>>        
>>>>
>>>18014398507517260 = 2^54 - 1964724.  and 2^54KB == 2^64 bytes.  Is it
>>>possible that rot13:/mnt2 has negative free space?  (ie it's into the
>>>8-10% reserved area).
>>>      
>>>
>>Yes, that's precisely what it is..the bug is either in df or the
>>kernel (I suspect the latter, i.e. something in the nfs code).
>>    
>>
>
>And it's nothing new - I'm seeing this since several years now.
>  
>

The NFS protocols have unsigned fields where statfs has signed 
equivalents: NFS can't represent negative available disk space ( Without 
the knowledge of the underlying filesystem on the server, negative free 
space is a little nonsensical anyway, I suppose)

The attached patch stops the NFS server assigning negative values to 
unsigned fields in the statfs response, and works against my local 
solaris box.  Seem reasonable?

--------------010306020905030705080501
Content-Type: text/plain;
 name="statfs.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="statfs.txt"

Index: nfs_serv.c
===================================================================
RCS file: /pub/FreeBSD/development/FreeBSD-CVS/src/sys/nfsserver/nfs_serv.c,v
retrieving revision 1.137
diff -u -r1.137 nfs_serv.c
--- nfs_serv.c	24 Oct 2003 18:36:49 -0000	1.137
+++ nfs_serv.c	14 Nov 2003 13:27:42 -0000
@@ -3812,7 +3812,7 @@
 		tval = (u_quad_t)sf->f_bfree;
 		tval *= (u_quad_t)sf->f_bsize;
 		txdr_hyper(tval, &sfp->sf_fbytes);
-		tval = (u_quad_t)sf->f_bavail;
+		tval = sf->f_bavail > 0 ? (u_quad_t)sf->f_bavail : 0;
 		tval *= (u_quad_t)sf->f_bsize;
 		txdr_hyper(tval, &sfp->sf_abytes);
 		sfp->sf_tfiles.nfsuquad[0] = 0;
@@ -3827,7 +3827,8 @@
 		sfp->sf_bsize = txdr_unsigned(sf->f_bsize);
 		sfp->sf_blocks = txdr_unsigned(sf->f_blocks);
 		sfp->sf_bfree = txdr_unsigned(sf->f_bfree);
-		sfp->sf_bavail = txdr_unsigned(sf->f_bavail);
+		sfp->sf_bavail = txdr_unsigned(sf->f_bavail > 0 ?
+		    sf->f_bavail : 0);
 	}
 nfsmout:
 	if (vp)

--------------010306020905030705080501--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FB4E8A1.6090402>