From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@kernel.org>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] common/rc: _scratch_mkfs_sized supports extra arguments
Date: Mon, 18 Nov 2024 14:43:13 -0800 [thread overview]
Message-ID: <20241118224313.GL9425@frogsfrogsfrogs> (raw)
In-Reply-To: <20241118222136.GJ9425@frogsfrogsfrogs>
On Mon, Nov 18, 2024 at 02:21:36PM -0800, Darrick J. Wong wrote:
> On Sun, Nov 17, 2024 at 03:07:59AM +0800, Zorro Lang wrote:
> > To give more arguments to _scratch_mkfs_sized, we generally do as:
> >
> > MKFS_OPTIONS="-L oldlabel $MKFS_OPTIONS" _scratch_mkfs_sized $fs_size
> >
> > to give "-L oldlabel" to it. But if _scratch_mkfs_sized fails, it
> > will get rid of the whole MKFS_OPTIONS and try to mkfs again.
> > Likes:
> >
> > ** mkfs failed with extra mkfs options added to "-L oldlabel -m rmapbt=1" by test 157 **
> > ** attempting to mkfs using only test 157 options: -d size=524288000 -b size=4096 **
> >
> > But that's not the fault of "-L oldlabel". So for keeping the mkfs
> > options ("-L oldlabel") we need, we'd better to let the
> > scratch_mkfs_sized to support extra arguments, rather than using
> > global MKFS_OPTIONS.
> >
> > Signed-off-by: Zorro Lang <zlang@kernel.org>
> > ---
> > common/rc | 34 ++++++++++++++++++----------------
> > 1 file changed, 18 insertions(+), 16 deletions(-)
> >
> > diff --git a/common/rc b/common/rc
> > index 2af26f23f..ce8602383 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -1023,11 +1023,13 @@ _small_fs_size_mb()
> > }
> >
> > # Create fs of certain size on scratch device
> > -# _try_scratch_mkfs_sized <size in bytes> [optional blocksize]
> > +# _try_scratch_mkfs_sized <size in bytes> [optional blocksize] [other options]
> > _try_scratch_mkfs_sized()
> > {
> > local fssize=$1
> > - local blocksize=$2
> > + shift
> > + local blocksize=$1
> > + shift
> > local def_blksz
> > local blocksize_opt
> > local rt_ops
> > @@ -1091,10 +1093,10 @@ _try_scratch_mkfs_sized()
> > # don't override MKFS_OPTIONS that set a block size.
> > echo $MKFS_OPTIONS |grep -E -q "b\s*size="
> > if [ $? -eq 0 ]; then
> > - _try_scratch_mkfs_xfs -d size=$fssize $rt_ops
> > + _try_scratch_mkfs_xfs -d size=$fssize $rt_ops "$@"
> > else
> > _try_scratch_mkfs_xfs -d size=$fssize $rt_ops \
> > - -b size=$blocksize
> > + -b size=$blocksize "$@"
> > fi
> > ;;
> > ext2|ext3|ext4)
> > @@ -1105,7 +1107,7 @@ _try_scratch_mkfs_sized()
> > _notrun "Could not make scratch logdev"
> > MKFS_OPTIONS="$MKFS_OPTIONS -J device=$SCRATCH_LOGDEV"
> > fi
> > - ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
> > + ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize "$@" $SCRATCH_DEV $blocks
> > ;;
> > gfs2)
> > # mkfs.gfs2 doesn't automatically shrink journal files on small
> > @@ -1120,13 +1122,13 @@ _try_scratch_mkfs_sized()
> > (( journal_size >= min_journal_size )) || journal_size=$min_journal_size
> > MKFS_OPTIONS="-J $journal_size $MKFS_OPTIONS"
> > fi
> > - ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
> > + ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS -O -b $blocksize "$@" $SCRATCH_DEV $blocks
> > ;;
> > ocfs2)
> > - yes | ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
> > + yes | ${MKFS_PROG} -t $FSTYP -F $MKFS_OPTIONS -b $blocksize "$@" $SCRATCH_DEV $blocks
> > ;;
> > udf)
> > - $MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
> > + $MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize "$@" $SCRATCH_DEV $blocks
> > ;;
> > btrfs)
> > local mixed_opt=
> > @@ -1134,33 +1136,33 @@ _try_scratch_mkfs_sized()
> > # the device is not zoned. Ref: btrfs-progs: btrfs_min_dev_size()
> > (( fssize < $((256 * 1024 * 1024)) )) &&
> > ! _scratch_btrfs_is_zoned && mixed_opt='--mixed'
> > - $MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
> > + $MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize "$@" $SCRATCH_DEV
> > ;;
> > jfs)
> > - ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
> > + ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS "$@" $SCRATCH_DEV $blocks
> > ;;
> > reiserfs)
> > - ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
> > + ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS -b $blocksize "$@" $SCRATCH_DEV $blocks
> > ;;
> > reiser4)
> > # mkfs.resier4 requires size in KB as input for creating filesystem
> > - $MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
> > + $MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize "$@" $SCRATCH_DEV \
> > `expr $fssize / 1024`
> > ;;
> > f2fs)
> > # mkfs.f2fs requires # of sectors as an input for the size
> > local sector_size=`blockdev --getss $SCRATCH_DEV`
> > - $MKFS_F2FS_PROG $MKFS_OPTIONS $SCRATCH_DEV `expr $fssize / $sector_size`
> > + $MKFS_F2FS_PROG $MKFS_OPTIONS "$@" $SCRATCH_DEV `expr $fssize / $sector_size`
> > ;;
> > tmpfs)
> > local free_mem=`_free_memory_bytes`
> > if [ "$free_mem" -lt "$fssize" ] ; then
> > _notrun "Not enough memory ($free_mem) for tmpfs with $fssize bytes"
> > fi
> > - export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
> > + export MOUNT_OPTIONS="-o size=$fssize "$@" $TMPFS_MOUNT_OPTIONS"
> > ;;
> > bcachefs)
> > - $MKFS_BCACHEFS_PROG $MKFS_OPTIONS --fs_size=$fssize $blocksize_opt $SCRATCH_DEV
> > + $MKFS_BCACHEFS_PROG $MKFS_OPTIONS --fs_size=$fssize $blocksize_opt "$@" $SCRATCH_DEV
> > ;;
> > *)
> > _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
> > @@ -1170,7 +1172,7 @@ _try_scratch_mkfs_sized()
> >
> > _scratch_mkfs_sized()
> > {
> > - _try_scratch_mkfs_sized $* || _notrun "_scratch_mkfs_sized failed with ($*)"
> > + _try_scratch_mkfs_sized "$@" || _notrun "_scratch_mkfs_sized failed with ($@)"
>
> Nit: Don't use '$@' within a longer string -- either it's "$@" so that
> each element in the arg array is rendered individually as a separate
> string parameter to the program being called, or "foo $*" so that you
> end up with a single string.
>
> shellcheck will complain about that, though bash itself doesn't seem to
> care.
Oh, also, as I was rebasing my branch atop yours, I wondered, should
this patch convert these MKFS_OPTIONS overrides?
ext4/059
ext4/060
xfs/107
xfs/547
--D
> --D
>
> > }
> >
> > # Emulate an N-data-disk stripe w/ various stripe units
> > --
> > 2.45.2
> >
> >
>
next prev parent reply other threads:[~2024-11-18 22:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 19:07 [PATCH 0/2] fstests: fix test issue of xfs/157 Zorro Lang
2024-11-16 19:07 ` [PATCH 1/2] common/rc: _scratch_mkfs_sized supports extra arguments Zorro Lang
2024-11-18 22:21 ` Darrick J. Wong
2024-11-18 22:43 ` Darrick J. Wong [this message]
2024-11-21 9:17 ` Zorro Lang
2024-11-21 15:50 ` Darrick J. Wong
2024-11-16 19:08 ` [PATCH 2/2] xfs/157: do not drop necessary mkfs options Zorro Lang
2024-11-18 22:26 ` Darrick J. Wong
2024-11-21 9:35 ` Zorro Lang
2024-11-21 15:52 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241118224313.GL9425@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.