linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@inwind.it>
To: Chris Murphy <lists@colorremedies.com>
Cc: "linux-btrfs@vger.kernel.org list" <linux-btrfs@vger.kernel.org>
Subject: Re: BUG btrfs fi show displays stale btrfs volume
Date: Sun, 06 Jan 2013 17:26:57 +0100	[thread overview]
Message-ID: <50E9A5D1.4050704@inwind.it> (raw)
In-Reply-To: <96FA5245-87A9-43C4-9B56-C0F4ADB9D975@colorremedies.com>

Hi Chris
On 01/06/2013 12:21 AM, Chris Murphy wrote:
> I've filed this bug under util-linux, because I think wipefs isn't deleting all btrfs metadata it could. But ultimately it appears to be a btrfs bug because nothing else sees the stale volume.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=889888#c15
> 
> btrfs-progs-0.20.rc1.20121017git92d9eec-1.fc18.x86_64
> e2fs-progs-1.42.5-1.fc18.x86_64
> kernel 3.7.1-2
> 
> Brand new 80GB virtual disk, so it's completely zero'd.
> 
> 1. fdisk to create one partition, all defaults.
> 2. Format that sda1 with mkfs.btrfs -L first.
> 3. btrfs fi show displays "first" labeled volume.
> 4. wipefs -a /dev/sda1 and it finds btrfs metadata, ostensibly removes it.
> 5. btrfs fi show does NOT show "first" anymore.
> 6. fdisk /dev/sda again, delete the one partition; create a new partition 500MB and a second one for remaining space.
> 7. btrfs fi show still does not show "first".
> 8. mkfs.ext4 /dev/sda1
> 9. btrfs fi show NOW SHOWS "first" on sda1!
> 10. Reboot
> 11. btrfs fi show still shows "first" on sda1, size 80GB.
> 
> Tentative conclusions:
> 
> A. wipefs isn't deleting all btrfs metadata it could. 
True
> 
> B. mkfs.ext4 is refreshing stale btrfs metadata in a way that causes btrfs fi show to see.
True

Btrfs stores several copies of the superblock (IIRC three). During the
scan it searches for a valid superblock. If the first is wrong, checks
the second and so on...
It stops the search when one of the following conditions is true:
1) the superblock "magic" field is zero (typically when a disk is removed)
2) the superblock is valid
3) there is no other superblock.

I think that wipefs zeros the "magic" field on the first superblock. So
the btrfs scan process ends at the first superblock.

When the disk is used again, it is possible that the first superblock is
overwritten and the "magic" field is not zero any more. So in case of
further scan by btrfs, the first superblock is ignored and the check is
performed to the second one and the third one, which could be valid, if
nobody zeroed its "magic" field.

I think that wipefs should be improved to reset to zero also the other
superblocks.

I will start to update the wiki; then I will give a look to wipefs to
improve it.

BR
G.Baroncelli
-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

  reply	other threads:[~2013-01-06 16:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-05 23:21 BUG btrfs fi show displays stale btrfs volume Chris Murphy
2013-01-06 16:26 ` Goffredo Baroncelli [this message]
2013-01-06 17:20   ` Goffredo Baroncelli

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=50E9A5D1.4050704@inwind.it \
    --to=kreijack@inwind.it \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.com \
    /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).