Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 513044 - app-benchmarks/piozone - Disk size is detected incorrectly and other issues
Summary: app-benchmarks/piozone - Disk size is detected incorrectly and other issues
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard: Pending removal: 2016-09-21
Keywords: PATCH, PMASKED
Depends on:
Blocks:
 
Reported: 2014-06-12 12:05 UTC by eroen
Modified: 2016-10-01 07:49 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fix-disksize-determination.patch (fix-disksize-determination.patch,665 bytes, patch)
2014-06-12 12:08 UTC, eroen
Details | Diff
02-use-o_direct-to-reduce-cache.patch (02-use-o_direct-to-reduce-cache.patch,2.54 KB, patch)
2014-06-12 21:34 UTC, eroen
Details | Diff
03-bench_linear-should-fail-if.patch (03-bench_linear-should-fail-if.patch,836 bytes, patch)
2014-06-12 21:36 UTC, eroen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description eroen 2014-06-12 12:05:20 UTC
The function disksize() reports disks smaller than 64 GiB as zero size. A later algorithm subtracts a "buffer" value from this to obtain an intermediate value, and later parts of the program assume this intermediate value is positive.

I be

Reproducible: Always

Steps to Reproduce:
1. Obtain 32 GB storage media as /dev/sdb
2. piozone -v /dev/sdb
Actual Results:  
occam ~ # piozone /dev/sdb
[PIOZONE, version 1.0 - Copyright (c) 2002 Peter Eriksson <pen@lysator.liu.se>]

Linear read transfer rates:
26.6 MB/s at offset   0 GB using  64 KiB reads
27.1 MB/s at offset 633437444 GB using  64 KiB reads
27.5 MB/s at offset 1266874888 GB using  64 KiB reads
27.1 MB/s at offset 633437443 GB using  64 KiB reads
26.9 MB/s at offset 1266874887 GB using  64 KiB reads
26.8 MB/s at offset 633437442 GB using  64 KiB reads
26.8 MB/s at offset 1266874886 GB using  64 KiB reads
26.9 MB/s at offset 633437441 GB using  64 KiB reads
26.9 MB/s at offset 1266874885 GB using  64 KiB reads
27.2 MB/s at offset 633437440 GB using  64 KiB reads
27.2 MB/s at offset 1266874884 GB using  64 KiB reads
27.1 MB/s at offset 633437438 GB using  64 KiB reads
27.4 MB/s at offset 1266874883 GB using  64 KiB reads
27.1 MB/s at offset 633437437 GB using  64 KiB reads
26.8 MB/s at offset 1266874882 GB using  64 KiB reads
26.8 MB/s at offset 633437436 GB using  64 KiB reads
27.2 MB/s at offset 1266874881 GB using  64 KiB reads
27.2 MB/s at offset 633437435 GB using  64 KiB reads
27.3 MB/s at offset 1266874880 GB using  64 KiB reads
26.9 MB/s at offset 633437434 GB using  64 KiB reads
27.1 MB/s at offset 1266874878 GB using  64 KiB reads
26.8 MB/s at offset 633437433 GB using  64 KiB reads
26.9 MB/s at offset 1266874877 GB using  64 KiB reads
26.9 MB/s at offset 633437432 GB using  64 KiB reads
26.9 MB/s at offset 1266874876 GB using  64 KiB reads
27.2 MB/s at offset 633437431 GB using  64 KiB reads
28.0 MB/s at offset 1266874875 GB using  64 KiB reads
28.0 MB/s at offset 633437430 GB using  64 KiB reads
28.2 MB/s at offset 1266874874 GB using  64 KiB reads
28.2 MB/s at offset 633437429 GB using  64 KiB reads
28.1 MB/s at offset 1266874873 GB using  64 KiB reads
28.3 MB/s at offset 633437428 GB using  64 KiB reads
27.8 MB/s at offset 1266874872 GB using  64 KiB reads
27.9 MB/s at offset 633437427 GB using  64 KiB reads
27.9 MB/s at offset 1266874871 GB using  64 KiB reads
28.1 MB/s at offset 633437426 GB using  64 KiB reads
28.0 MB/s at offset 1266874870 GB using  64 KiB reads
                    
