Bug#666972: manpages: 'man proc': /proc/partition block size and count method undocumented

2013-09-04 Thread Michael Kerrisk (man-pages)
On Wed, Aug 21, 2013 at 11:49 PM, Simon Paillard spaill...@debian.org wrote:
 Control: tag -1 +upstream

 On Mon, Apr 02, 2012 at 08:43:17PM -0400, A. Costa wrote:
 Package: manpages
 Version: 3.35-0.1
 Severity: normal

 Dear Maintainer,

 % man proc | grep -A 2 -n '/proc/partition'
 988:   /proc/partitions
 989-  Contains major and minor numbers of each partition as 
 well as number of
 990-  blocks and partition name.

 There's no mention of how many bytes are in a block, and no description of 
 how
 block numbers are counted.

 A full definition of fields is available in the kernel tree:
 http://lxr.linux.no/#linux+v3.5/Documentation/iostats.txt

 We can either just point to that doc in the manpage, or document all the 
 fields
 of /proc/partition.

It would I think be best to have this information in the man page.
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 * 100 / 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


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of The Linux Programming Interface; http://man7.org/tlpi/


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#666972: manpages: 'man proc': /proc/partition block size and count method undocumented

2013-08-21 Thread Simon Paillard
Control: tag -1 +upstream

On Mon, Apr 02, 2012 at 08:43:17PM -0400, A. Costa wrote:
 Package: manpages
 Version: 3.35-0.1
 Severity: normal
 
 Dear Maintainer,
 
 % man proc | grep -A 2 -n '/proc/partition'
 988:   /proc/partitions
 989-  Contains major and minor numbers of each partition as 
 well as number of
 990-  blocks and partition name.
 
 There's no mention of how many bytes are in a block, and no description of how
 block numbers are counted.

A full definition of fields is available in the kernel tree:
http://lxr.linux.no/#linux+v3.5/Documentation/iostats.txt

We can either just point to that doc in the manpage, or document all the fields
of /proc/partition.

-- 
Simon Paillard


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#666972: manpages: 'man proc': /proc/partition block size and count method undocumented

2012-04-02 Thread A. Costa
Package: manpages
Version: 3.35-0.1
Severity: normal

Dear Maintainer,

% man proc | grep -A 2 -n '/proc/partition'
988:   /proc/partitions
989-  Contains major and minor numbers of each partition as 
well as number of
990-  blocks and partition name.

There's no mention of how many bytes are in a block, and no description of how
block numbers are counted.

The counting method seems relevant since 'df' returns different numbers; numbers
which must have been counted using a different method:

% D=/proc/partitions
% cat $D | grep -w $D
   8   37   58348048 sdc5

# show 'df /dev/sdc5' output, 1000 bytes per block
% df -B 1KB $D
Filesystem 1kB-blocks Used Available Use% Mounted on
/dev/sdc558765693 47037772   9337988  84% /tmp

# Again, with 1024 byte blocks:
% df -B 1K  $D
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdc5   57388372 45935324   9119128  84% /tmp

Summary:

1024b   57388372
1000b   58765693
proc58348048

Neither 'df' block size matches 'proc'.

HTH...

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)
Shell: /bin/sh linked to /bin/dash

manpages depends on no packages.

manpages recommends no packages.

Versions of packages manpages suggests:
ii  coolman [man-browser]3.17.7-3
ii  konqueror [man-browser]  4:4.7.4-2
ii  man-db [man-browser] 2.6.1-1
ii  tkman [man-browser]  2.2-4

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org