On Wed, Mar 22, 2023 at 4:13 AM Amol Dixit <amoldd@xxxxxxxxx> wrote: > > Hello, > Apologies if this has been discussed or clarified in the past. > > The lack of file modification notification events (inotify, fanotify) > for mmap() regions is a big hole to anybody watching file changes from > userspace. I can imagine atleast 2 reasons why that support may be > lacking, perhaps there are more: > > 1. mmap() writeback is async (unless msync/fsync triggered) driven by > file IO and page cache writeback mechanims, unlike write system calls > that get funneled via the vfs layer, whih is a convenient common place > to issue notifications. Now mm code would have to find a common ground > with filesystem/vfs, which is messy. > > 2. writepages, being an address-space op is treated by each file > system independently. If mm did not want to get involved, onus would > be on each filesystem to make their .writepages handlers notification > aware. This is probably also considered not worth the trouble. > > So my question is, notwithstanding minor hurdles (like lost events, > hardlinks etc.), would the community like to extend inotify support > for mmap'ed writes to files? Under configs options, would a fix on a > per filesystem basis be an acceptable solution (I can start with say > ext4 writepages linking back to inode/dentry and firing a > notification)? > > Eventually we will have larger support across the board and > inotify/fanotify can be a reliable tracking mechanism for > modifications to files. > What is the use case? Would it be sufficient if you had an OPEN_WRITE event? or if OPEN event had the O_ flags as an extra info to the event? I have a patch for the above and I personally find this information missing from OPEN events. Are you trying to monitor mmap() calls? write to an mmaped area? because writepages() will get you neither of these. Please specify the use case and we will work out what can be done from there. Thanks, Amir.