SUNRPC/NFS: make rpc pipe upcall generic
authorPeng Tao <bergwolf@gmail.com>
Fri, 23 Sep 2011 01:50:10 +0000 (21:50 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 18 Oct 2011 16:08:12 +0000 (09:08 -0700)
The same function is used by idmap, gss and blocklayout code. Make it
generic.

Signed-off-by: Peng Tao <peng_tao@emc.com>
Signed-off-by: Jim Rees <rees@umich.edu>
Cc: stable@kernel.org [3.0]
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/blocklayout/blocklayout.c
fs/nfs/blocklayout/blocklayout.h
fs/nfs/blocklayout/blocklayoutdev.c
fs/nfs/idmap.c
include/linux/sunrpc/rpc_pipe_fs.h
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/rpc_pipe.c

index d2432f0dc40c1835044a88519840515776cdbb41..dc23833c02317c130b45b8541b22a4f23e8d4df3 100644 (file)
@@ -964,7 +964,7 @@ static struct pnfs_layoutdriver_type blocklayout_type = {
 };
 
 static const struct rpc_pipe_ops bl_upcall_ops = {
-       .upcall         = bl_pipe_upcall,
+       .upcall         = rpc_pipe_generic_upcall,
        .downcall       = bl_pipe_downcall,
        .destroy_msg    = bl_pipe_destroy_msg,
 };
index 58dc256402e3b9ac74a5210a1a80023a82ec0053..42acf7ef59926d61ce0b4a12e208585d928a9aad 100644 (file)
@@ -169,8 +169,6 @@ extern wait_queue_head_t bl_wq;
 #define BL_DEVICE_REQUEST_ERR          0x2 /* User level process fails */
 
 /* blocklayoutdev.c */
-ssize_t bl_pipe_upcall(struct file *, struct rpc_pipe_msg *,
-                      char __user *, size_t);
 ssize_t bl_pipe_downcall(struct file *, const char __user *, size_t);
 void bl_pipe_destroy_msg(struct rpc_pipe_msg *);
 struct block_device *nfs4_blkdev_get(dev_t dev);
index 0b1fb0e25b9383c31cd31398d744be7ba4c06cbc..d08ba9107fde2fa5c608a9b581cc4f7e12e5cb4f 100644 (file)
@@ -79,28 +79,6 @@ int nfs4_blkdev_put(struct block_device *bdev)
        return blkdev_put(bdev, FMODE_READ);
 }
 
-/*
- * Shouldn't there be a rpc_generic_upcall() to do this for us?
- */
-ssize_t bl_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
-                      char __user *dst, size_t buflen)
-{
-       char *data = (char *)msg->data + msg->copied;
-       size_t mlen = min(msg->len - msg->copied, buflen);
-       unsigned long left;
-
-       left = copy_to_user(dst, data, mlen);
-       if (left == mlen) {
-               msg->errno = -EFAULT;
-               return -EFAULT;
-       }
-
-       mlen -= left;
-       msg->copied += mlen;
-       msg->errno = 0;
-       return mlen;
-}
-
 static struct bl_dev_msg bl_mount_reply;
 
 ssize_t bl_pipe_downcall(struct file *filp, const char __user *src,
index f20801ae0a16582850f95e03f148d5b704b720aa..47d1c6ff2d8e845625e60fbcf3ba5cf65786282e 100644 (file)
@@ -336,8 +336,6 @@ struct idmap {
        struct idmap_hashtable  idmap_group_hash;
 };
 
-static ssize_t idmap_pipe_upcall(struct file *, struct rpc_pipe_msg *,
-                                char __user *, size_t);
 static ssize_t idmap_pipe_downcall(struct file *, const char __user *,
                                   size_t);
 static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *);
@@ -345,7 +343,7 @@ static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *);
 static unsigned int fnvhash32(const void *, size_t);
 
 static const struct rpc_pipe_ops idmap_upcall_ops = {
-       .upcall         = idmap_pipe_upcall,
+       .upcall         = rpc_pipe_generic_upcall,
        .downcall       = idmap_pipe_downcall,
        .destroy_msg    = idmap_pipe_destroy_msg,
 };
@@ -595,27 +593,6 @@ nfs_idmap_name(struct idmap *idmap, struct idmap_hashtable *h,
        return ret;
 }
 
-/* RPC pipefs upcall/downcall routines */
-static ssize_t
-idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
-                 char __user *dst, size_t buflen)
-{
-       char *data = (char *)msg->data + msg->copied;
-       size_t mlen = min(msg->len, buflen);
-       unsigned long left;
-
-       left = copy_to_user(dst, data, mlen);
-       if (left == mlen) {
-               msg->errno = -EFAULT;
-               return -EFAULT;
-       }
-
-       mlen -= left;
-       msg->copied += mlen;
-       msg->errno = 0;
-       return mlen;
-}
-
 static ssize_t
 idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
 {
index cf14db975da00b6e8031e7ffe1780e7cc9c88832..e4ea43058d8f5af1763a455a62b0adc76181442f 100644 (file)
@@ -44,6 +44,8 @@ RPC_I(struct inode *inode)
        return container_of(inode, struct rpc_inode, vfs_inode);
 }
 
+extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
+                                      char __user *, size_t);
 extern int rpc_queue_upcall(struct inode *, struct rpc_pipe_msg *);
 
 struct rpc_clnt;
index 364eb45e989d6c4fbdc70c182c032cb59b6270b3..e9b76939268d45a82e1f129ed304ac49ae8be697 100644 (file)
@@ -603,26 +603,6 @@ out:
        return err;
 }
 
-static ssize_t
-gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
-               char __user *dst, size_t buflen)
-{
-       char *data = (char *)msg->data + msg->copied;
-       size_t mlen = min(msg->len, buflen);
-       unsigned long left;
-
-       left = copy_to_user(dst, data, mlen);
-       if (left == mlen) {
-               msg->errno = -EFAULT;
-               return -EFAULT;
-       }
-
-       mlen -= left;
-       msg->copied += mlen;
-       msg->errno = 0;
-       return mlen;
-}
-
 #define MSG_BUF_MAXSIZE 1024
 
 static ssize_t
@@ -1590,7 +1570,7 @@ static const struct rpc_credops gss_nullops = {
 };
 
 static const struct rpc_pipe_ops gss_upcall_ops_v0 = {
-       .upcall         = gss_pipe_upcall,
+       .upcall         = rpc_pipe_generic_upcall,
        .downcall       = gss_pipe_downcall,
        .destroy_msg    = gss_pipe_destroy_msg,
        .open_pipe      = gss_pipe_open_v0,
@@ -1598,7 +1578,7 @@ static const struct rpc_pipe_ops gss_upcall_ops_v0 = {
 };
 
 static const struct rpc_pipe_ops gss_upcall_ops_v1 = {
-       .upcall         = gss_pipe_upcall,
+       .upcall         = rpc_pipe_generic_upcall,
        .downcall       = gss_pipe_downcall,
        .destroy_msg    = gss_pipe_destroy_msg,
        .open_pipe      = gss_pipe_open_v1,
index b181e3441323e4bfc5aff8831055a3641b29a421..67dbc1884383d545893d08cba87071d33c8c70eb 100644 (file)
@@ -77,6 +77,26 @@ rpc_timeout_upcall_queue(struct work_struct *work)
        rpc_purge_list(rpci, &free_list, destroy_msg, -ETIMEDOUT);
 }
 
+ssize_t rpc_pipe_generic_upcall(struct file *filp, struct rpc_pipe_msg *msg,
+                               char __user *dst, size_t buflen)
+{
+       char *data = (char *)msg->data + msg->copied;
+       size_t mlen = min(msg->len - msg->copied, buflen);
+       unsigned long left;
+
+       left = copy_to_user(dst, data, mlen);
+       if (left == mlen) {
+               msg->errno = -EFAULT;
+               return -EFAULT;
+       }
+
+       mlen -= left;
+       msg->copied += mlen;
+       msg->errno = 0;
+       return mlen;
+}
+EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall);
+
 /**
  * rpc_queue_upcall - queue an upcall message to userspace
  * @inode: inode of upcall pipe on which to queue given message
This page took 0.035066 seconds and 5 git commands to generate.