After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705426 - Formatting Existing BTRFS Partition as BTRFS Fails Because mkfs.btrfs Is Not Run with "-f"
Formatting Existing BTRFS Partition as BTRFS Fails Because mkfs.btrfs Is Not ...
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: application
0.16.1
Other Linux
: Normal normal
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2013-08-03 23:12 UTC by catlover2
Modified: 2013-09-18 16:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Log of failure (2.96 KB, text/plain)
2013-08-03 23:13 UTC, catlover2
  Details
Clear all btrfs signatures (v1) (11.43 KB, patch)
2013-08-26 10:41 UTC, Mike Fleetwood
none Details | Review

Description catlover2 2013-08-03 23:12:31 UTC
To reproduce:

1. Create a BTRFS partition.
2. In GParted, right click the newly created partition and select Format to > btrfs. Apply all operations.
3. Formatting will fail because mkfs.btrfs still believes the partition contains a BTRFS filesystem and was not run with -f.

As a workaround, mkfs.btrfs can be manually run with the -f flag instead of using GParted. It formats the partition as expected in this case.
Comment 1 catlover2 2013-08-03 23:13:15 UTC
Created attachment 250781 [details]
Log of failure
Comment 2 Curtis Gedak 2013-08-07 16:58:55 UTC
Thank you for your interest in GParted.

I tried "Btrfs v0.19" and did not encounter this problem.

From the gparted details log file in comment #1, it appears that a non-official btrfs release was used:

  Btrfs v0.20-rc1-253-g7854c8b

Perhaps this is a bug or change in behaviour in this particular Btrfs release candidate?
Comment 3 Mike Fleetwood 2013-08-07 19:34:06 UTC
Hi Curtis,

Unfortunately btrfs-tools are effectively never released.  (v0.19 was
tagged in GIT in 2009 and has since been removed, yet v0.20 hasn't been
tagged yet.  So there's 4 years of kernel releases with significant
btrfs improvements without a supporting tools release).  Distributions
have no option but just to use a recent copy of btrfs-tools straight
from the GIT repository.

So newer versions of mkfs.btrfs now check for existing contents of a
partition before overwritting it.  This includes checking for all the
mirror copies of the btrfs superblock.

https://btrfs.wiki.kernel.org/index.php/User:Wtachi/On-disk_Format#Superblock

"-f" is a new option to mkfs.btrfs which doesn't exist in older
versions.  This is going to need to be handled if this is the solution
used.

I had intended for GParted_Core::erase_filesystem_signatures() to do
everything necessary to remove all signatures of file systems.  It could
be extended to clear all the mirror copies of the btrfs superblock too.

I'll have a look at doing something in a few weeks.

Mike
Comment 4 Curtis Gedak 2013-08-08 15:50:50 UTC
Hi Mike,

Thanks for the brief history of btrfs-tools release tagging, or lack thereof.

I guess the preferred route would be to also zero out new locations for btrfs signatures.  That way we would not need to test if the "-f" flag is available.

Feel free to implement a solution as you see fit.

Curtis
Comment 5 Mike Fleetwood 2013-08-26 10:41:49 UTC
Created attachment 253112 [details] [review]
Clear all btrfs signatures (v1)

Hi Curtis,

Here's the patch.  I used Fedora 19 to test as it's the first Fedora to
include a recent enough btrfs-progs to encounter this problem without
compiling it yourself.

The diff seems particularly unhelpful in understanding the code change
to erase_filesystem_signatures().  I replaced the clear primary and
secondary signature sections with a single looping section which clears
all entries in the ranges[] array.

Thanks,
Mike
Comment 6 Curtis Gedak 2013-08-26 19:14:02 UTC
Hi Mike,

This patch looks good to me.  I confirmed the problem with the prior source code on Fedora 19 and verified that the problem is resolved with the patch in comment #5.

My testing included Fedora 19 and Kubuntu 12.04, and involved reformatting MiB and Cylinder aligned partitions with btrfs and nilfs2.  All tests concluded successfully.

The patch has been committed to the git repository for inclusion in the next release of GParted.

The relevant git commit can be viewed at the following link:

Clear btrfs file system super block mirror copies too (#705426)
https://git.gnome.org/browse/gparted/commit/?id=246e05559d91865dd135690a62d56144f375c26b

Thanks for the clean fix to this bug report Mike.

Curtis
Comment 7 Curtis Gedak 2013-09-18 16:53:54 UTC
The patch to address this report has been included in GParted 0.16.2 released on September 18, 2013.