Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > It's not great, but with David wanting to change how PageFsCache is used, > it may be unavoidable (I'm not sure if he's discussed that with you yet) > https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?h=fscache-iter&id=6f10fd7766ed6d87c3f696bb7931281557b389f5 shows part of it > -- essentially he wants to make PagePrivate2 mean that I/O is currently > ongoing to an fscache, and so truncate needs to wait on it being finished. ->invalidatepage() and ->releasepage() had to wait anyway. PG_fscache used to mean that the cache might have some knowledge of the page and it might have I/O in progress on it - entirely as and when the cache felt like doing it. Now it just means that there's write I/O in progress on it at the netfs's behest (though it might be issued by a cache helper). The main part of the cache doesn't know about the page and doesn't care about the page flag, it just sees an iov_iter. In a sense, it's now a second PG_writeback flag. A page can be being written to two locations at the same time (the server and the cache). Each write is independent, though they may be started from the same place, and one of the writes may be being handled by another filesystem entirely (the cache may have started a DIO write to ext4, for example). It's not needed for reading, since the PG_locked flag entirely suffices for that. The read helper doesn't do parallel reads from the server and the cache to the same chunk of pagecache. Willy has asked that I either make PG_writeback cover both cases or that PG_fscache can only be set if PG_writeback is also set. However, both of these require extra state to be attached to page->private to be able to coordinate this as there may be (as mentioned above) two parallel writes from the same data that may finish at different times. David