SUNRPC: move per-net operations from svc_destroy()
The idea is to separate service destruction and per-net operations, because these are two different things and the mix looks ugly. Notes: 1) For NFS server this patch looks ugly (sorry for that). But these place will be rewritten soon during NFSd containerization. 2) LockD per-net counter increase int lockd_up() was moved prior to make_socks() to make lockd_down_net() call safe in case of error. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
此提交包含在:
@@ -257,7 +257,7 @@ static int lockd_up_net(struct net *net)
|
||||
struct svc_serv *serv = nlmsvc_rqst->rq_server;
|
||||
int error;
|
||||
|
||||
if (ln->nlmsvc_users)
|
||||
if (ln->nlmsvc_users++)
|
||||
return 0;
|
||||
|
||||
error = svc_rpcb_setup(serv, net);
|
||||
@@ -272,6 +272,7 @@ static int lockd_up_net(struct net *net)
|
||||
err_socks:
|
||||
svc_rpcb_cleanup(serv, net);
|
||||
err_rpcb:
|
||||
ln->nlmsvc_users--;
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -299,6 +300,7 @@ int lockd_up(struct net *net)
|
||||
{
|
||||
struct svc_serv *serv;
|
||||
int error = 0;
|
||||
struct lockd_net *ln = net_generic(net, lockd_net_id);
|
||||
|
||||
mutex_lock(&nlmsvc_mutex);
|
||||
/*
|
||||
@@ -330,9 +332,11 @@ int lockd_up(struct net *net)
|
||||
goto destroy_and_out;
|
||||
}
|
||||
|
||||
ln->nlmsvc_users++;
|
||||
|
||||
error = make_socks(serv, net);
|
||||
if (error < 0)
|
||||
goto destroy_and_out;
|
||||
goto err_start;
|
||||
|
||||
/*
|
||||
* Create the kernel thread and wait for it to start.
|
||||
@@ -344,7 +348,7 @@ int lockd_up(struct net *net)
|
||||
printk(KERN_WARNING
|
||||
"lockd_up: svc_rqst allocation failed, error=%d\n",
|
||||
error);
|
||||
goto destroy_and_out;
|
||||
goto err_start;
|
||||
}
|
||||
|
||||
svc_sock_update_bufs(serv);
|
||||
@@ -358,7 +362,7 @@ int lockd_up(struct net *net)
|
||||
nlmsvc_rqst = NULL;
|
||||
printk(KERN_WARNING
|
||||
"lockd_up: kthread_run failed, error=%d\n", error);
|
||||
goto destroy_and_out;
|
||||
goto err_start;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -368,14 +372,14 @@ int lockd_up(struct net *net)
|
||||
destroy_and_out:
|
||||
svc_destroy(serv);
|
||||
out:
|
||||
if (!error) {
|
||||
struct lockd_net *ln = net_generic(net, lockd_net_id);
|
||||
|
||||
ln->nlmsvc_users++;
|
||||
if (!error)
|
||||
nlmsvc_users++;
|
||||
}
|
||||
mutex_unlock(&nlmsvc_mutex);
|
||||
return error;
|
||||
|
||||
err_start:
|
||||
lockd_down_net(net);
|
||||
goto destroy_and_out;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lockd_up);
|
||||
|
||||
@@ -386,11 +390,10 @@ void
|
||||
lockd_down(struct net *net)
|
||||
{
|
||||
mutex_lock(&nlmsvc_mutex);
|
||||
lockd_down_net(net);
|
||||
if (nlmsvc_users) {
|
||||
if (--nlmsvc_users) {
|
||||
lockd_down_net(net);
|
||||
if (--nlmsvc_users)
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
printk(KERN_ERR "lockd_down: no users! task=%p\n",
|
||||
nlmsvc_task);
|
||||
|
新增問題並參考
封鎖使用者