kernel - Fix issues where tmpfs loses file data
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 7 Dec 2012 22:20:31 +0000 (14:20 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 7 Dec 2012 22:20:31 +0000 (14:20 -0800)
commitd86d27a81d75c46fb451b36f43f87b3300c1a260
treef75bbf0383744c981e58f1a001dffb88f66b8a00
parentc5a69a2a1c43226870e437e74e4f4df2ff971bb0
kernel - Fix issues where tmpfs loses file data

* For TMPFS, UIO_NOCOPY writes must use bawrite() or bwrite() and must NEVER
  used buwrite() because these operations are being called via the VM page
  cleaning code via the pageout daemon or the vnode termination code
  (when maxvnodes is reached), and the underlying pages are about to be
  destroyed.

* vm_object_terminate() must call vinvalbuf() both before (for normal
  filesystems) and also after (for tmpfs style filesystems).  Otherwise
  buffers potentially not disposed of during the page cleaning might
  get left hanging.  This is a safety feature.

* Remove post-flush test code from vm_object_page_collect_flush() entirely.
  The IO's are in progress at this point so it makes no sense to set
  PG_CLEANCHK here.

* vm_page_need_commit() must make the object writeable and dirty, I think.

* Fix multiple places where m->dirty is tested and PG_NEED_COMMIT is not.

Reported-by: vsrinivas, others
sys/vfs/tmpfs/tmpfs_subr.c
sys/vfs/tmpfs/tmpfs_vnops.c
sys/vm/vm_object.c
sys/vm/vm_page.c