Skip to content

Commit

Permalink
ZTS: dnode stress test
Browse files Browse the repository at this point in the history
Add dnode stress test to test dirty dnode corruption:
#15526

Signed-off-by: Tony Hutter <[email protected]>
  • Loading branch information
tonyhutter committed Nov 29, 2023
1 parent acb33ee commit 95c2fc7
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TEST
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
3 changes: 3 additions & 0 deletions tests/zfs-tests/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
36 changes: 36 additions & 0 deletions tests/zfs-tests/tests/functional/dnode_stress/cleanup.ksh
Original file line number Diff line number Diff line change
@@ -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
80 changes: 80 additions & 0 deletions tests/zfs-tests/tests/functional/dnode_stress/dnode_stress.ksh
Original file line number Diff line number Diff line change
@@ -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"
36 changes: 36 additions & 0 deletions tests/zfs-tests/tests/functional/dnode_stress/setup.ksh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 95c2fc7

Please sign in to comment.