xfs
[Top] [All Lists]

Re: [PATCH] xfs_mkfs: wipe old signatures from the device

To: Lukas Czerner <lczerner@xxxxxxxxxx>
Subject: Re: [PATCH] xfs_mkfs: wipe old signatures from the device
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 13 Feb 2013 07:27:53 +1100
Cc: xfs@xxxxxxxxxxx, sandeen@xxxxxxxxxx, kzak@xxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1360667215-14701-1-git-send-email-lczerner@xxxxxxxxxx>
References: <1360667215-14701-1-git-send-email-lczerner@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Tue, Feb 12, 2013 at 12:06:55PM +0100, Lukas Czerner wrote:
> We should wipe off all the signatures from the device prior the file
> system creation. It is because because some file systems (btrfs) may
> still have their signatures on the device which can be confusing for
> userspace possibly resulting in the unmountable file system.
> 
> This patch adds a function which uses libblkid library to wipe all the
> signatures from the device.
> 
> If user disables libblkid library or does not have it installed this new
> feature will not be used. This case can be implemented separately.

mkfs.xfs already zeros the first part of the block device regardless
of whether it is using libblkid or not:

....
/* amount (in bytes) we zero at the beginning and end of the device to
 * remove traces of other filesystems, raid superblocks, etc.
 */
#define WHACK_SIZE (128 * 1024)
....

        /*
         * Zero out the beginning of the device, to obliterate any old
         * filesystem signatures out there.  This should take care of
         * swap (somewhere around the page size), jfs (32k),
         * ext[2,3] and reiserfs (64k) - and hopefully all else.
         */
        mp->m_ddev_targ.dev = xi.ddev;
        mp->m_ddev_targ.bt_mount = mp;
        buf = libxfs_getbuf(mp->m_ddev_targ, 0, BTOBB(WHACK_SIZE));
        memset(XFS_BUF_PTR(buf), 0, WHACK_SIZE);
        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
        libxfs_purgebuf(buf);

Isn't 128k of zeroing enough to kill existing filesystem signatures?
If not how much is, and why can't we just change WHACK_SIZE to
reflect the size that will kill those signatures that are further
offset into the device?

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>