Skip to content

Commit 350db61

Browse files
author
Al Viro
committed
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>
1 parent 3ee735e commit 350db61

3 files changed

Lines changed: 21 additions & 29 deletions

File tree

include/linux/sunrpc/rpc_pipe_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static inline bool rpc_msg_is_inflight(const struct rpc_pipe_msg *msg) {
9898
}
9999

100100
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 *);
102102
extern int rpc_remove_client_dir(struct rpc_clnt *);
103103

104104
extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh);

net/sunrpc/clnt.c

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,47 +112,46 @@ static void rpc_clnt_remove_pipedir(struct rpc_clnt *clnt)
112112
}
113113
}
114114

115-
static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb,
115+
static int rpc_setup_pipedir_sb(struct super_block *sb,
116116
struct rpc_clnt *clnt)
117117
{
118118
static uint32_t clntid;
119119
const char *dir_name = clnt->cl_program->pipe_dir_name;
120120
char name[15];
121-
struct dentry *dir, *dentry;
121+
struct dentry *dir;
122+
int err;
122123

123124
dir = rpc_d_lookup_sb(sb, dir_name);
124125
if (dir == NULL) {
125126
pr_info("RPC: pipefs directory doesn't exist: %s\n", dir_name);
126-
return dir;
127+
return -ENOENT;
127128
}
128129
for (;;) {
129130
snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
130131
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)
133134
break;
134-
if (dentry == ERR_PTR(-EEXIST))
135+
if (err == -EEXIST)
135136
continue;
136137
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);
139140
break;
140141
}
141142
dput(dir);
142-
return dentry;
143+
return err;
143144
}
144145

145146
static int
146147
rpc_setup_pipedir(struct super_block *pipefs_sb, struct rpc_clnt *clnt)
147148
{
148-
struct dentry *dentry;
149-
150149
clnt->pipefs_sb = pipefs_sb;
151150

152151
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;
156155
}
157156
return 0;
158157
}
@@ -180,16 +179,9 @@ static int rpc_clnt_skip_event(struct rpc_clnt *clnt, unsigned long event)
180179
static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event,
181180
struct super_block *sb)
182181
{
183-
struct dentry *dentry;
184-
185182
switch (event) {
186183
case RPC_PIPEFS_MOUNT:
187-
dentry = rpc_setup_pipedir_sb(sb, clnt);
188-
if (!dentry)
189-
return -ENOENT;
190-
if (IS_ERR(dentry))
191-
return PTR_ERR(dentry);
192-
break;
184+
return rpc_setup_pipedir_sb(sb, clnt);
193185
case RPC_PIPEFS_UMOUNT:
194186
__rpc_clnt_remove_pipedir(clnt);
195187
break;

net/sunrpc/rpc_pipe.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,27 +863,27 @@ rpc_destroy_pipe_dir_objects(struct rpc_pipe_dir_head *pdh)
863863
* information about the client, together with any "pipes" that may
864864
* later be created using rpc_mkpipe().
865865
*/
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)
869869
{
870870
struct dentry *ret;
871871
int err;
872872

873873
ret = rpc_new_dir(dentry, name, 0555);
874874
if (IS_ERR(ret))
875-
return ret;
875+
return PTR_ERR(ret);
876876
err = rpc_new_file(ret, "info", S_IFREG | 0400,
877877
&rpc_info_operations, rpc_client);
878878
if (err) {
879879
pr_warn("%s failed to populate directory %pd\n",
880880
__func__, ret);
881881
simple_recursive_removal(ret, NULL);
882-
return ERR_PTR(err);
882+
return err;
883883
}
884884
rpc_client->cl_pipedir_objects.pdh_dentry = ret;
885885
rpc_create_pipe_dir_objects(&rpc_client->cl_pipedir_objects);
886-
return ret;
886+
return 0;
887887
}
888888

889889
/**

0 commit comments

Comments
 (0)