zpool create: report which device caused failure#18213
Merged
behlendorf merged 1 commit intoopenzfs:masterfrom Apr 3, 2026
Merged
zpool create: report which device caused failure#18213behlendorf merged 1 commit intoopenzfs:masterfrom
behlendorf merged 1 commit intoopenzfs:masterfrom
Conversation
298ce20 to
a22cd15
Compare
behlendorf
reviewed
Feb 13, 2026
Contributor
behlendorf
left a comment
There was a problem hiding this comment.
Thanks for working on this!
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
Outdated
Show resolved
Hide resolved
a22cd15 to
cc184fe
Compare
f2bd62e to
e533157
Compare
tonyhutter
reviewed
Feb 26, 2026
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
Outdated
Show resolved
Hide resolved
tonyhutter
reviewed
Feb 26, 2026
tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_errinfo_001_neg.ksh
Outdated
Show resolved
Hide resolved
e533157 to
8a053f5
Compare
behlendorf
reviewed
Mar 3, 2026
8a053f5 to
4818a2a
Compare
fd7b80e to
4aca7e5
Compare
Contributor
Author
|
Updated with @behlendorf suggestions from 2c5fa0d — also added Tested on Arch Linux (6.19.10) with two loop devices on the same backing file: Also built and tested on FreeBSD 16.0-CURRENT — module loads fine, normal pool ops and ztest work. |
4aca7e5 to
39989c5
Compare
behlendorf
reviewed
Mar 31, 2026
When zpool create fails because a vdev is already in use, the
error message now identifies the problematic device and the pool
it belongs to, e.g.:
cannot create 'tank': device '/dev/sdb1' is part of
active pool 'rpool'
Implementation follows the ZPOOL_CONFIG_LOAD_INFO pattern used
by zpool import:
- Add spa_create_info to spa_t to capture error info during
vdev_label_init(), before vdev_close() resets vdev state
- When vdev_inuse() detects a conflict, read the on-disk
label to extract the pool name and store it with the
device path
- Return the info wrapped under ZPOOL_CONFIG_CREATE_INFO
through the ioctl zc_nvlist_dst to userspace
- In libzfs, zpool_create_info() unwraps the nvlist and
formats the device-specific error message
Restructure zpool_create() error handling so all switch cases
use break instead of return, eliminating duplicated cleanup
code and using the single create_failed exit path.
Suggested-by: Brian Behlendorf <[email protected]>
Signed-off-by: Christos Longros <[email protected]>
39989c5 to
d6839be
Compare
behlendorf
approved these changes
Apr 1, 2026
tonyhutter
approved these changes
Apr 1, 2026
behlendorf
approved these changes
Apr 3, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
When
zpool createfails because a vdev is already in use, the error message does not identify which device caused the problem:This is frustrating when creating pools with many disks, as there is no way to tell which device is the culprit without manually checking each one.
Description
This patch adds device-specific error reporting so the message now identifies the problematic device and the pool it belongs to:
Implementation follows the
ZPOOL_CONFIG_LOAD_INFOpattern used byzpool import, as suggested in #18184:spa_create_infotospa_tto capture error info duringvdev_label_init(), beforevdev_close()resets vdev statevdev_inuse()detects a conflict, read the on-disk label to extract the pool name and store it with the device pathZPOOL_CONFIG_CREATE_INFOthrough the ioctlzc_nvlist_dstto userspacezpool_create_info()helper unwraps the nvlist and formats the device-specific error messageIf the pool name cannot be read from the label, the device path alone is reported as a fallback.
Testing
zpool_create_errinfo_001_negverifies the error message names the device and the active pool when creating a mirror with duplicate loopback vdevs (portable across Linux and FreeBSD)checkstylepassesSuggested-by: Brian Behlendorf <[email protected]>
Signed-off-by: Christos Longros <[email protected]>