diff mbox series

[1/2] xfs: refactor calls to xfs_admin

Message ID 158086095320.1990521.15734406558551927388.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series xfs_admin: unify online/offline fs label setting | expand

Commit Message

Darrick J. Wong Feb. 5, 2020, 12:02 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Create a helper to run xfs_admin on the scratch device, then refactor
all tests to use it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/config |    1 +
 common/xfs    |    8 ++++++++
 tests/xfs/287 |    2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

Comments

Amir Goldstein Feb. 5, 2020, 6:35 a.m. UTC | #1
On Wed, Feb 5, 2020 at 2:02 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Create a helper to run xfs_admin on the scratch device, then refactor
> all tests to use it.

all tests... heh overstatement :)

Maybe say something about how logdev is needed as argument and
supported only since recent v5.4 xfsprogs.
Does older xfsprogs cope well with the extra argument?

Thanks,
Amir.

>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/config |    1 +
>  common/xfs    |    8 ++++++++
>  tests/xfs/287 |    2 +-
>  3 files changed, 10 insertions(+), 1 deletion(-)
>
>
> diff --git a/common/config b/common/config
> index 9a9c7760..1116cb99 100644
> --- a/common/config
> +++ b/common/config
> @@ -154,6 +154,7 @@ MKSWAP_PROG="$MKSWAP_PROG -f"
>  export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)"
>  export XFS_REPAIR_PROG="$(type -P xfs_repair)"
>  export XFS_DB_PROG="$(type -P xfs_db)"
> +export XFS_ADMIN_PROG="$(type -P xfs_admin)"
>  export XFS_GROWFS_PROG=$(type -P xfs_growfs)
>  export XFS_SPACEMAN_PROG="$(type -P xfs_spaceman)"
>  export XFS_SCRUB_PROG="$(type -P xfs_scrub)"
> diff --git a/common/xfs b/common/xfs
> index 706ddf85..d9a9784f 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -218,6 +218,14 @@ _scratch_xfs_db()
>         $XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
>  }
>
> +_scratch_xfs_admin()
> +{
> +       local options=("$SCRATCH_DEV")
> +       [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> +               options+=("$SCRATCH_LOGDEV")
> +       $XFS_ADMIN_PROG "$@" "${options[@]}"
> +}
> +
>  _scratch_xfs_logprint()
>  {
>         SCRATCH_OPTIONS=""
> diff --git a/tests/xfs/287 b/tests/xfs/287
> index 8dc754a5..f77ed2f1 100755
> --- a/tests/xfs/287
> +++ b/tests/xfs/287
> @@ -70,7 +70,7 @@ $XFS_IO_PROG -r -c "lsproj" $dir/32bit
>  _scratch_unmount
>
>  # Now, enable projid32bit support by xfs_admin
> -xfs_admin -p $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_admin failed"
> +_scratch_xfs_admin -p >> $seqres.full 2>&1 || _fail "xfs_admin failed"
>
>  # Now mount the fs, 32bit project quotas shall be supported, now
>  _qmount_option "pquota"
>
Darrick J. Wong Feb. 5, 2020, 4:23 p.m. UTC | #2
On Wed, Feb 05, 2020 at 08:35:05AM +0200, Amir Goldstein wrote:
> On Wed, Feb 5, 2020 at 2:02 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
> >
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Create a helper to run xfs_admin on the scratch device, then refactor
> > all tests to use it.
> 
> all tests... heh overstatement :)

"all tests that use xfs_admin"?

> Maybe say something about how logdev is needed as argument and
> supported only since recent v5.4 xfsprogs.
> Does older xfsprogs cope well with the extra argument?

Prior to 5.4, xfs_admin will reject the logdev argument and exit; and
if you try to work around it by constructing the xfs_db command by hand,
xfs_db will reject the filesystem because the log device isn't
specified.

IOWs, prior to 5.4 it just plain didn't work at all.

--D

> Thanks,
> Amir.
> 
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/config |    1 +
> >  common/xfs    |    8 ++++++++
> >  tests/xfs/287 |    2 +-
> >  3 files changed, 10 insertions(+), 1 deletion(-)
> >
> >
> > diff --git a/common/config b/common/config
> > index 9a9c7760..1116cb99 100644
> > --- a/common/config
> > +++ b/common/config
> > @@ -154,6 +154,7 @@ MKSWAP_PROG="$MKSWAP_PROG -f"
> >  export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)"
> >  export XFS_REPAIR_PROG="$(type -P xfs_repair)"
> >  export XFS_DB_PROG="$(type -P xfs_db)"
> > +export XFS_ADMIN_PROG="$(type -P xfs_admin)"
> >  export XFS_GROWFS_PROG=$(type -P xfs_growfs)
> >  export XFS_SPACEMAN_PROG="$(type -P xfs_spaceman)"
> >  export XFS_SCRUB_PROG="$(type -P xfs_scrub)"
> > diff --git a/common/xfs b/common/xfs
> > index 706ddf85..d9a9784f 100644
> > --- a/common/xfs
> > +++ b/common/xfs
> > @@ -218,6 +218,14 @@ _scratch_xfs_db()
> >         $XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
> >  }
> >
> > +_scratch_xfs_admin()
> > +{
> > +       local options=("$SCRATCH_DEV")
> > +       [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> > +               options+=("$SCRATCH_LOGDEV")
> > +       $XFS_ADMIN_PROG "$@" "${options[@]}"
> > +}
> > +
> >  _scratch_xfs_logprint()
> >  {
> >         SCRATCH_OPTIONS=""
> > diff --git a/tests/xfs/287 b/tests/xfs/287
> > index 8dc754a5..f77ed2f1 100755
> > --- a/tests/xfs/287
> > +++ b/tests/xfs/287
> > @@ -70,7 +70,7 @@ $XFS_IO_PROG -r -c "lsproj" $dir/32bit
> >  _scratch_unmount
> >
> >  # Now, enable projid32bit support by xfs_admin
> > -xfs_admin -p $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_admin failed"
> > +_scratch_xfs_admin -p >> $seqres.full 2>&1 || _fail "xfs_admin failed"
> >
> >  # Now mount the fs, 32bit project quotas shall be supported, now
> >  _qmount_option "pquota"
> >
diff mbox series

Patch

diff --git a/common/config b/common/config
index 9a9c7760..1116cb99 100644
--- a/common/config
+++ b/common/config
@@ -154,6 +154,7 @@  MKSWAP_PROG="$MKSWAP_PROG -f"
 export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)"
 export XFS_REPAIR_PROG="$(type -P xfs_repair)"
 export XFS_DB_PROG="$(type -P xfs_db)"
+export XFS_ADMIN_PROG="$(type -P xfs_admin)"
 export XFS_GROWFS_PROG=$(type -P xfs_growfs)
 export XFS_SPACEMAN_PROG="$(type -P xfs_spaceman)"
 export XFS_SCRUB_PROG="$(type -P xfs_scrub)"
diff --git a/common/xfs b/common/xfs
index 706ddf85..d9a9784f 100644
--- a/common/xfs
+++ b/common/xfs
@@ -218,6 +218,14 @@  _scratch_xfs_db()
 	$XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
 }
 
+_scratch_xfs_admin()
+{
+	local options=("$SCRATCH_DEV")
+	[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+		options+=("$SCRATCH_LOGDEV")
+	$XFS_ADMIN_PROG "$@" "${options[@]}"
+}
+
 _scratch_xfs_logprint()
 {
 	SCRATCH_OPTIONS=""
diff --git a/tests/xfs/287 b/tests/xfs/287
index 8dc754a5..f77ed2f1 100755
--- a/tests/xfs/287
+++ b/tests/xfs/287
@@ -70,7 +70,7 @@  $XFS_IO_PROG -r -c "lsproj" $dir/32bit
 _scratch_unmount
 
 # Now, enable projid32bit support by xfs_admin
-xfs_admin -p $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_admin failed"
+_scratch_xfs_admin -p >> $seqres.full 2>&1 || _fail "xfs_admin failed"
 
 # Now mount the fs, 32bit project quotas shall be supported, now
 _qmount_option "pquota"