mirror_zfs/lib/libspl/include/sys
Ameer Hamza 88d012a1d6
Fix snapshot automount expiry cancellation deadlock
A deadlock occurs when snapshot expiry tasks are cancelled while holding
locks. The snapshot expiry task (snapentry_expire) spawns an umount
process and waits for it to complete. Concurrently, ARC memory pressure
triggers arc_prune which calls zfs_exit_fs(), attempting to cancel the
expiry task while holding locks. The umount process spawned by the
expiry task blocks trying to acquire locks held by arc_prune, which is
blocked waiting for the expiry task to complete. This creates a circular
dependency: expiry task waits for umount, umount waits for arc_prune,
arc_prune waits for expiry task.

Fix by adding non-blocking cancellation support to taskq_cancel_id().
The zfs_exit_fs() path calls zfsctl_snapshot_unmount_delay() to
reschedule the unmount, which needs to cancel any existing expiry task.
It now uses non-blocking cancellation to avoid waiting while holding
locks, breaking the deadlock by returning immediately when the task is
already running.

The per-entry se_taskqid_lock has been removed, with all taskqid
operations now protected by the global zfs_snapshot_lock held as
WRITER. Additionally, an se_in_umount flag prevents recursive waits when
zfsctl_destroy() is called during unmount. The taskqid is now only
cleared by the caller on successful cancellation; running tasks clear
their own taskqid upon completion.

Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #17941
2025-12-01 14:43:42 -08:00
..
dktp SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
acl_impl.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
acl.h zfs_context: remove duplicated access control stuff; remove kernel gate 2025-11-12 10:00:52 -08:00
asm_linkage.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
backtrace.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
callb.h libspl: move callb stubs from zfs_context.h 2025-11-12 10:01:44 -08:00
cmn_err.h libspl: move cmn_err definitions from zfs_context.h 2025-11-12 09:59:09 -08:00
condvar.h libspl: move condvar definitions from zfs_context.h 2025-11-12 09:58:59 -08:00
cred.h libspl: move cred definitions from zfs_context.h 2025-11-12 09:59:51 -08:00
debug.h zfs_context: move empty __init/__exit macros to sys/debug.h 2025-11-12 10:02:42 -08:00
dkio.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
dklabel.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
feature_tests.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
inttypes.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
isa_defs.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
kmem.h libspl: move kmem definitions from zfs_context.h 2025-11-12 10:00:17 -08:00
kstat.h libspl: move kstat definitions from zfs_context.h, slim down to basics 2025-11-12 10:00:03 -08:00
list_impl.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
list.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
mhd.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
misc.h libspl: hide global data objects 2025-11-12 10:04:22 -08:00
mkdev.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
mod.h libspl: implement ZFS_MODULE_PARAM for userspace 2025-07-15 15:46:51 -07:00
mutex.h libspl: move mutex headers from zfs_context.h 2025-11-12 09:58:37 -08:00
policy.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
poll.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
priv.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
processor.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
procfs_list.h libspl: move procfs_list definitions from zfs_context.h 2025-11-12 10:00:10 -08:00
random.h libspl/random: add switch to force pseudo-random numbers for all calls 2025-11-12 10:04:30 -08:00
rwlock.h libspl: move rwlock definitions from zfs_context.h 2025-11-12 09:58:50 -08:00
sid.h libspl: move SID definitions from zfs_context.h; remove kernel gate 2025-11-12 10:01:48 -08:00
simd.h Backport AVX2 AES-GCM implementation from BoringSSL 2025-08-13 14:51:20 -07:00
stack.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
stdtypes.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
string.h libspl: add include guards for sys/string.h 2025-11-12 10:00:41 -08:00
sunddi.h libspl: move remaining ddi_* prototypes from zfs_context.h 2025-11-12 10:02:12 -08:00
sysmacros.h libspl: common sysmacros.h 2025-11-12 10:02:25 -08:00
systeminfo.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
systm.h libspl: hide global data objects 2025-11-12 10:04:22 -08:00
taskq.h Fix snapshot automount expiry cancellation deadlock 2025-12-01 14:43:42 -08:00
thread.h libspl: hide global data objects 2025-11-12 10:04:22 -08:00
time.h Detect a slow raidz child during reads 2025-09-10 15:25:03 -07:00
timer.h libspl: move time definitions from zfs_context_os.h 2025-11-12 09:58:31 -08:00
trace.h libspl: move DTRACE_PROBE macros from zfs_context.h 2025-11-12 10:02:20 -08:00
tsd.h libspl: move tsd definitions from zfs_context.h 2025-11-12 09:59:59 -08:00
tunables.h libspl: hide zfs_tunable_* symbols 2025-11-12 09:38:54 -08:00
types32.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
types.h libspl: move loff_t declaration from zfs_context.h 2025-11-12 10:02:46 -08:00
uio.h Add missing include statement 2025-10-07 09:21:03 -07:00
vnode.h libspl: move vattr and xvattr definitions from zfs_context.h 2025-11-12 10:00:24 -08:00
wmsum.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zone.h libspl: move zone definitions from zfs_context.h 2025-11-12 10:02:00 -08:00