tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: msync(2)

On Mon, Feb 22, 2010 at 04:40:58PM -0500, Matthew Mondor wrote:
 > After reading the manual page of msync(2), I have the impression that
 > if invoked with the MS_SYNC flag, it should be safe enough not to need
 > a further fdatasync(2)/fsync_range(2) call afterwards?

That is the theory.

 > And how about the metadata?  Would sync(2) be the only true way to
 > ensure it's synchronized (considering fsync(2) seems fd-specific)?

What metadata? You can't get to things like the time stamps via mmap.

Granted, in FFS-land someone might have thought it made sense to write
out all the data blocks and not the FS-level metadata that describes
them on disk... but since doing this does not guarantee that the data
can be read back again later, it is not a correct implementation of
msync(2). (Or fdatasync(2) either.)

 > Also, I am auditing an application which seems to modify mmaped files
 > but which does not use msync(2) at all (and I can see that an older
 > fsync(2) call was used, but is now commented out).  Should this be
 > considered a bug?

Why would it be?

David A. Holland

Home | Main Index | Thread Index | Old Index