-
Notifications
You must be signed in to change notification settings - Fork 2k
zpool create: report which device caused failure #18213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chrislongros
wants to merge
1
commit into
openzfs:master
Choose a base branch
from
chrislongros:feature/zpool-create-device-errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
103 changes: 103 additions & 0 deletions
103
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
This file contains hidden or 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,103 @@ | ||
| #!/bin/ksh -p | ||
| # SPDX-License-Identifier: CDDL-1.0 | ||
| # | ||
| # 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) 2026, Christos Longros. All rights reserved. | ||
| # | ||
|
|
||
| . $STF_SUITE/include/libtest.shlib | ||
|
|
||
| # | ||
| # DESCRIPTION: | ||
| # 'zpool create' should report which device is in use when it fails | ||
| # because a vdev belongs to an active pool. | ||
| # | ||
| # STRATEGY: | ||
| # 1. Create a backing file for two block devices. | ||
| # 2. Attach two block devices to the same file. | ||
| # 3. Attempt to create a mirror pool using both devices. | ||
| # 4. Verify the error message identifies the specific device. | ||
| # 5. Verify the error message names the active pool. | ||
| # | ||
|
|
||
| verify_runnable "global" | ||
|
|
||
| TESTFILE="$TEST_BASE_DIR/vdev_errinfo" | ||
| TESTPOOL2="testpool_errinfo" | ||
| BLKDEV1="" | ||
| BLKDEV2="" | ||
|
|
||
| function cleanup | ||
| { | ||
| destroy_pool $TESTPOOL2 | ||
| destroy_pool $TESTPOOL | ||
|
|
||
| if is_linux; then | ||
| [[ -n "$BLKDEV1" ]] && losetup -d "$BLKDEV1" 2>/dev/null | ||
| [[ -n "$BLKDEV2" ]] && losetup -d "$BLKDEV2" 2>/dev/null | ||
| elif is_freebsd; then | ||
| [[ -n "$BLKDEV1" ]] && mdconfig -d -u "$BLKDEV1" 2>/dev/null | ||
| [[ -n "$BLKDEV2" ]] && mdconfig -d -u "$BLKDEV2" 2>/dev/null | ||
| fi | ||
|
|
||
| rm -f "$TESTFILE" | ||
| } | ||
|
|
||
| log_assert "'zpool create' reports device-specific errors for in-use vdevs." | ||
| log_onexit cleanup | ||
|
|
||
| # Create a file to back the block devices | ||
| log_must truncate -s $MINVDEVSIZE "$TESTFILE" | ||
|
|
||
| # Attach two block devices to the same file (platform-specific) | ||
| if is_linux; then | ||
| BLKDEV1=$(losetup -f --show "$TESTFILE") | ||
| BLKDEV2=$(losetup -f --show "$TESTFILE") | ||
| elif is_freebsd; then | ||
| BLKDEV1=/dev/$(mdconfig -a -t vnode -f "$TESTFILE") | ||
| BLKDEV2=/dev/$(mdconfig -a -t vnode -f "$TESTFILE") | ||
| else | ||
| log_unsupported "Platform not supported for this test" | ||
| fi | ||
|
|
||
| log_note "Using devices: $BLKDEV1 $BLKDEV2" | ||
|
|
||
| # Attempt to create a mirror pool; this should fail because both | ||
| # devices refer to the same underlying file. | ||
| log_mustnot zpool create $TESTPOOL2 mirror $BLKDEV1 $BLKDEV2 | ||
|
|
||
| # Re-run to capture the error message for content verification | ||
| errmsg=$(zpool create $TESTPOOL2 mirror $BLKDEV1 $BLKDEV2 2>&1) | ||
| log_note "zpool create output: $errmsg" | ||
|
|
||
| # Error message should name one of the devices | ||
| log_must eval "echo '$errmsg' | grep -qE '$BLKDEV1|$BLKDEV2'" | ||
|
|
||
| # Error message should name the active pool | ||
| if echo "$errmsg" | grep -q "active pool"; then | ||
| log_note "Error message correctly identifies the active pool" | ||
| else | ||
| log_fail "Error message does not mention the active pool: $errmsg" | ||
| fi | ||
|
|
||
| log_pass "'zpool create' reports device-specific errors for in-use vdevs." |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we're going to have infrastructure to report more detailed errors in
zpool createI suspect we'll want to make use of it in some of the other error cases. I've thrown together a completely untested commit which restructures things so we can access the nvlists where we need them. Can you take a look at 2c5fa0d, refine as needed, and then squash something that's actually tested in to this PR!