Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pool can be created on top of a ext2 device #2448

Closed
FransUrbo opened this issue Jun 30, 2014 · 13 comments
Closed

Pool can be created on top of a ext2 device #2448

FransUrbo opened this issue Jun 30, 2014 · 13 comments
Milestone

Comments

@FransUrbo
Copy link
Contributor

Way to reproduce:

#!/bin/sh                                                                                                                                                     

rm -f /var/tmp/zfs_test-1
truncate -s 25000m /var/tmp/zfs_test-1
zpool create test /var/tmp/zfs_test-1

parted -s /var/tmp/zfs_test-1 mklabel msdos
parted -s /var/tmp/zfs_test-1 mkpart primary 1 205

set -- `kpartx -asfv /var/tmp/zfs_test-1`
loop_part=/dev/mapper/${8##*/}p1
mke2fs ${loop_part} > /dev/null

zpool create test2 ${loop_part}
res=$?
echo "zpool create test2: $res"

[ "$res" -eq "0" ] && zpool destroy test2
kpartx -d /var/tmp/zfs_test-1

Results in:

# /tmp/testme.sh
mke2fs 1.42.5 (29-Jul-2012)
zpool create test2: 0
loop deleted : /dev/loop0
@behlendorf behlendorf added this to the 0.6.4 milestone Jul 1, 2014
@behlendorf behlendorf added the Bug label Jul 1, 2014
@behlendorf
Copy link
Contributor

I'm not sure what can be done about this. The best we could hope for is to have ZFS open the file O_EXCL and then hope the various other utilities honor that.

@FransUrbo
Copy link
Contributor Author

I'm not sure what can be done about this. The best we could hope for is to have ZFS open the file O_EXCL and then hope the various other utilities honor that.

The other way around... First ext2 and then ZFS - we need to verify what type of device we're "sending" (using) to zpool and ignore (or at least require "-f") if it's of a known type (extX, xfs, jfs, md etc, etc).

@ryao
Copy link
Contributor

ryao commented Jul 2, 2014

@FransUrbo What you want to accomplish is doable by hooking into libblkid.

That being said, I am think this is on the borderline of being a bug and not being a bug. My reasoning is that mkfs and zpool create are destructive operations like dd and should be treated as such. While there have been users who lost data misusing the dd tool, no one has proposed modifying dd to be safe. At the same time, I believe that the ext4 developers rely on libblkid to check and it would be good to reciprocate.

@FransUrbo
Copy link
Contributor Author

That being said, I am think this is on the borderline of being a bug and not being a bug.

I'm borderline agreeing with you :).

HOWEVER, this is a bug in the Illumos code. If it's a bug there, it should be
one here as well - "all ZFS should behave similarly"...

My reasoning is that mkfs and zpool create are destructive operations like dd and should be treated as such.

Yes, but not without a 'force' option. Accepting such a device, without any
warning what so ever is simply wrong. It should warn, and force the admin/user
to use '-f'...
While there have been users who lost data misusing the dd tool, no one has proposed modifying dd to be safe.

Fair enough...

@FransUrbo FransUrbo changed the title Pool can be created with a ext2 device Pool can be created on top of a ext2 device Jul 6, 2014
@behlendorf
Copy link
Contributor

@FransUrbo I see what you're saying now. Actually this case should be already handled assuming you've built with libblkid support. The current code makes this functionality optional but perhaps it should be mandatory. Check if your build has HAVE_LIBBLKID enabled. The function check_slice() will be called during by zpool create to check if each device is safe to use. Assuming libblkid is available it should fail with the following warning if there is a fileystem on the partition.

/dev/loop1 contains a filesystem of type 'ext4'

@FransUrbo
Copy link
Contributor Author

The current code makes this functionality optional but perhaps it should be mandatory.

I think it's such an important (and expected - on Linux?) feature that it should be mandatory. "Everyone else" does it :)
Check if your build has HAVE_LIBBLKID enabled.

It doesn't. I'll try to remember to make sure it does in the future... Thanx.

Close or relabel as "Linking with libblkid should be mandatory"?

behlendorf added a commit to behlendorf/zfs that referenced this issue Jul 16, 2014
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
@behlendorf
Copy link
Contributor

@FransUrbo Better yet, let's just enable it by default in the packaging. I believe @ryao already does this in the Gentoo packaging.

http://www.rpm.org/wiki/PackagerDocs/ConditionalBuilds
#2502

With the above patch applied I get the correct behavior with your test script.

Warning: The resulting partition is not properly aligned for best performance.
mke2fs 1.41.12 (17-May-2010)
invalid vdev specification
use '-f' to override the following errors:
/dev/mapper/loop0p1 contains a filesystem of type 'ext2'
zpool create test2: 1
loop deleted : /dev/loop0

@ryao
Copy link
Contributor

ryao commented Jul 16, 2014

@FransUrbo Better yet, let's just enable it by default in the packaging. I believe @ryao already does this in the Gentoo packaging.

That is correct.

@FransUrbo
Copy link
Contributor Author

@FransUrbo Better yet, let's just enable it by default in the packaging.

So your saying that a source install shouldn't have this by default? Only packages?

@behlendorf
Copy link
Contributor

No... I'm just saying that is slightly more work. A source install will enable this by default if the libblkid-devel package is installed. The current behavior is to auto-detect the library. Arguably your right we should make the default to require it but allow it to be conditionally disabled.

FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jul 18, 2014
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
@FransUrbo
Copy link
Contributor Author

Pull request #2512 includes your fix, with additional changes to config/user-libblkid.m4 to make sure that libblkid is included in build (i.e. make it default/required). To disable this behaviour, use --without-blkid.

@behlendorf
Copy link
Contributor

@FransUrbo I'm all for changing the default as you've done in #2512. I've posted a few review comments on the patch so we can conform to the standard guidelines for this kind of check.

@FransUrbo
Copy link
Contributor Author

Ok, force updated with your suggestions...

FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jul 23, 2014
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Aug 3, 2014
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Aug 3, 2014
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Aug 5, 2014
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Aug 5, 2014
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Aug 7, 2014
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Aug 7, 2014
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Aug 13, 2014
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Mar 15, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Mar 29, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Mar 30, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Mar 30, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Apr 21, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue May 3, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue May 17, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jun 10, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jun 11, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
@behlendorf behlendorf modified the milestones: 0.7.0, 0.6.5 Jul 16, 2015
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jul 22, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jul 24, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jul 24, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
FransUrbo pushed a commit to FransUrbo/zfs that referenced this issue Jul 31, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448

Make linking with and finding libblkid required (so that creating
pools on devices with existing filesystem will get a warning).
Use '--without-blkid' to explicitly disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Nov 5, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Nov 5, 2015
This ensures that when creating a pool on a device with an existing
filesystem will get a warning.  Use '--without-blkid' to explicitly
disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Nov 5, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Nov 5, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Nov 5, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Nov 18, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Nov 18, 2015
This ensures that when creating a pool on a device with an existing
filesystem will get a warning.  Use '--without-blkid' to explicitly
disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Dec 4, 2015
Support for libblkid has been in the ZoL for years but has been
disabled by default in the packaging.  When libblkid is disabled
the 'zpool create' command will not warn you if you're going to
overwrite an existing filesystem.  For this reason the default
behavior has been changed to require libblkid.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Dec 4, 2015
This ensures that when creating a pool on a device with an existing
filesystem will get a warning.  Use '--without-blkid' to explicitly
disable this.

Signed-off-by: Turbo Fredriksson <[email protected]>
Closes: openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Feb 20, 2016
Historically libblkid support was detected as part of configure
and optionally enabled.  This was done because at the time support
for detecting ZFS pool vdevs had just be added to libblkid and
those updated packages were not yet part of many distributions.
This is no longer the case and any reasonably current distribution
will ship a version of libblkid which can detect ZFS pool vdevs.

This patch makes libblkid mandatory at build time but does not
change the default directory method of scanning for ZFS pools.
This is in part because blkid can't detect log devices until ZFS
is updated to write complete labels for these vdevs.  And partly
to ease the transition to making this the preferred scanning
method.

Additionally making libblkid mandatory means that the 'zpool create'
command can reliably detect if a specified device has an existing
non-ZFS filesystem (ext4, xfs) and print a warning.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Feb 25, 2016
Historically libblkid support was detected as part of configure
and optionally enabled.  This was done because at the time support
for detecting ZFS pool vdevs had just be added to libblkid and
those updated packages were not yet part of many distributions.
This is no longer the case and any reasonably current distribution
will ship a version of libblkid which can detect ZFS pool vdevs.

This patch makes libblkid mandatory at build time and libblkid
the preferred method of scanning for ZFS pools.  For distributions
which include a modern version of libblkid there is no change in
behavior.  Explicitly scanning the default search paths is still
supported and can be enabled with the '-s' command line option.

Additionally making libblkid mandatory means that the 'zpool create'
command can reliably detect if a specified device has an existing
non-ZFS filesystem (ext4, xfs) and print a warning.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
behlendorf added a commit to behlendorf/zfs that referenced this issue Feb 26, 2016
Historically libblkid support was detected as part of configure
and optionally enabled.  This was done because at the time support
for detecting ZFS pool vdevs had just be added to libblkid and
those updated packages were not yet part of many distributions.
This is no longer the case and any reasonably current distribution
will ship a version of libblkid which can detect ZFS pool vdevs.

This patch makes libblkid mandatory at build time and libblkid
the preferred method of scanning for ZFS pools.  For distributions
which include a modern version of libblkid there is no change in
behavior.  Explicitly scanning the default search paths is still
supported and can be enabled with the '-s' command line option.

Additionally making libblkid mandatory means that the 'zpool create'
command can reliably detect if a specified device has an existing
non-ZFS filesystem (ext4, xfs) and print a warning.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#2448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants