mirror_zfs/include/os/linux/spl/sys
Ameer Hamza 74bbdda1ef 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-10 10:21:29 -08:00
..
ia32 SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
acl.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
atomic.h linux/atomic: fill out API for atomic pointer ops 2025-07-31 15:51:47 -07:00
byteorder.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
callb.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
callo.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
cmn_err.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
condvar.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
cred.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
ctype.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
debug.h ZIL: allow zil_commit() to fail with error 2025-08-08 16:43:09 -07:00
disp.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
errno.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
fcntl.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
file.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
inttypes.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
isa_defs.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
kmem_cache.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
kmem.h linux/kmem: remove HAVE_ATOMIC64_T and kmem_alloc_used wrappers 2025-07-22 15:08:07 -07:00
kstat.h linux/kstat: allow multi-level module names 2025-03-20 16:24:50 -07:00
list.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
misc.h Skip dbuf_evict_one() from dbuf_evict_notify() for reclaim thread 2025-08-01 16:47:41 -07:00
mod.h mod.h: make consistent across all three platforms 2025-07-15 15:46:14 -07:00
mutex.h Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
param.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
proc.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
processor.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
procfs_list.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
random.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
rwlock.h linux/rw_destroy: assert no holders before destroying 2025-09-10 15:01:02 -07:00
shrinker.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
sid.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
signal.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
simd.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
stat.h linux: use sys/stat.h instead of linux/stat.h 2025-09-09 17:04:15 -07:00
string.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
sunddi.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
sysmacros.h spa: ZIO_TASKQ_ISSUE: Use symbolic priority 2025-06-30 10:24:23 -04:00
systeminfo.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
taskq.h Fix snapshot automount expiry cancellation deadlock 2025-12-10 10:21:29 -08:00
thread.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
time.h Detect a slow raidz child during reads 2025-09-10 15:31:30 -07:00
timer.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
trace_spl.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
trace_taskq.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
trace.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
tsd.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
types32.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
types.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
uio.h linux/uio: remove "skip" offset for UIO_ITER 2025-05-11 12:46:40 -04:00
user.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
vfs.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
vmem.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
vmsystm.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
vnode.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
wait.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
wmsum.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zmod.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00
zone.h SPDX: license tags: GPL-2.0-or-later 2025-03-13 17:57:09 -07:00