On Mon, Aug 26, 2019, 9:00 PM Arthur Krewat wrote:
As for what mmap() doesn't do right, I started using memory mapped files
back in the early 80s on VMS on a VAX-11/780 when I and a colleague were
converting a database from TOPS-10 to VMS. Perhaps I am misunderstanding
your dislike for mmap() but please, enlighten me. It was my
understanding at the time that it was akin to swapping/virtual-memory
using an MMU. The difference was that instead of using the main paging
area, the kernel would use an actual file. Why would mmap() be a bad
thing, when it's hooked into the kernel, and possibly hardware, at such
a low point?
I don't mean to put words in Larry's mouth, but I think he meant that ZFS
bypasses the OS page cache, so that file IO and mmap use a different
buffering scheme that is not mutually consistent. So a process could mmap()
a file, write to it via a pointer indirection, and then invoke read() at a
relevant offset and (perhaps) not see the earlier write reflected; or vice
versa. It's not that mmap is a priori bad, but rather that ZFS has this
unfortunate corner case related to mmap.
- Dan C.