Bug 11810 - Wrong filesystem size reported to client (df)
Wrong filesystem size reported to client (df)
Status: NEW
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services
4.4.0
All Solaris
: P5 normal
: ---
Assigned To: Samba QA Contact
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-25 09:57 UTC by alexandre.lecuyer
Modified: 2016-03-25 09:57 UTC (History)
0 users

See Also:


Attachments
patch to add solaris_statvfs() (3.03 KB, application/mbox)
2016-03-25 09:57 UTC, alexandre.lecuyer
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description alexandre.lecuyer 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 :
f_blocks: 20971520
f_frsize: 512
f_bsize: 131072

Client side :
f_blocks: 20971520
f_frsize: 131072
f_bsize: 131072 

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.