1e4c795beSTom Caputi#!/bin/ksh -p 2e4c795beSTom Caputi 3e4c795beSTom Caputi# 4e4c795beSTom Caputi# This file and its contents are supplied under the terms of the 5e4c795beSTom Caputi# Common Development and Distribution License ("CDDL"), version 1.0. 6e4c795beSTom Caputi# You may only use this file in accordance with the terms of version 7e4c795beSTom Caputi# 1.0 of the CDDL. 8e4c795beSTom Caputi# 9e4c795beSTom Caputi# A full copy of the text of the CDDL should have accompanied this 10e4c795beSTom Caputi# source. A copy of the CDDL is also available via the Internet at 11e4c795beSTom Caputi# http://www.illumos.org/license/CDDL. 12e4c795beSTom Caputi# 13e4c795beSTom Caputi 14e4c795beSTom Caputi# 15e4c795beSTom Caputi# Copyright (c) 2017 Open-E, Inc. All Rights Reserved. 16e4c795beSTom Caputi# 17e4c795beSTom Caputi 18e4c795beSTom Caputi. $STF_SUITE/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib 19e4c795beSTom Caputi 20e4c795beSTom Caputi# 21e4c795beSTom Caputi# DESCRIPTION: 22e4c795beSTom Caputi# Test zpool reopen -n while scrub is running. 23e4c795beSTom Caputi# Checks if re-plugged device is NOT resilvered. 24e4c795beSTom Caputi# 25e4c795beSTom Caputi# STRATEGY: 26e4c795beSTom Caputi# 1. Create a pool 27e4c795beSTom Caputi# 2. Remove a disk. 28e4c795beSTom Caputi# 3. Write test file to pool. 29e4c795beSTom Caputi# 4. Execute scrub. 30e4c795beSTom Caputi# 5. "Plug back" disk. 31e4c795beSTom Caputi# 6. Reopen a pool with an -n flag. 32e4c795beSTom Caputi# 7. Check if resilver was deferred. 33e4c795beSTom Caputi# 8. Check if trying to put device to offline fails because of no valid 34e4c795beSTom Caputi# replicas. 35e4c795beSTom Caputi# 36e4c795beSTom Caputi# NOTES: 37e4c795beSTom Caputi# A 125ms delay is added to make sure that the scrub is running while 38e4c795beSTom Caputi# the reopen is invoked. 39e4c795beSTom Caputi# 40e4c795beSTom Caputi 41e4c795beSTom Caputiverify_runnable "global" 42e4c795beSTom Caputi 43e4c795beSTom Caputifunction cleanup 44e4c795beSTom Caputi{ 45e4c795beSTom Caputi log_must zinject -c all 46e4c795beSTom Caputi # bring back removed disk online for further tests 47e4c795beSTom Caputi insert_disk $REMOVED_DISK $scsi_host 48e4c795beSTom Caputi poolexists $TESTPOOL && destroy_pool $TESTPOOL 49e4c795beSTom Caputi} 50e4c795beSTom Caputi 51e4c795beSTom Caputilog_assert "Testing zpool reopen with pool name as argument" 52e4c795beSTom Caputilog_onexit cleanup 53e4c795beSTom Caputi 54e4c795beSTom Caputiset_removed_disk 55e4c795beSTom Caputiscsi_host=$(get_scsi_host $REMOVED_DISK) 56e4c795beSTom Caputi 57e4c795beSTom Caputi# 1. Create a pool 58e4c795beSTom Caputidefault_mirror_setup_noexit $REMOVED_DISK_ID $DISK2 59e4c795beSTom Caputi# 2. Remove a disk. 60e4c795beSTom Caputiremove_disk $REMOVED_DISK 61e4c795beSTom Caputilog_must zpool reopen -n $TESTPOOL 62e4c795beSTom Caputilog_must check_state $TESTPOOL "$REMOVED_DISK_ID" "unavail" 63e4c795beSTom Caputi# 3. Write test file to pool. 64e4c795beSTom Caputilog_must generate_random_file /$TESTPOOL/data $LARGE_FILE_SIZE 65*09fbbb7dSAllan Judesync_pool $TESTPOOL 66e4c795beSTom Caputi# 4. Execute scrub. 67e4c795beSTom Caputi# add delay to I/O requests for remaining disk in pool 68e4c795beSTom Caputilog_must zinject -d $DISK2 -D125:1 $TESTPOOL 69e4c795beSTom Caputilog_must zpool scrub $TESTPOOL 70e4c795beSTom Caputi# 5. "Plug back" disk. 71e4c795beSTom Caputiinsert_disk $REMOVED_DISK $scsi_host 72e4c795beSTom Caputi# 6. Reopen a pool with an -n flag. 73e4c795beSTom Caputilog_must zpool reopen -n $TESTPOOL 74e4c795beSTom Caputilog_must check_state $TESTPOOL "$REMOVED_DISK_ID" "online" 75e4c795beSTom Caputi# remove delay from disk 76e4c795beSTom Caputilog_must zinject -c all 77e4c795beSTom Caputi# 7. Check if scrub scan is NOT replaced by resilver. 78e4c795beSTom Caputilog_must wait_for_scrub_end $TESTPOOL $MAXTIMEOUT 79e4c795beSTom Caputilog_must is_deferred_scan_started $TESTPOOL 80e4c795beSTom Caputi 81e4c795beSTom Caputi# 8. Check if trying to put device to offline fails because of no valid 82e4c795beSTom Caputi# replicas. 83e4c795beSTom Caputilog_must wait_for_resilver_end $TESTPOOL $MAXTIMEOUT 84e4c795beSTom Caputilog_must zpool offline $TESTPOOL $DISK2 85e4c795beSTom Caputi 86e4c795beSTom Caputi# clean up 87e4c795beSTom Caputilog_must zpool destroy $TESTPOOL 88e4c795beSTom Caputi 89e4c795beSTom Caputilog_pass "Zpool reopen test successful" 90