Commit d85ed443 authored by Stanislav Kinsbursky's avatar Stanislav Kinsbursky Committed by J. Bruce Fields

nfsd: cleanup NFSd state start a bit

This patch renames nfs4_state_start_net() into nfs4_state_create_net(), where
get_net() now performed.
Also it introduces new nfs4_state_start_net(), which is now responsible for
state creation and initializing all per-net data and which is now called from
nfs4_state_start().
Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 4dce0ac9
...@@ -4770,7 +4770,7 @@ set_max_delegations(void) ...@@ -4770,7 +4770,7 @@ set_max_delegations(void)
max_delegations = nr_free_buffer_pages() >> (20 - 2 - PAGE_SHIFT); max_delegations = nr_free_buffer_pages() >> (20 - 2 - PAGE_SHIFT);
} }
static int nfs4_state_start_net(struct net *net) static int nfs4_state_create_net(struct net *net)
{ {
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int i; int i;
...@@ -4813,6 +4813,7 @@ static int nfs4_state_start_net(struct net *net) ...@@ -4813,6 +4813,7 @@ static int nfs4_state_start_net(struct net *net)
spin_lock_init(&nn->client_lock); spin_lock_init(&nn->client_lock);
INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main); INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main);
get_net(net);
return 0; return 0;
...@@ -4860,37 +4861,35 @@ nfs4_state_destroy_net(struct net *net) ...@@ -4860,37 +4861,35 @@ nfs4_state_destroy_net(struct net *net)
put_net(net); put_net(net);
} }
/* initialization to perform when the nfsd service is started: */ static int
nfs4_state_start_net(struct net *net)
int
nfs4_state_start(void)
{ {
struct net *net = &init_net;
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int ret; int ret;
/* ret = nfs4_state_create_net(net);
* FIXME: For now, we hang most of the pernet global stuff off of
* init_net until nfsd is fully containerized. Eventually, we'll
* need to pass a net pointer into this function, take a reference
* to that instead and then do most of the rest of this on a per-net
* basis.
*/
get_net(net);
ret = nfs4_state_start_net(net);
if (ret) if (ret)
return ret; return ret;
nfsd4_client_tracking_init(net); nfsd4_client_tracking_init(net);
nn->boot_time = get_seconds(); nn->boot_time = get_seconds();
locks_start_grace(net, &nn->nfsd4_manager); locks_start_grace(net, &nn->nfsd4_manager);
nn->grace_ended = false; nn->grace_ended = false;
printk(KERN_INFO "NFSD: starting %ld-second grace period\n", printk(KERN_INFO "NFSD: starting %ld-second grace period (net %p)\n",
nfsd4_grace); nfsd4_grace, net);
queue_delayed_work(laundry_wq, &nn->laundromat_work, nfsd4_grace * HZ);
return 0;
}
/* initialization to perform when the nfsd service is started: */
int
nfs4_state_start(void)
{
int ret;
ret = set_callback_cred(); ret = set_callback_cred();
if (ret) { if (ret)
ret = -ENOMEM; return -ENOMEM;
goto out_recovery;
}
laundry_wq = create_singlethread_workqueue("nfsd4"); laundry_wq = create_singlethread_workqueue("nfsd4");
if (laundry_wq == NULL) { if (laundry_wq == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -4900,14 +4899,26 @@ nfs4_state_start(void) ...@@ -4900,14 +4899,26 @@ nfs4_state_start(void)
if (ret) if (ret)
goto out_free_laundry; goto out_free_laundry;
queue_delayed_work(laundry_wq, &nn->laundromat_work, nfsd4_grace * HZ);
set_max_delegations(); set_max_delegations();
/*
* FIXME: For now, we hang most of the pernet global stuff off of
* init_net until nfsd is fully containerized. Eventually, we'll
* need to pass a net pointer into this function, take a reference
* to that instead and then do most of the rest of this on a per-net
* basis.
*/
ret = nfs4_state_start_net(&init_net);
if (ret)
goto out_free_callback;
return 0; return 0;
out_free_callback:
nfsd4_destroy_callback_queue();
out_free_laundry: out_free_laundry:
destroy_workqueue(laundry_wq); destroy_workqueue(laundry_wq);
out_recovery: out_recovery:
nfsd4_client_tracking_exit(net);
nfs4_state_destroy_net(net);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment