From 3363fa4482e24fb87d8aea3443e11d90f1bfc462 Mon Sep 17 00:00:00 2001 From: Bari Antebi Date: Thu, 22 Nov 2018 20:14:57 +0200 Subject: [PATCH] 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 Signed-off-by: Jens Axboe --- lib/rand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rand.c b/lib/rand.c index 99846a8d..f18bd8d8 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -166,6 +166,7 @@ void __fill_random_buf_percentage(unsigned long seed, void *buf, if (!len) break; buf += this_len; + this_len = segment - this_len; if (this_len > len) this_len = len; -- 2.25.1