]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rpc_unlink(): use simple_recursive_removal()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 20 Feb 2024 04:24:41 +0000 (23:24 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:44:55 +0000 (22:44 -0400)
note that the callback of simple_recursive_removal() is called with
the parent locked; the victim isn't locked by the caller.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
net/sunrpc/rpc_pipe.c

index 9571cbd913052ffff37a80bc85967a8ebec70c8d..67621a94f67b23a0146ccf177f058b854c867d6b 100644 (file)
@@ -168,8 +168,9 @@ rpc_inode_setowner(struct inode *inode, void *private)
 }
 
 static void
-rpc_close_pipes(struct inode *inode)
+rpc_close_pipes(struct dentry *dentry)
 {
+       struct inode *inode = dentry->d_inode;
        struct rpc_pipe *pipe = RPC_I(inode)->pipe;
        int need_release;
        LIST_HEAD(free_list);
@@ -619,14 +620,6 @@ static int __rpc_unlink(struct inode *dir, struct dentry *dentry)
        return ret;
 }
 
-static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry)
-{
-       struct inode *inode = d_inode(dentry);
-
-       rpc_close_pipes(inode);
-       return __rpc_unlink(dir, dentry);
-}
-
 static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
                                          const char *name)
 {
@@ -814,17 +807,8 @@ EXPORT_SYMBOL_GPL(rpc_mkpipe_dentry);
 int
 rpc_unlink(struct dentry *dentry)
 {
-       struct dentry *parent;
-       struct inode *dir;
-       int error = 0;
-
-       parent = dget_parent(dentry);
-       dir = d_inode(parent);
-       inode_lock_nested(dir, I_MUTEX_PARENT);
-       error = __rpc_rmpipe(dir, dentry);
-       inode_unlock(dir);
-       dput(parent);
-       return error;
+       simple_recursive_removal(dentry, rpc_close_pipes);
+       return 0;
 }
 EXPORT_SYMBOL_GPL(rpc_unlink);