aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/zfs/spa_config.c2
-rw-r--r--tests/runfiles/linux.run2
-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_014_pos.ksh91
4 files changed, 94 insertions, 2 deletions
diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c
index a813dfbd0..4f5d16543 100644
--- a/module/zfs/spa_config.c
+++ b/module/zfs/spa_config.c
@@ -426,7 +426,7 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
config = fnvlist_alloc();
fnvlist_add_uint64(config, ZPOOL_CONFIG_VERSION, spa_version(spa));
- fnvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, spa_name(spa));
+ fnvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, pool_name);
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE, spa_state(spa));
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG, txg);
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID, spa_guid(spa));
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
index 5ceebefeb..6b88e801c 100644
--- a/tests/runfiles/linux.run
+++ b/tests/runfiles/linux.run
@@ -295,7 +295,7 @@ tests = ['zpool_import_001_pos',
'zpool_import_003_pos', 'zpool_import_004_pos', 'zpool_import_005_pos',
'zpool_import_006_pos', 'zpool_import_007_pos', 'zpool_import_008_pos',
'zpool_import_009_neg', 'zpool_import_010_pos', 'zpool_import_011_neg',
- 'zpool_import_013_neg',
+ 'zpool_import_013_neg', 'zpool_import_014_pos',
'zpool_import_features_001_pos', 'zpool_import_features_002_neg',
'zpool_import_features_003_pos','zpool_import_missing_001_pos',
'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos',
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 bdc631a4c..c7e5c7590 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
@@ -16,6 +16,7 @@ dist_pkgdata_SCRIPTS = \
zpool_import_011_neg.ksh \
zpool_import_012_pos.ksh \
zpool_import_013_neg.ksh \
+ zpool_import_014_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_014_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_014_pos.ksh
new file mode 100755
index 000000000..8a5c6553f
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_014_pos.ksh
@@ -0,0 +1,91 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2016, loli10K. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
+
+#
+# DESCRIPTION:
+# Temporary pool names should not be persisted on devices.
+#
+# STRATEGY:
+# 1. Create pool A, then export it.
+# 2. Re-import the pool with a temporary name B, then export it.
+# 3. Verify device labels still contain the expected pool name (A).
+#
+
+verify_runnable "global"
+
+function cleanup
+{
+ typeset dt
+ for dt in $poolB $poolA; do
+ destroy_pool $dt
+ done
+
+ log_must $RM -rf $DEVICE_DIR/*
+ typeset i=0
+ while (( i < $MAX_NUM )); do
+ log_must $MKFILE $FILE_SIZE ${DEVICE_DIR}/${DEVICE_FILE}$i
+ ((i += 1))
+ done
+}
+
+#
+# Verify name of (exported) pool from device $1 label is equal to $2
+# $1 device
+# $2 pool name
+#
+function verify_pool_name
+{
+ typeset device=$1
+ typeset poolname=$2
+ typeset labelname
+
+ $ZDB -e -l $device | $GREP " name:" | {
+ while read labelname ; do
+ if [[ "name: '$poolname'" != "$labelname" ]]; then
+ return 1
+ fi
+ done
+ }
+ return 0
+}
+
+log_assert "Temporary pool names should not be persisted on devices."
+log_onexit cleanup
+
+poolA=poolA.$$; poolB=poolB.$$;
+
+log_must $ZPOOL create $poolA $VDEV0
+log_must $ZPOOL export $poolA
+
+log_must $ZPOOL import -t $poolA $poolB -d $DEVICE_DIR
+log_must $ZPOOL export $poolB
+
+log_must eval "verify_pool_name $VDEV0 $poolA"
+
+log_pass "Temporary pool names are not persisted on devices."