Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Sep 2017 22:06:09 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r323938 - projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import
Message-ID:  <201709222206.v8MM698O077752@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Fri Sep 22 22:06:09 2017
New Revision: 323938
URL: https://svnweb.freebsd.org/changeset/base/323938

Log:
  Add a new ZFS test case for importing destroyed pools
  
  tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile
  tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_001_neg.ksh
  tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
  	Test that importing a destroyed pool with an out-of-date
  	non-destroyed label will fail.  This can happen if a disk gets
  	removed from the system, the pool has a configuratoin change, the
  	pool gets destroyed, the disk gets reinserted, and the admin tries
  	to import the pool.
  
  Sponsored by:	Spectra Logic Corp

Added:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_001_neg.ksh
Modified:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile
  projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile	Fri Sep 22 22:00:26 2017	(r323937)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/Makefile	Fri Sep 22 22:06:09 2017	(r323938)
@@ -14,6 +14,7 @@ ${PACKAGE}FILES+=	zpool_import_missing_003_pos.ksh
 ${PACKAGE}FILES+=	zpool_import_all_001_pos.ksh
 ${PACKAGE}FILES+=	zpool_import.cfg
 ${PACKAGE}FILES+=	zpool_import_corrupt_001_pos.ksh
+${PACKAGE}FILES+=	zpool_import_destroyed_001_neg.ksh
 ${PACKAGE}FILES+=	zpool_import_012_pos.ksh
 ${PACKAGE}FILES+=	zpool_import_013_neg.ksh
 ${PACKAGE}FILES+=	zpool_import_007_pos.ksh

Added: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_001_neg.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_destroyed_001_neg.ksh	Fri Sep 22 22:06:09 2017	(r323938)
@@ -0,0 +1,66 @@
+#!/usr/local/bin/ksh93
+#
+# Copyright (c) 2017 Spectra Logic Corporation
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions, and the following disclaimer,
+#    without modification.
+# 2. Redistributions in binary form must reproduce at minimum a disclaimer       
+#    substantially similar to the "NO WARRANTY" disclaimer below
+#    ("Disclaimer") and any redistribution must be conditioned upon
+#    including a substantially similar Disclaimer requirement for further
+#    binary redistribution.
+#
+# NO WARRANTY
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL     
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGES.
+#
+# $FreeBSD$
+
+. $STF_SUITE/include/libtest.kshlib
+set_disks
+
+# A destroyed pool cannot be imported, even if an out-of-date non-destroyed
+# label is present
+#
+# This situation arose when a user activated a spare, removed the spare disk,
+# destroyed the pool, reinserted the spare disk, and then tried to import the
+# pool.  Since the pool was destroyed, nothing should've happened.  But the
+# spare disk had a non-destroyed label, so zpool tried to import it.  A panic
+# ensued.
+#
+# More generally, this situation can happen any time the following things happen:
+# 1) A disk gets removed with its label intact
+# 2) The pool's configuration changes
+# 3) The pool gets destroyed
+# 4) Somebody tries to import the pool
+
+log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1}
+
+# Offline a disk so it's label won't get updated by the upcoming destroy
+log_must $ZPOOL offline $TESTPOOL ${DISK0}
+
+# Now change the pool's configuration, so DISK0's label will be out-of-date
+log_must $ZPOOL attach $TESTPOOL ${DISK1} ${DISK2}
+
+# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed
+# state, leaving DISK0's label as the most recent non-destroyed label
+log_must $ZPOOL destroy $TESTPOOL
+
+# Now try to import the pool.  It should fail.
+log_mustnot $ZPOOL import $TESTPOOL
+
+log_pass

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh	Fri Sep 22 22:00:26 2017	(r323937)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh	Fri Sep 22 22:06:09 2017	(r323938)
@@ -515,7 +515,27 @@ zpool_import_corrupt_001_pos_cleanup()
 	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
 }
 
+atf_test_case zpool_import_destroyed_001_neg cleanup
+zpool_import_destroyed_001_neg_head()
+{
+	atf_set "descr" "A destroyed pool cannot be imported even if an out-of-date non-destroyed label remains"
+	atf_set "require.progs"  zfs zpool
+}
+zpool_import_destroyed_001_neg_body()
+{
+	. $(atf_get_srcdir)/../../../include/default.cfg
 
+	verify_disk_count "$DISKS" 3
+	ksh93 $(atf_get_srcdir)/zpool_import_destroyed_001_neg.ksh || atf_fail "Testcase failed"
+}
+zpool_import_destroyed_001_neg_cleanup()
+{
+	. $(atf_get_srcdir)/../../../include/default.cfg
+
+	cleanup_devices "$DISKS"
+}
+
+
 atf_init_test_cases()
 {
 
@@ -540,4 +560,5 @@ atf_init_test_cases()
 	atf_add_test_case zpool_import_missing_005_pos
 	atf_add_test_case zpool_import_rename_001_pos
 	atf_add_test_case zpool_import_corrupt_001_pos
+	atf_add_test_case zpool_import_destroyed_001_neg
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709222206.v8MM698O077752>