diff mbox series

[3/4] xfs: detect time limits from filesystem

Message ID 160382545348.1203848.12227735405144915534.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfstests: widen timestamps to deal with y2038+ | expand

Commit Message

Darrick J. Wong Oct. 27, 2020, 7:04 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Teach fstests to extract timestamp limits of a filesystem using the new
xfs_db timelimit command.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc         |    2 +-
 common/xfs        |   14 ++++++++++++++
 tests/xfs/911     |   44 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/911.out |   15 +++++++++++++++
 tests/xfs/group   |    1 +
 5 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100755 tests/xfs/911
 create mode 100644 tests/xfs/911.out

Comments

Amir Goldstein Oct. 29, 2020, 10:47 a.m. UTC | #1
On Wed, Oct 28, 2020 at 10:24 PM Darrick J. Wong
<darrick.wong@oracle.com> wrote:
>
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Teach fstests to extract timestamp limits of a filesystem using the new
> xfs_db timelimit command.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/rc         |    2 +-
>  common/xfs        |   14 ++++++++++++++
>  tests/xfs/911     |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/911.out |   15 +++++++++++++++
>  tests/xfs/group   |    1 +
>  5 files changed, 75 insertions(+), 1 deletion(-)
>  create mode 100755 tests/xfs/911
>  create mode 100644 tests/xfs/911.out
>
>
> diff --git a/common/rc b/common/rc
> index 41f93047..162d957a 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2029,7 +2029,7 @@ _filesystem_timestamp_range()
>                 echo "0 $u32max"
>                 ;;
>         xfs)
> -               echo "$s32min $s32max"
> +               _xfs_timestamp_range "$device"
>                 ;;
>         btrfs)
>                 echo "$s64min $s64max"
> diff --git a/common/xfs b/common/xfs
> index e548a0a1..19ccee03 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -994,3 +994,17 @@ _require_xfs_scratch_inobtcount()
>                 _notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
>         _scratch_unmount
>  }
> +
> +_xfs_timestamp_range()
> +{
> +       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
> +               echo "-$((1<<31)) $(((1<<31)-1))"

This embodies an assumption that the tested filesystem does not have
bigtime enabled if xfs_db tool is not uptodate.
Maybe it makes sense, but it may be safer to return "-1 -1" and not_run
generic/402 if xfs_db is not uptodate, perhaps with an extra message
hinting the user to upgrade xfs_db.

Thanks,
Amir.
Darrick J. Wong Oct. 29, 2020, 6:27 p.m. UTC | #2
On Thu, Oct 29, 2020 at 12:47:32PM +0200, Amir Goldstein wrote:
> On Wed, Oct 28, 2020 at 10:24 PM Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
> >
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Teach fstests to extract timestamp limits of a filesystem using the new
> > xfs_db timelimit command.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/rc         |    2 +-
> >  common/xfs        |   14 ++++++++++++++
> >  tests/xfs/911     |   44 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/911.out |   15 +++++++++++++++
> >  tests/xfs/group   |    1 +
> >  5 files changed, 75 insertions(+), 1 deletion(-)
> >  create mode 100755 tests/xfs/911
> >  create mode 100644 tests/xfs/911.out
> >
> >
> > diff --git a/common/rc b/common/rc
> > index 41f93047..162d957a 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -2029,7 +2029,7 @@ _filesystem_timestamp_range()
> >                 echo "0 $u32max"
> >                 ;;
> >         xfs)
> > -               echo "$s32min $s32max"
> > +               _xfs_timestamp_range "$device"
> >                 ;;
> >         btrfs)
> >                 echo "$s64min $s64max"
> > diff --git a/common/xfs b/common/xfs
> > index e548a0a1..19ccee03 100644
> > --- a/common/xfs
> > +++ b/common/xfs
> > @@ -994,3 +994,17 @@ _require_xfs_scratch_inobtcount()
> >                 _notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> >         _scratch_unmount
> >  }
> > +
> > +_xfs_timestamp_range()
> > +{
> > +       local use_db=0
> > +       local dbprog="$XFS_DB_PROG $device"

Heh, device isn't defined, I'll fix that.

> > +       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
> > +               echo "-$((1<<31)) $(((1<<31)-1))"
> 
> This embodies an assumption that the tested filesystem does not have
> bigtime enabled if xfs_db tool is not uptodate.

If the xfs_db tool doesn't support the timelimit command then it doesn't
support formatting with bigtime.  I don't think it's reasonable to
expect to be able to run fstests on a test filesystem that xfsprogs
doesn't support.  Hence it's fine to output the old limits if the
timelimit command doesn't exist.

> Maybe it makes sense, but it may be safer to return "-1 -1" and not_run
> generic/402 if xfs_db is not uptodate, perhaps with an extra message
> hinting the user to upgrade xfs_db.

TBH it boggles my mind that there *still* is no way to ask the kernel
for the supported timestamp range of a mounted filesystem.  The
timelimit command and this mess in fstests was supposed to be a
temporary workaround that would (in my ideal world) have become
unnecessary before this landed, but ... ugh.

--D

> Thanks,
> Amir.
Amir Goldstein Oct. 29, 2020, 6:56 p.m. UTC | #3
On Thu, Oct 29, 2020 at 8:27 PM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> On Thu, Oct 29, 2020 at 12:47:32PM +0200, Amir Goldstein wrote:
> > On Wed, Oct 28, 2020 at 10:24 PM Darrick J. Wong
> > <darrick.wong@oracle.com> wrote:
> > >
> > > From: Darrick J. Wong <darrick.wong@oracle.com>
> > >
> > > Teach fstests to extract timestamp limits of a filesystem using the new
> > > xfs_db timelimit command.
> > >
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > >  common/rc         |    2 +-
> > >  common/xfs        |   14 ++++++++++++++
> > >  tests/xfs/911     |   44 ++++++++++++++++++++++++++++++++++++++++++++
> > >  tests/xfs/911.out |   15 +++++++++++++++
> > >  tests/xfs/group   |    1 +
> > >  5 files changed, 75 insertions(+), 1 deletion(-)
> > >  create mode 100755 tests/xfs/911
> > >  create mode 100644 tests/xfs/911.out
> > >
> > >
> > > diff --git a/common/rc b/common/rc
> > > index 41f93047..162d957a 100644
> > > --- a/common/rc
> > > +++ b/common/rc
> > > @@ -2029,7 +2029,7 @@ _filesystem_timestamp_range()
> > >                 echo "0 $u32max"
> > >                 ;;
> > >         xfs)
> > > -               echo "$s32min $s32max"
> > > +               _xfs_timestamp_range "$device"
> > >                 ;;
> > >         btrfs)
> > >                 echo "$s64min $s64max"
> > > diff --git a/common/xfs b/common/xfs
> > > index e548a0a1..19ccee03 100644
> > > --- a/common/xfs
> > > +++ b/common/xfs
> > > @@ -994,3 +994,17 @@ _require_xfs_scratch_inobtcount()
> > >                 _notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
> > >         _scratch_unmount
> > >  }
> > > +
> > > +_xfs_timestamp_range()
> > > +{
> > > +       local use_db=0
> > > +       local dbprog="$XFS_DB_PROG $device"
>
> Heh, device isn't defined, I'll fix that.
>
> > > +       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
> > > +               echo "-$((1<<31)) $(((1<<31)-1))"
> >
> > This embodies an assumption that the tested filesystem does not have
> > bigtime enabled if xfs_db tool is not uptodate.
>
> If the xfs_db tool doesn't support the timelimit command then it doesn't
> support formatting with bigtime.  I don't think it's reasonable to
> expect to be able to run fstests on a test filesystem that xfsprogs
> doesn't support.  Hence it's fine to output the old limits if the
> timelimit command doesn't exist.

ok.

>
> > Maybe it makes sense, but it may be safer to return "-1 -1" and not_run
> > generic/402 if xfs_db is not uptodate, perhaps with an extra message
> > hinting the user to upgrade xfs_db.
>
> TBH it boggles my mind that there *still* is no way to ask the kernel
> for the supported timestamp range of a mounted filesystem.  The
> timelimit command and this mess in fstests was supposed to be a
> temporary workaround that would (in my ideal world) have become
> unnecessary before this landed, but ... ugh.
>

Oh well, consider this

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index 41f93047..162d957a 100644
--- a/common/rc
+++ b/common/rc
@@ -2029,7 +2029,7 @@  _filesystem_timestamp_range()
 		echo "0 $u32max"
 		;;
 	xfs)
