diff --git a/TEST b/TEST index 376d6eb691e2..266fe0714a3d 100644 --- a/TEST +++ b/TEST @@ -35,7 +35,7 @@ #TEST_ZFSTESTS_ITERS="1" #TEST_ZFSTESTS_OPTIONS="-vx" #TEST_ZFSTESTS_RUNFILE="linux.run" -#TEST_ZFSTESTS_TAGS="functional" +TEST_ZFSTESTS_TAGS="dnode_stress" ### zfsstress #TEST_ZFSSTRESS_SKIP="yes" diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 20c9b823c648..093b9143d45a 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -962,6 +962,10 @@ tags = ['functional', 'zvol', 'zvol_misc'] tests = ['zvol_stress'] tags = ['functional', 'zvol', 'zvol_stress'] +[tests/functional/dnode_stress] +tests = ['dnode_stress'] +tags = ['functional','dnode_stress'] + [tests/functional/zvol/zvol_swap] tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_004_pos'] tags = ['functional', 'zvol', 'zvol_swap'] diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index 79aef1900b59..4c45c1da2a29 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -2063,6 +2063,9 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ functional/zvol/zvol_stress/cleanup.ksh \ functional/zvol/zvol_stress/setup.ksh \ functional/zvol/zvol_stress/zvol_stress.ksh \ + functional/dnode_stress/cleanup.ksh \ + functional/dnode_stress/setup.ksh \ + functional/dnode_stress/dnode_stress.ksh \ functional/zvol/zvol_swap/cleanup.ksh \ functional/zvol/zvol_swap/setup.ksh \ functional/zvol/zvol_swap/zvol_swap_001_pos.ksh \ diff --git a/tests/zfs-tests/tests/functional/dnode_stress/cleanup.ksh b/tests/zfs-tests/tests/functional/dnode_stress/cleanup.ksh new file mode 100755 index 000000000000..a0555aff06c2 --- /dev/null +++ b/tests/zfs-tests/tests/functional/dnode_stress/cleanup.ksh @@ -0,0 +1,36 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +verify_runnable "global" + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/dnode_stress/dnode_stress.ksh b/tests/zfs-tests/tests/functional/dnode_stress/dnode_stress.ksh new file mode 100755 index 000000000000..65fee0c08409 --- /dev/null +++ b/tests/zfs-tests/tests/functional/dnode_stress/dnode_stress.ksh @@ -0,0 +1,80 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Stress the dirty dnode bug: +# issue - https://github.com/openzfs/zfs/issues/15526 +# fix - https://github.com/openzfs/zfs/pull/15571) +# +# Copyright (c) 2023 by Lawrence Livermore National Security, LLC. + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/reservation/reservation.shlib +. $STF_SUITE/tests/functional/zvol/zvol_common.shlib + +verify_runnable "global" + +function reproducer { + cd /$TESTPOOL + mypid=$(exec sh -c 'echo $PPID') + + prefix="reproducer_${mypid}_" + log_must dd if=/dev/urandom of=${prefix}0 bs=64k count=1 status=none + + log_note "writing files" + end=50000 + h=0 + for i in `seq 1 2 $end` ; do + let "j=$i+1" + cp ${prefix}$h ${prefix}$i + cp --reflink=never ${prefix}$i ${prefix}$j + let "h++" + done +} + +spawn=4 +for i in `seq 1 $spawn` ; do + reproducer & + pids[$i]=$! +done + +log_note "Waiting" +wait +log_note "Checking files" +fail=0 +cd /$TESTPOOL +for i in `seq 1 $spawn` ; do + mypid=${pids[$i]} + prefix="reproducer_${mypid}_" + out="$(diff -q ${prefix}0 ${prefix}$i)" + if [ $? != 0 ] ; then + log_note "$mypid: failed match ${prefix}0 ${prefix}$i" + log_note "$mypid: ls: $(ls -l ${prefix}0 ${prefix}$i)" + log_note "$mypid: diff: $out" + fail=1 + fi +done +cd + +if [ "$fail" == "1" ] ; then + log_fail "Saw dirty dnode corruption" +fi + +log_pass "Saw no dirty dnode corruption" diff --git a/tests/zfs-tests/tests/functional/dnode_stress/setup.ksh b/tests/zfs-tests/tests/functional/dnode_stress/setup.ksh new file mode 100755 index 000000000000..2abf3411fd07 --- /dev/null +++ b/tests/zfs-tests/tests/functional/dnode_stress/setup.ksh @@ -0,0 +1,36 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or https://opensource.org/licenses/CDDL-1.0. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +verify_runnable "global" + +default_setup "$DISKS"