aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pidfs.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-02-21 09:59:51 +0100
committerChristian Brauner <brauner@kernel.org>2024-03-01 12:26:29 +0100
commit2558e3b23112adb82a558bab616890a790a38bc6 (patch)
tree89ce523bb85eab34592d8d859469858e90f9ef8f /fs/pidfs.c
parent159a0d9fd50b92cc48e4c82cde79c4cb34c85953 (diff)
downloadlinux-2558e3b23112adb82a558bab616890a790a38bc6.tar.gz
libfs: add stashed_dentry_prune()
Both pidfs and nsfs use a memory location to stash a dentry for reuse by concurrent openers. Right now two custom dentry->d_prune::{ns,pidfs}_prune_dentry() methods are needed that do the same thing. The only thing that differs is that they need to get to the memory location to store or retrieve the dentry from differently. Fix that by remember the stashing location for the dentry in dentry->d_fsdata which allows us to retrieve it in dentry->d_prune. That in turn makes it possible to add a common helper that pidfs and nsfs can both use. Link: https://lore.kernel.org/r/CAHk-=wg8cHY=i3m6RnXQ2Y2W8psicKWQEZq1=94ivUiviM-0OA@mail.gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/pidfs.c')
-rw-r--r--fs/pidfs.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/fs/pidfs.c b/fs/pidfs.c
index 5f33c820b7f8e..d38b7a1849942 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -187,21 +187,10 @@ static char *pidfs_dname(struct dentry *dentry, char *buffer, int buflen)
d_inode(dentry)->i_ino);
}
-static void pidfs_prune_dentry(struct dentry *dentry)
-{
- struct inode *inode;
-
- inode = d_inode(dentry);
- if (inode) {
- struct pid *pid = inode->i_private;
- cmpxchg(&pid->stashed, dentry, NULL);
- }
-}
-
static const struct dentry_operations pidfs_dentry_operations = {
.d_delete = always_delete_dentry,
.d_dname = pidfs_dname,
- .d_prune = pidfs_prune_dentry,
+ .d_prune = stashed_dentry_prune,
};
static int pidfs_init_fs_context(struct fs_context *fc)