msync(..., MS_INVALIDATE) will incorrectly remove dirty pages without
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 23 Apr 2004 06:23:46 +0000 (06:23 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 23 Apr 2004 06:23:46 +0000 (06:23 +0000)
commit10e49b8b2bfed5e58c5477e44d18a2b4d1277266
tree302547c387e227fe84e6f9a4ff2f34bb55060241
parent5b22b655fb5d29fcfb99c0331311eb8f60f90a5b
msync(..., MS_INVALIDATE) will incorrectly remove dirty pages without
synchronizing them to their backing store under certain circumstances,
and can also cause struct buf's to become inconsistent.  This can be
particularly gruesome when MS_INVALIDATE is used on a range of memory that
is mmap()'d to be read-only.

Fix MS_INVALIDATE's operation (1) by making UFS honor the invalidation
request when flushing to backing store to destroy the related struct buf
and (2) by never removing pages wired into the buffer cache and never
removing pages that are found to still be dirty.

Note that NFS was already coded to honor invalidation requests in
nfs_write().  Filesystems other then NFS and UFS do not currently support
buffer-invalidation-on-write but all that means now is that the pages
will remain in cache, rather then be incorrectly removed and cause corruption.

Reported-by: Stephan Uphoff <ups@tree.com>, Julian Elischer <julian@elischer.org>
sys/vfs/ufs/ufs_readwrite.c
sys/vm/vm_map.c