wollman at csail.mit.edu
Mon Aug 1 01:32:14 GMT 2005
<<On Mon, 1 Aug 2005 01:46:01 +0300, Giorgos Keramidas <keramida at freebsd.org> said:
> Is the fact that the data written to the mapped region visible after the
> close (by mapping the same region) expected too?
No, that's a bug. (It's not a particularly surprising one, although
I'm no VM expert and I have no idea how difficult it would be to fix.)
The problem is that the VM system has no efficient way of telling that
you modified the part of the page that's after the end of the file, so
when you close the file, the dirty but only partially valid page is
cached. Because you did a MAP_SHARED, mmap() can't use an anonymous
page -- it has to use the actual page from the file. If the page
isn't in cache, it will correctly zero-fill the parts beyond the end
of the file, but it doesn't appear to do this for cached pages on
0->1 refcount transitions.
More information about the freebsd-current