Skip to content

Commit 47319ef

Browse files
ixhamzabehlendorf
authored andcommitted
ZTS: Add test for snapshot automount race
Add snapshot_019_pos to verify parallel snapshot automount operations don't cause AVL tree panic. Regression test for commit 4ce030e. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ameer Hamza <[email protected]> Closes #18035
1 parent 0bcbee6 commit 47319ef

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed

tests/runfiles/common.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ tests = ['clone_001_pos', 'rollback_001_pos', 'rollback_002_pos',
10201020
'snapshot_006_pos', 'snapshot_007_pos', 'snapshot_008_pos',
10211021
'snapshot_009_pos', 'snapshot_010_pos', 'snapshot_011_pos',
10221022
'snapshot_012_pos', 'snapshot_013_pos', 'snapshot_014_pos',
1023-
'snapshot_017_pos', 'snapshot_018_pos']
1023+
'snapshot_017_pos', 'snapshot_018_pos', 'snapshot_019_pos']
10241024
tags = ['functional', 'snapshot']
10251025

10261026
[tests/functional/snapused]

tests/runfiles/sanity.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ tests = ['clone_001_pos', 'rollback_001_pos', 'rollback_002_pos',
580580
'snapshot_007_pos', 'snapshot_008_pos', 'snapshot_009_pos',
581581
'snapshot_010_pos', 'snapshot_011_pos', 'snapshot_012_pos',
582582
'snapshot_013_pos', 'snapshot_014_pos', 'snapshot_017_pos',
583-
'snapshot_018_pos']
583+
'snapshot_018_pos', 'snapshot_019_pos']
584584
tags = ['functional', 'snapshot']
585585

586586
[tests/functional/snapused]

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
21222122
functional/snapshot/snapshot_016_pos.ksh \
21232123
functional/snapshot/snapshot_017_pos.ksh \
21242124
functional/snapshot/snapshot_018_pos.ksh \
2125+
functional/snapshot/snapshot_019_pos.ksh \
21252126
functional/snapused/cleanup.ksh \
21262127
functional/snapused/setup.ksh \
21272128
functional/snapused/snapused_001_pos.ksh \
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
#
25+
# Copyright 2025 iXsystems, Inc.
26+
#
27+
28+
. $STF_SUITE/include/libtest.shlib
29+
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
30+
31+
#
32+
# DESCRIPTION:
33+
# Verify that parallel snapshot automount operations don't cause AVL tree
34+
# panic due to duplicate mount attempts.
35+
#
36+
# STRATEGY:
37+
# 1. Create a filesystem with snapdir=visible
38+
# 2. Create a snapshot
39+
# 3. Trigger parallel ls operations on the snapshot directory
40+
# 4. Verify no kernel panic occurred and snapshot is accessible
41+
#
42+
43+
function cleanup
44+
{
45+
destroy_pool $TESTPOOL
46+
}
47+
48+
verify_runnable "both"
49+
50+
log_assert "Verify parallel snapshot automount doesn't cause AVL tree panic"
51+
52+
log_onexit cleanup
53+
54+
# Create pool and filesystem
55+
create_pool $TESTPOOL $DISKS
56+
log_must zfs create -o snapdir=visible -o mountpoint=$TESTDIR $TESTPOOL/$TESTFS
57+
58+
# Create a snapshot
59+
log_must zfs snapshot $SNAPFS
60+
61+
# Trigger parallel automount operations to reproduce the race condition.
62+
# Multiple concurrent ls operations will attempt to automount the same
63+
# unmounted snapshot, which previously could cause duplicate mount helpers
64+
# and AVL tree panic.
65+
snapdir_path="$TESTDIR/.zfs/snapshot/$TESTSNAP"
66+
for i in {1..100}
67+
do
68+
ls $snapdir_path >/dev/null 2>&1 &
69+
done
70+
71+
# Wait for all background processes to complete
72+
wait
73+
74+
# Verify the snapshot is accessible and properly mounted after parallel access
75+
log_must ls $snapdir_path
76+
77+
# Verify we can unmount the filesystem cleanly. This confirms no processes
78+
# are stuck in a syscall and all automated snapshots were unmounted properly.
79+
# If the AVL panic occurred, unmount would fail.
80+
log_must zfs unmount $TESTPOOL/$TESTFS
81+
82+
log_pass "Parallel snapshot automount completed without AVL tree panic"

0 commit comments

Comments
 (0)