comments on st_blksize and f_bsize for 2.5
PATCH 1/1 comments on st_blksize and f_bsize for 2.5
Since a few applications, and the linux manpages, seem to not really understand what these are for, they need comments like SUSv2 has for them. A larger discussion will be provided if requested.
Signature · 1 line
Hans
Hello!
Here's the patch that adds necessary comments
===== include/asm-alpha/stat.h 1.1 vs edited =====
include/asm-alpha/stat.h +2 -2
@@ -13,7 +13,7 @@unsigned long st_atime;unsigned long st_mtime;unsigned long st_ctime; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ int st_blocks;unsigned int st_flags;unsigned int st_gen;
@@ -31,7 +31,7 @@unsigned long st_atime;unsigned long st_mtime;unsigned long st_ctime; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ int st_blocks;unsigned int st_flags;unsigned int st_gen;
===== include/asm-alpha/statfs.h 1.1 vs edited =====
include/asm-alpha/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {int f_type; -int f_bsize; +int f_bsize;/* Filesystem blocksize */ int f_blocks;int f_bfree;int f_bavail;
===== include/asm-arm/stat.h 1.4 vs edited =====
include/asm-arm/stat.h +2 -2
@@ -28,7 +28,7 @@unsigned short st_rdev;unsigned short __pad2;unsigned long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
@@ -73,7 +73,7 @@unsigned char __pad3[4 ];long long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ #if defined(__ARMEB__)unsigned long __pad4;/* Future possible st_blocks hi bits */
===== include/asm-arm/statfs.h 1.1 vs edited =====
include/asm-arm/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-cris/stat.h 1.3 vs edited =====
include/asm-cris/stat.h +2 -2
@@ -31,7 +31,7 @@unsigned short st_rdev;unsigned short __pad2;unsigned long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
@@ -63,7 +63,7 @@unsigned char __pad3[10 ];long long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;/* Number 512-byte blocks allocated. */ unsigned long __pad4;/* future possible st_blocks high bits */
===== include/asm-cris/statfs.h 1.1 vs edited =====
include/asm-cris/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-i386/stat.h 1.2 vs edited =====
include/asm-i386/stat.h +2 -2
@@ -26,7 +26,7 @@unsigned short st_rdev;unsigned short __pad2;unsigned long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
@@ -58,7 +58,7 @@unsigned char __pad3[10 ];long long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;/* Number 512-byte blocks allocated. */ unsigned long __pad4;/* future possible st_blocks high bits */
===== include/asm-i386/statfs.h 1.1 vs edited =====
include/asm-i386/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-ia64/stat.h 1.2 vs edited =====
include/asm-ia64/stat.h +2 -2
@@ -22,7 +22,7 @@unsigned long st_mtime_nsec;unsigned long st_ctime;unsigned long st_ctime_nsec; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ long st_blocks;unsigned long __unused[3 ]; };
@@ -42,7 +42,7 @@unsigned long st_atime;unsigned long st_mtime;unsigned long st_ctime; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ int st_blocks;unsigned int __unused1;unsigned int __unused2;
===== include/asm-ia64/statfs.h 1.1 vs edited =====
include/asm-ia64/statfs.h +1 -1
@@ -13,7 +13,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-m68k/stat.h 1.3 vs edited =====
include/asm-m68k/stat.h +2 -2
@@ -26,7 +26,7 @@unsigned short st_rdev;unsigned short __pad2;unsigned long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long __unused1;
@@ -60,7 +60,7 @@unsigned char __pad3[2 ];long long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long __pad4;/* future possible st_blocks high bits */ unsigned long st_blocks;/* Number 512-byte blocks allocated. */
===== include/asm-m68k/statfs.h 1.1 vs edited =====
include/asm-m68k/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-mips/stat.h 1.3 vs edited =====
include/asm-mips/stat.h +3 -3
@@ -15,7 +15,7 @@unsigned int st_atime, st_res1;unsigned int st_mtime, st_res2;unsigned int st_ctime, st_res3; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ int st_blocks;unsigned int st_unused0[2 ]; };
@@ -42,7 +42,7 @@long st_mtime_nsec;time_t st_ctime;long st_ctime_nsec; -long st_blksize; +long st_blksize;/* Optimal I/O size */ long st_blocks;long st_pad4[14 ]; };
@@ -83,7 +83,7 @@time_t st_ctime;unsigned long reserved2;/* Reserved for st_ctime expansion */ -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_pad2;long long st_blocks;
===== include/asm-mips/statfs.h 1.1 vs edited =====
include/asm-mips/statfs.h +1 -1
@@ -23,7 +23,7 @@struct statfs {long f_type;#define f_fstyp f_type -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_frsize;/* Fragment size - unsupported */ long f_blocks;long f_bfree;
===== include/asm-mips64/stat.h 1.3 vs edited =====
include/asm-mips64/stat.h +3 -3
@@ -24,7 +24,7 @@unsigned int st_atime, st_res1;unsigned int st_mtime, st_res2;unsigned int st_ctime, st_res3; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ int st_blocks;unsigned int st_unused[2 ]; };
@@ -47,7 +47,7 @@int reserved1;compat_time_t st_ctime;int reserved2; -int st_blksize; +int st_blksize;/* Optimal I/O size */ int st_blocks;int st_pad4[14 ]; };
@@ -83,7 +83,7 @@unsigned int st_ctime;unsigned int st_ctime_nsec; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ unsigned int st_pad2;unsigned long st_blocks;
===== include/asm-mips64/statfs.h 1.2 vs edited =====
include/asm-mips64/statfs.h +1 -1
@@ -21,7 +21,7 @@struct statfs {long f_type;#define f_fstyp f_type -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_frsize;/* Fragment size - unsupported */ long f_blocks;long f_bfree;
===== include/asm-parisc/stat.h 1.4 vs edited =====
include/asm-parisc/stat.h +3 -3
@@ -18,7 +18,7 @@unsigned int st_mtime_nsec;time_t st_ctime;unsigned int st_ctime_nsec; -int st_blksize; +int st_blksize;/* Optimal I/O size */ int st_blocks;unsigned int __unused1;/* ACL stuff */ dev_t __unused2;/* network */
@@ -53,7 +53,7 @@unsigned int st_spare2;time_t st_ctime;unsigned int st_spare3; -int st_blksize; +int st_blksize;/* Optimal I/O size */ __u64 st_blocks;unsigned int __unused1;/* ACL stuff */ dev_t __unused2;/* network */
@@ -85,7 +85,7 @@unsigned long long st_rdev;unsigned int __pad2;signed long long st_size; -signed int st_blksize; +signed int st_blksize;/* Optimal I/O size */ signed long long st_blocks;signed int st_atime;
===== include/asm-parisc/statfs.h 1.1 vs edited =====
include/asm-parisc/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-ppc/stat.h 1.4 vs edited =====
include/asm-ppc/stat.h +1 -1
@@ -30,7 +30,7 @@gid_t st_gid;dev_t st_rdev;off_t st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
===== include/asm-ppc/statfs.h 1.3 vs edited =====
include/asm-ppc/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-ppc64/stat.h 1.4 vs edited =====
include/asm-ppc64/stat.h +1 -1
@@ -19,7 +19,7 @@gid_t st_gid;dev_t st_rdev;off_t st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
===== include/asm-ppc64/statfs.h 1.1 vs edited =====
include/asm-ppc64/statfs.h +1 -1
@@ -15,7 +15,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-s390/stat.h 1.3 vs edited =====
include/asm-s390/stat.h +2 -2
@@ -34,7 +34,7 @@unsigned short st_rdev;unsigned short __pad2;unsigned long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
@@ -65,7 +65,7 @@unsigned short st_rdev;unsigned int __pad3;long long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned char __pad4[4 ];unsigned long __pad5;/* future possible st_blocks high bits */ unsigned long st_blocks;/* Number 512-byte blocks allocated. */
===== include/asm-s390/statfs.h 1.1 vs edited =====
include/asm-s390/statfs.h +1 -1
@@ -19,7 +19,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-s390x/stat.h 1.2 vs edited =====
include/asm-s390x/stat.h +1 -1
@@ -25,7 +25,7 @@unsigned long st_mtime_nsec;unsigned long st_ctime;unsigned long st_ctime_nsec; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ long st_blocks;unsigned long __unused[3 ]; };
===== include/asm-s390x/statfs.h 1.1 vs edited =====
include/asm-s390x/statfs.h +1 -1
@@ -19,7 +19,7 @@struct statfs {int f_type; -int f_bsize; +int f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-sh/stat.h 1.3 vs edited =====
include/asm-sh/stat.h +2 -2
@@ -26,7 +26,7 @@unsigned short st_rdev;unsigned short __pad2;unsigned long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long st_atime_nsec;
@@ -72,7 +72,7 @@unsigned char __pad3[4 ];long long st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ #if defined(__BIG_ENDIAN__)unsigned long __pad4;/* Future possible st_blocks hi bits */
===== include/asm-sh/statfs.h 1.1 vs edited =====
include/asm-sh/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-sparc/stat.h 1.2 vs edited =====
include/asm-sparc/stat.h +2 -2
@@ -33,7 +33,7 @@unsigned long st_mtime_nsec;long st_ctime;unsigned long st_ctime_nsec; -long st_blksize; +long st_blksize;/* Optimal I/O size */ long st_blocks;unsigned long __unused4[2 ]; };
@@ -58,7 +58,7 @@unsigned char __pad3[8 ];long long st_size; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ unsigned char __pad4[8 ];unsigned int st_blocks;
===== include/asm-sparc/statfs.h 1.1 vs edited =====
include/asm-sparc/statfs.h +1 -1
@@ -12,7 +12,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-sparc64/stat.h 1.5 vs edited =====
include/asm-sparc64/stat.h +2 -2
@@ -16,7 +16,7 @@time_t st_atime;time_t st_mtime;time_t st_ctime; -off_t st_blksize; +off_t st_blksize;/* Optimal I/O size */ off_t st_blocks;unsigned long __unused4[2 ]; };
@@ -42,7 +42,7 @@unsigned char __pad3[8 ];long long st_size; -unsigned int st_blksize; +unsigned int st_blksize;/* Optimal I/O size */ unsigned char __pad4[8 ];unsigned int st_blocks;
===== include/asm-sparc64/statfs.h 1.3 vs edited =====
include/asm-sparc64/statfs.h +1 -1
@@ -12,7 +12,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-v850/stat.h 1.3 vs edited =====
include/asm-v850/stat.h +2 -2
@@ -25,7 +25,7 @@__kernel_gid_t st_gid;__kernel_dev_t st_rdev;__kernel_off_t st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;unsigned long st_atime;unsigned long __unused1;
@@ -55,7 +55,7 @@unsigned long __unused3;__kernel_loff_t st_size; -unsigned long st_blksize; +unsigned long st_blksize;/* Optimal I/O size */ unsigned long st_blocks;/* No. of 512-byte blocks allocated */ unsigned long __unused4;/* future possible st_blocks high bits */
===== include/asm-v850/statfs.h 1.1 vs edited =====
include/asm-v850/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/asm-x86_64/stat.h 1.2 vs edited =====
include/asm-x86_64/stat.h +1 -1
@@ -14,7 +14,7 @@unsigned int __pad0;unsigned long st_rdev;long st_size; -long st_blksize; +long st_blksize;/* Optimal I/O size */ long st_blocks;/* Number 512-byte blocks allocated. */ unsigned long st_atime;
===== include/asm-x86_64/statfs.h 1.1 vs edited =====
include/asm-x86_64/statfs.h +1 -1
@@ -11,7 +11,7 @@struct statfs {long f_type; -long f_bsize; +long f_bsize;/* Filesystem blocksize */ long f_blocks;long f_bfree;long f_bavail;
===== include/linux/stat.h 1.3 vs edited =====
include/linux/stat.h +1 -1
@@ -68,7 +68,7 @@struct timespec atime;struct timespec mtime;struct timespec ctime; -unsigned long blksize; +unsigned long blksize;/* Optimal I/O size */ unsigned long blocks; };
include/asm-alpha/statfs.h line 14
Quoted 7 lines · Hans Reiser
Since a few applications, and the linux manpages, seem to not really understand what these are for, they need comments like SUSv2 has for them. A larger discussion will be provided if requested.
include/asm-alpha/statfs.h +2
-0+unsigned int st_blksize;/* Optimal I/O size */ +int f_bsize;/* Filesystem blocksize */
Yes, discussion - I wouldnt mind seeing details.
The trivial part is st_blksize: all agree. Quoting the man page:
The value st_blksize gives the "preferred" blocksize for efficient file system I/O. (Writing to a file in smaller chunks may cause an inefficient read-modify-rewrite.)
The nontrivial part is f_bsize. As far as I can see BSD and SYSV and SUS all differ. And there are the use in struct statfs and the use in struct statvfs that are nonequivalent.
Maybe BSD f_iosize, f_bsize in statfs corresponds to SYSV f_bsize, f_frsize in statfs. Linux is again a bit different.
Andries
Hello!
Quoted 6 lines · Andries Brouwer
The trivial part is
st_blksize: all agree.
Quoting the man page:
The valuest_blksizegives the "preferred" blocksize for efficient file system I/O. (Writing to a file in smaller chunks may cause an inefficient read-modify-rewrite.)
Quoted 7 lines
The nontrivial part is
f_bsize. As far as I can see BSD and SYSV and SUS all differ. And there are the use in struct statfs and the use in struct statvfs that are nonequivalent.
Maybe BSDf_iosize,f_bsizein statfs corresponds to SYSVf_bsize,f_frsizein statfs. Linux is again a bit different.
Traditionally in Linux f_bsize in struct statfs is used as FS block size. (e.g. df calculates fs capacity by multiplying amount of blocks on fs by f_bsize).
Actually, this is the only field in struct statfs that holds any data regarding fs blocksize. (well, some arches have f_frsize, but it is marked as unused).
Bye,
Oleg
Quoted 22 lines · Andries Brouwer
Quoted 8 lines · Hans Reiser
Since a few applications, and the linux manpages, seem to not really understand what these are for, they need comments like SUSv2 has for them. A larger discussion will be provided if requested.
Review
Quoted 7 lines
(quoted diff) +2
-0+ unsigned int st_blksize; /* Optimal I/O size */ + int f_bsize; /* Filesystem blocksize */Yes, discussion - I wouldnt mind seeing details.
Quoted 7 lines
The trivial part is
st_blksize: all agree.
Quoting the man page:The value
st_blksizegives the "preferred" blocksize for efficient file system I/O. (Writing to a file in smaller chunks may cause an inefficient read-modify-rewrite.)
Oh my, I must confess that we read just the comment on the struct in the manpage:
blksize_t st_blksize; /* blocksize for filesystem
I/O */
and not the text below it which is correct if less clear than it could be.
How about using our comment on the struct on the manpage as it is more clear?
How about instead saying in the manpage body:
Historically, st_blksize was the block size, and applications would do I/O's at that size for greater efficiency of IO. Now, after some evolution, st_blksize represents the most efficient size of an IO to that file, and no longer always represents the actual size of blocks in the underlying filesystem.
Or you could even use the longer comment on the struct, but then I have always liked lng comments more than most....;-)
Signature · 1 line
Hans