linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, david@fromorbit.com
Subject: [PATCH 1/2] fstests: btrfs streamlining mkfs command for post-mkfs operations
Date: Thu, 28 Sep 2023 12:23:04 +0800	[thread overview]
Message-ID: <728cfa8f2ce67d2b260851e10d4922fd710364e2.1695543976.git.anand.jain@oracle.com> (raw)
In-Reply-To: <cover.1695543976.git.anand.jain@oracle.com>

To prepare for adding post-mkfs operations support for Btrfs, streamline
the mkfs command functions.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/btrfs | 21 +++++++++++++++++++++
 common/rc    | 13 ++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index c9903a413cb0..798c899f6233 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -689,3 +689,24 @@ _require_btrfs_scratch_logical_resolve_v2()
 	fi
 	_scratch_unmount
 }
+
+_scratch_mkfs_retry_btrfs()
+{
+	# _scratch_do_mkfs() may retry mkfs without $MKFS_OPTIONS
+	_scratch_do_mkfs "$MKFS_BTRFS_PROG" "cat" $*
+
+	return $?
+}
+
+_scratch_mkfs_btrfs()
+{
+	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
+	return $?
+}
+
+_scratch_pool_mkfs_btrfs()
+{
+	$MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL
+
+	return $?
+}
diff --git a/common/rc b/common/rc
index a438a8de1461..2e602caa2f3b 100644
--- a/common/rc
+++ b/common/rc
@@ -729,8 +729,8 @@ _scratch_mkfs()
 		mkfs_filter="cat"
 		;;
 	btrfs)
-		mkfs_cmd="$MKFS_BTRFS_PROG"
-		mkfs_filter="cat"
+		_scratch_mkfs_retry_btrfs $*
+		return $?
 		;;
 	ext3)
 		mkfs_cmd="$MKFS_PROG -t $FSTYP -- -F"
@@ -881,7 +881,7 @@ _scratch_pool_mkfs()
 {
     case $FSTYP in
     btrfs)
-        $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
+	_scratch_pool_mkfs_btrfs $*
         ;;
     *)
         echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
@@ -1018,7 +1018,10 @@ _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
+
+		# _scratch_mkfs_btrfs appends $MKFS_OPTIONS and ends with
+		# $SCRATCH_DEV
+		_scratch_mkfs_btrfs $mixed_opt -b $fssize
 		;;
 	jfs)
 		${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
@@ -1112,7 +1115,7 @@ _scratch_mkfs_blocksized()
 		grep -wq $blocksize /sys/fs/btrfs/features/supported_sectorsizes || \
 		_notrun "$FSTYP does not support sectorsize=$blocksize yet"
 
-		_scratch_mkfs --sectorsize=$blocksize
+		_scratch_mkfs_retry_btrfs --sectorsize=$blocksize
 		;;
 	xfs)
 		_scratch_mkfs_xfs $MKFS_OPTIONS -b size=$blocksize
-- 
2.39.3


  reply	other threads:[~2023-09-28  4:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28  4:23 [PATCH 0/2] fstests: add config option to run after mkfs Anand Jain
2023-09-28  4:23 ` Anand Jain [this message]
2023-09-28  4:23 ` [PATCH 2/2] fstests: add configuration option for executing post mkfs commands Anand Jain
2023-09-28  4:26   ` Qu Wenruo
2023-09-28  5:34     ` Anand Jain
2023-09-28  7:40       ` Qu Wenruo
2023-10-06  5:17         ` Dave Chinner
2023-10-09 12:18           ` Anand Jain
2023-10-06  6:09         ` Darrick J. Wong
2023-10-06  6:46           ` Qu Wenruo
2023-10-06 22:12             ` Dave Chinner
2023-10-07  2:45               ` Qu Wenruo
2023-10-09 12:23           ` Anand Jain

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=728cfa8f2ce67d2b260851e10d4922fd710364e2.1695543976.git.anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).