rand: fix compressible data ratio per segment
authorBari Antebi <bari@lightbitslabs.com>
Thu, 22 Nov 2018 18:14:57 +0000 (20:14 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Nov 2018 15:23:19 +0000 (08:23 -0700)
commit3363fa4482e24fb87d8aea3443e11d90f1bfc462
tree4ba9777e2b4dfc22463fe9b57fcfedc0a706cce1
parentc36210b443a37c53978bbea88f1dabb0b61799d7
rand: fix compressible data ratio per segment

I've noticed a bug in fio while testing it. I expected to receive
output similar to the expected output below for: "hexdump -n 4096
/dev/nvme0n1" (considering the configuration file I've used that may
be found below).

Expected output:

0000000 fdc6 a8a8 7190 0219 1fb8 9632 d9dd 1e64
/* random data */
00004c0 d8a3 13fe aeec 0fb6 5b14 162e 0000 0000
00004d0 0000 0000 0000 0000 0000 0000 0000 0000
*
0001000

However, the output I've received contained data after address 4cc
(which should have been filled with zeroes until 1000 as far as I
understand, but as you can see 99a contains data.

0000000 fdc6 a8a8 7190 0219 1fb8 9632 d9dd 1e64
/* random data */
00004c0 d8a3 13fe aeec 0fb6 5b14 162e 0000 0000
00004d0 0000 0000 0000 0000 0000 0000 0000 0000
*
0000990 0000 0000 0000 0000 fdc6 a8a8 7190 0219

Config file:

[global]
group_reporting=1
filename=/dev/nvme0n1
name=task_nvme0n1
rw=write
bs=4096
numjobs=1
iodepth=32
buffer_compress_chunk=4096
buffer_compress_percentage=70
cpus_allowed=0-8
cpus_allowed_policy=split
direct=1
ioengine=libaio
loops=1
refill_buffers=0

[job empty]
size=4096

Fio should write (100 - compress_percentage) * segemnt of random data
followed by compress_percentage * segemnt of compressible
data.

Currently, at each itereation fio fills (100 - compress_percentage) * segemnt
data, followed by (100 - compress_percentage) * segemnt of compressible
data until a the segment is filled.

Fixes: 811ac503a619 ("Compression fixes")
Signed-off-by: Bari Antebi <bari@lightbitslabs.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
lib/rand.c