27.9 MB/s at offset   0 GB using 1024 KiB reads
27.9 MB/s at offset 633437444 GB using 1024 KiB reads
28.1 MB/s at offset 1266874888 GB using 1024 KiB reads
28.2 MB/s at offset 633437443 GB using 1024 KiB reads
28.3 MB/s at offset 1266874887 GB using 1024 KiB reads
28.2 MB/s at offset 633437442 GB using 1024 KiB reads
27.8 MB/s at offset 1266874886 GB using 1024 KiB reads
28.2 MB/s at offset 633437441 GB using 1024 KiB reads
28.3 MB/s at offset 1266874885 GB using 1024 KiB reads
36.5 MB/s at offset 633437440 GB using 1024 KiB reads
30.4 MB/s at offset 1266874884 GB using 1024 KiB reads
28.1 MB/s at offset 633437438 GB using 1024 KiB reads
27.2 MB/s at offset 1266874883 GB using 1024 KiB reads
26.9 MB/s at offset 633437437 GB using 1024 KiB reads
28.2 MB/s at offset 1266874882 GB using 1024 KiB reads
32.1 MB/s at offset 633437436 GB using 1024 KiB reads
29.9 MB/s at offset 1266874881 GB using 1024 KiB reads
27.4 MB/s at offset 633437435 GB using 1024 KiB reads
27.1 MB/s at offset 1266874880 GB using 1024 KiB reads
27.3 MB/s at offset 633437434 GB using 1024 KiB reads
26.9 MB/s at offset 1266874878 GB using 1024 KiB reads
26.9 MB/s at offset 633437433 GB using 1024 KiB reads
29.5 MB/s at offset 1266874877 GB using 1024 KiB reads
27.2 MB/s at offset 633437432 GB using 1024 KiB reads
27.0 MB/s at offset 1266874876 GB using 1024 KiB reads
28.6 MB/s at offset 633437431 GB using 1024 KiB reads
28.1 MB/s at offset 1266874875 GB using 1024 KiB reads
26.9 MB/s at offset 633437430 GB using 1024 KiB reads
26.9 MB/s at offset 1266874874 GB using 1024 KiB reads
26.8 MB/s at offset 633437429 GB using 1024 KiB reads
26.8 MB/s at offset 1266874873 GB using 1024 KiB reads
29.3 MB/s at offset 633437428 GB using 1024 KiB reads
26.8 MB/s at offset 1266874872 GB using 1024 KiB reads
26.9 MB/s at offset 633437427 GB using 1024 KiB reads
30.9 MB/s at offset 1266874871 GB using 1024 KiB reads
                    
Random access read transfer rates (area size: 1 GiB):
7994.8 MB/s at offset   0 GB using  64 KiB reads
                    
65.0 MB/s at offset   0 GB using 1024 KiB reads


Expected Results:  
occam ~ # ~eroen/repos/piozone/piozone -v /dev/sdb
[PIOZONE, version 1.0 - Copyright (c) 2002 Peter Eriksson <pen@lysator.liu.se>]

Disk size: 32 GB (29 GiB)

Linear read transfer rates:
20.3 MB/s at offset   0 GB using  64 KiB reads
20.3 MB/s at offset  15 GB using  64 KiB reads
20.5 MB/s at offset  30 GB using  64 KiB reads
                    
40.7 MB/s at offset   0 GB using 1024 KiB reads
40.7 MB/s at offset  15 GB using 1024 KiB reads
                    
Random access read transfer rates (area size: 1 GiB):
8444.3 MB/s at offset   0 GB using  64 KiB reads
8878.6 MB/s at offset  15 GB using  64 KiB reads
8952.0 MB/s at offset  30 GB using  64 KiB reads
                    
7855.2 MB/s at offset   0 GB using 1024 KiB reads
8144.7 MB/s at offset  15 GB using 1024 KiB reads
8254.3 MB/s at offset  30 GB using 1024 KiB reads

The problematic piece of code:

uint64_t
disksize(int fd)
{
    char buf[8*KiB];
    uint64_t off, del;
    

    off = 0;
    del = 64*GiB;

    while (del > 8*KiB && lseek64(fd, off+del, SEEK_SET) != -1)
    {
	if (read(fd, buf, 8*KiB) < 0)
	    del >>= 1;
	else
	    off += del;
    }

    return off;
}
Comment 1 eroen 2014-06-12 12:08:30 UTC
Created attachment 378748 [details, diff]
fix-disksize-determination.patch

Please find attached a proposed patch to rectify this issue.
Comment 2 eroen 2014-06-12 21:34:05 UTC
Created attachment 378768 [details, diff]
02-use-o_direct-to-reduce-cache.patch

I also ran into a few other issues with piozone, for which I will attach proposed patches.

You will see in Comment 0 that (in particular) the random reads are highly inflated due to caching. With this patch, the device under test is opened with O_DIRECT where available, which reduces the impact of caching on the results.
Comment 3 eroen 2014-06-12 21:36:52 UTC
Created attachment 378770 [details, diff]
03-bench_linear-should-fail-if.patch

In the existing bench_linear(), errors from seeking to invalid offsets is silently ignored, which causes re-testing of the same area (and incorrect output) rather than progression though the program.
Comment 4 eroen 2014-06-13 11:40:10 UTC
Tangentially related, but LICENSE="GPL-2" seems wrong. The source has no mention of gpl, but rather this statement:

** Copyright (c) 2002 Peter Eriksson <pen@lysator.liu.se>
**
** This program is free software; you can redistribute it and/or
** modify it as you wish - as long as you don't claim that you wrote
** it.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Comment 5 Pacho Ramos gentoo-dev 2016-01-27 21:35:15 UTC
Are you willing to proxy maintain this old package? Otherwise I don't see much sense on trying to keep this software from 2002 in the tree (as we will likely be unable to fix the bugs that will probably arise as soon as someone tries to rely on it extensively )
Comment 6 Pacho Ramos gentoo-dev 2016-10-01 07:49:22 UTC
removed