1#! /usr/bin/ksh -p 2# 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright 2016 Nexenta Systems, Inc. 16# 17 18. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg 19 20# DESCRIPTION: 21# Check that zpool labelclear will refuse to clear the label 22# (with or without -f) on any vdevs of the imported pool. 23# 24# STRATEGY: 25# 1. Create the pool with log device. 26# 2. Try clearing the label on data and log devices. 27# 3. Add auxilary (cache/spare) vdevs. 28# 4. Try clearing the label on auxilary vdevs. 29# 5. Check that zpool labelclear will return non-zero and 30# labels are intact. 31 32verify_runnable "global" 33 34function cleanup 35{ 36 poolexists $TESTPOOL && destroy_pool $TESTPOOL 37} 38 39log_onexit cleanup 40log_assert "zpool labelclear will fail on all vdevs of imported pool" 41 42# Create simple pool, skip any mounts 43log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2 44 45# Check that labelclear [-f] will fail on ACTIVE pool vdevs 46log_mustnot zpool labelclear $disk1 47log_must zdb -lq $disk1 48log_mustnot zpool labelclear -f $disk1 49log_must zdb -lq $disk1 50log_mustnot zpool labelclear $disk2 51log_must zdb -lq $disk2 52log_mustnot zpool labelclear -f $disk2 53log_must zdb -lq $disk2 54 55# Add a cache/spare to the pool, check that labelclear [-f] will fail 56# on the vdev and will succeed once it's removed from pool config 57for vdevtype in "cache" "spare"; do 58 log_must zpool add $TESTPOOL $vdevtype $disk3 59 log_mustnot zpool labelclear $disk3 60 log_must zdb -lq $disk3 61 log_mustnot zpool labelclear -f $disk3 62 log_must zdb -lq $disk3 63 log_must zpool remove $TESTPOOL $disk3 64 log_must zpool labelclear $disk3 65 log_mustnot zdb -lq $disk3 66done 67 68log_pass "zpool labelclear will fail on all vdevs of imported pool" 69