[PATCH v1 1/7] xfs: Introduce _require_realtime_xfs_{shrink,grow} pre-condition

Nirjhar Roy (IBM)
2026-02-19T06:11:58Z

From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>

These is required for the set of XFS realtime grow/shrink tests in the
upcoming patches.

Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
common/xfs | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/common/xfs b/common/xfs
index 7fa0db2e..8e4425b4 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1233,7 +1233,11 @@ _require_xfs_mkfs_validation()

_require_scratch_xfs_shrink()
{
+ local is_realtime="$1"
_require_scratch
+ if [ "$is_realtime" == "1" ]; then
+ _require_realtime
+ fi
_require_command "$XFS_GROWFS_PROG" xfs_growfs

_try_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
@@ -1241,7 +1245,12 @@ _require_scratch_xfs_shrink()
_scratch_mount
# here just to check if kernel supports, no need do more extra work
local errmsg
- errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
+ if [ "$is_realtime" == "1" ]; then
+ errmsg=$($XFS_GROWFS_PROG -R$((rtblocks-1)) "$SCRATCH_MNT" 2>&1)
+ else
+ errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
+ fi
+
if [ "$?" -ne 0 ]; then
echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \
_notrun "kernel does not support shrinking"
@@ -1251,6 +1260,48 @@ _require_scratch_xfs_shrink()
fi
_scratch_unmount
}
+_require_realtime_xfs_shrink()
+{
+ _require_scratch_xfs_shrink "1"
+}
+
+_require_scratch_xfs_grow()
+{
+ local is_realtime="$1"
+ _require_scratch
+ if [ "$is_realtime" == "1" ]; then
+ _require_realtime
+ fi
+ _require_command "$XFS_GROWFS_PROG" xfs_growfs
+
+ _try_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+ . $tmp.mkfs
+ _scratch_mount
+ # here just to check if kernel supports, no need do more extra work
+ local errmsg
+ if [ "$is_realtime" == "1" ]; then
+ errmsg=$($XFS_GROWFS_PROG -R$((rtblocks+1)) "$SCRATCH_MNT" 2>&1)
+ else
+ errmsg=$($XFS_GROWFS_PROG -D$((dblocks+1)) "$SCRATCH_MNT" 2>&1)
+ fi
+
+ if [ "$?" -ne 0 ]; then
+ echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \
+ _notrun "kernel does not support shrinking"
+ # if the fssize is already = backing device size, in that case,
+ # the above xfs_growfs will fail - but I don't want to the
+ # pre-condition to fail. This test case i.e, the new fs size
+ # greater than the backing device size is a test case that is
+ # covered in the test, so I will let the mount to take place so that the
+ # new fssize > device size can be actually be validated in a test case.
+ fi
+ _scratch_unmount
+}
+
+_require_realtime_xfs_grow()
+{
+ _require_scratch_xfs_shrink "1"
+}

# this test requires mkfs.xfs have case-insensitive naming support
_require_xfs_mkfs_ciname()
--
2.34.1