-		echo "$s32min $s32max"
+		_xfs_timestamp_range "$device"
 		;;
 	btrfs)
 		echo "$s64min $s64max"
diff --git a/common/xfs b/common/xfs
index e548a0a1..19ccee03 100644
--- a/common/xfs
+++ b/common/xfs
@@ -994,3 +994,17 @@  _require_xfs_scratch_inobtcount()
 		_notrun "inobtcount not supported by scratch filesystem type: $FSTYP"
 	_scratch_unmount
 }
+
+_xfs_timestamp_range()
+{
+	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
+		echo "-$((1<<31)) $(((1<<31)-1))"
+	else
+		$dbprog -f -c 'timelimit --compact' | awk '{printf("%s %s", $1, $2);}'
+	fi
+}
diff --git a/tests/xfs/911 b/tests/xfs/911
new file mode 100755
index 00000000..bccd1e8f
--- /dev/null
+++ b/tests/xfs/911
@@ -0,0 +1,44 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 911
+#
+# 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/911.out b/tests/xfs/911.out
new file mode 100644
index 00000000..84dc475b
--- /dev/null
+++ b/tests/xfs/911.out
@@ -0,0 +1,15 @@ 
+QA output created by 911
+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
diff --git a/tests/xfs/group b/tests/xfs/group
index 862df3be..f61d46a1 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -525,6 +525,7 @@ 
 761 auto quick realtime
 763 auto quick rw realtime
 910 auto quick inobtcount
+911 auto quick bigtime
 915 auto quick quota
 917 auto quick db
 918 auto quick db