You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix snapshot automount race causing AVL tree panic
Multiple threads racing to automount the same snapshot can both pass
the initial mount check and spawn separate mount helper processes.
Both helpers successfully create or find a superblock via sget(), and
both return success to their parent threads. Since zpl_mount_impl()
doesn't distinguish between creating a new mount versus reusing an
existing one, both parent threads proceed to register the mount in
the AVL tree, causing a VERIFY() panic in avl_add(). Additionally,
this creates duplicate VFS mounts that persist in the kernel.
The root cause is that automount uses the newer fsconfig/fsmount API
which lacks the lock_mount() serialization present in the traditional
mount() syscall path. Manual mounts are protected by lock_mount() which
serializes mount point attachment, but automount parent threads execute
in parallel without such protection.
The fix introduces per-snapshot mount locks using an AVL tree to track
locks by snapshot name. Each unique snapshot gets its own lock, allowing
different snapshots to mount in parallel while serializing attempts to
mount the same snapshot. Locks are dynamically allocated on first use
and freed when the last thread releases them.
Reproducible with parallel access to a fresh snapshot:
ls /mnt/test/.zfs/snapshot/snap1/ &
ls /mnt/test/.zfs/snapshot/snap1/ &
Signed-off-by: Ameer Hamza <[email protected]>
0 commit comments