mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
zpool import cachefile improvements
Importing a pool using the cachefile is ideal to reduce the time required to import a pool. However, if the devices associated with a pool in the cachefile have changed, then the import would fail. This can easily be corrected by doing a normal import which would then read the pool configuration from the labels. The goal of this change is make importing using a cachefile more resilient and auto-correcting. This is accomplished by having the cachefile import logic automatically fallback to reading the labels of the devices similar to a normal import. The main difference between the fallback logic and a normal import is that the cachefile import logic will only look at the device directories that were originally used when the cachefile was populated. Additionally, the fallback logic will always import by guid to ensure that only the pools in the cachefile would be imported. External-issue: DLPX-71980 Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Wilson <gwilson@delphix.com> Closes #11716
This commit is contained in:
@@ -398,6 +398,7 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos',
|
||||
'import_cachefile_device_replaced',
|
||||
'import_cachefile_mirror_attached',
|
||||
'import_cachefile_mirror_detached',
|
||||
'import_cachefile_paths_changed',
|
||||
'import_cachefile_shared_device',
|
||||
'import_devices_missing',
|
||||
'import_paths_changed',
|
||||
|
||||
@@ -9,6 +9,7 @@ dist_pkgdata_SCRIPTS = \
|
||||
import_cachefile_device_replaced.ksh \
|
||||
import_cachefile_mirror_attached.ksh \
|
||||
import_cachefile_mirror_detached.ksh \
|
||||
import_cachefile_paths_changed.ksh \
|
||||
import_cachefile_shared_device.ksh \
|
||||
import_devices_missing.ksh \
|
||||
import_paths_changed.ksh \
|
||||
|
||||
Executable
+117
@@ -0,0 +1,117 @@
|
||||
#!/bin/ksh -p
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# A pool should be importable from a cachefile even if device paths
|
||||
# have changed.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a pool using a cachefile
|
||||
# 2. Backup cachefile
|
||||
# 3. Export the pool.
|
||||
# 4. Change the paths of some of the devices.
|
||||
# 5. Verify that we can import the pool using the cachefile.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
function test_new_paths
|
||||
{
|
||||
typeset poolcreate="$1"
|
||||
typeset pathstochange="$2"
|
||||
|
||||
log_note "$0: pool '$poolcreate', changing paths of $pathstochange."
|
||||
|
||||
log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $poolcreate
|
||||
|
||||
log_must cp $CPATH $CPATHBKP
|
||||
|
||||
log_must zpool export $TESTPOOL1
|
||||
|
||||
for dev in $pathstochange; do
|
||||
log_must mv $dev "${dev}_new"
|
||||
done
|
||||
|
||||
log_must zpool import -c $CPATHBKP $TESTPOOL1
|
||||
log_must check_pool_healthy $TESTPOOL1
|
||||
|
||||
# Cleanup
|
||||
log_must zpool destroy $TESTPOOL1
|
||||
log_must rm -f $CPATH $CPATHBKP
|
||||
for dev in $pathstochange; do
|
||||
log_must mv "${dev}_new" $dev
|
||||
done
|
||||
|
||||
log_note ""
|
||||
}
|
||||
|
||||
function test_duplicate_pools
|
||||
{
|
||||
typeset poolcreate="$1"
|
||||
typeset pathstocopy="$2"
|
||||
|
||||
log_note "$0: pool '$poolcreate', creating duplicate pool using $pathstocopy."
|
||||
|
||||
log_must zpool create -o cachefile=$CPATH $TESTPOOL1 $poolcreate
|
||||
log_must zpool export $TESTPOOL1
|
||||
|
||||
for dev in $pathstocopy; do
|
||||
log_must cp $dev "${dev}_orig"
|
||||
|
||||
done
|
||||
|
||||
log_must zpool create -f -o cachefile=$CPATH $TESTPOOL1 $poolcreate
|
||||
log_must cp $CPATH $CPATHBKP
|
||||
log_must zpool export $TESTPOOL1
|
||||
|
||||
for dev in $pathstocopy; do
|
||||
log_must mv $dev "${dev}_new"
|
||||
done
|
||||
|
||||
log_must zpool import -c $CPATHBKP
|
||||
log_must zpool import -c $CPATHBKP $TESTPOOL1
|
||||
log_must check_pool_healthy $TESTPOOL1
|
||||
|
||||
# Cleanup
|
||||
log_must zpool destroy $TESTPOOL1
|
||||
log_must rm -f $CPATH $CPATHBKP
|
||||
for dev in $pathstocopy; do
|
||||
log_must rm "${dev}_orig"
|
||||
log_must mv "${dev}_new" $dev
|
||||
done
|
||||
|
||||
log_note ""
|
||||
}
|
||||
|
||||
test_new_paths "$VDEV0 $VDEV1" "$VDEV0 $VDEV1"
|
||||
test_new_paths "mirror $VDEV0 $VDEV1" "$VDEV0 $VDEV1"
|
||||
test_new_paths "$VDEV0 log $VDEV1" "$VDEV0 $VDEV1"
|
||||
test_new_paths "raidz $VDEV0 $VDEV1 $VDEV2" "$VDEV0 $VDEV1 $VDEV2"
|
||||
test_new_paths "draid $VDEV0 $VDEV1 $VDEV2" "$VDEV0 $VDEV1 $VDEV2"
|
||||
|
||||
test_duplicate_pools "$VDEV0 $VDEV1" "$VDEV0 $VDEV1"
|
||||
test_duplicate_pools "mirror $VDEV0 $VDEV1" "$VDEV0 $VDEV1"
|
||||
test_duplicate_pools "$VDEV0 log $VDEV1" "$VDEV0 $VDEV1"
|
||||
test_duplicate_pools "raidz $VDEV0 $VDEV1 $VDEV2" "$VDEV0 $VDEV1 $VDEV2"
|
||||
test_duplicate_pools "draid $VDEV0 $VDEV1 $VDEV2" "$VDEV0 $VDEV1 $VDEV2"
|
||||
|
||||
log_pass "zpool import with cachefile succeeded after changing device paths."
|
||||
Reference in New Issue
Block a user