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 4ce030e025.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #18035
This commit is contained in:
Ameer Hamza 2025-12-10 22:16:45 +05:00 committed by Brian Behlendorf
parent 0bcbee6040
commit 47319ef7a6
4 changed files with 85 additions and 2 deletions

View File

@ -1020,7 +1020,7 @@ tests = ['clone_001_pos', 'rollback_001_pos', 'rollback_002_pos',
'snapshot_006_pos', 'snapshot_007_pos', 'snapshot_008_pos',
'snapshot_009_pos', 'snapshot_010_pos', 'snapshot_011_pos',
'snapshot_012_pos', 'snapshot_013_pos', 'snapshot_014_pos',
'snapshot_017_pos', 'snapshot_018_pos']
'snapshot_017_pos', 'snapshot_018_pos', 'snapshot_019_pos']
tags = ['functional', 'snapshot']
[tests/functional/snapused]

View File

@ -580,7 +580,7 @@ tests = ['clone_001_pos', 'rollback_001_pos', 'rollback_002_pos',
'snapshot_007_pos', 'snapshot_008_pos', 'snapshot_009_pos',
'snapshot_010_pos', 'snapshot_011_pos', 'snapshot_012_pos',
'snapshot_013_pos', 'snapshot_014_pos', 'snapshot_017_pos',
'snapshot_018_pos']
'snapshot_018_pos', 'snapshot_019_pos']
tags = ['functional', 'snapshot']
[tests/functional/snapused]

View File

@ -2122,6 +2122,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/snapshot/snapshot_016_pos.ksh \
functional/snapshot/snapshot_017_pos.ksh \
functional/snapshot/snapshot_018_pos.ksh \
functional/snapshot/snapshot_019_pos.ksh \
functional/snapused/cleanup.ksh \
functional/snapused/setup.ksh \
functional/snapused/snapused_001_pos.ksh \

View File

@ -0,0 +1,82 @@
#!/bin/ksh -p
# SPDX-License-Identifier: CDDL-1.0
#
# 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 2025 iXsystems, Inc.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/snapshot/snapshot.cfg
#
# DESCRIPTION:
# Verify that parallel snapshot automount operations don't cause AVL tree
# panic due to duplicate mount attempts.
#
# STRATEGY:
# 1. Create a filesystem with snapdir=visible
# 2. Create a snapshot
# 3. Trigger parallel ls operations on the snapshot directory
# 4. Verify no kernel panic occurred and snapshot is accessible
#
function cleanup
{
destroy_pool $TESTPOOL
}
verify_runnable "both"
log_assert "Verify parallel snapshot automount doesn't cause AVL tree panic"
log_onexit cleanup
# Create pool and filesystem
create_pool $TESTPOOL $DISKS
log_must zfs create -o snapdir=visible -o mountpoint=$TESTDIR $TESTPOOL/$TESTFS
# Create a snapshot
log_must zfs snapshot $SNAPFS
# Trigger parallel automount operations to reproduce the race condition.
# Multiple concurrent ls operations will attempt to automount the same
# unmounted snapshot, which previously could cause duplicate mount helpers
# and AVL tree panic.
snapdir_path="$TESTDIR/.zfs/snapshot/$TESTSNAP"
for i in {1..100}
do
ls $snapdir_path >/dev/null 2>&1 &
done
# Wait for all background processes to complete
wait
# Verify the snapshot is accessible and properly mounted after parallel access
log_must ls $snapdir_path
# Verify we can unmount the filesystem cleanly. This confirms no processes
# are stuck in a syscall and all automated snapshots were unmounted properly.
# If the AVL panic occurred, unmount would fail.
log_must zfs unmount $TESTPOOL/$TESTFS
log_pass "Parallel snapshot automount completed without AVL tree panic"