But, I cannot see where you are finding the info in
Documentation/iostats.txt, Simon.
A. Costa: From scanning the source code (where the count of blocks is
"part_nr_sects_read(part) >> 1" in block/genhd.c::show_partition() --
I assume a sector is 512 B), I'm reasonably sure that /proc/partitions
is giving us 1024-byte blocks. Here's my experiment:
$ cat /proc/partitions | grep sdc1
8 33 1465136128 sdc1
$ df -B 1024 | grep sdc1
/dev/sdc1 1464421040 447518960 1016902080 31% /run/media/mtk/CNM1500
$ bc -q
1465136128 * 1000000 / 1464421040
1000488
In other words, the difference between the two values is just under
0.05%. Looking at the source code of 'df', it gets it's information
using the statvfs() function which in turn calls statfs(2). I
confirmed that direct statfs(2) calls return information precisely
consistent with the output of df.
The question is still why there is a difference between blocks as
reported by statfs() and /proc/partitions, with the latter always a
little bigger than the former. Well, looking at the statfs()
implementation (fs/statfs.c), the relevant field pulled from kernel
data structures is 'f_blocks', and looking in (for example),
fs/ext4/super.c::ext4_statfs(),, I find:
buf->f_blocks = ext4_blocks_count(es) - EXT4_C2B(sbi, overhead);
"sbi" is super block info.
That looks to me to mean that stafs() is deducting a small amount from
the number of blocks, for the overhead of the super block info, and
without digging too much further, I'm going to guess that that might
explain the difference from /proc/partitions. However, that's all
fairly speculative, so I'm not confident enough to put too much detail
into the page. However, I did apply the small patch below:
Cheers,
Michael
diff --git a/man5/proc.5 b/man5/proc.5
index e40dd4d..95eb743 100644
--- a/man5/proc.5
+++ b/man5/proc.5
@@ -2160,7 +2160,7 @@ socket and Path is the bound path (if any) of the socket.
.TP
.I /proc/partitions
Contains major and minor numbers of each partition as well as number
-of blocks and partition name.
+of 1024-byte blocks and partition name.
.TP
.I /proc/pci
This is a listing of all PCI devices found during kernel initialization