Skip to content

Commit b08dbb7

Browse files
committed
ZTS: add regression test for #17180
in #17180, we fixed an interesting bug that i believe i hit in one of my pools, but as far as i can tell, there was no test for it. this patch adds a regression test for #17180, minimised from my attempts to reproduce the bug in a way that resembled the history of my pool. Signed-off-by: delan azabani <dazabani@igalia.com>
1 parent b9b8444 commit b08dbb7

3 files changed

Lines changed: 64 additions & 1 deletion

File tree

tests/runfiles/common.run

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ tests = ['block_cloning_clone_mmap_cached',
8282
'block_cloning_copyfilerange_fallback_same_txg',
8383
'block_cloning_replay', 'block_cloning_replay_encrypted',
8484
'block_cloning_lwb_buffer_overflow', 'block_cloning_clone_mmap_write',
85-
'block_cloning_rlimit_fsize', 'block_cloning_large_offset']
85+
'block_cloning_rlimit_fsize', 'block_cloning_large_offset',
86+
'block_cloning_after_device_removal']
8687
tags = ['functional', 'block_cloning']
8788

8889
[tests/functional/bootfs]

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
491491
functional/block_cloning/block_cloning_lwb_buffer_overflow.ksh \
492492
functional/block_cloning/block_cloning_rlimit_fsize.ksh \
493493
functional/block_cloning/block_cloning_large_offset.ksh \
494+
functional/block_cloning/block_cloning_after_device_removal.ksh \
494495
functional/bootfs/bootfs_001_pos.ksh \
495496
functional/bootfs/bootfs_002_neg.ksh \
496497
functional/bootfs/bootfs_003_pos.ksh \
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
. $STF_SUITE/include/libtest.shlib
25+
. $STF_SUITE/tests/functional/block_cloning/block_cloning.kshlib
26+
27+
#
28+
# DESCRIPTION:
29+
# Verify that when modifying and freeing cloned blocks after a top-level
30+
# vdev removal, there is no panic. This is a regression test for #17180.
31+
#
32+
33+
verify_runnable "global"
34+
35+
export VDIR=$TEST_BASE_DIR/disk-bclone
36+
export VDEV="$VDIR/0 $VDIR/1"
37+
log_must rm -rf $VDIR
38+
log_must mkdir -p $VDIR
39+
log_must truncate -s $MINVDEVSIZE $VDEV
40+
41+
claim="No panic when destroying dataset with cloned blocks after top-level vdev removal"
42+
43+
log_assert $claim
44+
45+
function cleanup
46+
{
47+
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
48+
rm -rf $TESTDIR $VDIR
49+
}
50+
51+
log_onexit cleanup
52+
53+
log_must zpool create -o feature@block_cloning=enabled $TESTPOOL $VDEV
54+
log_must dd if=/dev/urandom of=/$TESTPOOL/file bs=16M count=2
55+
log_must zpool remove -w $TESTPOOL $VDIR/1
56+
log_must zfs create $TESTPOOL/$TESTFS
57+
log_must clonefile -f /$TESTPOOL/file /$TESTPOOL/$TESTFS/file
58+
log_must dd if=/dev/urandom of=/$TESTPOOL/file bs=16M count=2
59+
log_must zfs destroy -r $TESTPOOL/$TESTFS
60+
61+
log_pass $claim

0 commit comments

Comments
 (0)