git: kernel - Fix mtime for deferred writes from mmap R+W

Matthew Dillon dillon at crater.dragonflybsd.org
Mon Nov 13 14:08:27 PST 2017


commit 723be147ababbad4180c682b14f923fbae07b89f
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Mon Nov 13 14:03:20 2017 -0800

    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

Summary of changes:
 sys/kern/vfs_default.c          |  5 +++++
 sys/sys/vnode.h                 |  9 +++++++++
 sys/vfs/hammer/hammer_vnops.c   | 14 +++++++++++++-
 sys/vfs/hammer2/hammer2_vnops.c | 10 +++++++++-
 sys/vfs/tmpfs/tmpfs_vnops.c     |  7 ++++++-
 sys/vfs/ufs/inode.h             |  1 +
 sys/vfs/ufs/ufs_readwrite.c     |  5 +++++
 sys/vfs/ufs/ufs_vnops.c         | 14 ++++++++++----
 8 files changed, 58 insertions(+), 7 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/723be147ababbad4180c682b14f923fbae07b89f


-- 
DragonFly BSD source repository


More information about the Commits mailing list