aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-11-26 07:22:13 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-11-28 10:13:52 -0500
commitd85ed443052570b25ea4b5f5fa70c57e0129fbc4 (patch)
tree005815dd0f5bd4d067d202b4b9201f6f216f1242 /fs/nfsd/nfs4state.c
parent4dce0ac9069bbebfd34f890f599ccdb92fa76e9f (diff)
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: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 84a27a24b806..6f5798623eb1 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4770,7 +4770,7 @@ set_max_delegations(void)
4770 max_delegations = nr_free_buffer_pages() >> (20 - 2 - PAGE_SHIFT); 4770 max_delegations = nr_free_buffer_pages() >> (20 - 2 - PAGE_SHIFT);
4771} 4771}
4772 4772
4773static int nfs4_state_start_net(struct net *net) 4773static int nfs4_state_create_net(struct net *net)
4774{ 4774{
4775 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 4775 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
4776 int i; 4776 int i;
@@ -4813,6 +4813,7 @@ static int nfs4_state_start_net(struct net *net)
4813 spin_lock_init(&nn->client_lock); 4813 spin_lock_init(&nn->client_lock);
4814 4814
4815 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main); 4815 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main);
4816 get_net(net);
4816 4817
4817 return 0; 4818 return 0;
4818 4819
@@ -4860,37 +4861,35 @@ nfs4_state_destroy_net(struct net *net)
4860 put_net(net); 4861 put_net(net);
4861} 4862}
4862 4863
4863/* initialization to perform when the nfsd service is started: */ 4864static int
4864 4865nfs4_state_start_net(struct net *net)
4865int
4866nfs4_state_start(void)
4867{ 4866{
4868 struct net *net = &init_net;
4869 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 4867 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
4870 int ret; 4868 int ret;
4871 4869
4872 /* 4870 ret = nfs4_state_create_net(net);
4873 * FIXME: For now, we hang most of the pernet global stuff off of
4874 * init_net until nfsd is fully containerized. Eventually, we'll
4875 * need to pass a net pointer into this function, take a reference
4876 * to that instead and then do most of the rest of this on a per-net
4877 * basis.
4878 */
4879 get_net(net);
4880 ret = nfs4_state_start_net(net);
4881 if (ret) 4871 if (ret)
4882 return ret; 4872 return ret;
4883 nfsd4_client_tracking_init(net); 4873 nfsd4_client_tracking_init(net);
4884 nn->boot_time = get_seconds(); 4874 nn->boot_time = get_seconds();
4885 locks_start_grace(net, &nn->nfsd4_manager); 4875 locks_start_grace(net, &nn->nfsd4_manager);
4886 nn->grace_ended = false; 4876 nn->grace_ended = false;
4887 printk(KERN_INFO "NFSD: starting %ld-second grace period\n", 4877 printk(KERN_INFO "NFSD: starting %ld-second grace period (net %p)\n",
4888 nfsd4_grace); 4878 nfsd4_grace, net);
4879 queue_delayed_work(laundry_wq, &nn->laundromat_work, nfsd4_grace * HZ);
4880 return 0;
4881}
4882
4883/* initialization to perform when the nfsd service is started: */
4884
4885int
4886nfs4_state_start(void)
4887{
4888 int ret;
4889
4889 ret = set_callback_cred(); 4890 ret = set_callback_cred();
4890 if (ret) { 4891 if (ret)
4891 ret = -ENOMEM; 4892 return -ENOMEM;
4892 goto out_recovery;
4893 }
4894 laundry_wq = create_singlethread_workqueue("nfsd4"); 4893 laundry_wq = create_singlethread_workqueue("nfsd4");
4895 if (laundry_wq == NULL) { 4894 if (laundry_wq == NULL) {
4896 ret = -ENOMEM; 4895 ret = -ENOMEM;
@@ -4900,14 +4899,26 @@ nfs4_state_start(void)
4900 if (ret) 4899 if (ret)
4901 goto out_free_laundry; 4900 goto out_free_laundry;
4902 4901
4903 queue_delayed_work(laundry_wq, &nn->laundromat_work, nfsd4_grace * HZ);
4904 set_max_delegations(); 4902 set_max_delegations();
4903
4904 /*
4905 * FIXME: For now, we hang most of the pernet global stuff off of
4906 * init_net until nfsd is fully containerized. Eventually, we'll
4907 * need to pass a net pointer into this function, take a reference
4908 * to that instead and then do most of the rest of this on a per-net
4909 * basis.
4910 */
4911 ret = nfs4_state_start_net(&init_net);
4912 if (ret)
4913 goto out_free_callback;
4914
4905 return 0; 4915 return 0;
4916
4917out_free_callback:
4918 nfsd4_destroy_callback_queue();
4906out_free_laundry: 4919out_free_laundry:
4907 destroy_workqueue(laundry_wq); 4920 destroy_workqueue(laundry_wq);
4908out_recovery: 4921out_recovery:
4909 nfsd4_client_tracking_exit(net);
4910 nfs4_state_destroy_net(net);
4911 return ret; 4922 return ret;
4912} 4923}
4913 4924