]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh
FreeBSD: Add zfs_link_create() error handling
[mirror_zfs.git] / tests / zfs-tests / tests / functional / online_offline / online_offline_001_pos.ksh
CommitLineData
6bb24f4d
BB
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1d3ba0bf 10# or https://opensource.org/licenses/CDDL-1.0.
6bb24f4d
BB
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25# Use is subject to license terms.
26#
27
28#
c1d9abf9 29# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
6bb24f4d
BB
30#
31
32. $STF_SUITE/include/libtest.shlib
95401cb6 33. $STF_SUITE/tests/functional/online_offline/online_offline.cfg
6bb24f4d
BB
34
35#
36# DESCRIPTION:
37# Turning a disk offline and back online during I/O completes.
38#
39# STRATEGY:
40# 1. Create a mirror and start some random I/O
41# 2. For each disk in the mirror, set it offline and online
42# 3. Verify the integrity of the file system and the resilvering.
43#
44
45verify_runnable "global"
46log_onexit cleanup
47
48DISKLIST=$(get_disklist $TESTPOOL)
49
50function cleanup
51{
52 #
53 # Ensure we don't leave disks in the offline state
54 #
55 for disk in $DISKLIST; do
c1d9abf9 56 log_must zpool online $TESTPOOL $disk
23914a3b 57 log_must check_state $TESTPOOL $disk "online"
6bb24f4d
BB
58
59 done
60
c1d9abf9
JWK
61 kill $killpid >/dev/null 2>&1
62 [[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
6bb24f4d
BB
63}
64
65log_assert "Turning a disk offline and back online during I/O completes."
66
c1d9abf9 67file_trunc -f $((64 * 1024 * 1024)) -b 8192 -c 0 -r $TESTDIR/$TESTFILE1 &
6bb24f4d
BB
68typeset killpid="$! "
69
70for disk in $DISKLIST; do
95401cb6 71 for i in 'do_offline' 'do_offline_while_already_offline'; do
c1d9abf9 72 log_must zpool offline $TESTPOOL $disk
23914a3b 73 log_must check_state $TESTPOOL $disk "offline"
95401cb6
BB
74 done
75
76 log_must zpool online $TESTPOOL $disk
23914a3b 77 log_must check_state $TESTPOOL $disk "online"
95401cb6
BB
78
79 # Delay for resilver to complete
80 sleep 3
6bb24f4d
BB
81done
82
c1d9abf9 83log_must kill $killpid
7454275a
AJ
84sync_all_pools
85log_must sync
6bb24f4d
BB
86
87typeset dir=$(get_device_dir $DISKS)
88verify_filesys "$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir"
89
90log_pass