freebsd-dev/sys/fs/nullfs
Jason A. Harmening 59409cb90f Add a generic mechanism for preventing forced unmount
This is aimed at preventing stacked filesystems like nullfs and unionfs
from "losing" their lower mounts due to forced unmount.  Otherwise,
VFS operations that are passed through to the lower filesystem(s) may
crash or otherwise cause unpredictable behavior.

Introduce two new functions: vfs_pin_from_vp() and vfs_unpin().
which are intended to be called on the lower mount(s) when the stacked
filesystem is mounted and unmounted, respectively.
Much as registration in the mnt_uppers list previously did, pinning
will prevent even forced unmount of the lower FS and will allow the
stacked FS to freely operate on the lower mount either by direct
use of the struct mount* or indirect use through a properly-referenced
vnode's v_mount field.

vfs_pin_from_vp() is modeled after vfs_ref_from_vp() in that it uses
the mount interlock coupled with re-checking vp->v_mount to ensure
that it will fail in the face of a pending unmount request, even if
the concurrent unmount fully completes.

Adopt these new functions in both nullfs and unionfs.

Reviewed By:	kib, markj
Differential Revision: https://reviews.freebsd.org/D30401
2021-06-05 18:20:36 -07:00
..
null_subr.c vfs: add v_irflag accessors 2021-01-03 06:50:06 +00:00
null_vfsops.c Add a generic mechanism for preventing forced unmount 2021-06-05 18:20:36 -07:00
null_vnops.c nullfs: dirty v_object must imply the need for inactivation 2021-05-22 12:30:17 +03:00
null.h Save lower root vnode in nullfs mnt data instead of upper. 2020-01-28 11:29:06 +00:00