SUNRPC: traverse clients tree on PipeFS event
v2: recursion was replaced by loop If client is a clone, then it's parent can not be in the list. But parent's Pipefs dentries have to be created and destroyed. Note: event skip helper for clients introduced Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
37629b572c
commit
ea8cfa0679
@ -176,8 +176,16 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, const char *dir_name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event,
|
static inline int rpc_clnt_skip_event(struct rpc_clnt *clnt, unsigned long event)
|
||||||
struct super_block *sb)
|
{
|
||||||
|
if (((event == RPC_PIPEFS_MOUNT) && clnt->cl_dentry) ||
|
||||||
|
((event == RPC_PIPEFS_UMOUNT) && !clnt->cl_dentry))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event,
|
||||||
|
struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -206,6 +214,20 @@ static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event,
|
||||||
|
struct super_block *sb)
|
||||||
|
{
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
for (;; clnt = clnt->cl_parent) {
|
||||||
|
if (!rpc_clnt_skip_event(clnt, event))
|
||||||
|
error = __rpc_clnt_handle_event(clnt, event, sb);
|
||||||
|
if (error || clnt == clnt->cl_parent)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
|
static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
|
||||||
{
|
{
|
||||||
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
|
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
|
||||||
@ -215,8 +237,7 @@ static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
|
|||||||
list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
|
list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
|
||||||
if (clnt->cl_program->pipe_dir_name == NULL)
|
if (clnt->cl_program->pipe_dir_name == NULL)
|
||||||
break;
|
break;
|
||||||
if (((event == RPC_PIPEFS_MOUNT) && clnt->cl_dentry) ||
|
if (rpc_clnt_skip_event(clnt, event))
|
||||||
((event == RPC_PIPEFS_UMOUNT) && !clnt->cl_dentry))
|
|
||||||
continue;
|
continue;
|
||||||
if (atomic_inc_not_zero(&clnt->cl_count) == 0)
|
if (atomic_inc_not_zero(&clnt->cl_count) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user