diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2011-12-26 07:43:57 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-01-31 18:20:25 -0500 |
commit | 9beae4677de76cfa4ce8899dc8cd1a1cf8cd8332 (patch) | |
tree | 5745aa9f5b40fcdb05aca68c186e4a329f3d911e /net/sunrpc/auth_gss | |
parent | d706ed1f50d3f7fae61a177183562179abe8e4bb (diff) |
SUNRPC: cleanup GSS pipes usage
Currently gss auth holds RPC inode pointer which is now redundant since it
requires only pipes operations which takes private pipe data as an argument.
Thus this code can be cleaned and all references to RPC inode can be replaced
with privtae pipe data references.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth_gss')
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 4157e3151581..304b8309f217 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -112,7 +112,7 @@ gss_put_ctx(struct gss_cl_ctx *ctx) | |||
112 | /* gss_cred_set_ctx: | 112 | /* gss_cred_set_ctx: |
113 | * called by gss_upcall_callback and gss_create_upcall in order | 113 | * called by gss_upcall_callback and gss_create_upcall in order |
114 | * to set the gss context. The actual exchange of an old context | 114 | * to set the gss context. The actual exchange of an old context |
115 | * and a new one is protected by the rpci->pipe->lock. | 115 | * and a new one is protected by the pipe->lock. |
116 | */ | 116 | */ |
117 | static void | 117 | static void |
118 | gss_cred_set_ctx(struct rpc_cred *cred, struct gss_cl_ctx *ctx) | 118 | gss_cred_set_ctx(struct rpc_cred *cred, struct gss_cl_ctx *ctx) |
@@ -251,7 +251,7 @@ struct gss_upcall_msg { | |||
251 | struct rpc_pipe_msg msg; | 251 | struct rpc_pipe_msg msg; |
252 | struct list_head list; | 252 | struct list_head list; |
253 | struct gss_auth *auth; | 253 | struct gss_auth *auth; |
254 | struct rpc_inode *inode; | 254 | struct rpc_pipe *pipe; |
255 | struct rpc_wait_queue rpc_waitqueue; | 255 | struct rpc_wait_queue rpc_waitqueue; |
256 | wait_queue_head_t waitqueue; | 256 | wait_queue_head_t waitqueue; |
257 | struct gss_cl_ctx *ctx; | 257 | struct gss_cl_ctx *ctx; |
@@ -294,10 +294,10 @@ gss_release_msg(struct gss_upcall_msg *gss_msg) | |||
294 | } | 294 | } |
295 | 295 | ||
296 | static struct gss_upcall_msg * | 296 | static struct gss_upcall_msg * |
297 | __gss_find_upcall(struct rpc_inode *rpci, uid_t uid) | 297 | __gss_find_upcall(struct rpc_pipe *pipe, uid_t uid) |
298 | { | 298 | { |
299 | struct gss_upcall_msg *pos; | 299 | struct gss_upcall_msg *pos; |
300 | list_for_each_entry(pos, &rpci->pipe->in_downcall, list) { | 300 | list_for_each_entry(pos, &pipe->in_downcall, list) { |
301 | if (pos->uid != uid) | 301 | if (pos->uid != uid) |
302 | continue; | 302 | continue; |
303 | atomic_inc(&pos->count); | 303 | atomic_inc(&pos->count); |
@@ -315,17 +315,17 @@ __gss_find_upcall(struct rpc_inode *rpci, uid_t uid) | |||
315 | static inline struct gss_upcall_msg * | 315 | static inline struct gss_upcall_msg * |
316 | gss_add_msg(struct gss_upcall_msg *gss_msg) | 316 | gss_add_msg(struct gss_upcall_msg *gss_msg) |
317 | { | 317 | { |
318 | struct rpc_inode *rpci = gss_msg->inode; | 318 | struct rpc_pipe *pipe = gss_msg->pipe; |
319 | struct gss_upcall_msg *old; | 319 | struct gss_upcall_msg *old; |
320 | 320 | ||
321 | spin_lock(&rpci->pipe->lock); | 321 | spin_lock(&pipe->lock); |
322 | old = __gss_find_upcall(rpci, gss_msg->uid); | 322 | old = __gss_find_upcall(pipe, gss_msg->uid); |
323 | if (old == NULL) { | 323 | if (old == NULL) { |
324 | atomic_inc(&gss_msg->count); | 324 | atomic_inc(&gss_msg->count); |
325 | list_add(&gss_msg->list, &rpci->pipe->in_downcall); | 325 | list_add(&gss_msg->list, &pipe->in_downcall); |
326 | } else | 326 | } else |
327 | gss_msg = old; | 327 | gss_msg = old; |
328 | spin_unlock(&rpci->pipe->lock); | 328 | spin_unlock(&pipe->lock); |
329 | return gss_msg; | 329 | return gss_msg; |
330 | } | 330 | } |
331 | 331 | ||
@@ -341,14 +341,14 @@ __gss_unhash_msg(struct gss_upcall_msg *gss_msg) | |||
341 | static void | 341 | static void |
342 | gss_unhash_msg(struct gss_upcall_msg *gss_msg) | 342 | gss_unhash_msg(struct gss_upcall_msg *gss_msg) |
343 | { | 343 | { |
344 | struct rpc_inode *rpci = gss_msg->inode; | 344 | struct rpc_pipe *pipe = gss_msg->pipe; |
345 | 345 | ||
346 | if (list_empty(&gss_msg->list)) | 346 | if (list_empty(&gss_msg->list)) |
347 | return; | 347 | return; |
348 | spin_lock(&rpci->pipe->lock); | 348 | spin_lock(&pipe->lock); |
349 | if (!list_empty(&gss_msg->list)) | 349 | if (!list_empty(&gss_msg->list)) |
350 | __gss_unhash_msg(gss_msg); | 350 | __gss_unhash_msg(gss_msg); |
351 | spin_unlock(&rpci->pipe->lock); | 351 | spin_unlock(&pipe->lock); |
352 | } | 352 | } |
353 | 353 | ||
354 | static void | 354 | static void |
@@ -375,11 +375,11 @@ gss_upcall_callback(struct rpc_task *task) | |||
375 | struct gss_cred *gss_cred = container_of(task->tk_rqstp->rq_cred, | 375 | struct gss_cred *gss_cred = container_of(task->tk_rqstp->rq_cred, |
376 | struct gss_cred, gc_base); | 376 | struct gss_cred, gc_base); |
377 | struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; | 377 | struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; |
378 | struct rpc_inode *rpci = gss_msg->inode; | 378 | struct rpc_pipe *pipe = gss_msg->pipe; |
379 | 379 | ||
380 | spin_lock(&rpci->pipe->lock); | 380 | spin_lock(&pipe->lock); |
381 | gss_handle_downcall_result(gss_cred, gss_msg); | 381 | gss_handle_downcall_result(gss_cred, gss_msg); |
382 | spin_unlock(&rpci->pipe->lock); | 382 | spin_unlock(&pipe->lock); |
383 | task->tk_status = gss_msg->msg.errno; | 383 | task->tk_status = gss_msg->msg.errno; |
384 | gss_release_msg(gss_msg); | 384 | gss_release_msg(gss_msg); |
385 | } | 385 | } |
@@ -449,7 +449,7 @@ gss_alloc_msg(struct gss_auth *gss_auth, struct rpc_clnt *clnt, | |||
449 | kfree(gss_msg); | 449 | kfree(gss_msg); |
450 | return ERR_PTR(vers); | 450 | return ERR_PTR(vers); |
451 | } | 451 | } |
452 | gss_msg->inode = RPC_I(gss_auth->dentry[vers]->d_inode); | 452 | gss_msg->pipe = RPC_I(gss_auth->dentry[vers]->d_inode)->pipe; |
453 | INIT_LIST_HEAD(&gss_msg->list); | 453 | INIT_LIST_HEAD(&gss_msg->list); |
454 | rpc_init_wait_queue(&gss_msg->rpc_waitqueue, "RPCSEC_GSS upcall waitq"); | 454 | rpc_init_wait_queue(&gss_msg->rpc_waitqueue, "RPCSEC_GSS upcall waitq"); |
455 | init_waitqueue_head(&gss_msg->waitqueue); | 455 | init_waitqueue_head(&gss_msg->waitqueue); |
@@ -473,7 +473,7 @@ gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cr | |||
473 | return gss_new; | 473 | return gss_new; |
474 | gss_msg = gss_add_msg(gss_new); | 474 | gss_msg = gss_add_msg(gss_new); |
475 | if (gss_msg == gss_new) { | 475 | if (gss_msg == gss_new) { |
476 | int res = rpc_queue_upcall(gss_new->inode->pipe, &gss_new->msg); | 476 | int res = rpc_queue_upcall(gss_new->pipe, &gss_new->msg); |
477 | if (res) { | 477 | if (res) { |
478 | gss_unhash_msg(gss_new); | 478 | gss_unhash_msg(gss_new); |
479 | gss_msg = ERR_PTR(res); | 479 | gss_msg = ERR_PTR(res); |
@@ -504,7 +504,7 @@ gss_refresh_upcall(struct rpc_task *task) | |||
504 | struct gss_cred *gss_cred = container_of(cred, | 504 | struct gss_cred *gss_cred = container_of(cred, |
505 | struct gss_cred, gc_base); | 505 | struct gss_cred, gc_base); |
506 | struct gss_upcall_msg *gss_msg; | 506 | struct gss_upcall_msg *gss_msg; |
507 | struct rpc_inode *rpci; | 507 | struct rpc_pipe *pipe; |
508 | int err = 0; | 508 | int err = 0; |
509 | 509 | ||
510 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, | 510 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, |
@@ -522,8 +522,8 @@ gss_refresh_upcall(struct rpc_task *task) | |||
522 | err = PTR_ERR(gss_msg); | 522 | err = PTR_ERR(gss_msg); |
523 | goto out; | 523 | goto out; |
524 | } | 524 | } |
525 | rpci = gss_msg->inode; | 525 | pipe = gss_msg->pipe; |
526 | spin_lock(&rpci->pipe->lock); | 526 | spin_lock(&pipe->lock); |
527 | if (gss_cred->gc_upcall != NULL) | 527 | if (gss_cred->gc_upcall != NULL) |
528 | rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL); | 528 | rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL); |
529 | else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { | 529 | else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { |
@@ -536,7 +536,7 @@ gss_refresh_upcall(struct rpc_task *task) | |||
536 | gss_handle_downcall_result(gss_cred, gss_msg); | 536 | gss_handle_downcall_result(gss_cred, gss_msg); |
537 | err = gss_msg->msg.errno; | 537 | err = gss_msg->msg.errno; |
538 | } | 538 | } |
539 | spin_unlock(&rpci->pipe->lock); | 539 | spin_unlock(&pipe->lock); |
540 | gss_release_msg(gss_msg); | 540 | gss_release_msg(gss_msg); |
541 | out: | 541 | out: |
542 | dprintk("RPC: %5u gss_refresh_upcall for uid %u result %d\n", | 542 | dprintk("RPC: %5u gss_refresh_upcall for uid %u result %d\n", |
@@ -547,7 +547,7 @@ out: | |||
547 | static inline int | 547 | static inline int |
548 | gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) | 548 | gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) |
549 | { | 549 | { |
550 | struct rpc_inode *rpci; | 550 | struct rpc_pipe *pipe; |
551 | struct rpc_cred *cred = &gss_cred->gc_base; | 551 | struct rpc_cred *cred = &gss_cred->gc_base; |
552 | struct gss_upcall_msg *gss_msg; | 552 | struct gss_upcall_msg *gss_msg; |
553 | DEFINE_WAIT(wait); | 553 | DEFINE_WAIT(wait); |
@@ -571,14 +571,14 @@ retry: | |||
571 | err = PTR_ERR(gss_msg); | 571 | err = PTR_ERR(gss_msg); |
572 | goto out; | 572 | goto out; |
573 | } | 573 | } |
574 | rpci = gss_msg->inode; | 574 | pipe = gss_msg->pipe; |
575 | for (;;) { | 575 | for (;;) { |
576 | prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE); | 576 | prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE); |
577 | spin_lock(&rpci->pipe->lock); | 577 | spin_lock(&pipe->lock); |
578 | if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { | 578 | if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { |
579 | break; | 579 | break; |
580 | } | 580 | } |
581 | spin_unlock(&rpci->pipe->lock); | 581 | spin_unlock(&pipe->lock); |
582 | if (fatal_signal_pending(current)) { | 582 | if (fatal_signal_pending(current)) { |
583 | err = -ERESTARTSYS; | 583 | err = -ERESTARTSYS; |
584 | goto out_intr; | 584 | goto out_intr; |
@@ -589,7 +589,7 @@ retry: | |||
589 | gss_cred_set_ctx(cred, gss_msg->ctx); | 589 | gss_cred_set_ctx(cred, gss_msg->ctx); |
590 | else | 590 | else |
591 | err = gss_msg->msg.errno; | 591 | err = gss_msg->msg.errno; |
592 | spin_unlock(&rpci->pipe->lock); | 592 | spin_unlock(&pipe->lock); |
593 | out_intr: | 593 | out_intr: |
594 | finish_wait(&gss_msg->waitqueue, &wait); | 594 | finish_wait(&gss_msg->waitqueue, &wait); |
595 | gss_release_msg(gss_msg); | 595 | gss_release_msg(gss_msg); |
@@ -607,7 +607,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
607 | const void *p, *end; | 607 | const void *p, *end; |
608 | void *buf; | 608 | void *buf; |
609 | struct gss_upcall_msg *gss_msg; | 609 | struct gss_upcall_msg *gss_msg; |
610 | struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode); | 610 | struct rpc_pipe *pipe = RPC_I(filp->f_dentry->d_inode)->pipe; |
611 | struct gss_cl_ctx *ctx; | 611 | struct gss_cl_ctx *ctx; |
612 | uid_t uid; | 612 | uid_t uid; |
613 | ssize_t err = -EFBIG; | 613 | ssize_t err = -EFBIG; |
@@ -637,14 +637,14 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
637 | 637 | ||
638 | err = -ENOENT; | 638 | err = -ENOENT; |
639 | /* Find a matching upcall */ | 639 | /* Find a matching upcall */ |
640 | spin_lock(&rpci->pipe->lock); | 640 | spin_lock(&pipe->lock); |
641 | gss_msg = __gss_find_upcall(rpci, uid); | 641 | gss_msg = __gss_find_upcall(pipe, uid); |
642 | if (gss_msg == NULL) { | 642 | if (gss_msg == NULL) { |
643 | spin_unlock(&rpci->pipe->lock); | 643 | spin_unlock(&pipe->lock); |
644 | goto err_put_ctx; | 644 | goto err_put_ctx; |
645 | } | 645 | } |
646 | list_del_init(&gss_msg->list); | 646 | list_del_init(&gss_msg->list); |
647 | spin_unlock(&rpci->pipe->lock); | 647 | spin_unlock(&pipe->lock); |
648 | 648 | ||
649 | p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); | 649 | p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); |
650 | if (IS_ERR(p)) { | 650 | if (IS_ERR(p)) { |
@@ -672,9 +672,9 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
672 | err = mlen; | 672 | err = mlen; |
673 | 673 | ||
674 | err_release_msg: | 674 | err_release_msg: |
675 | spin_lock(&rpci->pipe->lock); | 675 | spin_lock(&pipe->lock); |
676 | __gss_unhash_msg(gss_msg); | 676 | __gss_unhash_msg(gss_msg); |
677 | spin_unlock(&rpci->pipe->lock); | 677 | spin_unlock(&pipe->lock); |
678 | gss_release_msg(gss_msg); | 678 | gss_release_msg(gss_msg); |
679 | err_put_ctx: | 679 | err_put_ctx: |
680 | gss_put_ctx(ctx); | 680 | gss_put_ctx(ctx); |
@@ -720,23 +720,23 @@ static int gss_pipe_open_v1(struct inode *inode) | |||
720 | static void | 720 | static void |
721 | gss_pipe_release(struct inode *inode) | 721 | gss_pipe_release(struct inode *inode) |
722 | { | 722 | { |
723 | struct rpc_inode *rpci = RPC_I(inode); | 723 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
724 | struct gss_upcall_msg *gss_msg; | 724 | struct gss_upcall_msg *gss_msg; |
725 | 725 | ||
726 | restart: | 726 | restart: |
727 | spin_lock(&rpci->pipe->lock); | 727 | spin_lock(&pipe->lock); |
728 | list_for_each_entry(gss_msg, &rpci->pipe->in_downcall, list) { | 728 | list_for_each_entry(gss_msg, &pipe->in_downcall, list) { |
729 | 729 | ||
730 | if (!list_empty(&gss_msg->msg.list)) | 730 | if (!list_empty(&gss_msg->msg.list)) |
731 | continue; | 731 | continue; |
732 | gss_msg->msg.errno = -EPIPE; | 732 | gss_msg->msg.errno = -EPIPE; |
733 | atomic_inc(&gss_msg->count); | 733 | atomic_inc(&gss_msg->count); |
734 | __gss_unhash_msg(gss_msg); | 734 | __gss_unhash_msg(gss_msg); |
735 | spin_unlock(&rpci->pipe->lock); | 735 | spin_unlock(&pipe->lock); |
736 | gss_release_msg(gss_msg); | 736 | gss_release_msg(gss_msg); |
737 | goto restart; | 737 | goto restart; |
738 | } | 738 | } |
739 | spin_unlock(&rpci->pipe->lock); | 739 | spin_unlock(&pipe->lock); |
740 | 740 | ||
741 | put_pipe_version(); | 741 | put_pipe_version(); |
742 | } | 742 | } |