diff options
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r-- | fs/nfsd/nfssvc.c | 83 |
1 files changed, 57 insertions, 26 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 140e3a2d1b9f..5d473d8f0630 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -195,6 +195,52 @@ void nfsd_reset_versions(void) | |||
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | static int nfsd_create_serv(void) | ||
199 | { | ||
200 | int err = 0; | ||
201 | lock_kernel(); | ||
202 | if (nfsd_serv) { | ||
203 | nfsd_serv->sv_nrthreads++; | ||
204 | unlock_kernel(); | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | atomic_set(&nfsd_busy, 0); | ||
209 | nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE, | ||
210 | nfsd_last_thread); | ||
211 | if (nfsd_serv == NULL) | ||
212 | err = -ENOMEM; | ||
213 | else | ||
214 | nfsd_serv->sv_nrthreads++; | ||
215 | unlock_kernel(); | ||
216 | do_gettimeofday(&nfssvc_boot); /* record boot time */ | ||
217 | return err; | ||
218 | } | ||
219 | |||
220 | static int nfsd_init_socks(int port) | ||
221 | { | ||
222 | int error; | ||
223 | if (!list_empty(&nfsd_serv->sv_permsocks)) | ||
224 | return 0; | ||
225 | |||
226 | error = svc_makesock(nfsd_serv, IPPROTO_UDP, port); | ||
227 | if (error < 0) | ||
228 | return error; | ||
229 | error = lockd_up(IPPROTO_UDP); | ||
230 | if (error < 0) | ||
231 | return error; | ||
232 | |||
233 | #ifdef CONFIG_NFSD_TCP | ||
234 | error = svc_makesock(nfsd_serv, IPPROTO_TCP, port); | ||
235 | if (error < 0) | ||
236 | return error; | ||
237 | error = lockd_up(IPPROTO_TCP); | ||
238 | if (error < 0) | ||
239 | return error; | ||
240 | #endif | ||
241 | return 0; | ||
242 | } | ||
243 | |||
198 | int | 244 | int |
199 | nfsd_svc(unsigned short port, int nrservs) | 245 | nfsd_svc(unsigned short port, int nrservs) |
200 | { | 246 | { |
@@ -216,32 +262,17 @@ nfsd_svc(unsigned short port, int nrservs) | |||
216 | error = nfs4_state_start(); | 262 | error = nfs4_state_start(); |
217 | if (error<0) | 263 | if (error<0) |
218 | goto out; | 264 | goto out; |
219 | if (!nfsd_serv) { | 265 | |
220 | nfsd_reset_versions(); | 266 | nfsd_reset_versions(); |
221 | 267 | ||
222 | atomic_set(&nfsd_busy, 0); | 268 | error = nfsd_create_serv(); |
223 | error = -ENOMEM; | 269 | |
224 | nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE, | 270 | if (error) |
225 | nfsd_last_thread); | 271 | goto out; |
226 | if (nfsd_serv == NULL) | 272 | error = nfsd_init_socks(port); |
227 | goto out; | 273 | if (error) |
228 | error = svc_makesock(nfsd_serv, IPPROTO_UDP, port); | 274 | goto failure; |
229 | if (error < 0) | 275 | |
230 | goto failure; | ||
231 | error = lockd_up(IPPROTO_UDP); | ||
232 | if (error < 0) | ||
233 | goto failure; | ||
234 | #ifdef CONFIG_NFSD_TCP | ||
235 | error = svc_makesock(nfsd_serv, IPPROTO_TCP, port); | ||
236 | if (error < 0) | ||
237 | goto failure; | ||
238 | error = lockd_up(IPPROTO_TCP); | ||
239 | if (error < 0) | ||
240 | goto failure; | ||
241 | #endif | ||
242 | do_gettimeofday(&nfssvc_boot); /* record boot time */ | ||
243 | } else | ||
244 | nfsd_serv->sv_nrthreads++; | ||
245 | nrservs -= (nfsd_serv->sv_nrthreads-1); | 276 | nrservs -= (nfsd_serv->sv_nrthreads-1); |
246 | while (nrservs > 0) { | 277 | while (nrservs > 0) { |
247 | nrservs--; | 278 | nrservs--; |