aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2011-12-26 07:44:06 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 18:20:25 -0500
commitc239d83b9921b8a8005a3bcd23000cfe18acf5c2 (patch)
treec94e20d8f286e63a2e75b15d413c3a8c5da45b8d /net
parent9beae4677de76cfa4ce8899dc8cd1a1cf8cd8332 (diff)
SUNRPC: split SUNPRC PipeFS dentry and private pipe data creation
This patch is a final step towards to removing PipeFS inode references from kernel code other than PipeFS itself. It makes all kernel SUNRPC PipeFS users depends on pipe private data, which state depend on their specific operations, etc. This patch completes SUNRPC PipeFS preparations and allows to create pipe private data and PipeFS dentries independently. Next step will be making SUNPRC PipeFS dentries allocated by SUNRPC PipeFS network namespace aware routines. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c54
-rw-r--r--net/sunrpc/rpc_pipe.c54
2 files changed, 67 insertions, 41 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 304b8309f217..f684ce606667 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -81,7 +81,7 @@ struct gss_auth {
81 * mechanism (for example, "krb5") and exists for 81 * mechanism (for example, "krb5") and exists for
82 * backwards-compatibility with older gssd's. 82 * backwards-compatibility with older gssd's.
83 */ 83 */
84 struct dentry *dentry[2]; 84 struct rpc_pipe *pipe[2];
85}; 85};
86 86
87/* pipe_version >= 0 if and only if someone has a pipe open. */ 87/* pipe_version >= 0 if and only if someone has a pipe open. */
@@ -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->pipe = RPC_I(gss_auth->dentry[vers]->d_inode)->pipe; 452 gss_msg->pipe = gss_auth->pipe[vers];
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);
@@ -799,21 +799,33 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
799 * that we supported only the old pipe. So we instead create 799 * that we supported only the old pipe. So we instead create
800 * the new pipe first. 800 * the new pipe first.
801 */ 801 */
802 gss_auth->dentry[1] = rpc_mkpipe(clnt->cl_path.dentry, 802 gss_auth->pipe[1] = rpc_mkpipe_data(&gss_upcall_ops_v1,
803 "gssd", 803 RPC_PIPE_WAIT_FOR_OPEN);
804 clnt, &gss_upcall_ops_v1, 804 if (IS_ERR(gss_auth->pipe[1])) {
805 RPC_PIPE_WAIT_FOR_OPEN); 805 err = PTR_ERR(gss_auth->pipe[1]);
806 if (IS_ERR(gss_auth->dentry[1])) {
807 err = PTR_ERR(gss_auth->dentry[1]);
808 goto err_put_mech; 806 goto err_put_mech;
809 } 807 }
810 808
811 gss_auth->dentry[0] = rpc_mkpipe(clnt->cl_path.dentry, 809 gss_auth->pipe[0] = rpc_mkpipe_data(&gss_upcall_ops_v0,
812 gss_auth->mech->gm_name, 810 RPC_PIPE_WAIT_FOR_OPEN);
813 clnt, &gss_upcall_ops_v0, 811 if (IS_ERR(gss_auth->pipe[0])) {
814 RPC_PIPE_WAIT_FOR_OPEN); 812 err = PTR_ERR(gss_auth->pipe[0]);
815 if (IS_ERR(gss_auth->dentry[0])) { 813 goto err_destroy_pipe_1;
816 err = PTR_ERR(gss_auth->dentry[0]); 814 }
815
816 gss_auth->pipe[1]->dentry = rpc_mkpipe_dentry(clnt->cl_path.dentry,
817 "gssd",
818 clnt, gss_auth->pipe[1]);
819 if (IS_ERR(gss_auth->pipe[1]->dentry)) {
820 err = PTR_ERR(gss_auth->pipe[1]->dentry);
821 goto err_destroy_pipe_0;
822 }
823
824 gss_auth->pipe[0]->dentry = rpc_mkpipe_dentry(clnt->cl_path.dentry,
825 gss_auth->mech->gm_name,
826 clnt, gss_auth->pipe[0]);
827 if (IS_ERR(gss_auth->pipe[0]->dentry)) {
828 err = PTR_ERR(gss_auth->pipe[0]->dentry);
817 goto err_unlink_pipe_1; 829 goto err_unlink_pipe_1;
818 } 830 }
819 err = rpcauth_init_credcache(auth); 831 err = rpcauth_init_credcache(auth);
@@ -822,9 +834,13 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
822 834
823 return auth; 835 return auth;
824err_unlink_pipe_0: 836err_unlink_pipe_0:
825 rpc_unlink(gss_auth->dentry[0]); 837 rpc_unlink(gss_auth->pipe[0]->dentry);
826err_unlink_pipe_1: 838err_unlink_pipe_1:
827 rpc_unlink(gss_auth->dentry[1]); 839 rpc_unlink(gss_auth->pipe[1]->dentry);
840err_destroy_pipe_0:
841 rpc_destroy_pipe_data(gss_auth->pipe[0]);
842err_destroy_pipe_1:
843 rpc_destroy_pipe_data(gss_auth->pipe[1]);
828err_put_mech: 844err_put_mech:
829 gss_mech_put(gss_auth->mech); 845 gss_mech_put(gss_auth->mech);
830err_free: 846err_free:
@@ -837,8 +853,10 @@ out_dec:
837static void 853static void
838gss_free(struct gss_auth *gss_auth) 854gss_free(struct gss_auth *gss_auth)
839{ 855{
840 rpc_unlink(gss_auth->dentry[1]); 856 rpc_unlink(gss_auth->pipe[0]->dentry);
841 rpc_unlink(gss_auth->dentry[0]); 857 rpc_unlink(gss_auth->pipe[1]->dentry);
858 rpc_destroy_pipe_data(gss_auth->pipe[0]);
859 rpc_destroy_pipe_data(gss_auth->pipe[1]);
842 gss_mech_put(gss_auth->mech); 860 gss_mech_put(gss_auth->mech);
843 861
844 kfree(gss_auth); 862 kfree(gss_auth);
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 4093da79d512..6dd8b96e8df7 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -206,7 +206,6 @@ static void
206rpc_i_callback(struct rcu_head *head) 206rpc_i_callback(struct rcu_head *head)
207{ 207{
208 struct inode *inode = container_of(head, struct inode, i_rcu); 208 struct inode *inode = container_of(head, struct inode, i_rcu);
209 kfree(RPC_I(inode)->pipe);
210 kmem_cache_free(rpc_inode_cachep, RPC_I(inode)); 209 kmem_cache_free(rpc_inode_cachep, RPC_I(inode));
211} 210}
212 211
@@ -575,34 +574,44 @@ init_pipe(struct rpc_pipe *pipe)
575 rpc_timeout_upcall_queue); 574 rpc_timeout_upcall_queue);
576 pipe->ops = NULL; 575 pipe->ops = NULL;
577 spin_lock_init(&pipe->lock); 576 spin_lock_init(&pipe->lock);
577 pipe->dentry = NULL;
578}
578 579
580void rpc_destroy_pipe_data(struct rpc_pipe *pipe)
581{
582 kfree(pipe);
579} 583}
584EXPORT_SYMBOL_GPL(rpc_destroy_pipe_data);
580 585
581static int __rpc_mkpipe(struct inode *dir, struct dentry *dentry, 586struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags)
582 umode_t mode,
583 const struct file_operations *i_fop,
584 void *private,
585 const struct rpc_pipe_ops *ops,
586 int flags)
587{ 587{
588 struct rpc_pipe *pipe; 588 struct rpc_pipe *pipe;
589 struct rpc_inode *rpci;
590 int err;
591 589
592 pipe = kzalloc(sizeof(struct rpc_pipe), GFP_KERNEL); 590 pipe = kzalloc(sizeof(struct rpc_pipe), GFP_KERNEL);
593 if (!pipe) 591 if (!pipe)
594 return -ENOMEM; 592 return ERR_PTR(-ENOMEM);
595 init_pipe(pipe); 593 init_pipe(pipe);
594 pipe->ops = ops;
595 pipe->flags = flags;
596 return pipe;
597}
598EXPORT_SYMBOL_GPL(rpc_mkpipe_data);
599
600static int __rpc_mkpipe_dentry(struct inode *dir, struct dentry *dentry,
601 umode_t mode,
602 const struct file_operations *i_fop,
603 void *private,
604 struct rpc_pipe *pipe)
605{
606 struct rpc_inode *rpci;
607 int err;
608
596 err = __rpc_create_common(dir, dentry, S_IFIFO | mode, i_fop, private); 609 err = __rpc_create_common(dir, dentry, S_IFIFO | mode, i_fop, private);
597 if (err) { 610 if (err)
598 kfree(pipe);
599 return err; 611 return err;
600 }
601 rpci = RPC_I(dentry->d_inode); 612 rpci = RPC_I(dentry->d_inode);
602 rpci->private = private; 613 rpci->private = private;
603 rpci->pipe = pipe; 614 rpci->pipe = pipe;
604 rpci->pipe->flags = flags;
605 rpci->pipe->ops = ops;
606 fsnotify_create(dir, dentry); 615 fsnotify_create(dir, dentry);
607 return 0; 616 return 0;
608} 617}
@@ -819,9 +828,8 @@ static int rpc_rmdir_depopulate(struct dentry *dentry,
819 * The @private argument passed here will be available to all these methods 828 * The @private argument passed here will be available to all these methods
820 * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private. 829 * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private.
821 */ 830 */
822struct dentry *rpc_mkpipe(struct dentry *parent, const char *name, 831struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name,
823 void *private, const struct rpc_pipe_ops *ops, 832 void *private, struct rpc_pipe *pipe)
824 int flags)
825{ 833{
826 struct dentry *dentry; 834 struct dentry *dentry;
827 struct inode *dir = parent->d_inode; 835 struct inode *dir = parent->d_inode;
@@ -829,9 +837,9 @@ struct dentry *rpc_mkpipe(struct dentry *parent, const char *name,
829 struct qstr q; 837 struct qstr q;
830 int err; 838 int err;
831 839
832 if (ops->upcall == NULL) 840 if (pipe->ops->upcall == NULL)
833 umode &= ~S_IRUGO; 841 umode &= ~S_IRUGO;
834 if (ops->downcall == NULL) 842 if (pipe->ops->downcall == NULL)
835 umode &= ~S_IWUGO; 843 umode &= ~S_IWUGO;
836 844
837 q.name = name; 845 q.name = name;
@@ -842,8 +850,8 @@ struct dentry *rpc_mkpipe(struct dentry *parent, const char *name,
842 dentry = __rpc_lookup_create_exclusive(parent, &q); 850 dentry = __rpc_lookup_create_exclusive(parent, &q);
843 if (IS_ERR(dentry)) 851 if (IS_ERR(dentry))
844 goto out; 852 goto out;
845 err = __rpc_mkpipe(dir, dentry, umode, &rpc_pipe_fops, 853 err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops,
846 private, ops, flags); 854 private, pipe);
847 if (err) 855 if (err)
848 goto out_err; 856 goto out_err;
849out: 857out:
@@ -856,7 +864,7 @@ out_err:
856 err); 864 err);
857 goto out; 865 goto out;
858} 866}
859EXPORT_SYMBOL_GPL(rpc_mkpipe); 867EXPORT_SYMBOL_GPL(rpc_mkpipe_dentry);
860 868
861/** 869/**
862 * rpc_unlink - remove a pipe 870 * rpc_unlink - remove a pipe