From 8d87273e43f1cb1bf2542697056c1f6461c399a0 Mon Sep 17 00:00:00 2001 From: Catherine Hoang Date: Wed, 25 Jun 2025 17:27:33 -0700 Subject: [PATCH] common/atomicwrites: add helper for multi block atomic writes Add a helper to check that we can perform multi block atomic writes. We will use this in the following patches that add testing for large atomic writes. This helper will prevent these tests from running on kernels that only support single block atomic writes. Signed-off-by: Catherine Hoang Reviewed-by: John Garry Reviewed-by: Ritesh Harjani (IBM) Reviewed-by: Darrick J. Wong Reviewed-by: Ojaswin Mujoo Signed-off-by: Zorro Lang --- common/atomicwrites | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common/atomicwrites b/common/atomicwrites index 391bb6f6..ac4facc3 100644 --- a/common/atomicwrites +++ b/common/atomicwrites @@ -24,6 +24,27 @@ _get_atomic_write_segments_max() grep -w atomic_write_segments_max | grep -o '[0-9]\+' } +_require_scratch_write_atomic_multi_fsblock() +{ + _require_scratch + + _scratch_mkfs > /dev/null 2>&1 || \ + _notrun "cannot format scratch device for atomic write checks" + _try_scratch_mount || \ + _notrun "cannot mount scratch device for atomic write checks" + + local testfile=$SCRATCH_MNT/testfile + touch $testfile + + local bsize=$(_get_file_block_size $SCRATCH_MNT) + local awu_max_fs=$(_get_atomic_write_unit_max $testfile) + + _scratch_unmount + + test $awu_max_fs -ge $((bsize * 2)) || \ + _notrun "multi-block atomic writes not supported by this filesystem" +} + _require_scratch_write_atomic() { _require_scratch -- 2.39.5