]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
remove emulation of VFS_HOLD and VFS_RELE from opensolaris compat
authoravg <avg@FreeBSD.org>
Sat, 2 Apr 2016 16:25:46 +0000 (16:25 +0000)
committeravg <avg@FreeBSD.org>
Sat, 2 Apr 2016 16:25:46 +0000 (16:25 +0000)
commit4a4b7f856b58f95be83bc24408bbf5e5c74c4da4
tree0695bd54f34f055e010a001fa2bf01bbdd2cf425
parente0e88029f1d404f5a73b978a88bfc87d184af472
remove emulation of VFS_HOLD and VFS_RELE from opensolaris compat

On FreeBSD VFS_HOLD/VN_RELE were mapped to MNT_REF/MNT_REL that
manipulate mnt_ref.  But the job of properly maintaining the reference
count is already automatically performed by insmntque(9) and
delmntque(9).  So, in effect all ZFS vnodes referenced the corresponding
mountpoint twice.

That was completely harmless, but we want to be very explicit about what
FreeBSD VFS APIs are used, because illumos VFS_HOLD and FreeBSD MNT_REF
provide quite different guarantees with respect to the held vfs_t /
mountpoint.  On illumos VFS_HOLD is sufficient to guarantee that
vfs_t.vfs_data stays valid.  On the other hand, on FreeBSD MNT_REF does
*not* provide the same guarantee about mnt_data.  We have to use
vfs_busy() to get that guarantee.

Thus, the calls to VFS_HOLD/VFS_RELE on vnode init and fini are removed.
VFS_HOLD calls are replaced with vfs_busy in the ioctl handlers.

And because vfs_busy has a richer interface that can not be dumbed down
in all cases it's better to explicitly use it rather than trying to mask
it behind VFS_HOLD.

This change fixes a panic that could result from a race between
zfs_umount() and zfs_ioc_rollback().  We observed a case where
zfsvfs_free() tried to destroy data that zfsvfs_teardown() was still
using.  That happened because there was nothing to prevent unmounting of
a ZFS filesystem that was in between zfs_suspend_fs() and
zfs_resume_fs().

Reviewed by: kib, smh
MFC after: 3 weeks
Sponsored by: ClusterHQ
Differential Revision: https://reviews.freebsd.org/D2794
sys/cddl/compat/opensolaris/sys/vfs.h
sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c