zfs/lib/libzfs
Brian Behlendorf 83bf769d50 Fix 'zpool import' detection issues
This patch addresses multiple 'zpool import' block device
indentification problems which are most likely to occur on a
system configured to use blkid, by_vdev paths, multipath and
failover.  The symptom most commonly observed is the import
uses different path names to import the pool than would
normally be expected.

* When using blkid to identify vdevs the listed devices may
be added to the cache in any order.  In order to apply the
preferred search order heuristic a zfs_path_order() function
was added to calculate the order given full path names.

* Since it's possible to have multiple block devices with
different vdev guids which refer to the same ZPOOL_CONFIG_PATH
the slice cache must be indexed by guid and name.  By avoiding
collisions the preferred ordering can be maintaining even
when multiple block devices claim the same ZPOOL_CONFIG_PATH.
The preferred sorting by partition was never benefitial for
a Linux system and was removed as part of this change.

* When adding entries to the blkid cache avl_find/avl_insert
are used instead of avl_add because collisions are possible
and must be handled gracefully.

* For pools using multipath devices there are, at a minimum,
three devices where a vdev label may be read.  They are the
dm-* device and each underlying /dev/sd* device.  Due to the
way the block cache is implemented each of these devices may
have a different cached copy of the vdev label.  This can
result in "ghost pools" which appear to persist even after
a 'zpool labelclear' has been done to the dm-* device.  In
order to prevent this the vdev label is read with O_DIRECT
in order to bypass any caching to get the on-disk version.

* When opening a block device verify that vdev guid read from
the disk matches the expected vdev guid.  This allows for bad
labels to be filtered out.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5359
2016-11-07 10:28:57 -08:00
..
.gitignore Add a pkgconfig file 2014-08-28 07:59:43 -07:00
Makefile.am Multipath autoreplace, control enclosure LEDs, event rate limiting 2016-10-19 12:55:59 -07:00
libzfs.pc.in Add a pkgconfig file 2014-08-28 07:59:43 -07:00
libzfs_changelist.c Fix coverity defects: CID 147654, 147690 2016-10-13 14:02:07 -07:00
libzfs_config.c Fix indefinite article 2016-08-11 11:23:49 -07:00
libzfs_core.pc.in Add a pkgconfig file 2014-08-28 07:59:43 -07:00
libzfs_dataset.c Fix coverity defects: CID 147551, 147552 2016-10-20 11:49:50 -07:00
libzfs_diff.c Fix coverity defects: CID 147443, 147656, 147655, 147441, 147653 2016-09-29 13:33:09 -07:00
libzfs_fru.c cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
libzfs_import.c Fix 'zpool import' detection issues 2016-11-07 10:28:57 -08:00
libzfs_iter.c Performance optimization of AVL tree comparator functions 2016-08-31 14:35:34 -07:00
libzfs_mount.c Change /etc/mtab to /proc/self/mounts 2016-09-20 10:07:58 -07:00
libzfs_pool.c Allow for '-o feature@<feature>=disabled' on the command line 2016-10-25 16:17:47 -07:00
libzfs_sendrecv.c Fix coverity defects: CID 147654, 147690 2016-10-13 14:02:07 -07:00
libzfs_status.c Read spl_hostid module parameter before gethostid() 2015-02-04 16:44:53 -08:00
libzfs_util.c Fix 'zpool import' detection issues 2016-11-07 10:28:57 -08:00