Require libblkid

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 <behlendorf1@llnl.gov>
Closes #2448
This commit is contained in:
Brian Behlendorf
2016-02-19 15:43:43 -08:00
parent 048bb5bd49
commit 7d11e37e55
7 changed files with 49 additions and 147 deletions
+6 -16
View File
@@ -55,12 +55,8 @@
#include <sys/vtoc.h>
#include <sys/dktp/fdisk.h>
#include <sys/efi_partition.h>
#include <sys/vdev_impl.h>
#ifdef HAVE_LIBBLKID
#include <blkid/blkid.h>
#endif
#include "libzfs.h"
#include "libzfs_impl.h"
@@ -1203,7 +1199,6 @@ zpool_clear_label(int fd)
return (0);
}
#ifdef HAVE_LIBBLKID
/*
* Use libblkid to quickly search for zfs devices
*/
@@ -1273,7 +1268,6 @@ err_blkid2:
err_blkid1:
return (err);
}
#endif /* HAVE_LIBBLKID */
char *
zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
@@ -1313,17 +1307,15 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
verify(iarg->poolname == NULL || iarg->guid == 0);
/*
* Prefer to locate pool member vdevs using libblkid. Only fall
* back to legacy directory scanning when explicitly requested or
* if an error is encountered when consulted the libblkid cache.
*/
if (dirs == 0) {
#ifdef HAVE_LIBBLKID
/* Use libblkid to scan all device for their type */
if (zpool_find_import_blkid(hdl, &pools) == 0)
if (!iarg->scan && (zpool_find_import_blkid(hdl, &pools) == 0))
goto skip_scanning;
(void) zfs_error_fmt(hdl, EZFS_BADCACHE,
dgettext(TEXT_DOMAIN, "blkid failure falling back "
"to manual probing"));
#endif /* HAVE_LIBBLKID */
dir = zpool_default_import_path;
dirs = DEFAULT_IMPORT_PATH_SIZE;
}
@@ -1465,9 +1457,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
goto error;
}
#ifdef HAVE_LIBBLKID
skip_scanning:
#endif
ret = get_configs(hdl, &pools, iarg->can_be_active);
error: