From: Stefan Berger <stefanb@linux.ibm.com>
To: Amir Goldstein <amir73il@gmail.com>, Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Mimi Zohar <zohar@linux.ibm.com>,
linux-unionfs@vger.kernel.org, linux-integrity@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/2] fs: make file_dentry() a simple accessor
Date: Fri, 2 Feb 2024 10:16:47 -0500 [thread overview]
Message-ID: <9ff0da83-0be2-4fdc-8108-e65e043eacc3@linux.ibm.com> (raw)
In-Reply-To: <20240202110132.1584111-2-amir73il@gmail.com>
On 2/2/24 06:01, Amir Goldstein wrote:
> file_dentry() is a relic from the days that overlayfs was using files with
> a "fake" path, meaning, f_path on overlayfs and f_inode on underlying fs.
>
> In those days, file_dentry() was needed to get the underlying fs dentry
> that matches f_inode.
>
> Files with "fake" path should not exist nowadays, so make file_dentry() a
> simple accessor and use an assertion to make sure that file_dentry() was
> not papering over filesystem bugs.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Tested-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> include/linux/fs.h | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 023f37c60709..de9aa86d2624 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1078,9 +1078,20 @@ static inline struct inode *file_inode(const struct file *f)
> return f->f_inode;
> }
>
> +/*
> + * file_dentry() is a relic from the days that overlayfs was using files with a
> + * "fake" path, meaning, f_path on overlayfs and f_inode on underlying fs.
> + * In those days, file_dentry() was needed to get the underlying fs dentry that
> + * matches f_inode.
> + * Files with "fake" path should not exist nowadays, so use an assertion to make
> + * sure that file_dentry() was not papering over filesystem bugs.
> + */
> static inline struct dentry *file_dentry(const struct file *file)
> {
> - return d_real(file->f_path.dentry, file_inode(file));
> + struct dentry *dentry = file->f_path.dentry;
> +
> + WARN_ON_ONCE(d_inode(dentry) != file_inode(file));
> + return dentry;
> }
>
> struct fasync_struct {
next prev parent reply other threads:[~2024-02-02 15:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 11:01 [PATCH 0/2] Decomplicate file_dentry() Amir Goldstein
2024-02-02 11:01 ` [PATCH 1/2] fs: make file_dentry() a simple accessor Amir Goldstein
2024-02-02 15:16 ` Stefan Berger [this message]
2024-02-02 11:01 ` [PATCH 2/2] fs: remove the inode argument to ->d_real() method Amir Goldstein
2024-02-02 12:19 ` Miklos Szeredi
2024-02-02 12:41 ` Amir Goldstein
2024-02-02 13:54 ` Christian Brauner
2024-02-06 15:28 ` Amir Goldstein
2024-02-02 15:17 ` Stefan Berger
2024-02-02 16:05 ` Al Viro
2024-02-02 16:16 ` Al Viro
2024-02-02 17:34 ` Stefan Berger
2024-02-02 18:27 ` Al Viro
2024-02-02 18:32 ` Stefan Berger
2024-02-02 18:50 ` Al Viro
2024-02-02 18:38 ` Al Viro
2024-02-06 16:02 ` [PATCH 0/2] Decomplicate file_dentry() Christian Brauner
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=9ff0da83-0be2-4fdc-8108-e65e043eacc3@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=viro@zeniv.linux.org.uk \
--cc=zohar@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).