freebsd-skq/sys/fs/tmpfs
Konstantin Belousov 4cda7f7ece Rework the tmpfs unmount.
- Suspend filesystem for unmount.  This prevents new tmpfs nodes from
  instantiating, and also ensures that only unmount thread can destroy
  nodes.

- Do not start tmpfs node deletion until all vnodes are reclaimed,
  which guarantees that no thread can access tmpfs data.  For this,
  call vflush() in the loop, until the mnt_nvnodelistsize is non-zero.
  Note that after mnt_nvnodelistsize becomes 0, insmntque() blocks
  insertion of a vnode germ into the mount list of vnodes.

- Fail node allocation when the filesystem is being unmounted.  This
  is race-free due to the vflush() call in loop.  This is mostly
  cosmetic, avoiding some more work which might be done until
  suspension in unmount is started.

Note that there is currently no way to prevent new vnode instantiation
from readers during the unmount.  Due to this, forced unmount might
live-lock if vflush() loop cannot get to the zero vnode count due to
races with readers.  The unmount would proceed after the load is
lifted.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2014-07-14 09:52:33 +00:00
..
tmpfs_fifoops.c Remove code separator lines which do not conform to style(9). 2014-07-14 08:17:11 +00:00
tmpfs_fifoops.h Remove code separator lines which do not conform to style(9). 2014-07-14 08:17:11 +00:00
tmpfs_subr.c Rework the tmpfs unmount. 2014-07-14 09:52:33 +00:00
tmpfs_vfsops.c Rework the tmpfs unmount. 2014-07-14 09:52:33 +00:00
tmpfs_vnops.c Use tmpfs_vn_get_ino_gen() to handle the races with reclaim in tmpfs 2014-07-14 09:16:55 +00:00
tmpfs_vnops.h Remove code separator lines which do not conform to style(9). 2014-07-14 08:17:11 +00:00
tmpfs.h Rework the tmpfs unmount. 2014-07-14 09:52:33 +00:00