rpc_pipe: expand the calls of rpc_mkdir_populate()

... and get rid of convoluted callbacks.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2024-02-20 22:23:09 -05:00
parent 065e88fa33
commit 805060a69c

View File

@ -618,26 +618,6 @@ static int rpc_populate(struct dentry *parent,
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)