Skip to contentSkip to conversation

Btrfs: wipe all the superblock [redhat bugzilla 889888]

PATCH Goffredo Baroncelli 8 participants 15 messages Jan 6, 2013 – Jan 9, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

Currently wipefs doesn't clear all the superblock of btrfs. Only the first one is cleared.

Btrfs has three superblocks. The first one is placed at 64KB, the second one at 64MB, the third one at 256GB.

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

So zeroing the first superblock "magic field" at the beginning seems that the filesystem is wiped. But when the first superblock is overwritten (e.g. by another filesystem), then the other two superblocks may be considered valid, and the filesystem may resurrect.

# make a filesystem, wipe it and check if it disappears
$ sudo mkfs.btrfs -L "Btrfs-test" /dev/loop0
$ sudo btrfs filesystem  show /dev/loop0
Label: 'Btrfs-test'  uuid: 3156cef7-8522-411f-876a-ba8ec32cc781
	Total devices 1 FS bytes used 28.00KB
	devid    1 size 4.00TB used 2.04GB path /dev/loop0

Btrfs Btrfs v0.19

$ sudo wipefs /dev/loop0
offset               type
----------------------------------------------------------------
0x10040              btrfs   [filesystem]
                     LABEL: Btrfs-test
                     UUID:  3156cef7-8522-411f-876a-ba8ec32cc781
ghigo@venice:/tmp$ sudo wipefs /dev/loop0 -a
8 bytes were erased at offset 0x10040 (btrfs)
they were: 5f 42 48 52 66 53 5f 4d
$ sudo btrfs filesystem  show /dev/loop0
Btrfs Btrfs v0.19
# it seems that the filesystem is disappeared 
# now zero all the 1st superblock
$ sudo dd if=/dev/zero of=/dev/loop0 bs=1 count=4k seek=64k
4096+0 records in
4096+0 records out
4096 bytes (4.1 kB) copied, 0.00659795 s, 621 kB/s
# check if the filesystem is resurrected
$ sudo btrfs filesystem  show /dev/loop0
failed to read /dev/sr0
Label: 'Btrfs-test'  uuid: 3156cef7-8522-411f-876a-ba8ec32cc781
	Total devices 1 FS bytes used 28.00KB
	devid    1 size 4.00TB used 2.04GB path /dev/loop0

Btrfs Btrfs v0.19

# it is !!!

# With this patch, wipefs is able to find all the superblock:

$ sudo mkfs.btrfs -L "Btrfs-test" /dev/loop0
$ sudo ~/btrfs/util-linux/wipefs /dev/loop0 
offset               type
----------------------------------------------------------------
0x4000000040         btrfs [bak #2]   [filesystem]
                     LABEL: Btrfs-test
                     UUID:  5ca3239c-363c-4c28-b831-eac03cc5ca62

0x4000040 btrfs [bak #1] [filesystem]

                     LABEL: Btrfs-test
                     UUID:  5ca3239c-363c-4c28-b831-eac03cc5ca62

0x10040 btrfs [filesystem]

                     LABEL: Btrfs-test
                     UUID:  5ca3239c-363c-4c28-b831-eac03cc5ca62
ghigo@venice:/tmp$ sudo ~/btrfs/util-linux/wipefs -a /dev/loop0 
/dev/loop0: 8 bytes were erased at offset 0x00010040 (btrfs): 
	5f 42 48 52 66 53 5f 4d
/dev/loop0: 8 bytes were erased at offset 0x04000040 (btrfs [bak #1]):
	5f 42 48 52 66 53 5f 4d
/dev/loop0: 8 bytes were erased at offset 0x4000000040 (btrfs [bak #2]): 
	5f 42 48 52 66 53 5f 4d

# Now even if we zero the 1st superblock the filesystem doesn't resurrect

$ sudo dd if=/dev/zero of=/dev/loop0 bs=1 count=4k seek=64k4096+0 records in
4096+0 records out
4096 bytes (4.1 kB) copied, 0.00643427 s, 637 kB/s
$ sudo btrfs filesystem  show /dev/loop0
Btrfs Btrfs v0.19

Br
G.Baroncelli

You can pull the change from:
http://cassiopea.homelinux.net/git/util-linux.git
from the branch
btrfs-wipefs

------

Quoted 1 line

From 3ae972080495770205ec5da6d7a379a8d4a4d1c9 Mon Sep 17 00:00:00 2001

From: Goffredo Baroncelli <[email protected]>
Date: Sun, 6 Jan 2013 18:47:11 +0100
Subject: [PATCH] Add support for wiping the other btrfs superblock.

Btrfs has three superblock. The first one is placed at 64KB, the second one at 64MB, the third one at 256GB.

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

So zeroing the first superblock "magic field" at the beginning seems that the filesystem is wiped. But when the first superblock is overwritten (e.g. by another filesystem), then the other two superblock may be considered valid, and the filesystem may resurrect.

This patch allow to find and wipe the other btrfs superblocks signature.

---
 libblkid/src/superblocks/btrfs.c       |   32 ++++++++++++++++++++++++++++++++
 libblkid/src/superblocks/superblocks.c |    2 ++
 libblkid/src/superblocks/superblocks.h |    2 ++
 3 files changed, 36 insertions(+)
libblkid/src/superblocks/btrfs.c +32 -0
index 039be42..d1331e6 100644
@@ -91,3 +91,35 @@ const struct blkid_idinfo btrfs_idinfo =
 	}
 };
 
+const struct blkid_idinfo btrfs_idinfo1 =
+{
+	.name		= "btrfs [bak #1]",
+	.usage		= BLKID_USAGE_FILESYSTEM,
+	.probefunc	= probe_btrfs,
+	.minsz		= 64 * 1024 * 1024 + 4 * 1024,
+	.magics		=
+	{
+		{ .magic = "_BHRfS_M", 
+		  .len = 8, 
+		  .kboff = 64 * 1024, 
+		  .sboff = 0x40 },
+		{ NULL }
+	}
+};
+
+const struct blkid_idinfo btrfs_idinfo2 =
+{
+	.name		= "btrfs [bak #2]",
+	.usage		= BLKID_USAGE_FILESYSTEM,
+	.probefunc	= probe_btrfs,
+	.minsz		= 256 * 1024 * 1024 * 1024 + 4 *1024,
+	.magics		=
+	{
+		{ .magic = "_BHRfS_M", 
+		  .len = 8, 
+		  .kboff = 256 * 1024 * 1024, 
+		  .sboff = 0x40 },
+		{ NULL }
+	}
+};
+
libblkid/src/superblocks/superblocks.c +2 -0
index 2929a5f..1e88b63 100644
@@ -135,6 +135,8 @@ static const struct blkid_idinfo *idinfos[] =
 	&squashfs_idinfo,
 	&netware_idinfo,
 	&btrfs_idinfo,
+	&btrfs_idinfo1,
+	&btrfs_idinfo2,
 	&ubifs_idinfo,
 	&bfs_idinfo,
 	&vmfs_fs_idinfo,
libblkid/src/superblocks/superblocks.h +2 -0
index 08f1438..974ff8e 100644
@@ -59,6 +59,8 @@ extern const struct blkid_idinfo netware_idinfo;
 extern const struct blkid_idinfo sysv_idinfo;
 extern const struct blkid_idinfo xenix_idinfo;
 extern const struct blkid_idinfo btrfs_idinfo;
+extern const struct blkid_idinfo btrfs_idinfo1;
+extern const struct blkid_idinfo btrfs_idinfo2;
 extern const struct blkid_idinfo ubifs_idinfo;
 extern const struct blkid_idinfo zfs_idinfo;
 extern const struct blkid_idinfo bfs_idinfo;
Signature · 6 lines
1.7.10.4


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
#1 lore raw
Quoted 5 lines · Goffredo Baroncelli

Currently wipefs doesn't clear all the superblock of btrfs. Only the first one is cleared.

Btrfs has three superblocks. The first one is placed at 64KB, the second one at 64MB, the third one at 256GB.

It can have as much as 4 superblock backup copies:

Superblock offset 0 is 65536 (0x10000, block=16/0x10)
Superblock offset 1 is 67108864 (0x4000000, block=16384/0x4000)
Superblock offset 2 is 274877906944 (0x4000000000, block=67108864/0x4000000) Superblock offset 3 is 1125899906842624 (0x4000000000000, block=274877906944/0x4000000000) Superblock offset 4 is 4611686018427387904 (0x4000000000000000, block=1125899906842624/0x4000000000000)

Quoted 9 lines

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

So zeroing the first superblock "magic field" at the beginning seems that the filesystem is wiped. But when the first superblock is overwritten (e.g. by another filesystem), then the other two superblocks may be considered valid, and the filesystem may resurrect.

And for that purpose all the superblock copies should be taken into account, regardless of the tricks that btrfs_mount applies.

david

#2 lore raw

Hi David,

Quoted 7 lines · David Sterba
Quoted 5 lines · Goffredo Baroncelli

Currently wipefs doesn't clear all the superblock of btrfs. Only the first one is cleared.

Btrfs has three superblocks. The first one is placed at 64KB, the second one at 64MB, the third one at 256GB.

Quoted 7 lines

It can have as much as 4 superblock backup copies:

Superblock offset 0 is 65536 (0x10000, block=16/0x10)
Superblock offset 1 is 67108864 (0x4000000, block=16384/0x4000)
Superblock offset 2 is 274877906944 (0x4000000000, block=67108864/0x4000000) Superblock offset 3 is 1125899906842624 (0x4000000000000, block=274877906944/0x4000000000) Superblock offset 4 is 4611686018427387904 (0x4000000000000000, block=1125899906842624/0x4000000000000)

Are you sure ?

Regarding the btrfs-progs suite, I looked at the btrfs_read_dev_super():
[..]

        for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
                bytenr = btrfs_sb_offset(i);
                ret = pread64(fd, &buf, sizeof(buf), bytenr);

Where BTRFS_SUPER_MIRROR_MAX is 3.

Regarding the kernel code, I looked at several function which call btrfs_sb_offset(); everywhere there is an upper limit of the superblock numbero which is BTRFS_SUPER_MIRROR_MAX, which is still 3.

Moreover I performed the following test:

$ ls -lh 7tb-filesystem.img
-rw-r--r-- 1 ghigo ghigo 7.1E Jan  7 18:49 7eb-filesystem.img
$ /sbin/mkfs.btrfs 7eb-filesystem.img
$ cat extract-sign.py
import os

BTRFS_SUPER_MIRROR_SHIFT = 12
BTRFS_SUPER_INFO_OFFSET = (64*1024)

def btrfs_sb_offset(mirror):

    start = 16*1024
    if(mirror):
        return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror)
    return BTRFS_SUPER_INFO_OFFSET

f = open("7eb-filesystem.img","r")
for i in range(5):

    pos = btrfs_sb_offset(i)+64
    f.seek(pos)
    sign = f.read(8)

    print "Superblock #%d - %20d - '%s'"%(i,pos,sign)
$ python extract-sign.py
Superblock #0 -                65600 - '_BHRfS_M'
Superblock #1 -             67108928 - '_BHRfS_M'
Superblock #2 -         274877907008 - '_BHRfS_M'
Superblock #3 -     1125899906842688 - ''
Superblock #4 -  4611686018427387968 - ''

To me it seems that in a 7TB filesystem there is only 3 superblocks.

Quoted 17 lines
Quoted 10 lines

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

So zeroing the first superblock "magic field" at the beginning seems that the filesystem is wiped. But when the first superblock is overwritten (e.g. by another filesystem), then the other two superblocks may be considered valid, and the filesystem may resurrect.

And for that purpose all the superblock copies should be taken into account, regardless of the tricks that btrfs_mount applies.

david

Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
#3 lore raw
Quoted 52 lines · Goffredo Baroncelli

Hi David,

Quoted 7 lines · David Sterba
Quoted 5 lines · Goffredo Baroncelli

Currently wipefs doesn't clear all the superblock of btrfs. Only the first one is cleared.

Btrfs has three superblocks. The first one is placed at 64KB, the second one at 64MB, the third one at 256GB.

Quoted 7 lines

It can have as much as 4 superblock backup copies:

Superblock offset 0 is 65536 (0x10000, block=16/0x10)
Superblock offset 1 is 67108864 (0x4000000, block=16384/0x4000)
Superblock offset 2 is 274877906944 (0x4000000000, block=67108864/0x4000000) Superblock offset 3 is 1125899906842624 (0x4000000000000, block=274877906944/0x4000000000) Superblock offset 4 is 4611686018427387904 (0x4000000000000000, block=1125899906842624/0x4000000000000)

Are you sure ?

Regarding the btrfs-progs suite, I looked at the btrfs_read_dev_super():
[..]

        for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
                bytenr = btrfs_sb_offset(i);
                ret = pread64(fd, &buf, sizeof(buf), bytenr);

Where BTRFS_SUPER_MIRROR_MAX is 3.

Regarding the kernel code, I looked at several function which call btrfs_sb_offset(); everywhere there is an upper limit of the superblock numbero which is BTRFS_SUPER_MIRROR_MAX, which is still 3.

Moreover I performed the following test:

$ ls -lh 7tb-filesystem.img
-rw-r--r-- 1 ghigo ghigo 7.1E Jan  7 18:49 7eb-filesystem.img
$ /sbin/mkfs.btrfs 7eb-filesystem.img
$ cat extract-sign.py
import os

BTRFS_SUPER_MIRROR_SHIFT = 12
BTRFS_SUPER_INFO_OFFSET = (64*1024)

def btrfs_sb_offset(mirror):

    start = 16*1024
    if(mirror):
        return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror)
    return BTRFS_SUPER_INFO_OFFSET

f = open("7eb-filesystem.img","r")
for i in range(5):

Quoted 8 lines
    pos = btrfs_sb_offset(i)+64
    f.seek(pos)
    sign = f.read(8)

    print "Superblock #%d - %20d - '%s'"%(i,pos,sign)
$ python extract-sign.py
Superblock #0 -                65600 - '_BHRfS_M'

64 KiB

Quoted 1 line

Superblock #1 - 67108928 - '_BHRfS_M'

256 MiB

Quoted 1 line

Superblock #2 - 274877907008 - '_BHRfS_M'

1 TiB

Quoted 1 line

Superblock #3 - 1125899906842688 - ''

4 PiB

Quoted 1 line

Superblock #4 - 4611686018427387968 - ''

16 EiB

Quoted 1 line

To me it seems that in a 7TB filesystem there is only 3 superblocks.

That would be as expected. How many on a 5 PiB filesystem, though?
Or a 20 EiB one?

Hugo.

Signature · 4 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
  --- "He's a nutcase, you know. There's no getting away from it -- ---  
                     he'll end up with a knighthood"                     
#4 lore raw

Hi hugo

On 01/07/2013 07:24 PM, Hugo Mills wrote:
[...]

Quoted 6 lines
Quoted 4 lines
    print "Superblock #%d - %20d - '%s'"%(i,pos,sign)
$ python extract-sign.py
Superblock #0 -                65600 - '_BHRfS_M'

64 KiB

OK, (above)

Quoted 4 lines
Quoted 2 lines

Superblock #1 - 67108928 - '_BHRfS_M'

256 MiB

.... above is 64M, below is 256M !

Quoted 5 lines
Quoted 2 lines

Superblock #2 - 274877907008 - '_BHRfS_M'

1 TiB

Quoted 7 lines
Quoted 1 line

Superblock #3 - 1125899906842688 - ''

4 PiB

Quoted 1 line

Superblock #4 - 4611686018427387968 - ''

16 EiB

Not reachable in linux. There is a VFS limits to 8EB.

Quoted 6 lines
Quoted 3 lines

To me it seems that in a 7TB filesystem there is only 3 superblocks.

That would be as expected. How many on a 5 PiB filesystem, though?
Or a 20 EiB one?

I wrote 7TB, but I meant 8EB. I first tried a test with 7TB and I wrote the email, but then I retested with 8EB and I corrected the email, forgetting some 7t instead of 8e...

Anyway, if BTRFS would allow more than three super-block, in the 7TB case, the super-block at 1TB would appeared

Quoted 3 lines

Hugo.

Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
maintainer
#9 lore raw
In reply to Goffredo Baroncelli
Quoted 21 lines · Goffredo Baroncelli
libblkid/src/superblocks/btrfs.c +21 -0
+const struct blkid_idinfo btrfs_idinfo1 =
+{
+	.name		= "btrfs [bak #1]",
+	.usage		= BLKID_USAGE_FILESYSTEM,
+	.probefunc	= probe_btrfs,
+	.minsz		= 64 * 1024 * 1024 + 4 * 1024,
+	.magics		=
+	{
+		{ .magic = "_BHRfS_M", 
+		  .len = 8, 
+		  .kboff = 64 * 1024, 
+		  .sboff = 0x40 },
+		{ NULL }
+	}
+};
+
+const struct blkid_idinfo btrfs_idinfo2 =
+{
+	.name		= "btrfs [bak #2]",
+	.usage		= BLKID_USAGE_FILESYSTEM,
+	.probefunc	= probe_btrfs,

libblkid/src/superblocks/btrfs.c const struct blkid_idinfo btrfs_idinfo = · line 124

Quoted 10 lines
libblkid/src/superblocks/btrfs.c +10 -0
+	.minsz		= 256 * 1024 * 1024 * 1024 + 4 *1024,
+	.magics		=
+	{
+		{ .magic = "_BHRfS_M", 
+		  .len = 8, 
+		  .kboff = 256 * 1024 * 1024, 
+		  .sboff = 0x40 },
+		{ NULL }
+	}
+};

You can specify more than one magic strings for the same filesystem, the .magics = { } is array.

.magics = {

    /* backup #1 */
	{ .magic = "_BHRfS_M", 
	  .len = 8, 
	  .kboff = 64 * 1024, 
	  .sboff = 0x40 },
    },

    /* backup #2 */
    {   .magic = "_BHRfS_M",
        .len = 8,
        .kboff = 256 * 1024 * 1024,
        .sboff = 0x40
    }, 
    ...

}

see for example libblkid/src/superblocks/reiserfs.c

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#5 lore raw
In reply to Goffredo Baroncelli
Quoted 11 lines · Goffredo Baroncelli
Quoted 7 lines · David Sterba

It can have as much as 4 superblock backup copies:

Superblock offset 0 is 65536 (0x10000, block=16/0x10)
Superblock offset 1 is 67108864 (0x4000000, block=16384/0x4000)
Superblock offset 2 is 274877906944 (0x4000000000, block=67108864/0x4000000) Superblock offset 3 is 1125899906842624 (0x4000000000000, block=274877906944/0x4000000000) Superblock offset 4 is 4611686018427387904 (0x4000000000000000, block=1125899906842624/0x4000000000000)

Are you sure ?

Quoted 7 lines

Regarding the btrfs-progs suite, I looked at the btrfs_read_dev_super():
[..]

        for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
                bytenr = btrfs_sb_offset(i);
                ret = pread64(fd, &buf, sizeof(buf), bytenr);

Where BTRFS_SUPER_MIRROR_MAX is 3.

My bad, sorry, I was using the values from an old script that computed the values with a wrong upper limit.

david

maintainer
#12 lore raw
In reply to Goffredo Baroncelli
Quoted 4 lines · Goffredo Baroncelli

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

Hmm... why inconsistent (or missing) superblock is not reported as a problem? If I good understand the filesystem is still mountable, right?

Quoted 2 lines

So zeroing the first superblock "magic field" at the beginning seems that the filesystem is wiped.

Well, this is exactly the idea behind wipefs(8), just wipe minimal number of bytes from the device to make the filesystem invisible for libblkid (udev, ...). This concept is relatively safe, if you make a mistake than you can restore the magic string, your data should not be affected by wipefs(8).

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#13 lore raw

Hi Karel,

Quoted 9 lines · Karel Zak
Quoted 4 lines · Goffredo Baroncelli

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

Hmm... why inconsistent (or missing) superblock is not reported as a problem? If I good understand the filesystem is still mountable, right?

It should, however my tests were unsuccessful :-(... Chris ?

Quoted 9 lines
Quoted 3 lines

So zeroing the first superblock "magic field" at the beginning seems that the filesystem is wiped.

Well, this is exactly the idea behind wipefs(8), just wipe minimal number of bytes from the device to make the filesystem invisible for libblkid (udev, ...). This concept is relatively safe, if you make a mistake than you can restore the magic string, your data should not be affected by wipefs(8).

I fully agree. However wipefs should zero all three superblock

Quoted 3 lines

Karel

Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
#14 lore raw
Quoted 9 lines · Goffredo Baroncelli

Hi Karel,

Quoted 6 lines · Karel Zak
Quoted 4 lines · Goffredo Baroncelli

If the first superblock is valid except that the "magic field" is zeroed, btrfs skips the check of the other superblocks.
If the first superblock is fully invalid, btrfs checks for the other superblock.

Quoted 5 lines
Quoted 3 lines

Hmm... why inconsistent (or missing) superblock is not reported as a problem? If I good understand the filesystem is still mountable, right?

It should, however my tests were unsuccessful :-(... Chris ?

I haven't tried mounting after wipefs, only after wipefs and subsequent mkfs.ext4; in that case the file system mounts without error as ext4. If I use mount -t btrfs I get an error. I haven't tried mounting with -t btrfs -o recovery.

Chris Murphy

#7 lore raw
In reply to Günter Gersdorf

Hi Günter,

Quoted 9 lines · Günter Gersdorf

Am 06.01.2013 19:28, schrieb Goffredo Baroncelli:

Quoted 6 lines

You can pull the change from:
http://cassiopea.homelinux.net/git/util-linux.git
from the branch
btrfs-wipefs

After applying this patch, findfs and blkid didn't find filesystems smaller than 256GB, probably because there is no third superblock.

In my system also the stock "findfs" and "blkid" have the same problem:
ie without my patch these utilities were unable to detect a btrfs filesystem.

Could you confirm that ?

Quoted 2 lines

Günter

Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
#8 lore raw

Am 08.01.2013 21:31, schrieb Goffredo Baroncelli:

Quoted 10 lines

Hi Günter,

Quoted 7 lines · Günter Gersdorf

Am 06.01.2013 19:28, schrieb Goffredo Baroncelli:

Quoted 6 lines

You can pull the change from:
http://cassiopea.homelinux.net/git/util-linux.git
from the branch
btrfs-wipefs

Quoted 8 lines
Quoted 2 lines

After applying this patch, findfs and blkid didn't find filesystems smaller than 256GB, probably because there is no third superblock.

In my system also the stock "findfs" and "blkid" have the same problem:
ie without my patch these utilities were unable to detect a btrfs filesystem.

Could you confirm that ?

Without the patch?
On my systems, after applying the patch blkid and findfs will not find any btrfs filesystems, even if bigger than 256GB.

Günter

#10 lore raw
In reply to Karel Zak

Hi Karel,

Quoted 3 lines

You can specify more than one magic strings for the same filesystem, the .magics = { } is array.

thanks for you suggestion. However this seems to me not applicable. I tried to change the code, and what I got to me seems inconsistently:

Whit this change

1) if I do "wipefs <device>", I got the offset of the first superblock (good enough)
2) if I do "wipefs -a <device>", I clean-up *all three* superblocks (very good)
3) if I do "wipefs -o <offset> <device>", I clean-up only the superblock located at <offset> (very bad)

If the user doesn't know enough btrfs, trying 1) and 3) could think that the disk is cleaned-up. Instead the 2nd and the 3rd super-blocks still exist.

Quoted 1 line

see for example libblkid/src/superblocks/reiserfs.c

I think that this is a different case: the reiser superblocks are *alternative*; instead in the btrfs case, *all the three superblocks* exist at the same time.

Quoted 1 line

Karel

Ciao
Goffredo

Signature · 2 lines
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5
maintainer
#11 lore raw
Quoted 9 lines · Goffredo Baroncelli

Hi Karel,

Quoted 3 lines

You can specify more than one magic strings for the same filesystem, the .magics = { } is array.

thanks for you suggestion. However this seems to me not applicable. I tried to change the code, and what I got to me seems inconsistently:

Quoted 8 lines

Whit this change

1) if I do "wipefs <device>", I got the offset of the first superblock (good enough)
2) if I do "wipefs -a <device>", I clean-up *all three* superblocks (very good)
3) if I do "wipefs -o <offset> <device>", I clean-up only the superblock located at <offset> (very bad)

this is expected behavior described in wipefs man page:

Note that some filesystems or some partition tables store more magic strings on the devices. The wipefs lists the first offset where a magic string has been detected. The device is not scanned for additional magic strings for the same filesystem. It's possible that after wipefs -o <offset> will be the same filesystem or partition table visible by another magic string on another offset.

Quoted 3 lines

If the user doesn't know enough btrfs, trying 1) and 3) could think that the disk is cleaned-up. Instead the 2nd and the 3rd super-blocks still exist.

well, users (and installers) usually use wipefs -a or wipefs -t <fsname>

Quoted 3 lines
Quoted 1 line

see for example libblkid/src/superblocks/reiserfs.c

I think that this is a different case: the reiser superblocks are

it was example how to specify the magic strings in the code

Quoted 2 lines

*alternative*; instead in the btrfs case, *all the three superblocks* exist at the same time.

this is pretty common to have backup superblock (e.g. GPT) or more ways how to detect the filesystem (e.g. FAT).

Please, send me the patch with the magic strings :-)

I really don't want to add dummy filesystems to the library (like you did in the first version of the patch) -- it's very bad idea with many side effects.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com