freebsd-nq/sys
Andriy Gapon de2cb430ad another rework of getzfsvfs / getzfsvfs_impl code
This change is designed to account for yet another difference between
illumos and FreeBSD VFS.  In FreeBSD a filesystem driver is supposed to
clean up mnt_data in its VFS_UNMOUNT method because it's the last call
into the driver before a struct mount object is destroyed.  The VFS
drains all references to the object before destroying it, but for the
driver it's already as good as gone.
In contrast, illumos VFS provides another method, VFS_FREEVFS, that is
called when all references are drained.  So, the driver can keep its
data after VFS_UNMOUNT and clean it up in VFS_FREEVFS after all
references are gone. This is what ZFS does on illumos.
So there a reference to a filesystem is sufficient to guarantee that the
ZFS specific data, aka zfsvfs_t, stays around (even if the filesystem
gets unmounted).  In FreeBSD we need to vfs_busy the filesystem to get
the same guarantee.  vfs_ref guarantees only that the struct mount is
kept.

The following rules should be observed in getzfsvfs / getzfsvfs_impl on
FreeBSD:
- if we need access to zfsvfs_t then we must use vfs_busy
- if only we need to access struct mount (aka vfs_t), then vfs_ref is
  enough
- when illumos code actually needs only the vfs_t, they still can pass
  the zfsvfs_t and get the vfs_t from it;  that can work in FreeBSD if
  the filesystem is busied, but when it's just referenced then we have
  to pass the vfs_t explicitly
- we cannot call vfs_busy while holding a dataset because that creates a
  LOR with dp_config_rwlock

As a result:
- getzfsvfs_impl now only references the filesystem, same as in illumos,
  but unlike illumos it has to return the vfs_t
- the consumers are updated to account for the change
- getzfsvfs busies the filesystem (and drops the reference from
  getzfsvfs_impl)

Also, zfs_unmount_snap() now gets a busied a filesystem, references it
and then unbusies it essentially reverting actions done in getzfsvfs.
This is needed because the code may perform some checks that require the
zfsvfs_t.  So, those are done before the unbusying.

MFC after:	2 weeks
2018-02-22 13:06:27 +00:00
..
amd64 Remove accidental vim droppings 2018-02-22 03:37:01 +00:00
arm
arm64
bsm
cam Revert r329814 as well. It should have been in r329819. 2018-02-22 11:51:50 +00:00
cddl another rework of getzfsvfs / getzfsvfs_impl code 2018-02-22 13:06:27 +00:00
compat Correct proper nouns in the Linuxulator 2018-02-22 02:24:17 +00:00
conf MFV r329799, r329800: 2018-02-22 03:49:06 +00:00
contrib
crypto
ddb
dev Backout r329818, r329816 and r329815. 2018-02-22 11:18:33 +00:00
dts
fs
gdb
geom
gnu
i386 Correct proper nouns in the Linuxulator 2018-02-22 02:24:17 +00:00
isa
kern Fix the broken subqueue assignment for the cleanq. 2018-02-20 21:27:17 +00:00
kgssapi
libkern
mips
modules Add required header files. 2018-02-21 16:36:44 +00:00
net Allow route change requests to not specify the gateway. 2018-02-21 19:13:23 +00:00
net80211
netgraph
netinet
netinet6
netipsec
netpfil
netsmb
nfs
nfsclient
nfsserver
nlm
ofed
opencrypto
powerpc Add definition for the PowerPC A2. 2018-02-21 15:15:58 +00:00
riscv
rpc
security
sparc64
sys Use 'const int *' for sysentvec errno translation table 2018-02-22 01:59:59 +00:00
teken
tests
tools
ufs Refactor fix in r329600 to do its check once in readsuper() rather 2018-02-21 19:56:19 +00:00
vm
x86
xdr
xen
Makefile