Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] zram01.sh: Fill the filesystem with a single dd call
@ 2026-11-09 19:33 Petr Vorel
  2026-11-09 19:38 ` Petr Vorel
  2026-11-10  9:47 ` Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2026-11-09 19:33 UTC (permalink / raw)
  To: ltp

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-10 11:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 19:33 [LTP] [PATCH 1/1] zram01.sh: Fill the filesystem with a single dd call Petr Vorel
2026-11-09 19:38 ` Petr Vorel
2026-11-10  9:47 ` Cyril Hrubis
2026-11-10 11:18   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox