summaryrefslogtreecommitdiff
path: root/usr/src/test/zfs-tests/tests/functional/removal/removal_multiple_indirection.ksh
blob: 85a915d9094ea802a36b01e7c40a46ba4553bc99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! /bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#

#
# Copyright (c) 2014, 2016 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib

#
# DESCRIPTION:
#
# For device removal a file's contents should transfer
# completely from one disk to another. That should remain
# to be the case even if multiple levels of indirection
# are introduced as we remove more and more devices.
#
# STRATEGY:
#
# 1. We create a file of size 128k and we save its contents
#    in a local variable.
# 2. We set the limit of the maximum copied segment size of
#    removals to 32k, so during removal our 128k file will
#    be split to 4 blocks.
# 3. We start removing disks and adding them back in a loop.
#    This way the file is moved around and introduces split
#    blocks.
# 4. The loop itself tests that we don't have any problem
#    when removing many devices. Within the loop we test
#    that the files contents remain the same across transfers.
#

TMPDIR=${TMPDIR:-$TEST_BASE_DIR}
log_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk1
log_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk2
DISKS="$TMPDIR/dsk1 $TMPDIR/dsk2"
REMOVEDISK=$TMPDIR/dsk1

log_must default_setup_noexit "$DISKS"

function cleanup
{
	default_cleanup_noexit
	log_must rm -f $DISKS

	# reset zfs_remove_max_segment to 1M
	log_must mdb_set_uint32 zfs_remove_max_segment 1048576
}

log_onexit cleanup

# set zfs_remove_max_segment to 32k
log_must mdb_set_uint32 zfs_remove_max_segment 32768

log_must dd if=/dev/urandom of=$TESTDIR/$TESTFILE0 bs=128k count=1
FILE_CONTENTS=`cat $TESTDIR/$TESTFILE0`
log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]

for i in {1..100}; do
	log_must zpool remove $TESTPOOL $TMPDIR/dsk1
	log_must wait_for_removal $TESTPOOL
	log_mustnot vdevs_in_pool $TESTPOOL $TMPDIR/dsk1
	log_must zpool add $TESTPOOL $TMPDIR/dsk1

	log_must zinject -a
	log_must dd if=$TESTDIR/$TESTFILE0 of=/dev/null
	log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]

	log_must zpool remove $TESTPOOL $TMPDIR/dsk2
	log_must wait_for_removal $TESTPOOL
	log_mustnot vdevs_in_pool $TESTPOOL $TMPDIR/dsk2
	log_must zpool add $TESTPOOL $TMPDIR/dsk2

	log_must zinject -a
	log_must dd if=$TESTDIR/$TESTFILE0 of=/dev/null
	log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
done

log_pass "File contents transfered completely from one disk to another."