Re: [PATCH 1/2] msync: support syncing a small part of the file

From: Zan Lynx
Date: Wed Jun 13 2012 - 18:15:55 EST


On Wed, 2012-06-13 at 14:26 -0700, Andrew Morton wrote:
> On Thu, 31 May 2012 22:43:54 +0200
> Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> > msync does not need to flush changes to the entire file, even with MS_SYNC.
> > Instead, it can use vfs_fsync_range to only synchronize a part of the file.
> >
> > In addition, not all metadata has to be synced; msync is closer to
> > fdatasync than it is to msync. So, pass 1 to vfs_fsync_range.
>
> Would be nice, but if applications were previously assuming that an
> msync() was syncing the whole file, this patch will secretly and subtly
> break them. Convince me that this change won't weaken anyone's data
> integrity ;)

As an interested observer and a programmer who uses msync()...

I never assumed msync() did the whole file. It has an address and length
argument. I always assumed it only looked for dirty pages within that
range. That is also what the msync() documentation claims.

As for weakening data integrity because of assumptions programmers *may*
have made, I think this is a bad argument which followed to its logical
conclusion can only lead to requiring an implicit sync() before and
after every system call. :-)

Asking programmers to use sync_file_range() is not a replacement for
improving msync() because msync() is POSIX and can be used everywhere.
sync_file_range() requires Linux specific code.

--
Knowledge Is Power
Power Corrupts
Study Hard
Be Evil

Attachment: signature.asc
Description: This is a digitally signed message part