linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* reliably detect writes to a file: mmap, mtime, ...
@ 2015-12-29 20:24 Martin Uecker
  2015-12-30  6:20 ` Andy Lutomirski
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Uecker @ 2015-12-29 20:24 UTC (permalink / raw)
  To: linux-mm; +Cc: Andy Lutomirski



Hi all,

I want to reliably detect changes to a file even when 
written to using mmap. Surprisingly, there seems to be
no API which would make this possible. Or at least I 
haven't found a way to do it... 


I looked at:

- mtime. What is missing here is an API which would
force mtime to be updated if there are dirty PTEs
in some mapping (which need to be cleared/transferred 
to struct page at this point). This would allow to 
reliably detect changes to the file. If I understand it 
correctly, there was patch from Andy Lutomirski which
made msync(ASYNC) do exactly this:

http://oss.sgi.com/archives/xfs/2013-08/msg00748.html

But it seems this never got in. The other problem with
this is that mtime has limited granularity.
(but maybe that could be worked around by having some
kind of counter + API which tells how often mtime has
been updated without changing its nominal value)



- I also looked at soft-dirty bits, but this API seems
to have several limitations:  1.) it tracks writes
through a specific mapping 2.) it can only have
a single user at the same time 3.) who has to have 
special privileges 4.) and it seems impossible read
and clear the soft-dirty bits at the same time (so you
might miss writes).


But maybe there are other ways... I am missing
something?


Martin



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-30  6:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-29 20:24 reliably detect writes to a file: mmap, mtime, Martin Uecker
2015-12-30  6:20 ` Andy Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox