The Samba-Bugzilla – Bug 11810
Wrong filesystem size reported to client (df)
Last modified: 2016-03-25 09:57:32 UTC
Created attachment 11939 [details]
patch to add solaris_statvfs()
We run samba on solaris or similar (illumos).
When mounting a share on a linux client, the filesystem size as reported by "df" is wrong :
Server side :
Filesystem Size Used Available Capacity Mounted on
testpool/test 10G 96K 10G 1% /testpool/test
Client side (size is wrong ):
Filesystem Size Used Avail Use% Mounted on
//10.6.2.4/testpool_test 2.5T 24M 2.5T 1% /cifs
We see this difference in the statvfs() syscall result :
Server side :
Client side :
f_bsize is the "preferred file system block size". It is populated with the value of ZFS's recordsize, which in this example is 128k (default value).
f_frsize is the supported block size, 512 bytes.
(other filesystems have the same values for bsize and frsize, and there is no issue in this case)
Now on the samba side, sys_statvfs will be either linux_statvfs or bsd_statvfs, detected at ./configure time. On solaris, samba will use linux_statvfs because solaris statvfs struct lacks f_iosize.
linux_statvfs does this :
statbuf->OptimalTransferSize = statvfs_buf.f_frsize;
statbuf->BlockSize = statvfs_buf.f_bsize;
Which does not match the manpage definition on solaris. BlockSize should be made equal to f_frsize, not f_bsize.
Recompiling with this change fixes the problem.
I attach a patch that adds a solaris_statvfs() method. If it is not the correct approach, I'll be happy to modify it or test any other change.