Math is wrong if range requested is less or equals to block size xfs_io -c 'pwrite -b 4k 8k 4k -R' \ -c 'pread -b 4k 4k 4k -R' -f file Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx> --- io/pread.c | 6 +++++- io/pwrite.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/io/pread.c b/io/pread.c index f16c86c..b98355f 100644 --- a/io/pread.c +++ b/io/pread.c @@ -245,7 +245,11 @@ read_random( *total = 0; while (count > 0) { - off = ((offset + (random() % range)) / buffersize) * buffersize; + if (range) + off = ((offset + (random() % range)) / buffersize) * + buffersize; + else + off = offset; bytes = do_pread(fd, off, buffersize, buffersize); if (bytes == 0) break; diff --git a/io/pwrite.c b/io/pwrite.c index 4fc8de6..67631ce 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -128,7 +128,11 @@ write_random( *total = 0; while (count > 0) { - off = ((offset + (random() % range)) / buffersize) * buffersize; + if (range) + off = ((offset + (random() % range)) / buffersize) * + buffersize; + else + off = offset; bytes = do_pwrite(file->fd, off, buffersize, buffersize); if (bytes == 0) break; -- 1.8.3.1 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs