NFSv2 Wrong FS Size

Dan Nelson dnelson at allantgroup.com
Tue Feb 3 13:53:34 PST 2009


In the last episode (Feb 03), John Morgan Salomon said:
> On 3 Feb 2009, at 19:21, John Morgan Salomon wrote:
> > Hi there,
> >
> > I'm facing an odd problem with an NFSv2 mount.  I'm using userland  
> > nfsd from a Buffalo TeraStation Pro v1 NAS, running PPC Linux 2.4.20.
> >
> > root at LEVIATHAN:~# uname -a
> > Linux LEVIATHAN 2.4.20_mvl31-ppc_terastation #3 Tue Jul 18 09:29:11 JST 2006 ppc GNU/Linux
> >
> > I am sharing the following filesystem:
> >
> > root at LEVIATHAN:~# df -k
> > Filesystem           1K-blocks      Used Available Use% Mounted on
> > <local filesystems>
> > /dev/md1             1755708928 979032844 776676084  56% /mnt/array1
> >
> > Mounting this on a FreeBSD 7.1 client:
> >
> > behemoth# mount /data
> > behemoth# df -k
> > Filesystem                    1024-blocks        Used     Avail  
> > Capacity  Mounted on
> > <local filesystems>
> > 192.168.2.11:/mnt/array1/data  -391774720 -1168450804 776676084    
> 
> I did more digging and found this:
> 
> http://www.freebsd.org/projects/bigdisk/index.html
> 
> "An audit is needed to make sure that all reported fields are 64-bit  
> clean. There are reports with certain fields being incorrect or  
> negative with NFS volumes, which could either be an NFS or df problem."
> 
> Not sure where to go now, as the last entry in that project is dated  
> 2005 -- again, any tips welcome.

The real problem is that NFSv2 only provides a 32-bit field for filesystem
size, and multiplies that by the reported blocksize.  Most NFS servers claim
512-byte blocks no matter what the underlying filessytem has, so in your
case that would result in the filesystem size being reported as
1755708928*1024/512 = 3511417856 blocks.  This number is larger than 2^31,
which techinically isn't a problem because the NFSv2 spec says that the
filesystem size is unsigned.  FreeBSD treats it as signed, though, so it can
display "negative" free space when root starts using its 8% reserve, so your
unsigned 3511417856 gets printed as a signed -783549440, which messes
everything up.

NFSv3 uses 64-bit fields for those size values, so just mount with NFSv3
(which actually is the default on FreeBSD; maybe you have it disabled on
your TeraStation for some reason), and you should get correct filesystem
stats, as well as better performance and the ability to work with files over
2gb.

Alternatively, you could rebuild "df" to print its numbers as unsigned
instead of signed.  Just watch out if your local filesystems start eating
into their 8% reserve, since they'll start reporting huge values.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list