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

Qu Wenruo <[email protected]>
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-btrfs
Message-ID <[email protected]>

在 2026/6/5 13:38, Christoph Hellwig 写道:
> On Tue, Jun 02, 2026 at 10:47:39PM -0500, Eric Sandeen wrote:
>> 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.
> 
> I haven't run into this yet, but it seem like btrfs needs this.
> But maybe you should also Cc the btrfs list?

This is the wrong fix.

It's caused by a mkfs.btrfs help string output change, and it's properly 
fixed by this patch which is already merged for a while:

https://lore.kernel.org/linux-btrfs/[email protected]/

Thanks,
Qu
> 
>>
>> 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
>>
>>
> ---end quoted text---
>
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.