]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rpc_unlink(): saner calling conventions
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 20 Feb 2024 05:24:19 +0000 (00:24 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:44:55 +0000 (22:44 -0400)
1) pass it pipe instead of pipe->dentry
2) zero pipe->dentry afterwards
3) it always returns 0; why bother?

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/nfs/blocklayout/rpc_pipefs.c
fs/nfs/nfs4idmap.c
fs/nfsd/nfs4recover.c
include/linux/sunrpc/rpc_pipe_fs.h
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/rpc_pipe.c

index d8d50a88de04f2c7369fbaa1a6371f202fcebf62..25d429e44eb47b7e7102031d2993ff83bf0b6a4e 100644 (file)
@@ -154,13 +154,6 @@ static struct dentry *nfs4blocklayout_register_sb(struct super_block *sb,
        return dentry;
 }
 
-static void nfs4blocklayout_unregister_sb(struct super_block *sb,
-                                         struct rpc_pipe *pipe)
-{
-       if (pipe->dentry)
-               rpc_unlink(pipe->dentry);
-}
-
 static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
                           void *ptr)
 {
@@ -188,8 +181,7 @@ static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
                nn->bl_device_pipe->dentry = dentry;
                break;
        case RPC_PIPEFS_UMOUNT:
-               if (nn->bl_device_pipe->dentry)
-                       nfs4blocklayout_unregister_sb(sb, nn->bl_device_pipe);
+               rpc_unlink(nn->bl_device_pipe);
                break;
        default:
                ret = -ENOTSUPP;
@@ -224,7 +216,7 @@ static void nfs4blocklayout_unregister_net(struct net *net,
 
        pipefs_sb = rpc_get_sb_net(net);
        if (pipefs_sb) {
-               nfs4blocklayout_unregister_sb(pipefs_sb, pipe);
+               rpc_unlink(pipe);
                rpc_put_sb_net(net);
        }
 }
index 25a7c771cfd89f3e6d494f26a78212d3d619c135..adc03232b85155f16c1bd054e632a93c841e4599 100644 (file)
@@ -424,12 +424,8 @@ static void nfs_idmap_pipe_destroy(struct dentry *dir,
                struct rpc_pipe_dir_object *pdo)
 {
        struct idmap *idmap = pdo->pdo_data;
-       struct rpc_pipe *pipe = idmap->idmap_pipe;
 
-       if (pipe->dentry) {
-               rpc_unlink(pipe->dentry);
-               pipe->dentry = NULL;
-       }
+       rpc_unlink(idmap->idmap_pipe);
 }
 
 static int nfs_idmap_pipe_create(struct dentry *dir,
index 82785db730d9e1d698466525b30648e945432f01..bbd29b3b573f1e042b2cb052b59291ed265fd490 100644 (file)
@@ -963,13 +963,6 @@ nfsd4_cld_register_sb(struct super_block *sb, struct rpc_pipe *pipe)
        return dentry;
 }
 
-static void
-nfsd4_cld_unregister_sb(struct rpc_pipe *pipe)
-{
-       if (pipe->dentry)
-               rpc_unlink(pipe->dentry);
-}
-
 static struct dentry *
 nfsd4_cld_register_net(struct net *net, struct rpc_pipe *pipe)
 {
@@ -991,7 +984,7 @@ nfsd4_cld_unregister_net(struct net *net, struct rpc_pipe *pipe)
 
        sb = rpc_get_sb_net(net);
        if (sb) {
-               nfsd4_cld_unregister_sb(pipe);
+               rpc_unlink(pipe);
                rpc_put_sb_net(net);
        }
 }
@@ -2142,8 +2135,7 @@ rpc_pipefs_event(struct notifier_block *nb, unsigned long event, void *ptr)
                cn->cn_pipe->dentry = dentry;
                break;
        case RPC_PIPEFS_UMOUNT:
-               if (cn->cn_pipe->dentry)
-                       nfsd4_cld_unregister_sb(cn->cn_pipe);
+               rpc_unlink(cn->cn_pipe);
                break;
        default:
                ret = -ENOTSUPP;
index 3b35b6f6533aab0553b87757ff5a73ccffa44610..a8c0a500d55c048d94ce3000e2ef0cfe5522fe20 100644 (file)
@@ -129,7 +129,7 @@ struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags);
 void rpc_destroy_pipe_data(struct rpc_pipe *pipe);
 extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *,
                                        struct rpc_pipe *);
-extern int rpc_unlink(struct dentry *);
+extern void rpc_unlink(struct rpc_pipe *);
 extern int register_rpc_pipefs(void);
 extern void unregister_rpc_pipefs(void);
 
index 0fa244f16876f3c434fd507b4d53c5eefd748ce4..f2a44d589cfb0f2f6de1e0a36a988b6476cea289 100644 (file)
@@ -887,12 +887,8 @@ static void gss_pipe_dentry_destroy(struct dentry *dir,
                struct rpc_pipe_dir_object *pdo)
 {
        struct gss_pipe *gss_pipe = pdo->pdo_data;
-       struct rpc_pipe *pipe = gss_pipe->pipe;
 
-       if (pipe->dentry != NULL) {
-               rpc_unlink(pipe->dentry);
-               pipe->dentry = NULL;
-       }
+       rpc_unlink(gss_pipe->pipe);
 }
 
 static int gss_pipe_dentry_create(struct dentry *dir,
index 46fa00ac5e0e7667104b1bd8ba4f64194913a419..2046582c4f35747bfd0bf5215843c933aa399265 100644 (file)
@@ -737,17 +737,19 @@ EXPORT_SYMBOL_GPL(rpc_mkpipe_dentry);
 
 /**
  * rpc_unlink - remove a pipe
- * @dentry: dentry for the pipe, as returned from rpc_mkpipe
+ * @pipe: the pipe to be removed
  *
  * After this call, lookups will no longer find the pipe, and any
  * attempts to read or write using preexisting opens of the pipe will
  * return -EPIPE.
  */
-int
-rpc_unlink(struct dentry *dentry)
+void
+rpc_unlink(struct rpc_pipe *pipe)
 {
-       simple_recursive_removal(dentry, rpc_close_pipes);
-       return 0;
+       if (pipe->dentry) {
+               simple_recursive_removal(pipe->dentry, rpc_close_pipes);
+               pipe->dentry = NULL;
+       }
 }
 EXPORT_SYMBOL_GPL(rpc_unlink);