Commit 5ecebb7c7fd737cf387a552994df319c063973db
Committed by
Trond Myklebust
1 parent
bee42f688c
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
SUNRPC: unregister service on creation in current network namespace
On service shutdown we can be sure, that no more users of it left except current. Thus it looks like using current network namespace context is safe in this case. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 3 changed files with 14 additions and 13 deletions Side-by-side Diff
fs/nfsd/nfssvc.c
... | ... | @@ -251,13 +251,13 @@ |
251 | 251 | nfsd_up = false; |
252 | 252 | } |
253 | 253 | |
254 | -static void nfsd_last_thread(struct svc_serv *serv) | |
254 | +static void nfsd_last_thread(struct svc_serv *serv, struct net *net) | |
255 | 255 | { |
256 | 256 | /* When last nfsd thread exits we need to do some clean-up */ |
257 | 257 | nfsd_serv = NULL; |
258 | 258 | nfsd_shutdown(); |
259 | 259 | |
260 | - svc_rpcb_cleanup(serv); | |
260 | + svc_rpcb_cleanup(serv, net); | |
261 | 261 | |
262 | 262 | printk(KERN_WARNING "nfsd: last server has exited, flushing export " |
263 | 263 | "cache\n"); |
include/linux/sunrpc/svc.h
... | ... | @@ -84,7 +84,8 @@ |
84 | 84 | unsigned int sv_nrpools; /* number of thread pools */ |
85 | 85 | struct svc_pool * sv_pools; /* array of thread pools */ |
86 | 86 | |
87 | - void (*sv_shutdown)(struct svc_serv *serv); | |
87 | + void (*sv_shutdown)(struct svc_serv *serv, | |
88 | + struct net *net); | |
88 | 89 | /* Callback to use when last thread |
89 | 90 | * exits. |
90 | 91 | */ |
91 | 92 | |
92 | 93 | |
... | ... | @@ -413,14 +414,14 @@ |
413 | 414 | /* |
414 | 415 | * Function prototypes. |
415 | 416 | */ |
416 | -void svc_rpcb_cleanup(struct svc_serv *serv); | |
417 | +void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net); | |
417 | 418 | struct svc_serv *svc_create(struct svc_program *, unsigned int, |
418 | - void (*shutdown)(struct svc_serv *)); | |
419 | + void (*shutdown)(struct svc_serv *, struct net *net)); | |
419 | 420 | struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, |
420 | 421 | struct svc_pool *pool, int node); |
421 | 422 | void svc_exit_thread(struct svc_rqst *); |
422 | 423 | struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, |
423 | - void (*shutdown)(struct svc_serv *), | |
424 | + void (*shutdown)(struct svc_serv *, struct net *net), | |
424 | 425 | svc_thread_fn, struct module *); |
425 | 426 | int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); |
426 | 427 | int svc_pool_stats_open(struct svc_serv *serv, struct file *file); |
net/sunrpc/svc.c
... | ... | @@ -382,10 +382,10 @@ |
382 | 382 | return 0; |
383 | 383 | } |
384 | 384 | |
385 | -void svc_rpcb_cleanup(struct svc_serv *serv) | |
385 | +void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net) | |
386 | 386 | { |
387 | - svc_unregister(serv, &init_net); | |
388 | - rpcb_put_local(&init_net); | |
387 | + svc_unregister(serv, net); | |
388 | + rpcb_put_local(net); | |
389 | 389 | } |
390 | 390 | EXPORT_SYMBOL_GPL(svc_rpcb_cleanup); |
391 | 391 | |
... | ... | @@ -411,7 +411,7 @@ |
411 | 411 | */ |
412 | 412 | static struct svc_serv * |
413 | 413 | __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, |
414 | - void (*shutdown)(struct svc_serv *serv)) | |
414 | + void (*shutdown)(struct svc_serv *serv, struct net *net)) | |
415 | 415 | { |
416 | 416 | struct svc_serv *serv; |
417 | 417 | unsigned int vers; |
... | ... | @@ -485,7 +485,7 @@ |
485 | 485 | |
486 | 486 | struct svc_serv * |
487 | 487 | svc_create(struct svc_program *prog, unsigned int bufsize, |
488 | - void (*shutdown)(struct svc_serv *serv)) | |
488 | + void (*shutdown)(struct svc_serv *serv, struct net *net)) | |
489 | 489 | { |
490 | 490 | return __svc_create(prog, bufsize, /*npools*/1, shutdown); |
491 | 491 | } |
... | ... | @@ -493,7 +493,7 @@ |
493 | 493 | |
494 | 494 | struct svc_serv * |
495 | 495 | svc_create_pooled(struct svc_program *prog, unsigned int bufsize, |
496 | - void (*shutdown)(struct svc_serv *serv), | |
496 | + void (*shutdown)(struct svc_serv *serv, struct net *net), | |
497 | 497 | svc_thread_fn func, struct module *mod) |
498 | 498 | { |
499 | 499 | struct svc_serv *serv; |
... | ... | @@ -542,7 +542,7 @@ |
542 | 542 | svc_close_all(serv); |
543 | 543 | |
544 | 544 | if (serv->sv_shutdown) |
545 | - serv->sv_shutdown(serv); | |
545 | + serv->sv_shutdown(serv, current->nsproxy->net_ns); | |
546 | 546 | |
547 | 547 | cache_clean_deferred(serv); |
548 | 548 |