xfs: detect time limits from filesystem
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 Apr 2021 00:23:20 +0000 (17:23 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 25 Apr 2021 06:45:26 +0000 (14:45 +0800)
Teach fstests to extract timestamp limits of a filesystem using the new
xfs_db timelimit command.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc
common/xfs
tests/xfs/159 [new file with mode: 0755]
tests/xfs/159.out [new file with mode: 0644]
tests/xfs/group

index bed322f..2cf550e 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2124,7 +2124,7 @@ _filesystem_timestamp_range()
                echo "0 $u32max"
                ;;
        xfs)
                echo "0 $u32max"
                ;;
        xfs)
-               echo "$s32min $s32max"
+               _xfs_timestamp_range "$device"
                ;;
        btrfs)
                echo "$s64min $s64max"
                ;;
        btrfs)
                echo "$s64min $s64max"
index a072129..559d004 100644 (file)
@@ -1166,3 +1166,22 @@ _require_scratch_xfs_inobtcount()
                _notrun "kernel doesn't support xfs inobtcount feature"
        _scratch_unmount
 }
                _notrun "kernel doesn't support xfs inobtcount feature"
        _scratch_unmount
 }
+
+_xfs_timestamp_range()
+{
+       local device="$1"
+       local use_db=0
+       local dbprog="$XFS_DB_PROG $device"
+       test "$device" = "$SCRATCH_DEV" && dbprog=_scratch_xfs_db
+
+       $dbprog -f -c 'help timelimit' | grep -v -q 'not found' && use_db=1
+       if [ $use_db -eq 0 ]; then
+               # The "timelimit" command was added to xfs_db at the same time
+               # that bigtime was added to xfsprogs.  Therefore, we can assume
+               # the old timestamp range if the command isn't present.
+               echo "-$((1<<31)) $(((1<<31)-1))"
+       else
+               $dbprog -f -c 'timelimit --compact' | \
+                       awk '{printf("%s %s", $1, $2);}'
+       fi
+}
diff --git a/tests/xfs/159 b/tests/xfs/159
new file mode 100755 (executable)
index 0000000..2074494
--- /dev/null
@@ -0,0 +1,44 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 159
+#
+# Check that the xfs_db timelimit command prints the ranges that we expect.
+# This in combination with an xfs_ondisk.h build time check in the kernel
+# ensures that the kernel agrees with userspace.
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_xfs_db_command timelimit
+
+rm -f $seqres.full
+
+# Format filesystem without bigtime support and populate it
+_scratch_mkfs > $seqres.full
+echo classic xfs timelimits
+_scratch_xfs_db -c 'timelimit --classic'
+echo bigtime xfs timelimits
+_scratch_xfs_db -c 'timelimit --bigtime'
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/159.out b/tests/xfs/159.out
new file mode 100644 (file)
index 0000000..7723bfc
--- /dev/null
@@ -0,0 +1,15 @@
+QA output created by 159
+classic xfs timelimits
+time.min = -2147483648
+time.max = 2147483647
+dqtimer.min = 1
+dqtimer.max = 4294967295
+dqgrace.min = 0
+dqgrace.min = 4294967295
+bigtime xfs timelimits
+time.min = -2147483648
+time.max = 16299260424
+dqtimer.min = 4
+dqtimer.max = 16299260424
+dqgrace.min = 0
+dqgrace.min = 4294967295
index e746dde..e719ba5 100644 (file)
 156 auto quick admin
 157 auto quick admin
 158 auto quick inobtcount
 156 auto quick admin
 157 auto quick admin
 158 auto quick inobtcount
+159 auto quick bigtime
 164 rw pattern auto prealloc quick
 165 rw pattern auto prealloc quick
 166 rw metadata auto quick
 164 rw pattern auto prealloc quick
 165 rw pattern auto prealloc quick
 166 rw metadata auto quick