From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@infradead.org>,
Zorro Lang <zlang@kernel.org>,
fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs/157: mkfs does not need a specific fssize
Date: Thu, 7 Nov 2024 15:53:21 -0800 [thread overview]
Message-ID: <20241107235321.GX2386201@frogsfrogsfrogs> (raw)
In-Reply-To: <20241107101011.2j5tel7zucn3rbbf@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com>
On Thu, Nov 07, 2024 at 06:10:11PM +0800, Zorro Lang wrote:
> On Thu, Nov 07, 2024 at 04:40:34PM +1100, Dave Chinner wrote:
> > On Tue, Nov 05, 2024 at 07:47:12AM -0800, Darrick J. Wong wrote:
> > > On Tue, Nov 05, 2024 at 07:02:26AM -0800, Christoph Hellwig wrote:
> > > > On Tue, Nov 05, 2024 at 05:58:03PM +1100, Dave Chinner wrote:
> > > > > When the two conflict, _scratch_mkfs drops the global MKFS_OPTIONS
> > > > > and uses only the local parameters so the filesystem is set up with
> > > > > the configuration the test expects.
> > > > >
> > > > > In this case, MKFS_OPTIONS="-m rmapbt=1" which conflicts with the
> > > > > local RTDEV/USE_EXTERNAL test setup. Because the test icurrently
> > > > > overloads the global MKFS_OPTIONS with local test options, the local
> > > > > test parameters are dropped along with the global paramters when
> > > > > there is a conflict. Hence the mkfs_scratch call fails to set the
> > > > > filesystem up the way the test expects.
> > > >
> > > > But the rmapbt can be default on, in which case it does not get
> > > > removed. And then without the _sized we'll run into the problem that
> > > > Hans' patches fixed once again.
> > >
> > > Well we /could/ make _scratch_mkfs_sized pass options through to the
> > > underlying _scratch_mkfs.
> >
> > That seems like the right thing to do to me.
>
> OK, thanks for all of these suggestions, how about below (draft) change[1].
> If it's good to all of you, I'll send another patch.
>
> Thanks,
> Zorro
>
> diff --git a/common/rc b/common/rc
> index 2af26f23f..673f056fb 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1027,7 +1027,9 @@ _small_fs_size_mb()
> _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 ($@)"
> }
>
> # Emulate an N-data-disk stripe w/ various stripe units
> diff --git a/tests/xfs/157 b/tests/xfs/157
> index 9b5badbae..f8f102d78 100755
> --- a/tests/xfs/157
> +++ b/tests/xfs/157
> @@ -66,8 +66,7 @@ scenario() {
> }
>
> check_label() {
> - MKFS_OPTIONS="-L oldlabel $MKFS_OPTIONS" _scratch_mkfs_sized $fs_size \
> - >> $seqres.full
> + _scratch_mkfs_sized "$fs_size" "" "-L oldlabel" >> $seqres.full 2>&1
> _scratch_xfs_db -c label
> _scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> _scratch_xfs_db -c label
Looks good to me, though you probably still need to fix the double -L
case:
From: Darrick J. Wong <djwong@kernel.org>
Subject: [PATCH] xfs/157: fix test failures when MKFS_OPTIONS has -L options
Zorro reports that this test now fails if the test runner set an -L
(label) option in MKFS_OPTIONS. Fix the test to work around this with a
bunch of horrid sed filtering magic.
Cc: <fstests@vger.kernel.org> # v2024.10.14
Fixes: 2f7e1b8a6f09b6 ("xfs/157,xfs/547,xfs/548: switch to using _scratch_mkfs_sized")
---
tests/xfs/157 | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/tests/xfs/157 b/tests/xfs/157
index 9b5badbaeb3c76..30f8cc870b9af2 100755
--- a/tests/xfs/157
+++ b/tests/xfs/157
@@ -65,10 +65,35 @@ scenario() {
SCRATCH_RTDEV=$orig_rtdev
}
+extract_mkfs_label() {
+ set -- $MKFS_OPTIONS
+ local in_l
+
+ for arg in "$@"; do
+ if [ "$in_l" = "1" ]; then
+ echo "$arg"
+ return 0
+ elif [ "$arg" = "-L" ]; then
+ in_l=1
+ fi
+ done
+ return 1
+}
+
check_label() {
- MKFS_OPTIONS="-L oldlabel $MKFS_OPTIONS" _scratch_mkfs_sized $fs_size \
- >> $seqres.full
- _scratch_xfs_db -c label
+ local existing_label
+ local filter
+
+ # Handle -L somelabel being set in MKFS_OPTIONS
+ if existing_label="$(extract_mkfs_label)"; then
+ filter=(sed -e "s|$existing_label|oldlabel|g")
+ _scratch_mkfs_sized $fs_size >> $seqres.full
+ else
+ filter=(cat)
+ MKFS_OPTIONS="-L oldlabel $MKFS_OPTIONS" \
+ _scratch_mkfs_sized $fs_size >> $seqres.full
+ fi
+ _scratch_xfs_db -c label | "${filter[@]}"
_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
_scratch_xfs_db -c label
_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
next prev parent reply other threads:[~2024-11-07 23:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 19:35 [PATCH] xfs/157: mkfs does not need a specific fssize Zorro Lang
2024-10-31 22:08 ` Darrick J. Wong
2024-11-01 5:48 ` Zorro Lang
2024-11-01 21:49 ` Darrick J. Wong
2024-11-04 7:50 ` Christoph Hellwig
2024-11-04 13:04 ` Zorro Lang
2024-11-04 23:34 ` Darrick J. Wong
2024-11-05 6:58 ` Dave Chinner
2024-11-05 15:02 ` Christoph Hellwig
2024-11-05 15:47 ` Darrick J. Wong
2024-11-07 5:40 ` Dave Chinner
2024-11-07 10:10 ` Zorro Lang
2024-11-07 23:53 ` Darrick J. Wong [this message]
2024-11-14 23:43 ` Darrick J. Wong
2024-11-05 6:58 ` Dave Chinner
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=20241107235321.GX2386201@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@kernel.org \
--cc=zlang@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox