Thanks for correction. It has been a while for me and I thought writepages may be the common denominator (vague memory of reads blocking on DIO writeback with writepages casued me to believe it may be the path for mmap)...most certainly it is ext4_page_mkwrite that does get_block and and ends up with ll_rw_block(), so I stand corrected. Back to my point of tracking mmap writes to any region of a file. The use case is to build on top of inotify to know dirty files and take action as the app would wish - so this is more about completion of the API to track all writes. Just saw patches in the works for splice() go by, also in the same vein. Ideally I would want to take the inotify interface further, by returning offset/length information in the MODIFY event to further assist user applications built on this interface. For vfs originated events this would be at byte granularity, while for mmap originated events this may be at page granularity - in any case this would be valuable information surfaced up from the depths of the filesystem up to userspace. Thanks, Amol On Wed, Mar 22, 2023 at 7:50 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Tue, Mar 21, 2023 at 06:50:14PM -0700, Amol Dixit wrote: > > 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)? > > I don't understand why you think writepages is the right place for > monitoring. That tells you when data is leaving the page cache, not > when the file is modified. If you want to know when the file is > modified, you need to hook into the page_mkwrite path.