Skip to content

Commit 9d48676

Browse files
authored
Merge branch 'master' into ksm-tuning
2 parents ef98c57 + 131df3b commit 9d48676

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

lib/libzfs/libzfs_pool.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,6 +2961,18 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare,
29612961
idx = p + 1;
29622962
*p = '\0';
29632963

2964+
/*
2965+
* draid names are presented like: draid2:4d:6c:0s
2966+
* We match them up to the first ':' so we can still
2967+
* do the parity check below, but the other params
2968+
* are ignored.
2969+
*/
2970+
if ((p = strchr(type, ':')) != NULL) {
2971+
if (strncmp(type, VDEV_TYPE_DRAID,
2972+
strlen(VDEV_TYPE_DRAID)) == 0)
2973+
*p = '\0';
2974+
}
2975+
29642976
/*
29652977
* If the types don't match then keep looking.
29662978
*/

tests/runfiles/common.run

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ tags = ['functional', 'cli_root', 'zpool_export']
444444

445445
[tests/functional/cli_root/zpool_get]
446446
tests = ['zpool_get_001_pos', 'zpool_get_002_pos', 'zpool_get_003_pos',
447-
'zpool_get_004_neg', 'zpool_get_005_pos', 'vdev_get_001_pos']
447+
'zpool_get_004_neg', 'zpool_get_005_pos', 'vdev_get_001_pos',
448+
'vdev_get_all']
448449
tags = ['functional', 'cli_root', 'zpool_get']
449450

450451
[tests/functional/cli_root/zpool_history]

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
11031103
functional/cli_root/zpool_get/cleanup.ksh \
11041104
functional/cli_root/zpool_get/setup.ksh \
11051105
functional/cli_root/zpool_get/vdev_get_001_pos.ksh \
1106+
functional/cli_root/zpool_get/vdev_get_all.ksh \
11061107
functional/cli_root/zpool_get/zpool_get_001_pos.ksh \
11071108
functional/cli_root/zpool_get/zpool_get_002_pos.ksh \
11081109
functional/cli_root/zpool_get/zpool_get_003_pos.ksh \
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/ksh -p
2+
# SPDX-License-Identifier: CDDL-1.0
3+
#
4+
# CDDL HEADER START
5+
#
6+
# The contents of this file are subject to the terms of the
7+
# Common Development and Distribution License (the "License").
8+
# You may not use this file except in compliance with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or https://opensource.org/licenses/CDDL-1.0.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
24+
#
25+
# Copyright (c) 2025, Klara, Inc.
26+
#
27+
28+
. $STF_SUITE/include/libtest.shlib
29+
30+
#
31+
# DESCRIPTION:
32+
#
33+
# zpool get name <pool> all-vdevs works as expected
34+
#
35+
# STRATEGY:
36+
#
37+
# 1. create various kinds of pools
38+
# 2. get all vdev names
39+
# 3. make sure we get all the names back and they look correct
40+
#
41+
42+
verify_runnable "global"
43+
44+
function cleanup {
45+
zpool destroy -f $TESTPOOL1
46+
[[ -e $TESTDIR ]] && rm -rf $TESTDIR/*
47+
}
48+
log_onexit cleanup
49+
50+
log_assert "zpool get all-vdevs works as expected"
51+
52+
# map of vdev spec -> summary form
53+
#
54+
# left side is normal args to zpool create; single number will be replaced
55+
# with that number test file
56+
#
57+
# right side is a summary of the vdev tree, one char per vdev
58+
# ! root
59+
# 0-9 file number
60+
# m mirror
61+
# r raidz
62+
# d draid
63+
typeset -A specs=(
64+
["{0..9}"]="!0123456789"
65+
["mirror {0..9}"]="!m0123456789"
66+
["mirror 0 1 mirror 2 3 mirror 4 5 mirror 6 7"]="!m01m23m45m67"
67+
["raidz1 {0..9}"]="!r0123456789"
68+
["raidz1 {0..4} raidz1 {5..9}"]="!r01234r56789"
69+
["raidz2 {0..9}"]="!r0123456789"
70+
["raidz2 {0..4} raidz2 {5..9}"]="!r01234r56789"
71+
["raidz3 {0..9}"]="!r0123456789"
72+
["raidz3 {0..4} raidz3 {5..9}"]="!r01234r56789"
73+
["draid1 {0..9}"]="!d0123456789"
74+
["draid2 {0..9}"]="!d0123456789"
75+
["draid3 {0..9}"]="!d0123456789"
76+
)
77+
78+
for spec in "${!specs[@]}" ; do
79+
log_must truncate -s 100M $TESTDIR/$TESTFILE1.{0..9}
80+
log_must zpool create -f $TESTPOOL1 \
81+
$(echo $spec | sed -E "s#(^| )([0-9])#\1$TESTDIR/$TESTFILE1.\2#g")
82+
typeset desc=$( zpool get -Ho name name $TESTPOOL1 all-vdevs | awk '
83+
/^\// { t = t substr($1,length($1)) ; next }
84+
/^root/ { t = t "!" last ; next }
85+
/^[a-z]/ { t = t substr($1,0,1) last ; next }
86+
END { print t }
87+
')
88+
log_must test "${specs[$spec]}" == "$desc"
89+
cleanup
90+
done
91+
92+
log_pass

0 commit comments

Comments
 (0)