]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rpc_create_client_dir(): return 0 or -E...
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 23 Mar 2025 04:51:10 +0000 (00:51 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:44:55 +0000 (22:44 -0400)
Callers couldn't care less which dentry did we get - anything
valid is treated as success.

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

index 8cc3a5df98011df2d489a8d8b1e4cc1983e28e5c..2cb406f8ff4ef50d02541cfa3a3655299135d8e3 100644 (file)
@@ -98,7 +98,7 @@ static inline bool rpc_msg_is_inflight(const struct rpc_pipe_msg *msg) {
 }
 
 struct rpc_clnt;
-extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
+extern int rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
 extern int rpc_remove_client_dir(struct rpc_clnt *);
 
 extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh);
index 21426c3049d35094b81c0915fc755b0f4e00804c..8ca354ecfd02aa44ba0c59963ee5e355a7c106e1 100644 (file)
@@ -112,47 +112,46 @@ static void rpc_clnt_remove_pipedir(struct rpc_clnt *clnt)
        }
 }
 
-static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb,
+static int rpc_setup_pipedir_sb(struct super_block *sb,
                                    struct rpc_clnt *clnt)
 {
        static uint32_t clntid;
        const char *dir_name = clnt->cl_program->pipe_dir_name;
        char name[15];
-       struct dentry *dir, *dentry;
+       struct dentry *dir;
+       int err;
 
        dir = rpc_d_lookup_sb(sb, dir_name);
        if (dir == NULL) {
                pr_info("RPC: pipefs directory doesn't exist: %s\n", dir_name);
-               return dir;
+               return -ENOENT;
        }
        for (;;) {
                snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
                name[sizeof(name) - 1] = '\0';
-               dentry = rpc_create_client_dir(dir, name, clnt);
-               if (!IS_ERR(dentry))
+               err = rpc_create_client_dir(dir, name, clnt);
+               if (!err)
                        break;
-               if (dentry == ERR_PTR(-EEXIST))
+               if (err == -EEXIST)
                        continue;
                printk(KERN_INFO "RPC: Couldn't create pipefs entry"
-                               " %s/%s, error %ld\n",
-                               dir_name, name, PTR_ERR(dentry));
+                               " %s/%s, error %d\n",
+                               dir_name, name, err);
                break;
        }
        dput(dir);
-       return dentry;
+       return err;
 }
 
 static int
 rpc_setup_pipedir(struct super_block *pipefs_sb, struct rpc_clnt *clnt)
 {
-       struct dentry *dentry;
-
        clnt->pipefs_sb = pipefs_sb;
 
        if (clnt->cl_program->pipe_dir_name != NULL) {
-               dentry = rpc_setup_pipedir_sb(pipefs_sb, clnt);
-               if (IS_ERR(dentry))
-                       return PTR_ERR(dentry);
+               int err = rpc_setup_pipedir_sb(pipefs_sb, clnt);
+               if (err && err != -ENOENT)
+                       return err;
        }
        return 0;
 }
@@ -180,16 +179,9 @@ static int rpc_clnt_skip_event(struct rpc_clnt *clnt, unsigned long event)
 static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event,
                                   struct super_block *sb)
 {
-       struct dentry *dentry;
-
        switch (event) {
        case RPC_PIPEFS_MOUNT:
-               dentry = rpc_setup_pipedir_sb(sb, clnt);
-               if (!dentry)
-                       return -ENOENT;
-               if (IS_ERR(dentry))
-                       return PTR_ERR(dentry);
-               break;
+               return rpc_setup_pipedir_sb(sb, clnt);
        case RPC_PIPEFS_UMOUNT:
                __rpc_clnt_remove_pipedir(clnt);
                break;
index e4b53530eb1b61433dd28c4463f585cf49f97856..a12ec709c445146d5ad58b851df08105f377e5cf 100644 (file)
@@ -863,27 +863,27 @@ rpc_destroy_pipe_dir_objects(struct rpc_pipe_dir_head *pdh)
  * information about the client, together with any "pipes" that may
  * later be created using rpc_mkpipe().
  */
-struct dentry *rpc_create_client_dir(struct dentry *dentry,
-                                  const char *name,
-                                  struct rpc_clnt *rpc_client)
+int rpc_create_client_dir(struct dentry *dentry,
+                          const char *name,
+                          struct rpc_clnt *rpc_client)
 {
        struct dentry *ret;
        int err;
 
        ret = rpc_new_dir(dentry, name, 0555);
        if (IS_ERR(ret))
-               return ret;
+               return PTR_ERR(ret);
        err = rpc_new_file(ret, "info", S_IFREG | 0400,
                              &rpc_info_operations, rpc_client);
        if (err) {
                pr_warn("%s failed to populate directory %pd\n",
                                __func__, ret);
                simple_recursive_removal(ret, NULL);
-               return ERR_PTR(err);
+               return err;
        }
        rpc_client->cl_pipedir_objects.pdh_dentry = ret;
        rpc_create_pipe_dir_objects(&rpc_client->cl_pipedir_objects);
-       return ret;
+       return 0;
 }
 
 /**