aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2018-01-26 10:49:46 -0800
committerBrian Behlendorf <[email protected]>2018-01-26 10:49:46 -0800
commit522db29275b81c18c2bf53a95efa1aedeb13b428 (patch)
tree3edfce11d4d86d2fcb33e48cf80cbd8603b44b1e /tests/zfs-tests
parentf55a8757a6be24c36c25e24ab5c30dcddf2ad954 (diff)
zpool import -d to specify device path
When we know which devices have the pool we are looking for, sometime it's better if we can directly pass those device paths to zpool import instead of letting it to search through all unrelated stuff, which might take a lot of time if you have hundreds of disks. This patch allows option -d <dev_path> to zpool import. You can have multiple pairs of -d <dev_path>, and zpool import will only search through those devices. For example: zpool import -d /dev/sda -d /dev/sdb Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Chunwei Chen <[email protected]> Closes #7077
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am1
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_015_pos.ksh54
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am
index fab6e7459..94031b9a7 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am
@@ -17,6 +17,7 @@ dist_pkgdata_SCRIPTS = \
zpool_import_012_pos.ksh \
zpool_import_013_neg.ksh \
zpool_import_014_pos.ksh \
+ zpool_import_015_pos.ksh \
zpool_import_all_001_pos.ksh \
zpool_import_features_001_pos.ksh \
zpool_import_features_002_neg.ksh \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_015_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_015_pos.ksh
new file mode 100755
index 000000000..c984b9bf0
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_015_pos.ksh
@@ -0,0 +1,54 @@
+#!/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) 2018 by Nutanix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
+
+#
+# DESCRIPTION:
+# Make sure zpool import -d <device> works.
+#
+# STRATEGY:
+# 1. Create test pool A.
+# 2. Export pool A.
+# 3. Verify 'import -d <device>' works
+#
+
+verify_runnable "global"
+
+function cleanup
+{
+ destroy_pool $TESTPOOL1
+
+ log_must rm $VDEV0 $VDEV1
+ log_must truncate -s $FILE_SIZE $VDEV0 $VDEV1
+}
+
+log_assert "Pool can be imported with '-d <device>'"
+log_onexit cleanup
+
+log_must zpool create $TESTPOOL1 $VDEV0 $VDEV1
+log_must zpool export $TESTPOOL1
+
+log_must zpool import -d $VDEV0 -d $VDEV1 $TESTPOOL1
+log_must zpool export $TESTPOOL1
+
+# mix -d <dir> and -d <device>
+log_must mkdir $DEVICE_DIR/test_dir
+log_must ln -s $VDEV0 $DEVICE_DIR/test_dir/disk
+log_must zpool import -d $DEVICE_DIR/test_dir -d $VDEV1 $TESTPOOL1
+
+log_pass "Pool can be imported with '-d <device>'"