aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/rpc_pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/rpc_pipe.c')
-rw-r--r--net/sunrpc/rpc_pipe.c54
1 files changed, 31 insertions, 23 deletions
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