On 2016/05/04 01:20, Tinker wrote: > A separate question about combining mmap access and file > IO in the current absence of a unified buffer cache: > > If I have a readonly mmap and do fwrite to it, could I use > fsync (or msync or any other call) right after the fwrite, as a tool to > guarantee that the memory mapping interface is up to date?
It needs more than fsync. Playing around with the simple test program from https://lists.samba.org/archive/samba-technical/2001-May/013552.html (at least on amd64) it appears that msync (with either MS_SYNC, MS_ASYNC or MS_INVALIDATE) is needed after changes are made on the mmap side of things, and msync with MS_INVALIDATE is needed after changes done on the file io side of things. > Also between the fwrite and that call, the possible data inconsistency would > be limited to the particular bytes written right? I don't know.