From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Amir Goldstein <amir73il@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Shuah Khan <shuah@kernel.org>,
linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 2/3] ovl: support cachestat() syscall on overlayfs files
Date: Wed, 24 Jun 2026 13:45:17 +0200 [thread overview]
Message-ID: <c390081b-7b2e-4b83-9bca-5f93eec6a939@virtuozzo.com> (raw)
In-Reply-To: <CAKEwX=OaKTfNqzwa=djLxZDeBbR1+DKdqDnxdfPfZFKB-K+ECA@mail.gmail.com>
On 6/23/26 19:12, Nhat Pham wrote:
> On Tue, Jun 23, 2026 at 4:15 AM Pavel Tikhomirov
> <ptikhomirov@virtuozzo.com> wrote:
>>
>> Overlayfs forwards data I/O to the real (upper/lower) file, so the page
>> cache lives in the real inode's mapping and cachestat() on an overlay
>> fd returned all zeroes.
>>
>> Implement the ->cachestat() file operation by forwarding to the real
>> file via vfs_cachestat(), the same way ovl_fadvise() forwards
>> for fadvise.
>>
>> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
>> ---
>> fs/overlayfs/file.c | 18 ++++++++++++++++++
>> 1 file changed, 18 insertions(+)
>>
>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
>> index 27cc07738f33b..a7e252a91ea43 100644
>> --- a/fs/overlayfs/file.c
>> +++ b/fs/overlayfs/file.c
>> @@ -518,6 +518,21 @@ static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
>> return vfs_fadvise(realfile, offset, len, advice);
>> }
>>
>> +#ifdef CONFIG_CACHESTAT_SYSCALL
>> +static int ovl_cachestat(struct file *file, struct cachestat_range *csr,
>> + struct cachestat *cs)
>> +{
>> + struct file *realfile;
>> +
>> + realfile = ovl_real_file(file);
>> + if (IS_ERR(realfile))
>> + return PTR_ERR(realfile);
>
> We're propagating the error of ovl_real_file() all the way to
> userspace right? I think we need to handle this.
>
> For example, we might get -EIO here, which is unexpected and
> undocumented from cachestat's POV.
>
> Maybe handle it and just return -EBADF or sth like that (with some
> updated documentations, etc.)
>
> The rest LGTM, but I'll let overlayfs maintainers check the
> overlayfs-specific bits :)
Yeh, we probably can use EBADF here instead of propagating:
Man cachestat(2) says:
EBADF Invalid file descriptor.
not really a bad fd here, but probably close enough not to rewrite man.
I'm a bit hesitant though, since in other overlayfs operations we already
propagate, maybe that was by design?
>
>> +
>> + with_ovl_creds(file_inode(file)->i_sb)
>> + return vfs_cachestat(realfile, csr, cs);
>> +}
--
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.
next prev parent reply other threads:[~2026-06-24 11:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 11:14 [PATCH 0/3] ovl: make cachestat() work Pavel Tikhomirov
2026-06-23 11:14 ` [PATCH 1/3] fs, mm: add ->cachestat() file operation Pavel Tikhomirov
2026-06-23 13:48 ` Johannes Weiner
2026-06-23 14:55 ` Pavel Tikhomirov
2026-06-23 15:34 ` Amir Goldstein
2026-06-24 11:59 ` Pavel Tikhomirov
2026-06-24 14:11 ` Amir Goldstein
2026-06-25 10:36 ` Christian Brauner
2026-06-26 15:18 ` Amir Goldstein
2026-06-30 7:55 ` Christian Brauner
2026-06-30 9:45 ` Pavel Tikhomirov
2026-06-30 10:56 ` Amir Goldstein
2026-06-23 16:01 ` Nhat Pham
2026-06-24 11:46 ` Pavel Tikhomirov
2026-06-23 11:14 ` [PATCH 2/3] ovl: support cachestat() syscall on overlayfs files Pavel Tikhomirov
2026-06-23 17:12 ` Nhat Pham
2026-06-24 11:45 ` Pavel Tikhomirov [this message]
2026-06-24 14:16 ` Amir Goldstein
2026-06-24 19:06 ` Nhat Pham
2026-06-25 12:53 ` Matthew Wilcox
2026-06-25 16:12 ` Nhat Pham
2026-06-23 11:14 ` [PATCH 3/3] selftests/cachestat: add an overlayfs test case Pavel Tikhomirov
2026-06-23 16:13 ` Nhat Pham
2026-06-24 12:22 ` Pavel Tikhomirov
2026-06-24 20:50 ` [PATCH 0/3] ovl: make cachestat() work Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c390081b-7b2e-4b83-9bca-5f93eec6a939@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=nphamcs@gmail.com \
--cc=shuah@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®