public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] zram: skip exfat on systems with large page size
@ 2026-04-02  8:12 Soma Das
  2026-04-03  1:47 ` Li Wang via ltp
  0 siblings, 1 reply; 5+ messages in thread
From: Soma Das @ 2026-04-02  8:12 UTC (permalink / raw)
  To: ltp; +Cc: somadas1

exfat requires cluster size >= sector size, but defaults to 4KB.
On systems with large page sizes (e.g., 64KB on POWER),
zram uses page size as sector size, causing mkfs.exfat to fail.

Skip exfat filesystem creation when page size > 4096 to avoid test failure.

Signed-off-by: Soma Das <somadas1@linux.ibm.com>
---
 .../kernel/device-drivers/zram/zram01.sh      | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index 793f6603c..6afba21f0 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -11,6 +11,10 @@ TST_TESTFUNC="do_test"
 TST_NEEDS_CMDS="awk bc dd"
 TST_SETUP="setup"
 
+# Track devices that were skipped due to sector size incompatibility
+# Format: space-separated list of device numbers (e.g., "2 5" if zram2 and zram5 were skipped)
+skipped_devices=""
+
 check_space_for_fs()
 {
 	local fs="$1"
@@ -72,15 +76,59 @@ setup()
 	zram_load
 }
 
+check_fs_sector_support()
+{
+	local fs="$1"
+	local dev="$2"
+	local page_size
+	local sector_size
+
+	# Get the system page size - zram uses this as sector size
+	page_size=$(getconf PAGE_SIZE 2>/dev/null)
+	
+	if [ -z "$page_size" ] || [ "$page_size" -lt 4096 ]; then
+		# Default to 4KB if we can't determine page size
+		page_size=4096
+	fi
+
+	tst_res TINFO "check_fs_sector_support: $fs on zram$dev system_page_size=$page_size"
+
+	# CHECK: exfat requires cluster size >= sector size, but defaults to 4KB
+	# On systems with large page sizes (e.g., 64KB on POWER), sector size > 4KB
+	# This causes exfat filesystem creation to fail, so we skip it with TCONF
+	if [ "$fs" = "exfat" ] && [ "$page_size" -gt 4096 ]; then
+		tst_res TINFO "check_fs_sector_support: $fs on zram$dev has page_size=$page_size (> 4096), skipping"
+		return 1  # Return failure (skip this filesystem)
+	fi
+
+	return 0  # All other filesystems pass this check
+}
+
 zram_makefs()
 {
 	local i=$dev_start
 	local fs
+	local sector_size
 
+	# Loop through each filesystem assigned to each zram device
 	for fs in $zram_filesystems; do
+		tst_res TINFO "zram_makefs: checking device zram$i for filesystem $fs"
+		
+		# Check if this filesystem is compatible with the device's sector size
+		if ! check_fs_sector_support "$fs" "$i"; then
+			# Filesystem not supported on this device - mark device as skipped
+			sector_size=$(cat /sys/block/zram${i}/queue/logical_block_size)
+			tst_res TCONF "mkfs.$fs does not support sector size $sector_size"
+			skipped_devices="$skipped_devices $i"  # Add to skipped list
+			i=$(($i + 1))
+			continue  # Skip to next filesystem
+		fi
+
+		# Filesystem is supported - attempt to create it
 		tst_res TINFO "make $fs filesystem on /dev/zram$i"
 		mkfs.$fs /dev/zram$i > err.log 2>&1
 		if [ $? -ne 0 ]; then
+			# Filesystem creation failed
 			cat err.log
 			tst_res TFAIL "Failed to make $fs on /dev/zram$i"
 			tst_brk TBROK "Can't continue with mounting the FS"
@@ -95,8 +143,27 @@ zram_makefs()
 zram_mount()
 {
 	local i
+	local skip
 
+	# Attempt to mount all zram devices
 	for i in $(seq $dev_start $dev_end); do
+		skip=0
+		
+		# Check if this device was marked as skipped during filesystem creation
+		for dev in $skipped_devices; do
+			if [ "$dev" = "$i" ]; then
+				skip=1
+				break
+			fi
+		done
+
+		# Skip mounting devices that don't have filesystems
+		if [ $skip -eq 1 ]; then
+			tst_res TINFO "skipping mount of /dev/zram$i (filesystem not created)"
+			continue
+		fi
+
+		# Mount the filesystem that was created in zram_makefs
 		tst_res TINFO "mount /dev/zram$i"
 		mkdir zram$i
 		ROD mount /dev/zram$i zram$i
@@ -130,8 +197,27 @@ zram_fill_fs()
 {
 	local mem_used_total
 	local b i r v
+	local skip
 
+	# Fill each mounted filesystem with data to test compression
 	for i in $(seq $dev_start $dev_end); do
+		skip=0
+		
+		# Check if this device was marked as skipped (has no filesystem)
+		for dev in $skipped_devices; do
+			if [ "$dev" = "$i" ]; then
+				skip=1
+				break
+			fi
+		done
+
+		# Skip filling devices that don't have filesystems
+		if [ $skip -eq 1 ]; then
+			tst_res TINFO "skipping fill of zram$i (filesystem not created)"
+			continue
+		fi
+
+		# Fill this zram device with zeros to test compression ratio
 		tst_res TINFO "filling zram$i (it can take long time)"
 		b=0
 		while true; do
@@ -140,12 +226,15 @@ zram_fill_fs()
 				>/dev/null 2>err.txt || break
 			b=$(($b + 1))
 		done
+		
+		# Verify that at least some data was written
 		if [ $b -eq 0 ]; then
 			[ -s err.txt ] && tst_res TWARN "dd error: $(cat err.txt)"
 			tst_brk TBROK "cannot fill zram $i"
 		fi
 		tst_res TPASS "zram$i was filled with '$b' KB"
 
+		# Check if compression statistics are available (requires mm_stat)
 		if [ ! -f "/sys/block/zram$i/mm_stat" ]; then
 			if [ $i -eq 0 ]; then
 				tst_res TCONF "zram compression ratio test requires zram mm_stat sysfs file"
@@ -154,6 +243,7 @@ zram_fill_fs()
 			continue
 		fi
 
+		# Read and verify the compression ratio
 		TST_RETRY_FN_EXP_BACKOFF "check_read_mem_used_total /sys/block/zram$i/mm_stat" 0 10
 		mem_used_total=$(read_mem_used_total /sys/block/zram$i/mm_stat)
 		tst_res TINFO "mem_used_total: $mem_used_total"
@@ -161,6 +251,7 @@ zram_fill_fs()
 		v=$((100 * 1024 * $b / $mem_used_total))
 		r=$(echo "scale=2; $v / 100 " | bc)
 
+		# Fail if compression ratio is less than 1:1 (data grew instead of compressed)
 		if [ "$v" -lt 100 ]; then
 			tst_res TFAIL "compression ratio: $r:1"
 			break
-- 
2.39.1


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

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

end of thread, other threads:[~2026-04-04 16:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02  8:12 [LTP] [PATCH] zram: skip exfat on systems with large page size Soma Das
2026-04-03  1:47 ` Li Wang via ltp
2026-04-03 16:59   ` Soma Das
2026-04-04  1:14     ` Li Wang via ltp
2026-04-04 17:20       ` Soma Das

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