1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright (c) 2018, Nexenta Systems, Inc. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg 19 20# 21# DESCRIPTION: 22# 'zpool split' should fail if resilver in progress for a disk 23# 24# STRATEGY: 25# The first scenario: 26# 1. Create a mirror pool 27# 2. Offline the first VDEV 28# 3. Put some data 29# 4. Online the first VDEV 30# 5. Verify 'zpool split' must fail 31# 32# The second scenario: 33# 1. Create a mirror pool 34# 2. Offline the second VDEV 35# 3. Put some data 36# 4. Online the second VDEV 37# 5. Verify 'zpool split' must fail 38# 39 40verify_runnable "both" 41 42function cleanup 43{ 44 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0 45 destroy_pool $TESTPOOL 46 destroy_pool $TESTPOOL2 47 rm -f $DEVICE1 $DEVICE2 48} 49 50function setup_mirror 51{ 52 truncate -s $DEVSIZE $DEVICE1 53 truncate -s $DEVSIZE $DEVICE2 54 log_must zpool create -f $TESTPOOL mirror $DEVICE1 $DEVICE2 55} 56 57function zpool_split #disk_to_be_offline/online 58{ 59 typeset disk=$1 60 61 setup_mirror 62 63 # offline a disk, so it will not be fully sync before split 64 log_must zpool offline $TESTPOOL $disk 65 66 # Create 2G of additional data 67 mntpnt=$(get_prop mountpoint $TESTPOOL) 68 log_must file_write -b 2097152 -c 1024 -o create -d 0 -f $mntpnt/biggerfile 69 sync_all_pools 70 71 # temporarily prevent resilvering progress, so it will not finish too early 72 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1 73 74 log_must zpool online $TESTPOOL $disk 75 76 typeset i=0 77 while ! is_pool_resilvering $TESTPOOL; do 78 if (( i > 10 )); then 79 log_fail "resilvering is not started" 80 fi 81 ((i += 1)) 82 sleep 1 83 done 84 85 log_mustnot zpool split $TESTPOOL $TESTPOOL2 86 87 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0 88} 89 90log_assert "Verify 'zpool split' will fail if resilver in progress for a disk" 91log_onexit cleanup 92 93DEVSIZE='3g' 94DEVICE1="$TEST_BASE_DIR/device-1" 95DEVICE2="$TEST_BASE_DIR/device-2" 96 97log_note "Verify ZFS prevents main pool corruption during 'split'" 98zpool_split $DEVICE1 99 100cleanup 101 102log_note "Verify ZFS prevents new pool corruption during 'split'" 103zpool_split $DEVICE2 104 105log_pass "'zpool split' failed as expected" 106