Skip to content

Commit 32e6106

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 32e6106

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

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

0 commit comments

Comments
 (0)