1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14
15#
16# Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
17#
18
19. $STF_SUITE/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib
20
21#
22# DESCRIPTION:
23# Test zpool reopen while performing IO to the pool.
24# Verify that no IO errors of any kind of reported.
25#
26# STRATEGY:
27# 1. Create a non-redundant pool.
28# 2. Repeat:
29#   a. Write files to the pool.
30#   b. Execute 'zpool reopen'.
31# 3. Verify that no errors are reported by 'zpool status'.
32
33verify_runnable "global"
34
35function cleanup
36{
37	poolexists $TESTPOOL && destroy_pool $TESTPOOL
38}
39
40log_assert "Testing zpool reopen with concurrent user IO"
41log_onexit cleanup
42
43set_removed_disk
44scsi_host=$(get_scsi_host $REMOVED_DISK)
45
46# 1. Create a non-redundant pool.
47log_must zpool create $TESTPOOL $DISK1 $DISK2 $DISK3
48
49for i in $(seq 10); do
50	# 3a. Write files in the background to the pool.
51	mkfile 64m /$TESTPOOL/data.$i &
52
53	# 3b. Execute 'zpool reopen'.
54	log_must zpool reopen $TESTPOOL
55
56	for disk in $DISK1 $DISK2 $DISK3; do
57		zpool status -P -v $TESTPOOL | grep $disk | \
58		    read -r name state rd wr cksum
59		log_must [ $state = "ONLINE" ]
60	        log_must [ $rd -eq 0 ]
61	        log_must [ $wr -eq 0 ]
62	        log_must [ $cksum -eq 0 ]
63	done
64done
65
66wait
67
68log_pass "Zpool reopen with concurrent user IO successful"
69