Skip to content

Commit 4c639ad

Browse files
author
Don Brady
committed
Restrict raidz faulted vdev count
Specifically, a child in a replacing vdev won't count when assessing the dtl during a vdev_fault() Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Don Brady <[email protected]>
1 parent 6f50f8e commit 4c639ad

File tree

4 files changed

+136
-9
lines changed

4 files changed

+136
-9
lines changed

module/zfs/vdev.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,9 +3149,9 @@ vdev_dtl_should_excise(vdev_t *vd, boolean_t rebuild_done)
31493149
* Reassess DTLs after a config change or scrub completion. If txg == 0 no
31503150
* write operations will be issued to the pool.
31513151
*/
3152-
void
3153-
vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
3154-
boolean_t scrub_done, boolean_t rebuild_done)
3152+
static void
3153+
vdev_dtl_reassess_impl(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
3154+
boolean_t scrub_done, boolean_t rebuild_done, boolean_t dtl_outage)
31553155
{
31563156
spa_t *spa = vd->vdev_spa;
31573157
avl_tree_t reftree;
@@ -3160,8 +3160,8 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
31603160
ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0);
31613161

31623162
for (int c = 0; c < vd->vdev_children; c++)
3163-
vdev_dtl_reassess(vd->vdev_child[c], txg,
3164-
scrub_txg, scrub_done, rebuild_done);
3163+
vdev_dtl_reassess_impl(vd->vdev_child[c], txg,
3164+
scrub_txg, scrub_done, rebuild_done, dtl_outage);
31653165

31663166
if (vd == spa->spa_root_vdev || !vdev_is_concrete(vd) || vd->vdev_aux)
31673167
return;
@@ -3255,7 +3255,15 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
32553255
if (scrub_done)
32563256
range_tree_vacate(vd->vdev_dtl[DTL_SCRUB], NULL, NULL);
32573257
range_tree_vacate(vd->vdev_dtl[DTL_OUTAGE], NULL, NULL);
3258-
if (!vdev_readable(vd))
3258+
3259+
/*
3260+
* For the dtl_outage case, treat members of a replacing vdev
3261+
* as if they are not available. It's more likely than not that
3262+
* a vdev in a replacing vdev could encounter read errors so
3263+
* treat it as not being able to contribute.
3264+
*/
3265+
if (!vdev_readable(vd) || (dtl_outage &&
3266+
vd->vdev_parent->vdev_ops == &vdev_replacing_ops))
32593267
range_tree_add(vd->vdev_dtl[DTL_OUTAGE], 0, -1ULL);
32603268
else
32613269
range_tree_walk(vd->vdev_dtl[DTL_MISSING],
@@ -3321,6 +3329,20 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
33213329
}
33223330
}
33233331

3332+
void
3333+
vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
3334+
boolean_t scrub_done, boolean_t rebuild_done)
3335+
{
3336+
return (vdev_dtl_reassess_impl(vd, txg, scrub_txg, scrub_done,
3337+
rebuild_done, B_FALSE));
3338+
}
3339+
3340+
static void
3341+
vdev_dtl_reassess_outage(vdev_t *vd)
3342+
{
3343+
return (vdev_dtl_reassess_impl(vd, 0, 0, B_FALSE, B_FALSE, B_TRUE));
3344+
}
3345+
33243346
/*
33253347
* Iterate over all the vdevs except spare, and post kobj events
33263348
*/
@@ -3548,7 +3570,11 @@ vdev_dtl_sync(vdev_t *vd, uint64_t txg)
35483570
}
35493571

35503572
/*
3551-
* Determine whether the specified vdev can be offlined/detached/removed
3573+
* Determine whether the specified vdev can be
3574+
* - offlined
3575+
* - detached
3576+
* - removed
3577+
* - faulted
35523578
* without losing data.
35533579
*/
35543580
boolean_t
@@ -3570,10 +3596,10 @@ vdev_dtl_required(vdev_t *vd)
35703596
* If not, we can safely offline/detach/remove the device.
35713597
*/
35723598
vd->vdev_cant_read = B_TRUE;
3573-
vdev_dtl_reassess(tvd, 0, 0, B_FALSE, B_FALSE);
3599+
vdev_dtl_reassess_outage(tvd);
35743600
required = !vdev_dtl_empty(tvd, DTL_OUTAGE);
35753601
vd->vdev_cant_read = cant_read;
3576-
vdev_dtl_reassess(tvd, 0, 0, B_FALSE, B_FALSE);
3602+
vdev_dtl_reassess_outage(tvd);
35773603

35783604
if (!required && zio_injection_enabled) {
35793605
required = !!zio_handle_device_injection(vd, NULL,

tests/runfiles/common.run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ tags = ['functional', 'exec']
709709
tests = ['fallocate_punch-hole']
710710
tags = ['functional', 'fallocate']
711711

712+
[tests/functional/fault]
713+
tests = ['fault_limits']
714+
tags = ['functional', 'fault']
715+
712716
[tests/functional/features/async_destroy]
713717
tests = ['async_destroy_001_pos']
714718
tags = ['functional', 'features', 'async_destroy']

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
15251525
functional/fault/cleanup.ksh \
15261526
functional/fault/decompress_fault.ksh \
15271527
functional/fault/decrypt_fault.ksh \
1528+
functional/fault/fault_limits.ksh \
15281529
functional/fault/scrub_after_resilver.ksh \
15291530
functional/fault/suspend_resume_single.ksh \
15301531
functional/fault/setup.ksh \
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/ksh -p
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License (the "License").
7+
# You may not use this file except in compliance with the License.
8+
#
9+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10+
# or https://opensource.org/licenses/CDDL-1.0.
11+
# See the License for the specific language governing permissions
12+
# and limitations under the License.
13+
#
14+
# When distributing Covered Code, include this CDDL HEADER in each
15+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16+
# If applicable, add the following below this CDDL HEADER, with the
17+
# fields enclosed by brackets "[]" replaced with your own identifying
18+
# information: Portions Copyright [yyyy] [name of copyright owner]
19+
#
20+
# CDDL HEADER END
21+
#
22+
#
23+
# Copyright (c) 2024 by Klara, Inc.
24+
#
25+
26+
. $STF_SUITE/include/libtest.shlib
27+
. $STF_SUITE/tests/functional/fault/fault.cfg
28+
29+
#
30+
# DESCRIPTION: Verify that raidz children vdev fault count is restricted
31+
#
32+
# STRATEGY:
33+
# 1. Create a raidz2 or raidz3 pool and add some data to it
34+
# 2. Replace one of the child vdevs to create a replacing vdev
35+
# 3. While it is resilvering, attempt to fault disks
36+
# 4. Verify that less than parity count was faulted while replacing
37+
#
38+
39+
TESTPOOL="fault-test-pool"
40+
PARITY=$((RANDOM%(2) + 2))
41+
VDEV_CNT=$((4 + (2 * PARITY)))
42+
VDEV_SIZ=512M
43+
44+
function cleanup
45+
{
46+
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
47+
48+
for i in {0..$((VDEV_CNT - 1))}; do
49+
log_must rm -f "$TEST_BASE_DIR/dev-$i"
50+
done
51+
}
52+
53+
log_onexit cleanup
54+
log_assert "restricts raidz children vdev fault count"
55+
56+
log_note "creating $VDEV_CNT vdevs for parity $PARITY test"
57+
typeset -a disks
58+
for i in {0..$((VDEV_CNT - 1))}; do
59+
device=$TEST_BASE_DIR/dev-$i
60+
log_must truncate -s $VDEV_SIZ $device
61+
disks[${#disks[*]}+1]=$device
62+
done
63+
64+
log_must zpool create -f ${TESTPOOL} raidz${PARITY} ${disks[1..$((VDEV_CNT - 1))]}
65+
66+
# Add some data to the pool
67+
log_must zfs create $TESTPOOL/fs
68+
MNTPOINT="$(get_prop mountpoint $TESTPOOL/fs)"
69+
log_must fill_fs $MNTPOINT $PARITY 200 32768 1000 Z
70+
sync_pool $TESTPOOL
71+
72+
# Replace the last child vdev to form a replacing vdev
73+
log_must zpool replace ${TESTPOOL} ${disks[$((VDEV_CNT - 1))]} ${disks[$VDEV_CNT]}
74+
# imediately offline replacement disk to keep replacing vdev around
75+
log_must zpool offline ${TESTPOOL} ${disks[$VDEV_CNT]}
76+
77+
# Fault disks while a replacing vdev is still active
78+
for disk in ${disks[0..$PARITY]}; do
79+
log_must zpool offline -tf ${TESTPOOL} $disk
80+
done
81+
82+
zpool status $TESTPOOL
83+
84+
# Count the faults that succeeded
85+
faults=0
86+
for disk in ${disks[0..$PARITY]}; do
87+
state=$(zpool get -H -o value state ${TESTPOOL} ${disk})
88+
if [ "$state" = "FAULTED" ] ; then
89+
((faults=faults+1))
90+
fi
91+
done
92+
93+
log_must test "$faults" -lt "$PARITY"
94+
log_must test "$faults" -gt 0
95+
96+
log_pass "restricts raidz children vdev fault count"

0 commit comments

Comments
 (0)