1#! /bin/ksh -p
2#
3# CDDL HEADER START
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# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2020, George Amanakis. All rights reserved.
19#
20
21. $STF_SUITE/include/libtest.shlib
22. $STF_SUITE/tests/functional/removal/removal.kshlib
23
24#
25# DESCRIPTION:
26#	Resilvering results in no CKSUM errors in pools with indirect vdevs.
27#
28# STRATEGY:
29#	1. Create a pool with two top-vdevs
30#	2. Write some files
31#	3. Remove one of the top-vdevs
32#	4. Reattach it to make a mirror
33#
34
35command -v fio > /dev/null || log_unsupported "fio missing"
36
37TMPDIR=${TMPDIR:-$TEST_BASE_DIR}
38
39DISK1="$TMPDIR/dsk1"
40DISK2="$TMPDIR/dsk2"
41DISKS="$DISK1 $DISK2"
42
43# fio options
44export DIRECTORY=/$TESTPOOL
45export NUMJOBS=16
46export RUNTIME=10
47export PERF_RANDSEED=1234
48export PERF_COMPPERCENT=66
49export PERF_COMPCHUNK=0
50export BLOCKSIZE=4K
51export SYNC_TYPE=0
52export DIRECT=1
53export FILE_SIZE=128M
54
55log_must mkfile 4g $DISK1
56log_must mkfile 4g $DISK2
57
58function cleanup
59{
60	default_cleanup_noexit
61	log_must rm -f $DISKS
62}
63
64log_must zpool create -O recordsize=4k $TESTPOOL $DISK1 $DISK2
65log_onexit cleanup
66
67log_must fio $FIO_SCRIPTS/mkfiles.fio
68log_must fio $FIO_SCRIPTS/sequential_reads.fio
69
70log_must zpool remove -w $TESTPOOL $DISK2
71log_must zpool attach -w $TESTPOOL $DISK1 $DISK2
72
73verify_pool $TESTPOOL
74
75log_pass "Resilvering results in no CKSUM errors with indirect vdevs"
76