Recent changes (master)
The following changes since commit 6abe06547f4ad296ea62cd1a2d55fc5274059c77:
Merge branch 'fix/verify-default-stack-20261111' of https://github.com/ooonea/fio (2026-11-16 11:25:16 -0500)
are available in the Git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to af034f21a61a1e9eb3af281fafdfe93fbf783c36:
lib/rand: start every seed bucket odd in __fill_random_buf() (2026-11-16 21:42:29 -0500)
----------------------------------------------------------------
Vincent Fu (2):
test: add test for compressible random buffers lib/rand: start every seed bucket odd in __fill_random_buf()
lib/rand.c | 12 ++++++++++-- t/jobs/t0039.fio | 21 +++++++++++++++++++++ t/run-fio-tests.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 t/jobs/t0039.fio
---
Diff of recent changes:
lib/rand.c +10 -2
@@ -112,8 +112,8 @@ void __fill_random_buf_small(void *buf, unsigned int len, uint64_t seed)void __fill_random_buf (void *buf,unsigned int len,uint64_t seed) { -static uint64_t prime[] = {1 ,2 ,3 ,5 ,7 ,11 ,13 ,17 , -19 ,23 ,29 ,31 ,37 ,41 ,43 ,47 }; +static uint64_t prime[] = {1 ,3 ,5 ,7 ,11 ,13 ,17 ,19 , +23 ,29 ,31 ,37 ,41 ,43 ,47 ,53 };uint64_t *b, *e, s[CONFIG_SEED_BUCKETS ];unsigned int rest;int p;
@@ -128,6 +128,14 @@ void __fill_random_buf(void *buf, unsigned int len, uint64_t seed) rest = len - (rest *sizeof (*b)); +/* +* Each bucket advances by s *= GOLDEN_RATIO_64, which preserves the +* number of trailing zero bits in s. Start every bucket odd (an odd +* seed times an odd multiplier), otherwise a seed with several +* trailing zeros leaves the low byte of every word with only a few +* distinct values and the buffer becomes compressible. +*/ + seed |=1 ;for (p =0 ; p <CONFIG_SEED_BUCKETS ; p++) s[p] = seed * prime[p];
t/jobs/t0039.fio new file +21 -0
@@ -0,0 +1,21 @@ +# +# Make sure buffers filled with random data are not compressible. +# +# A weakness in __fill_random_buf() (GitHub issue #2157) let seeds with +# several trailing zero bits carry those zeros into every 64-bit word, +# leaving the low byte of each word with only a few distinct values. +# About 11% of 8 KiB buffers then compressed by hundreds of bytes. +# +# Expected result: (almost) no 8 KiB block compresses by >= 128 bytes +# Buggy result: roughly 11% of blocks compress by >= 128 bytes +# +# run-fio-tests.py checks the contents of the written file. +# + +[test] +filename=t0039file +rw=write +bs=8k +size=16M +refill_buffers=1 +buffer_compress_percentage=0
t/run-fio-tests.py +50 -0
68 lines not on this page · raw message