-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't persist temporary pool name on devices
Fix a regression accidentally introduced by e0ab3ab. Additionally, add a new script zpool_import_014_pos.ksh to the ZFS test suite to exercise 'zpool import -t' functionality. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #5466 Closes #5515
- Loading branch information
1 parent
547c593
commit 3500a14
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_014_pos.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |