Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* Re: [PATCH] btrfs: use -f by default for mkfs as xfs/extN do
       [not found] <a31e9841-fd0c-435f-b376-86a7e01ddca7@redhat.com>
@ 2026-06-05  4:08 ` Christoph Hellwig
  2026-06-05  4:14   ` Qu Wenruo
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2026-06-05  4:08 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: fstests@vger.kernel.org, linux-btrfs

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?

> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> 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---

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs: use -f by default for mkfs as xfs/extN do
  2026-06-05  4:08 ` [PATCH] btrfs: use -f by default for mkfs as xfs/extN do Christoph Hellwig
@ 2026-06-05  4:14   ` Qu Wenruo
  2026-06-05  4:17     ` Christoph Hellwig
  2026-06-05 17:59     ` Eric Sandeen
  0 siblings, 2 replies; 6+ messages in thread
From: Qu Wenruo @ 2026-06-05  4:14 UTC (permalink / raw)
  To: Christoph Hellwig, Eric Sandeen; +Cc: fstests@vger.kernel.org, linux-btrfs



在 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/20260510001704.68396-1-wqu@suse.com/

Thanks,
Qu
> 
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> 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---
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs: use -f by default for mkfs as xfs/extN do
  2026-06-05  4:14   ` Qu Wenruo
@ 2026-06-05  4:17     ` Christoph Hellwig
  2026-06-05  4:23       ` Qu Wenruo
  2026-06-05 17:59     ` Eric Sandeen
  1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2026-06-05  4:17 UTC (permalink / raw)
  To: Qu Wenruo
  Cc: Christoph Hellwig, Eric Sandeen, fstests@vger.kernel.org,
	linux-btrfs

On Fri, Jun 05, 2026 at 01:44:02PM +0930, Qu Wenruo wrote:
> 
> 
> 在 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/20260510001704.68396-1-wqu@suse.com/

In other words: we already get -f, but it got broken recently.  That
explains why things always worked for me.

I took me a bit to reverse-engineers this from your answer :)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs: use -f by default for mkfs as xfs/extN do
  2026-06-05  4:17     ` Christoph Hellwig
@ 2026-06-05  4:23       ` Qu Wenruo
  2026-06-05  4:27         ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2026-06-05  4:23 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Eric Sandeen, fstests@vger.kernel.org, linux-btrfs



在 2026/6/5 13:47, Christoph Hellwig 写道:
> On Fri, Jun 05, 2026 at 01:44:02PM +0930, Qu Wenruo wrote:
>>
>>
>> 在 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/20260510001704.68396-1-wqu@suse.com/
> 
> In other words: we already get -f, but it got broken recently.  That
> explains why things always worked for me.

Hey, this shows you're running on a proper server distro, not some 
rolling bleeding edge one :)

And thanks for CCing the btrfs list.

> 
> I took me a bit to reverse-engineers this from your answer :)
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs: use -f by default for mkfs as xfs/extN do
  2026-06-05  4:23       ` Qu Wenruo
@ 2026-06-05  4:27         ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-06-05  4:27 UTC (permalink / raw)
  To: Qu Wenruo
  Cc: Christoph Hellwig, Eric Sandeen, fstests@vger.kernel.org,
	linux-btrfs

On Fri, Jun 05, 2026 at 01:53:33PM +0930, Qu Wenruo wrote:
> > In other words: we already get -f, but it got broken recently.  That
> > explains why things always worked for me.
> 
> Hey, this shows you're running on a proper server distro, not some rolling
> bleeding edge one :)

Actually I run self-built btrfsprogs in my test VMs.  I just didn't have
a need to update it recently.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs: use -f by default for mkfs as xfs/extN do
  2026-06-05  4:14   ` Qu Wenruo
  2026-06-05  4:17     ` Christoph Hellwig
@ 2026-06-05 17:59     ` Eric Sandeen
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Sandeen @ 2026-06-05 17:59 UTC (permalink / raw)
  To: Qu Wenruo, Christoph Hellwig, Eric Sandeen
  Cc: fstests@vger.kernel.org, linux-btrfs

On 6/4/26 11:14 PM, Qu Wenruo wrote:
> 
> 
> 在 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?

Yeah, sorry.

> 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/20260510001704.68396-1-wqu@suse.com/

Oh, ugh. I did not know (ok: remember, because I wrote it in 2013) that
we had a special helper function used only for a subset of
filesystems, while hardcoding -f / -F on other filesystems. :(

Anyway, this fix is still on for-next and I missed it, sorry about that.

Thanks for the heads up.

-Eric
 
> Thanks,
> Qu


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-05 17:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <a31e9841-fd0c-435f-b376-86a7e01ddca7@redhat.com>
2026-06-05  4:08 ` [PATCH] btrfs: use -f by default for mkfs as xfs/extN do Christoph Hellwig
2026-06-05  4:14   ` Qu Wenruo
2026-06-05  4:17     ` Christoph Hellwig
2026-06-05  4:23       ` Qu Wenruo
2026-06-05  4:27         ` Christoph Hellwig
2026-06-05 17:59     ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox