From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH, RFC] mke2fs: wipe out old btrfs superblocks
Date: Tue, 29 Jan 2013 11:05:37 -0600 [thread overview]
Message-ID: <51080161.7000903@redhat.com> (raw)
In-Reply-To: <510800B6.4090505@redhat.com>
On 1/29/13 11:02 AM, Eric Sandeen wrote:
> btrfs sticks superblocks at 64k, 64M, and 256G. If we don't
> overwrite those, libblkid may accidentally identify an ext*
> filesystem with old btrfs superblocks as btrfs, and we'll
> be sad.
>
> libblkid provides a blkid_wipe_fs() functionality to zero
> all existing signatures, but that'd break our handy-dandy
> undo capability, I think. So I'm not sure we have any
> other choice but to do it ourselves.
>
> There is a slight error here in that if the mkfs
> does not span the entire device, we won't overwrite
> signatures past the end of the filesystem, but that case
> should be pretty rare. (The same slight error in logic
> applies to the existing "wipe old MD superblock" path).
Sorry, sent the wrong version, this one does it unconditionally
and doesn't test !noaction. I'll fix that & resend.
Feel free to comment on the general idea, though. :)
-Eric
> Signed-off-by: Eric Sandeen <sandeen@redhat.com
> Resolves-RHBZ: 902512
> ---
>
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index bbf477a..e68c705 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -2307,6 +2307,32 @@ static int mke2fs_discard_device(ext2_filsys fs)
> return retval;
> }
>
> +static int mke2fs_wipe_btrfs(ext2_filsys fs)
> +{
> + int blocks; /* nr of blocks to zero */
> + blk64_t start; /* location to zero out */
> + int retval = 0; /* accumulate any failures */
> +
> + blocks = 1;
> + if (fs->blocksize < 4096)
> + blocks = 4096 / fs->blocksize;
> + /*
> + * Wipe out any old btrfs superblocks, at
> + * 64k, 64M, and 256G.
> + */
> + start = 64ULL * 1024 / fs->blocksize;
> + retval += ext2fs_zero_blocks2(fs, start, blocks, NULL, NULL);
> + start = 64ULL * 1024 * 1024 / fs->blocksize;
> + if (start + blocks <= ext2fs_blocks_count(fs->super))
> + retval += ext2fs_zero_blocks2(fs, start, blocks, NULL, NULL);
> + start = 256ULL * 1024 * 1024 * 1024 / fs->blocksize;
> + if (start + blocks <= ext2fs_blocks_count(fs->super))
> + retval += ext2fs_zero_blocks2(fs, start, blocks, NULL, NULL);
> + /* free the static zeroing buffer */
> + ext2fs_zero_blocks2(0, 0, 0, 0, 0);
> + return retval;
> +}
> +
> static void fix_cluster_bg_counts(ext2_filsys fs)
> {
> blk64_t cluster, num_clusters, tot_free;
> @@ -2439,6 +2465,9 @@ int main (int argc, char *argv[])
> itable_zeroed = 1;
> }
> }
> + retval = mke2fs_wipe_btrfs(fs);
> + if (retval)
> + printf(_("Failed to wipe old btrfs super locations\n"));
>
> sprintf(tdb_string, "tdb_data_size=%d", fs->blocksize <= 4096 ?
> 32768 : fs->blocksize * 8);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-01-29 17:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-29 17:02 [PATCH, RFC] mke2fs: wipe out old btrfs superblocks Eric Sandeen
2013-01-29 17:05 ` Eric Sandeen [this message]
2013-01-29 17:10 ` [PATCH, RFC V2] " Eric Sandeen
2013-01-30 9:50 ` Lukáš Czerner
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=51080161.7000903@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/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).