]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rpc_pipe: expand the calls of rpc_mkdir_populate()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 21 Feb 2024 03:23:09 +0000 (22:23 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:44:55 +0000 (22:44 -0400)
... and get rid of convoluted callbacks.

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

index 9051842228ec23dd2de0417aba750d1b9c6f729d..15ec770bb7fbbf2f9e9da164da19bbc76eef48f6 100644 (file)
@@ -618,26 +618,6 @@ out_bad:
        return err;
 }
 
-static struct dentry *rpc_mkdir_populate(struct dentry *parent,
-               const char *name, umode_t mode, void *private,
-               int (*populate)(struct dentry *, void *), void *args_populate)
-{
-       struct dentry *dentry;
-       int error;
-
-       dentry = rpc_new_dir(parent, name, mode, private);
-       if (IS_ERR(dentry))
-               return dentry;
-       if (populate != NULL) {
-               error = populate(dentry, args_populate);
-               if (error) {
-                       simple_recursive_removal(dentry, NULL);
-                       return ERR_PTR(error);
-               }
-       }
-       return dentry;
-}
-
 /**
  * rpc_mkpipe_dentry - make an rpc_pipefs file for kernel<->userspace
  *                    communication
@@ -888,13 +868,6 @@ static const struct rpc_filelist authfiles[] = {
        },
 };
 
-static int rpc_clntdir_populate(struct dentry *dentry, void *private)
-{
-       return rpc_populate(dentry,
-                           authfiles, RPCAUTH_info, RPCAUTH_EOF,
-                           private);
-}
-
 /**
  * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs
  * @dentry: the parent of new directory
@@ -911,13 +884,19 @@ struct dentry *rpc_create_client_dir(struct dentry *dentry,
                                   struct rpc_clnt *rpc_client)
 {
        struct dentry *ret;
+       int error;
 
-       ret = rpc_mkdir_populate(dentry, name, 0555, NULL,
-                                rpc_clntdir_populate, rpc_client);
-       if (!IS_ERR(ret)) {
-               rpc_client->cl_pipedir_objects.pdh_dentry = ret;
-               rpc_create_pipe_dir_objects(&rpc_client->cl_pipedir_objects);
+       ret = rpc_new_dir(dentry, name, 0555, NULL);
+       if (IS_ERR(ret))
+               return ret;
+       error = rpc_populate(ret, authfiles, RPCAUTH_info, RPCAUTH_EOF,
+                   rpc_client);
+       if (unlikely(error)) {
+               simple_recursive_removal(ret, NULL);
+               return ERR_PTR(error);
        }
+       rpc_client->cl_pipedir_objects.pdh_dentry = ret;
+       rpc_create_pipe_dir_objects(&rpc_client->cl_pipedir_objects);
        return ret;
 }
 
@@ -955,18 +934,20 @@ static const struct rpc_filelist cache_pipefs_files[3] = {
        },
 };
 
-static int rpc_cachedir_populate(struct dentry *dentry, void *private)
-{
-       return rpc_populate(dentry,
-                           cache_pipefs_files, 0, 3,
-                           private);
-}
-
 struct dentry *rpc_create_cache_dir(struct dentry *parent, const char *name,
                                    umode_t umode, struct cache_detail *cd)
 {
-       return rpc_mkdir_populate(parent, name, umode, NULL,
-                       rpc_cachedir_populate, cd);
+       struct dentry *dentry;
+
+       dentry = rpc_new_dir(parent, name, umode, NULL);
+       if (!IS_ERR(dentry)) {
+               int error = rpc_populate(dentry, cache_pipefs_files, 0, 3, cd);
+               if (error) {
+                       simple_recursive_removal(dentry, NULL);
+                       return ERR_PTR(error);
+               }
+       }
+       return dentry;
 }
 
 void rpc_remove_cache_dir(struct dentry *dentry)