[PATCH] btrfs: use -f by default for mkfs as xfs/extN do

Eric Sandeen <[email protected]>
Newsgroups org.kernel.vger.fstests
Message-ID <[email protected]>
Recently saw a case where testing ext4, xfs, then btrfs failed all
btrfs tests because mkfs.btrfs refused to overwrite the left-over
xfs filesystem on $SCRATCH_DEV.

This seems well-enough fixed by only making the change to _scratch_mkfs,
but several other helper functions explicitly use -f / -F for xfs
and extN, so I've updated them for btrfs as well.

Signed-off-by: Eric Sandeen <[email protected]>
---

TBH I'm a little baffled, has nobody really run into this before, or
am I missing something?

 common/rc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/rc b/common/rc
index 9632b211..e77edf97 100644
--- a/common/rc
+++ b/common/rc
@@ -871,7 +871,7 @@ _test_mkfs()
         $MKFS_UDF_PROG $MKFS_OPTIONS $* $TEST_DEV > /dev/null
 	;;
     btrfs)
-        $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $TEST_DEV > /dev/null
+        $MKFS_BTRFS_PROG -f $MKFS_OPTIONS $* $TEST_DEV > /dev/null
 	;;
     ext2|ext3|ext4)
 	$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* $TEST_DEV
@@ -920,7 +920,7 @@ _try_mkfs_dev()
         $MKFS_UDF_PROG $MKFS_OPTIONS $*
 	;;
     btrfs)
-        $MKFS_BTRFS_PROG $MKFS_OPTIONS $*
+        $MKFS_BTRFS_PROG -f $MKFS_OPTIONS $*
 	;;
     ext2|ext3|ext4)
 	$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $*
@@ -1010,7 +1010,7 @@ _scratch_mkfs()
 		mkfs_filter="cat"
 		;;
 	btrfs)
-		mkfs_cmd="$MKFS_BTRFS_PROG"
+		mkfs_cmd="$MKFS_BTRFS_PROG -f"
 		mkfs_filter="cat"
 		;;
 	ext3)
@@ -1176,7 +1176,7 @@ _scratch_pool_mkfs()
 {
     case $FSTYP in
     btrfs)
-        $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
+        $MKFS_BTRFS_PROG -f $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
         ;;
     *)
         echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
@@ -1369,7 +1369,7 @@ _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 -f $MKFS_OPTIONS $mixed_opt -b $fssize "$@" $SCRATCH_DEV
 		;;
 	jfs)
 		${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS "$@" $SCRATCH_DEV $blocks
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.