From 2558e3b23112adb82a558bab616890a790a38bc6 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 21 Feb 2024 09:59:51 +0100 Subject: 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 --- fs/nsfs.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'fs/nsfs.c') diff --git a/fs/nsfs.c b/fs/nsfs.c index 3a36bb62353c..2ce229af34e9 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -34,22 +34,10 @@ static char *ns_dname(struct dentry *dentry, char *buffer, int buflen) ns_ops->name, inode->i_ino); } -static void ns_prune_dentry(struct dentry *dentry) -{ - struct inode *inode; - - inode = d_inode(dentry); - if (inode) { - struct ns_common *ns = inode->i_private; - cmpxchg(&ns->stashed, dentry, NULL); - } -} - -const struct dentry_operations ns_dentry_operations = -{ - .d_prune = ns_prune_dentry, +const struct dentry_operations ns_dentry_operations = { .d_delete = always_delete_dentry, .d_dname = ns_dname, + .d_prune = stashed_dentry_prune, }; static void nsfs_evict(struct inode *inode) -- cgit v1.2.3