[LTP] [PATCH 1/1] zram01.sh: Fill the filesystem with a single dd call

Petr Vorel pvorel@suse.cz
Mon Nov 9 20:33:44 CET 2026


zram_fill_fs() spawned a new dd process for every 1 KiB written. Filling
the 384 MiB Btrfs device alone takes up to ~390k process spawns, the four
smaller devices before it already needed 284k-350k. On slow process
creation (e.g. Xen PV dom0) the test then runs for hours: openQA jobs on
SLE12-SP5 and SLE15-SP6 were killed after 2h15m while still filling zram4
(Btrfs), with no kernel errors in the console log.

Write the whole file with a single dd using the same 1 KiB block size
until it fails with ENOSPC and take the written size from the file size.
The device is filled to the same level, the reported size and the
compression ratio calculation are unchanged.

This speedups the 7th test run rapidly, which avoids the timeout on
Btrfs.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hopefully this does not spoil the testcase itself by being too easy.

 testcases/kernel/device-drivers/zram/zram01.sh | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index 4b7f2a753f..f6dfb6f8aa 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -135,13 +135,11 @@ zram_fill_fs()
 
 	for i in $(seq $dev_start $dev_end); do
 		tst_res TINFO "filling zram$i (it can take long time)"
+		# dd is expected to fail with ENOSPC once the device is full
+		dd if=/dev/zero of="zram$i/file" bs=1024 status=none \
+			>/dev/null 2>err.txt
 		b=0
-		while true; do
-			dd conv=notrunc if=/dev/zero of=zram${i}/file \
-				oflag=append count=1 bs=1024 status=none \
-				>/dev/null 2>err.txt || break
-			b=$(($b + 1))
-		done
+		[ -f "zram$i/file" ] && b=$(($(wc -c < "zram$i/file") / 1024))
 		if [ $b -eq 0 ]; then
 			[ -s err.txt ] && tst_res TWARN "dd error: $(cat err.txt)"
 			tst_brk TBROK "cannot fill zram $i"
-- 
2.56.0



More information about the ltp mailing list