aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/callback.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/callback.c')
-rw-r--r--fs/nfs/callback.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index c1e7c8300629..f447f4b4476c 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -27,7 +27,7 @@
27 27
28struct nfs_callback_data { 28struct nfs_callback_data {
29 unsigned int users; 29 unsigned int users;
30 struct svc_serv *serv; 30 struct svc_rqst *rqst;
31 struct task_struct *task; 31 struct task_struct *task;
32}; 32};
33 33
@@ -91,21 +91,17 @@ nfs_callback_svc(void *vrqstp)
91 svc_process(rqstp); 91 svc_process(rqstp);
92 } 92 }
93 unlock_kernel(); 93 unlock_kernel();
94 nfs_callback_info.task = NULL;
95 svc_exit_thread(rqstp);
96 return 0; 94 return 0;
97} 95}
98 96
99/* 97/*
100 * Bring up the server process if it is not already up. 98 * Bring up the callback thread if it is not already up.
101 */ 99 */
102int nfs_callback_up(void) 100int nfs_callback_up(void)
103{ 101{
104 struct svc_serv *serv = NULL; 102 struct svc_serv *serv = NULL;
105 struct svc_rqst *rqstp;
106 int ret = 0; 103 int ret = 0;
107 104
108 lock_kernel();
109 mutex_lock(&nfs_callback_mutex); 105 mutex_lock(&nfs_callback_mutex);
110 if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) 106 if (nfs_callback_info.users++ || nfs_callback_info.task != NULL)
111 goto out; 107 goto out;
@@ -121,22 +117,23 @@ int nfs_callback_up(void)
121 nfs_callback_tcpport = ret; 117 nfs_callback_tcpport = ret;
122 dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); 118 dprintk("Callback port = 0x%x\n", nfs_callback_tcpport);
123 119
124 rqstp = svc_prepare_thread(serv, &serv->sv_pools[0]); 120 nfs_callback_info.rqst = svc_prepare_thread(serv, &serv->sv_pools[0]);
125 if (IS_ERR(rqstp)) { 121 if (IS_ERR(nfs_callback_info.rqst)) {
126 ret = PTR_ERR(rqstp); 122 ret = PTR_ERR(nfs_callback_info.rqst);
123 nfs_callback_info.rqst = NULL;
127 goto out_err; 124 goto out_err;
128 } 125 }
129 126
130 svc_sock_update_bufs(serv); 127 svc_sock_update_bufs(serv);
131 nfs_callback_info.serv = serv;
132 128
133 nfs_callback_info.task = kthread_run(nfs_callback_svc, rqstp, 129 nfs_callback_info.task = kthread_run(nfs_callback_svc,
130 nfs_callback_info.rqst,
134 "nfsv4-svc"); 131 "nfsv4-svc");
135 if (IS_ERR(nfs_callback_info.task)) { 132 if (IS_ERR(nfs_callback_info.task)) {
136 ret = PTR_ERR(nfs_callback_info.task); 133 ret = PTR_ERR(nfs_callback_info.task);
137 nfs_callback_info.serv = NULL; 134 svc_exit_thread(nfs_callback_info.rqst);
135 nfs_callback_info.rqst = NULL;
138 nfs_callback_info.task = NULL; 136 nfs_callback_info.task = NULL;
139 svc_exit_thread(rqstp);
140 goto out_err; 137 goto out_err;
141 } 138 }
142out: 139out:
@@ -149,7 +146,6 @@ out:
149 if (serv) 146 if (serv)
150 svc_destroy(serv); 147 svc_destroy(serv);
151 mutex_unlock(&nfs_callback_mutex); 148 mutex_unlock(&nfs_callback_mutex);
152 unlock_kernel();
153 return ret; 149 return ret;
154out_err: 150out_err:
155 dprintk("Couldn't create callback socket or server thread; err = %d\n", 151 dprintk("Couldn't create callback socket or server thread; err = %d\n",
@@ -159,17 +155,19 @@ out_err:
159} 155}
160 156
161/* 157/*
162 * Kill the server process if it is not already down. 158 * Kill the callback thread if it's no longer being used.
163 */ 159 */
164void nfs_callback_down(void) 160void nfs_callback_down(void)
165{ 161{
166 lock_kernel();
167 mutex_lock(&nfs_callback_mutex); 162 mutex_lock(&nfs_callback_mutex);
168 nfs_callback_info.users--; 163 nfs_callback_info.users--;
169 if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) 164 if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) {
170 kthread_stop(nfs_callback_info.task); 165 kthread_stop(nfs_callback_info.task);
166 svc_exit_thread(nfs_callback_info.rqst);
167 nfs_callback_info.rqst = NULL;
168 nfs_callback_info.task = NULL;
169 }
171 mutex_unlock(&nfs_callback_mutex); 170 mutex_unlock(&nfs_callback_mutex);
172 unlock_kernel();
173} 171}
174 172
175static int nfs_callback_authenticate(struct svc_rqst *rqstp) 173static int nfs_callback_authenticate(struct svc_rqst *rqstp)