Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rpc_create_client_dir(): return 0 or -E...

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>

Al Viro 350db61f 3ee735ef

+21 -29
+1 -1
include/linux/sunrpc/rpc_pipe_fs.h
··· 98 98 } 99 99 100 100 struct rpc_clnt; 101 - extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); 101 + extern int rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); 102 102 extern int rpc_remove_client_dir(struct rpc_clnt *); 103 103 104 104 extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh);
+14 -22
net/sunrpc/clnt.c
··· 112 112 } 113 113 } 114 114 115 - static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, 115 + static int rpc_setup_pipedir_sb(struct super_block *sb, 116 116 struct rpc_clnt *clnt) 117 117 { 118 118 static uint32_t clntid; 119 119 const char *dir_name = clnt->cl_program->pipe_dir_name; 120 120 char name[15]; 121 - struct dentry *dir, *dentry; 121 + struct dentry *dir; 122 + int err; 122 123 123 124 dir = rpc_d_lookup_sb(sb, dir_name); 124 125 if (dir == NULL) { 125 126 pr_info("RPC: pipefs directory doesn't exist: %s\n", dir_name); 126 - return dir; 127 + return -ENOENT; 127 128 } 128 129 for (;;) { 129 130 snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); 130 131 name[sizeof(name) - 1] = '\0'; 131 - dentry = rpc_create_client_dir(dir, name, clnt); 132 - if (!IS_ERR(dentry)) 132 + err = rpc_create_client_dir(dir, name, clnt); 133 + if (!err) 133 134 break; 134 - if (dentry == ERR_PTR(-EEXIST)) 135 + if (err == -EEXIST) 135 136 continue; 136 137 printk(KERN_INFO "RPC: Couldn't create pipefs entry" 137 - " %s/%s, error %ld\n", 138 - dir_name, name, PTR_ERR(dentry)); 138 + " %s/%s, error %d\n", 139 + dir_name, name, err); 139 140 break; 140 141 } 141 142 dput(dir); 142 - return dentry; 143 + return err; 143 144 } 144 145 145 146 static int 146 147 rpc_setup_pipedir(struct super_block *pipefs_sb, struct rpc_clnt *clnt) 147 148 { 148 - struct dentry *dentry; 149 - 150 149 clnt->pipefs_sb = pipefs_sb; 151 150 152 151 if (clnt->cl_program->pipe_dir_name != NULL) { 153 - dentry = rpc_setup_pipedir_sb(pipefs_sb, clnt); 154 - if (IS_ERR(dentry)) 155 - return PTR_ERR(dentry); 152 + int err = rpc_setup_pipedir_sb(pipefs_sb, clnt); 153 + if (err && err != -ENOENT) 154 + return err; 156 155 } 157 156 return 0; 158 157 } ··· 179 180 static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event, 180 181 struct super_block *sb) 181 182 { 182 - struct dentry *dentry; 183 - 184 183 switch (event) { 185 184 case RPC_PIPEFS_MOUNT: 186 - dentry = rpc_setup_pipedir_sb(sb, clnt); 187 - if (!dentry) 188 - return -ENOENT; 189 - if (IS_ERR(dentry)) 190 - return PTR_ERR(dentry); 191 - break; 185 + return rpc_setup_pipedir_sb(sb, clnt); 192 186 case RPC_PIPEFS_UMOUNT: 193 187 __rpc_clnt_remove_pipedir(clnt); 194 188 break;
+6 -6
net/sunrpc/rpc_pipe.c
··· 863 863 * information about the client, together with any "pipes" that may 864 864 * later be created using rpc_mkpipe(). 865 865 */ 866 - struct dentry *rpc_create_client_dir(struct dentry *dentry, 867 - const char *name, 868 - struct rpc_clnt *rpc_client) 866 + int rpc_create_client_dir(struct dentry *dentry, 867 + const char *name, 868 + struct rpc_clnt *rpc_client) 869 869 { 870 870 struct dentry *ret; 871 871 int err; 872 872 873 873 ret = rpc_new_dir(dentry, name, 0555); 874 874 if (IS_ERR(ret)) 875 - return ret; 875 + return PTR_ERR(ret); 876 876 err = rpc_new_file(ret, "info", S_IFREG | 0400, 877 877 &rpc_info_operations, rpc_client); 878 878 if (err) { 879 879 pr_warn("%s failed to populate directory %pd\n", 880 880 __func__, ret); 881 881 simple_recursive_removal(ret, NULL); 882 - return ERR_PTR(err); 882 + return err; 883 883 } 884 884 rpc_client->cl_pipedir_objects.pdh_dentry = ret; 885 885 rpc_create_pipe_dir_objects(&rpc_client->cl_pipedir_objects); 886 - return ret; 886 + return 0; 887 887 } 888 888 889 889 /**