mdconfig_test: determine page size at run time rather than assuming 4k

Sponsored by:	Netflix
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D52736
This commit is contained in:
Chuck Silvers
2025-10-13 09:07:43 -07:00
parent 376508ef2f
commit 24458c2431
+8 -7
View File
@@ -274,22 +274,23 @@ attach_size_rounddown()
attach_size_rounddown_body() attach_size_rounddown_body()
{ {
local md local md
local ss=8192 local pgsz=$(pagesize)
local ms=$(($ss + 4096)) local ss=$(($pgsz * 2))
local ms2=$((2 * $ss + 4096)) local ms=$(($ss + $pgsz))
local ms2=$((2 * $ss + $pgsz))
# Use a sector size that's a likely multiple of PAGE_SIZE, as md(4) # Use a sector size that's a multiple of the kernel page size, as md(4)
# expects that for swap MDs. # expects that for swap MDs.
atf_check -s exit:0 -o save:mdconfig.out -e empty \ atf_check -s exit:0 -o save:mdconfig.out -e empty \
-x "mdconfig -a -t swap -S $ss -s ${ms}b" -x "mdconfig -a -t swap -S $ss -s ${ms}b"
md=$(cat mdconfig.out) md=$(cat mdconfig.out)
# 12288 bytes should be rounded down to one sector. # one sector plus one page should be rounded down to one sector.
check_diskinfo "$md" 8192 1 $ss check_diskinfo "$md" $ss 1 $ss
# Resize and verify that the new size was also rounded down. # Resize and verify that the new size was also rounded down.
atf_check -s exit:0 -o empty -e empty \ atf_check -s exit:0 -o empty -e empty \
-x "mdconfig -r -u ${md#md} -s ${ms2}b" -x "mdconfig -r -u ${md#md} -s ${ms2}b"
check_diskinfo "$md" 16384 2 $ss check_diskinfo "$md" $((2 * $ss)) 2 $ss
} }
attach_size_rounddown_cleanup() attach_size_rounddown_cleanup()
{ {