Bug#925207: libsys-statistics-linux-perl: Sys::Statistics::Linux::DiskStats fails to parse /proc/diskstats for kernel >= v4.18

2019-03-21 Thread Florian Schlichting
Severity: important
thanks

On Thu, Mar 21, 2019 at 10:31:53AM +0100, Bryan Jurish wrote:
> According to https://www.kernel.org/doc/Documentation/iostats.txt, 4 new 
> fields
> were added to /proc/diskstats for kernel version 4.18.  As a result, device
> names and the "old" attribute fields are misparsed by the (very narrow) 
> regexes
> in Sys/Statistics/Linux/DiskStats.pm .  The attached patch appears to fix the
> problem.

The bug becomes visible when calling e.g.

$ perl -MData::Printer -MSys::Statistics::Linux::DiskStats -E'my $lxs = 
Sys::Statistics::Linux::DiskStats->new; $lxs->init; p $lxs->get;

The correct output will contain paragraphs like this:

sda1{
major8,
minor1,
rdbyt0.00,
rdreq0.00,
ttbyt0.00,
ttreq0.00,
wrtbyt   0.00,
wrtreq   0.00
},

However on buster currently, output looks like this (notice the "device
name"):

'sda1 3352 39 102172 153321'  {
major8,
minor1,
rdbyt0.00,
rdreq0.00,
ttbyt0.00,
ttreq0.00,
wrtbyt   0.00,
wrtreq   0.00
},

The patch from Bryan Jurish (thanks!) correctly fixes this issue for the
buster kernel, however to prevent this from happening again I think the
device name regex should make sure to never match the field separator,
by using (\S+) instead of (.+?) for example.

Florian



Bug#925207: libsys-statistics-linux-perl: Sys::Statistics::Linux::DiskStats fails to parse /proc/diskstats for kernel >= v4.18

2019-03-21 Thread Bryan Jurish
Package: libsys-statistics-linux-perl
Version: 0.66-2
Severity: normal
Tags: upstream patch

According to https://www.kernel.org/doc/Documentation/iostats.txt, 4 new fields
were added to /proc/diskstats for kernel version 4.18.  As a result, device
names and the "old" attribute fields are misparsed by the (very narrow) regexes
in Sys/Statistics/Linux/DiskStats.pm .  The attached patch appears to fix the
problem.

Already reported upstream as https://rt.cpan.org/Ticket/Display.html?id=128904



-- System Information:
Debian Release: 9.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-8-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libsys-statistics-linux-perl depends on:
ii  libuniversal-require-perl  0.17-1
ii  perl   5.24.1-3+deb9u5

libsys-statistics-linux-perl recommends no packages.

libsys-statistics-linux-perl suggests no packages.
--- Sys-Statistics-Linux-0.66/lib/Sys/Statistics/Linux/DiskStats.pm 
2019-03-21 10:12:36.584677649 +0100
+++ Sys-Statistics-Linux-0.66_patched/lib/Sys/Statistics/Linux/DiskStats.pm 
2019-03-21 10:13:20.236575029 +0100
@@ -239,9 +239,9 @@
 
 if (open $fh, '<', $file_diskstats) {
 while (my $line = <$fh>) {
-#   --  --  --  F1 F2 F3 
F4 F5 F6 F7 F8F9F10   F11
-#   $1  $2  $3  $4 -- $5 
-- $6 -- $7 --------
-if ($line =~ 
/^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+$/)
 {
+   #   --  --  --  F1 F2 F3 F4 
F5 F6 F7 F8F9F10   F11  (F12..F15)?
+#   $1  $2  $3  $4 -- $5 
-- $6 -- $7 --------   (-- .. --)?
+   if ($line =~ 
/^\s+(\d+)\s+(\d+)\s+(.+?)\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+(?:(?:\s+\d+){4})?$/)
 {
 for my $x ($stats{$3}) { # $3 -> the device name
 $x->{major}   = $1;
 $x->{minor}   = $2;