/
raidz_expand_007_neg.ksh
executable file
·86 lines (74 loc) · 2.43 KB
/
raidz_expand_007_neg.ksh
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
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2023 by iXsystems, Inc.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Negative for FreeBSD Only
#
# Attempting to expand a RAIDZ should fail if the scratch area on the
# existing disks contains BTX Server binary (used to boot FreeBSD when
# using MBR partitions with ZFS).
#
# STRATEGY:
# 1. Create raidz pool
# 2. Add a BTX header to the reserved boot area
# 3. Attempt to attach a device to the raidz vdev
# 4. Verify that device attached failed
# 5. Destroy the raidz pool
typeset -r devs=4
typeset -r dev_size_mb=128
typeset -a disks
function cleanup
{
log_pos zpool status "$TESTPOOL"
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
for i in {0..$devs}; do
log_must rm -f "$TEST_BASE_DIR/dev-$i"
done
}
log_onexit cleanup
for i in {0..$devs}; do
device=$TEST_BASE_DIR/dev-$i
# simulate active BTX Server data by inserting a BTX header
printf "\xeb\x0e%s\x01\x02\x80" "BTX" | dd of="$device" \
bs=512 seek=1024 status=none
log_must truncate -s ${dev_size_mb}M "$device"
if [[ $i -ne $devs ]]; then
disks[${#disks[*]}+1]=$device
fi
done
log_must zpool create -f -o cachefile=none "$TESTPOOL" raidz1 "${disks[@]}"
if is_freebsd; then
# expecting attach to fail
log_mustnot_expect "the reserved boot area" zpool attach -f \
"$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs"
log_must zpool destroy "$TESTPOOL"
log_pass "raidz attach failed with in-use reserved boot area"
else
# expecting attach to pass everywhere else
log_must zpool attach -f "$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs"
log_must zpool destroy "$TESTPOOL"
log_pass "raidz attach passed with in-use reserved boot area"
fi