diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-05-04 04:49:41 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-05-31 20:29:40 -0400 |
commit | 786185b5f8abefa6a8a16695bb4a59c164d5a071 (patch) | |
tree | 780eafd98f98a093fda540898595b47b4261764c /fs/lockd | |
parent | 9793f7c88937e7ac07305ab1af1a519225836823 (diff) |
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>
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/svc.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index b7e92ed56885..3250f280a171 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -257,7 +257,7 @@ static int lockd_up_net(struct net *net) | |||
257 | struct svc_serv *serv = nlmsvc_rqst->rq_server; | 257 | struct svc_serv *serv = nlmsvc_rqst->rq_server; |
258 | int error; | 258 | int error; |
259 | 259 | ||
260 | if (ln->nlmsvc_users) | 260 | if (ln->nlmsvc_users++) |
261 | return 0; | 261 | return 0; |
262 | 262 | ||
263 | error = svc_rpcb_setup(serv, net); | 263 | error = svc_rpcb_setup(serv, net); |
@@ -272,6 +272,7 @@ static int lockd_up_net(struct net *net) | |||
272 | err_socks: | 272 | err_socks: |
273 | svc_rpcb_cleanup(serv, net); | 273 | svc_rpcb_cleanup(serv, net); |
274 | err_rpcb: | 274 | err_rpcb: |
275 | ln->nlmsvc_users--; | ||
275 | return error; | 276 | return error; |
276 | } | 277 | } |
277 | 278 | ||
@@ -299,6 +300,7 @@ int lockd_up(struct net *net) | |||
299 | { | 300 | { |
300 | struct svc_serv *serv; | 301 | struct svc_serv *serv; |
301 | int error = 0; | 302 | int error = 0; |
303 | struct lockd_net *ln = net_generic(net, lockd_net_id); | ||
302 | 304 | ||
303 | mutex_lock(&nlmsvc_mutex); | 305 | mutex_lock(&nlmsvc_mutex); |
304 | /* | 306 | /* |
@@ -330,9 +332,11 @@ int lockd_up(struct net *net) | |||
330 | goto destroy_and_out; | 332 | goto destroy_and_out; |
331 | } | 333 | } |
332 | 334 | ||
335 | ln->nlmsvc_users++; | ||
336 | |||
333 | error = make_socks(serv, net); | 337 | error = make_socks(serv, net); |
334 | if (error < 0) | 338 | if (error < 0) |
335 | goto destroy_and_out; | 339 | goto err_start; |
336 | 340 | ||
337 | /* | 341 | /* |
338 | * Create the kernel thread and wait for it to start. | 342 | * Create the kernel thread and wait for it to start. |
@@ -344,7 +348,7 @@ int lockd_up(struct net *net) | |||
344 | printk(KERN_WARNING | 348 | printk(KERN_WARNING |
345 | "lockd_up: svc_rqst allocation failed, error=%d\n", | 349 | "lockd_up: svc_rqst allocation failed, error=%d\n", |
346 | error); | 350 | error); |
347 | goto destroy_and_out; | 351 | goto err_start; |
348 | } | 352 | } |
349 | 353 | ||
350 | svc_sock_update_bufs(serv); | 354 | svc_sock_update_bufs(serv); |
@@ -358,7 +362,7 @@ int lockd_up(struct net *net) | |||
358 | nlmsvc_rqst = NULL; | 362 | nlmsvc_rqst = NULL; |
359 | printk(KERN_WARNING | 363 | printk(KERN_WARNING |
360 | "lockd_up: kthread_run failed, error=%d\n", error); | 364 | "lockd_up: kthread_run failed, error=%d\n", error); |
361 | goto destroy_and_out; | 365 | goto err_start; |
362 | } | 366 | } |
363 | 367 | ||
364 | /* | 368 | /* |
@@ -368,14 +372,14 @@ int lockd_up(struct net *net) | |||
368 | destroy_and_out: | 372 | destroy_and_out: |
369 | svc_destroy(serv); | 373 | svc_destroy(serv); |
370 | out: | 374 | out: |
371 | if (!error) { | 375 | if (!error) |
372 | struct lockd_net *ln = net_generic(net, lockd_net_id); | ||
373 | |||
374 | ln->nlmsvc_users++; | ||
375 | nlmsvc_users++; | 376 | nlmsvc_users++; |
376 | } | ||
377 | mutex_unlock(&nlmsvc_mutex); | 377 | mutex_unlock(&nlmsvc_mutex); |
378 | return error; | 378 | return error; |
379 | |||
380 | err_start: | ||
381 | lockd_down_net(net); | ||
382 | goto destroy_and_out; | ||
379 | } | 383 | } |
380 | EXPORT_SYMBOL_GPL(lockd_up); | 384 | EXPORT_SYMBOL_GPL(lockd_up); |
381 | 385 | ||
@@ -386,11 +390,10 @@ void | |||
386 | lockd_down(struct net *net) | 390 | lockd_down(struct net *net) |
387 | { | 391 | { |
388 | mutex_lock(&nlmsvc_mutex); | 392 | mutex_lock(&nlmsvc_mutex); |
393 | lockd_down_net(net); | ||
389 | if (nlmsvc_users) { | 394 | if (nlmsvc_users) { |
390 | if (--nlmsvc_users) { | 395 | if (--nlmsvc_users) |
391 | lockd_down_net(net); | ||
392 | goto out; | 396 | goto out; |
393 | } | ||
394 | } else { | 397 | } else { |
395 | printk(KERN_ERR "lockd_down: no users! task=%p\n", | 398 | printk(KERN_ERR "lockd_down: no users! task=%p\n", |
396 | nlmsvc_task); | 399 | nlmsvc_task); |