Re: [PATCH 1/3] fs, mm: add ->cachestat() file operation
Pavel Tikhomirov <[email protected]> Wed, 24 Jun 2026 13:46:03 +0200
| Newsgroups | org.kernel.vger.linux-unionfs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On 6/23/26 18:01, Nhat Pham wrote: > On Tue, Jun 23, 2026 at 4:15 AM Pavel Tikhomirov > <[email protected]> wrote: >> >> The cachestat() syscall reads page cache statistics straight from the >> file's f_mapping. Stackable filesystems such as overlayfs keep the data >> pages in an underlying inode's mapping rather than in the overlay >> inode's, so cachestat() reports all zeroes for them. >> >> Add a ->cachestat() file operation and route the syscall through a new >> vfs_cachestat() helper that calls it when present, falling back to >> file's f_mapping otherwise. This lets stackable filesystems forward the >> query to the file that actually owns the page cache. No behaviour change >> for regular files. >> >> Signed-off-by: Pavel Tikhomirov <[email protected]> >> --- >> Note: Memset change might be a bit tricky, I moved it to no >> ->cachestat() path to avoid multiple memset on nested overlayfs, that >> means that ->cachestat() is expected to be able to handle unitialized >> cs. > > nit: maybe a comment somewhere to document this? Sure, will do in v2. > >> --- >> include/linux/fs.h | 10 ++++++++++ >> mm/filemap.c | 43 +++++++++++++++++++++++++++++++++++-------- >> 2 files changed, 45 insertions(+), 8 deletions(-) >> > > LGTM otherwise. With Amir's suggestions incorporated: > > Acked-by: Nhat Pham <[email protected]> -- Best regards, Pavel Tikhomirov Senior Software Developer, Virtuozzo.