kernel - Close a few SMP holes
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 25 Jul 2016 04:55:00 +0000 (21:55 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 25 Jul 2016 04:55:00 +0000 (21:55 -0700)
commitfda4c5f3ee0a939d4eec5cbb125d0944b4529cac
tree67219254956bc67e2b4d68b37d9c024b861fcfe7
parent2d1b280fd7290751e4da3171a396ae301829790f
kernel - Close a few SMP holes

* Don't trust the compiler when loading refs in cache_zap().  Make sure
  it doesn't reorder or re-use the memory reference.

* In cache_nlookup() and cache_nlookup_maybe_shared(), do a full re-test
  of the namecache element after locking instead of a partial re-test.

* Lock the namecache record in two situations where we need to set a
  flag.  Almost all other flag cases require similar locking.  This fixes
  a potential SMP race in a very thin window during mounting.

* Fix unmount / access races in sys_vquotactl() and, more importantly, in
  sys_mount().  We were disposing of the namecache record after extracting
  the mount pointer, then using the mount pointer.  This could race an
  unmount and result in a corrupt mount pointer.

  Change the code to dispose of the namecache record after we finish using
  the mount point.  This is somewhat more complex then I'd like, but it
  is important to unlock the namecache record across the potentially
  blocking operation to prevent a lock chain from propagating upwards
  towards the root.

* Enhanced debugging for the namecache teardown case when nc_refs changes
  unexpectedly.

* Remove some dead code (cache_purgevfs()).
sys/kern/vfs_cache.c
sys/kern/vfs_conf.c
sys/kern/vfs_quota.c
sys/kern/vfs_syscalls.c