Bug 24087 - statvfs f_bsize and f_bsize mixup
Summary: statvfs f_bsize and f_bsize mixup
Status: RESOLVED MOVED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.30
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-11 09:44 UTC by Björn Jacke
Modified: 2019-01-11 11:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Jacke 2019-01-11 09:44:35 UTC
there is some confusion about the statvfs struct members f_bsize and f_frsize in glibc and/or the Linux man page.

POSIX says about those:
-----------------------
 unsigned long f_bsize    File system block size. 
 unsigned long f_frsize   Fundamental file system block size.

The description of "File system block size" and "Fundamental file system block size" was not made very good I think the FreeBSD man page describes this much nicer and clear:

FreeBSD says about those
------------------------
f_frsize   The size in bytes of the minimum unit of allocation on this filesystem. (This corresponds to the f_bsize member of struct statfs.)

f_bsize    The preferred length of I/O requests for files on this file system. (Corresponds to the f_iosize member of struct statfs.)


The Linux man page description is less helpful, I would even say it's misleading or incorrect:
  unsigned long  f_bsize;    /* Filesystem block size */
  unsigned long  f_frsize;   /* Fragment size */

From what I could see in the glibc code it looks to me that glibc implements statvfs in a way, that the statvfs struct f_bsize member is the same as the statfs struct t_bsize member, which would be incorrect then. I don't have a test setup to verify if it's implemented right or wrong because I only found filesystems with bsize and frsize being the same. Can you please check if the implementation needs fixing?

This problem popped up via a Samba bug, where we mixed up the statvfs bsize/frsize values due to the above mentioned documentation issue in the Linux man page (https://bugzilla.samba.org/show_bug.cgi?id=11810)
Comment 1 Florian Weimer 2019-01-11 11:16:46 UTC
You need to report issues with the manual pages to the man-pages project:

<https://www.kernel.org/doc/man-pages/>

They are not maintained by glibc.

Please note that the “preferred length of I/O requests for files on this file system” is very misleading.  It is not uncommon to values of many hundred kilobytes there (even megabytes).  There is no single preferred block size, it depends on sequential vs random access, cache sizes, and so on.