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
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.
18 # Copyright (c) 2014, 2016 by Delphix. All rights reserved.
21 .
$STF_SUITE/include
/libtest.shlib
22 .
$STF_SUITE/tests
/functional
/removal
/removal.kshlib
27 # For device removal a file's contents should transfer
28 # completely from one disk to another. That should remain
29 # to be the case even if multiple levels of indirection
30 # are introduced as we remove more and more devices.
34 # 1. We create a file of size 128k and we save its contents
35 # in a local variable.
36 # 2. We set the limit of the maximum copied segment size of
37 # removals to 32k, so during removal our 128k file will
38 # be split to 4 blocks.
39 # 3. We start removing disks and adding them back in a loop.
40 # This way the file is moved around and introduces split
42 # 4. The loop itself tests that we don't have any problem
43 # when removing many devices. Within the loop we test
44 # that the files contents remain the same across transfers.
47 TMPDIR
=${TMPDIR:-$TEST_BASE_DIR}
48 log_must mkfile $
(($MINVDEVSIZE * 2)) $TMPDIR/dsk1
49 log_must mkfile $
(($MINVDEVSIZE * 2)) $TMPDIR/dsk2
50 DISKS
="$TMPDIR/dsk1 $TMPDIR/dsk2"
51 REMOVEDISK
=$TMPDIR/dsk1
53 log_must default_setup_noexit
"$DISKS"
57 default_cleanup_noexit
60 # reset zfs_remove_max_segment to 1M
61 set_tunable32 zfs_remove_max_segment
1048576
66 # set zfs_remove_max_segment to 32k
67 log_must set_tunable32 zfs_remove_max_segment
32768
69 log_must
dd if=/dev
/urandom of
=$TESTDIR/$TESTFILE0 bs
=128k count
=1
70 FILE_CONTENTS
=`cat $TESTDIR/$TESTFILE0`
71 log_must
[ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
74 log_must zpool remove
$TESTPOOL $TMPDIR/dsk1
75 log_must wait_for_removal
$TESTPOOL
76 log_mustnot vdevs_in_pool
$TESTPOOL $TMPDIR/dsk1
77 log_must zpool add
$TESTPOOL $TMPDIR/dsk1
80 log_must
dd if=$TESTDIR/$TESTFILE0 of
=/dev
/null
81 log_must
[ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
83 log_must zpool remove
$TESTPOOL $TMPDIR/dsk2
84 log_must wait_for_removal
$TESTPOOL
85 log_mustnot vdevs_in_pool
$TESTPOOL $TMPDIR/dsk2
86 log_must zpool add
$TESTPOOL $TMPDIR/dsk2
89 log_must
dd if=$TESTDIR/$TESTFILE0 of
=/dev
/null
90 log_must
[ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
93 log_pass
"File contents transferred completely from one disk to another."