mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
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
This commit is contained in:
@@ -64,6 +64,10 @@ extern "C" {
|
||||
*/
|
||||
#define DISK_LABEL_WAIT (30 * 1000) /* 30 seconds */
|
||||
|
||||
#define IMPORT_ORDER_PREFERRED_1 1
|
||||
#define IMPORT_ORDER_PREFERRED_2 2
|
||||
#define IMPORT_ORDER_SCAN_OFFSET 10
|
||||
#define IMPORT_ORDER_DEFAULT 100
|
||||
#define DEFAULT_IMPORT_PATH_SIZE 9
|
||||
extern char *zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE];
|
||||
|
||||
@@ -728,6 +732,7 @@ extern boolean_t zfs_bookmark_exists(const char *path);
|
||||
extern int zfs_append_partition(char *path, size_t max_len);
|
||||
extern int zfs_resolve_shortname(const char *name, char *path, size_t pathlen);
|
||||
extern int zfs_strcmp_pathname(char *name, char *cmp_name, int wholedisk);
|
||||
extern int zfs_path_order(char *path, int *order);
|
||||
|
||||
/*
|
||||
* Mount support functions.
|
||||
|
||||
Reference in New Issue
Block a user