summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2024-02-02 14:01:31 +0300
committerChristian Brauner <brauner@kernel.org>2024-02-06 18:54:45 +0300
commit3058fca1ed7955c904584a6d86108d664a927177 (patch)
tree3e741d5c49f03bbe25d3b76ffdccb01464e1cdf8
parente6f7958042a7b1dc9a4dfc19fca74217bc0c4865 (diff)
downloadlinux-3058fca1ed7955c904584a6d86108d664a927177.tar.xz
fs: make file_dentry() a simple accessor
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> Link: https://lore.kernel.org/r/20240202110132.1584111-2-amir73il@gmail.com Tested-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--include/linux/fs.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9efd6220b7c6..2e07cbbf92e3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1084,9 +1084,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 {