1#!/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 (c) 2017 Open-E, Inc. All Rights Reserved. 16# 17 18. $STF_SUITE/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib 19 20# 21# DESCRIPTION: 22# Test zpool reopen -n while scrub is running. 23# Checks if re-plugged device is NOT resilvered. 24# 25# STRATEGY: 26# 1. Create a pool 27# 2. Remove a disk. 28# 3. Write test file to pool. 29# 4. Execute scrub. 30# 5. "Plug back" disk. 31# 6. Reopen a pool with an -n flag. 32# 7. Check if resilver was deferred. 33# 8. Check if trying to put device to offline fails because of no valid 34# replicas. 35# 36# NOTES: 37# A 125ms delay is added to make sure that the scrub is running while 38# the reopen is invoked. 39# 40 41verify_runnable "global" 42 43function cleanup 44{ 45 log_must zinject -c all 46 # bring back removed disk online for further tests 47 insert_disk $REMOVED_DISK $scsi_host 48 poolexists $TESTPOOL && destroy_pool $TESTPOOL 49} 50 51log_assert "Testing zpool reopen with pool name as argument" 52log_onexit cleanup 53 54set_removed_disk 55scsi_host=$(get_scsi_host $REMOVED_DISK) 56 57# 1. Create a pool 58default_mirror_setup_noexit $REMOVED_DISK_ID $DISK2 59# 2. Remove a disk. 60remove_disk $REMOVED_DISK 61log_must zpool reopen -n $TESTPOOL 62log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "unavail" 63# 3. Write test file to pool. 64log_must generate_random_file /$TESTPOOL/data $LARGE_FILE_SIZE 65sync_pool $TESTPOOL 66# 4. Execute scrub. 67# add delay to I/O requests for remaining disk in pool 68log_must zinject -d $DISK2 -D125:1 $TESTPOOL 69log_must zpool scrub $TESTPOOL 70# 5. "Plug back" disk. 71insert_disk $REMOVED_DISK $scsi_host 72# 6. Reopen a pool with an -n flag. 73log_must zpool reopen -n $TESTPOOL 74log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "online" 75# remove delay from disk 76log_must zinject -c all 77# 7. Check if scrub scan is NOT replaced by resilver. 78log_must wait_for_scrub_end $TESTPOOL $MAXTIMEOUT 79log_must is_deferred_scan_started $TESTPOOL 80 81# 8. Check if trying to put device to offline fails because of no valid 82# replicas. 83log_must wait_for_resilver_end $TESTPOOL $MAXTIMEOUT 84log_must zpool offline $TESTPOOL $DISK2 85 86# clean up 87log_must zpool destroy $TESTPOOL 88 89log_pass "Zpool reopen test successful" 90