kernel - Fix mtime for deferred writes from mmap R+W
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 13 Nov 2017 22:03:20 +0000 (14:03 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 13 Nov 2017 22:03:20 +0000 (14:03 -0800)
commit723be147ababbad4180c682b14f923fbae07b89f
treeb5b58b2f66a1ee2e7e616f7630c6585e26fa47f9
parentf694fa517c2628d79a49719e25f72134babbdd0c
kernel - Fix mtime for deferred writes from mmap R+W

* When a program modifies a file via a shared R+W mmap and does not
  msync() it, the pages do not get synchronized to the filesystem until
  potentially up to 30 seconds later.  Our filesystems then record a
  mtime as-of when that synchronization occurs rather than when the
  modification was made to the pages.

* We cannot easily determine when the modification was made, but we do
  track close()'s on file pointers that were opened writable.  So what
  we do is record the timestamp as of the last close() of a file pointer
  that was opened for writing.  Then later on we pages are synchronizded,
  we use this timestamp for any mtime update.  It isn't perfect, but its
  better than it was before.

* This is not a perfect fix.  The mtime really needs to be updated at the
  time of the close() in this situation as well, but it will fix 'make'
  related issues for files that are modified with mmap rather than
  write() (aka such as ld.gold appears to do).

Reported-by: zrj
sys/kern/vfs_default.c
sys/sys/vnode.h
sys/vfs/hammer/hammer_vnops.c
sys/vfs/hammer2/hammer2_vnops.c
sys/vfs/tmpfs/tmpfs_vnops.c
sys/vfs/ufs/inode.h
sys/vfs/ufs/ufs_readwrite.c
sys/vfs/ufs/ufs_vnops.c