diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2011-12-26 07:43:23 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-01-31 18:20:24 -0500 |
commit | 766347bec3490111e1c4482af7c7394868c2aed1 (patch) | |
tree | afc06a17ceb7e7f1f0e119ec21e0102063b6992a /net/sunrpc/auth_gss | |
parent | efc46bf2b2893132e07628ad8c06e915f3281fdc (diff) |
SUNRPC: replace inode lock with pipe lock for RPC PipeFS operations
Currenly, inode i_lock is used to provide concurrent access to SUNPRC PipeFS
pipes. It looks redundant, since now other use of inode is present in most of
these places and thus can be easely replaced, which will allow to remove most
of inode references from PipeFS code. This is a first step towards to removing
PipeFS inode references from kernel code other than PipeFS itself.
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 | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index affa631ac1ab..a0844f92a447 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 inode->i_lock. | 115 | * and a new one is protected by the rpci->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) |
@@ -316,17 +316,16 @@ 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_inode *rpci = gss_msg->inode; |
319 | struct inode *inode = &rpci->vfs_inode; | ||
320 | struct gss_upcall_msg *old; | 319 | struct gss_upcall_msg *old; |
321 | 320 | ||
322 | spin_lock(&inode->i_lock); | 321 | spin_lock(&rpci->lock); |
323 | old = __gss_find_upcall(rpci, gss_msg->uid); | 322 | old = __gss_find_upcall(rpci, gss_msg->uid); |
324 | if (old == NULL) { | 323 | if (old == NULL) { |
325 | atomic_inc(&gss_msg->count); | 324 | atomic_inc(&gss_msg->count); |
326 | list_add(&gss_msg->list, &rpci->in_downcall); | 325 | list_add(&gss_msg->list, &rpci->in_downcall); |
327 | } else | 326 | } else |
328 | gss_msg = old; | 327 | gss_msg = old; |
329 | spin_unlock(&inode->i_lock); | 328 | spin_unlock(&rpci->lock); |
330 | return gss_msg; | 329 | return gss_msg; |
331 | } | 330 | } |
332 | 331 | ||
@@ -342,14 +341,14 @@ __gss_unhash_msg(struct gss_upcall_msg *gss_msg) | |||
342 | static void | 341 | static void |
343 | gss_unhash_msg(struct gss_upcall_msg *gss_msg) | 342 | gss_unhash_msg(struct gss_upcall_msg *gss_msg) |
344 | { | 343 | { |
345 | struct inode *inode = &gss_msg->inode->vfs_inode; | 344 | struct rpc_inode *rpci = gss_msg->inode; |
346 | 345 | ||
347 | if (list_empty(&gss_msg->list)) | 346 | if (list_empty(&gss_msg->list)) |
348 | return; | 347 | return; |
349 | spin_lock(&inode->i_lock); | 348 | spin_lock(&rpci->lock); |
350 | if (!list_empty(&gss_msg->list)) | 349 | if (!list_empty(&gss_msg->list)) |
351 | __gss_unhash_msg(gss_msg); | 350 | __gss_unhash_msg(gss_msg); |
352 | spin_unlock(&inode->i_lock); | 351 | spin_unlock(&rpci->lock); |
353 | } | 352 | } |
354 | 353 | ||
355 | static void | 354 | static void |
@@ -376,11 +375,11 @@ gss_upcall_callback(struct rpc_task *task) | |||
376 | 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, |
377 | struct gss_cred, gc_base); | 376 | struct gss_cred, gc_base); |
378 | struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; | 377 | struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; |
379 | struct inode *inode = &gss_msg->inode->vfs_inode; | 378 | struct rpc_inode *rpci = gss_msg->inode; |
380 | 379 | ||
381 | spin_lock(&inode->i_lock); | 380 | spin_lock(&rpci->lock); |
382 | gss_handle_downcall_result(gss_cred, gss_msg); | 381 | gss_handle_downcall_result(gss_cred, gss_msg); |
383 | spin_unlock(&inode->i_lock); | 382 | spin_unlock(&rpci->lock); |
384 | task->tk_status = gss_msg->msg.errno; | 383 | task->tk_status = gss_msg->msg.errno; |
385 | gss_release_msg(gss_msg); | 384 | gss_release_msg(gss_msg); |
386 | } | 385 | } |
@@ -506,7 +505,7 @@ gss_refresh_upcall(struct rpc_task *task) | |||
506 | struct gss_cred *gss_cred = container_of(cred, | 505 | struct gss_cred *gss_cred = container_of(cred, |
507 | struct gss_cred, gc_base); | 506 | struct gss_cred, gc_base); |
508 | struct gss_upcall_msg *gss_msg; | 507 | struct gss_upcall_msg *gss_msg; |
509 | struct inode *inode; | 508 | struct rpc_inode *rpci; |
510 | int err = 0; | 509 | int err = 0; |
511 | 510 | ||
512 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, | 511 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, |
@@ -524,8 +523,8 @@ gss_refresh_upcall(struct rpc_task *task) | |||
524 | err = PTR_ERR(gss_msg); | 523 | err = PTR_ERR(gss_msg); |
525 | goto out; | 524 | goto out; |
526 | } | 525 | } |
527 | inode = &gss_msg->inode->vfs_inode; | 526 | rpci = gss_msg->inode; |
528 | spin_lock(&inode->i_lock); | 527 | spin_lock(&rpci->lock); |
529 | if (gss_cred->gc_upcall != NULL) | 528 | if (gss_cred->gc_upcall != NULL) |
530 | rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL); | 529 | rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL); |
531 | else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { | 530 | else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { |
@@ -538,7 +537,7 @@ gss_refresh_upcall(struct rpc_task *task) | |||
538 | gss_handle_downcall_result(gss_cred, gss_msg); | 537 | gss_handle_downcall_result(gss_cred, gss_msg); |
539 | err = gss_msg->msg.errno; | 538 | err = gss_msg->msg.errno; |
540 | } | 539 | } |
541 | spin_unlock(&inode->i_lock); | 540 | spin_unlock(&rpci->lock); |
542 | gss_release_msg(gss_msg); | 541 | gss_release_msg(gss_msg); |
543 | out: | 542 | out: |
544 | dprintk("RPC: %5u gss_refresh_upcall for uid %u result %d\n", | 543 | dprintk("RPC: %5u gss_refresh_upcall for uid %u result %d\n", |
@@ -549,7 +548,7 @@ out: | |||
549 | static inline int | 548 | static inline int |
550 | gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) | 549 | gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) |
551 | { | 550 | { |
552 | struct inode *inode; | 551 | struct rpc_inode *rpci; |
553 | struct rpc_cred *cred = &gss_cred->gc_base; | 552 | struct rpc_cred *cred = &gss_cred->gc_base; |
554 | struct gss_upcall_msg *gss_msg; | 553 | struct gss_upcall_msg *gss_msg; |
555 | DEFINE_WAIT(wait); | 554 | DEFINE_WAIT(wait); |
@@ -573,14 +572,14 @@ retry: | |||
573 | err = PTR_ERR(gss_msg); | 572 | err = PTR_ERR(gss_msg); |
574 | goto out; | 573 | goto out; |
575 | } | 574 | } |
576 | inode = &gss_msg->inode->vfs_inode; | 575 | rpci = gss_msg->inode; |
577 | for (;;) { | 576 | for (;;) { |
578 | prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE); | 577 | prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE); |
579 | spin_lock(&inode->i_lock); | 578 | spin_lock(&rpci->lock); |
580 | if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { | 579 | if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { |
581 | break; | 580 | break; |
582 | } | 581 | } |
583 | spin_unlock(&inode->i_lock); | 582 | spin_unlock(&rpci->lock); |
584 | if (fatal_signal_pending(current)) { | 583 | if (fatal_signal_pending(current)) { |
585 | err = -ERESTARTSYS; | 584 | err = -ERESTARTSYS; |
586 | goto out_intr; | 585 | goto out_intr; |
@@ -591,7 +590,7 @@ retry: | |||
591 | gss_cred_set_ctx(cred, gss_msg->ctx); | 590 | gss_cred_set_ctx(cred, gss_msg->ctx); |
592 | else | 591 | else |
593 | err = gss_msg->msg.errno; | 592 | err = gss_msg->msg.errno; |
594 | spin_unlock(&inode->i_lock); | 593 | spin_unlock(&rpci->lock); |
595 | out_intr: | 594 | out_intr: |
596 | finish_wait(&gss_msg->waitqueue, &wait); | 595 | finish_wait(&gss_msg->waitqueue, &wait); |
597 | gss_release_msg(gss_msg); | 596 | gss_release_msg(gss_msg); |
@@ -609,7 +608,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
609 | const void *p, *end; | 608 | const void *p, *end; |
610 | void *buf; | 609 | void *buf; |
611 | struct gss_upcall_msg *gss_msg; | 610 | struct gss_upcall_msg *gss_msg; |
612 | struct inode *inode = filp->f_path.dentry->d_inode; | 611 | struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode); |
613 | struct gss_cl_ctx *ctx; | 612 | struct gss_cl_ctx *ctx; |
614 | uid_t uid; | 613 | uid_t uid; |
615 | ssize_t err = -EFBIG; | 614 | ssize_t err = -EFBIG; |
@@ -639,14 +638,14 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
639 | 638 | ||
640 | err = -ENOENT; | 639 | err = -ENOENT; |
641 | /* Find a matching upcall */ | 640 | /* Find a matching upcall */ |
642 | spin_lock(&inode->i_lock); | 641 | spin_lock(&rpci->lock); |
643 | gss_msg = __gss_find_upcall(RPC_I(inode), uid); | 642 | gss_msg = __gss_find_upcall(rpci, uid); |
644 | if (gss_msg == NULL) { | 643 | if (gss_msg == NULL) { |
645 | spin_unlock(&inode->i_lock); | 644 | spin_unlock(&rpci->lock); |
646 | goto err_put_ctx; | 645 | goto err_put_ctx; |
647 | } | 646 | } |
648 | list_del_init(&gss_msg->list); | 647 | list_del_init(&gss_msg->list); |
649 | spin_unlock(&inode->i_lock); | 648 | spin_unlock(&rpci->lock); |
650 | 649 | ||
651 | p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); | 650 | p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); |
652 | if (IS_ERR(p)) { | 651 | if (IS_ERR(p)) { |
@@ -674,9 +673,9 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
674 | err = mlen; | 673 | err = mlen; |
675 | 674 | ||
676 | err_release_msg: | 675 | err_release_msg: |
677 | spin_lock(&inode->i_lock); | 676 | spin_lock(&rpci->lock); |
678 | __gss_unhash_msg(gss_msg); | 677 | __gss_unhash_msg(gss_msg); |
679 | spin_unlock(&inode->i_lock); | 678 | spin_unlock(&rpci->lock); |
680 | gss_release_msg(gss_msg); | 679 | gss_release_msg(gss_msg); |
681 | err_put_ctx: | 680 | err_put_ctx: |
682 | gss_put_ctx(ctx); | 681 | gss_put_ctx(ctx); |
@@ -726,7 +725,7 @@ gss_pipe_release(struct inode *inode) | |||
726 | struct gss_upcall_msg *gss_msg; | 725 | struct gss_upcall_msg *gss_msg; |
727 | 726 | ||
728 | restart: | 727 | restart: |
729 | spin_lock(&inode->i_lock); | 728 | spin_lock(&rpci->lock); |
730 | list_for_each_entry(gss_msg, &rpci->in_downcall, list) { | 729 | list_for_each_entry(gss_msg, &rpci->in_downcall, list) { |
731 | 730 | ||
732 | if (!list_empty(&gss_msg->msg.list)) | 731 | if (!list_empty(&gss_msg->msg.list)) |
@@ -734,11 +733,11 @@ restart: | |||
734 | gss_msg->msg.errno = -EPIPE; | 733 | gss_msg->msg.errno = -EPIPE; |
735 | atomic_inc(&gss_msg->count); | 734 | atomic_inc(&gss_msg->count); |
736 | __gss_unhash_msg(gss_msg); | 735 | __gss_unhash_msg(gss_msg); |
737 | spin_unlock(&inode->i_lock); | 736 | spin_unlock(&rpci->lock); |
738 | gss_release_msg(gss_msg); | 737 | gss_release_msg(gss_msg); |
739 | goto restart; | 738 | goto restart; |
740 | } | 739 | } |
741 | spin_unlock(&inode->i_lock); | 740 | spin_unlock(&rpci->lock); |
742 | 741 | ||
743 | put_pipe_version(); | 742 | put_pipe_version(); |
744 | } | 743 | } |