-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect BTX boot loader in the zfs reserved boot section
Signed-off-by: Don Brady <[email protected]>
- Loading branch information
Showing
11 changed files
with
219 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 https://opensource.org/licenses/CDDL-1.0. | ||
* 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. | ||
*/ | ||
|
||
#include <sys/zfs_context.h> | ||
#include <sys/spa.h> | ||
#include <sys/spa_impl.h> | ||
#include <sys/vdev.h> | ||
#include <sys/vdev_impl.h> | ||
|
||
/* | ||
* Check if the reserved boot area is in-use. | ||
* | ||
* Not aware of any external uses on Linux. | ||
*/ | ||
int | ||
vdev_check_boot_reserve(spa_t *spa, vdev_t *childvd) | ||
{ | ||
(void) spa; | ||
(void) childvd; | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
tests/zfs-tests/tests/functional/raidz/raidz_expand_007_neg.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/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 | ||
|