Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC/NFS: make rpc pipe upcall generic

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>

authored by

Peng Tao and committed by
Trond Myklebust
c1225158 fdc17abb

+26 -71
+1 -1
fs/nfs/blocklayout/blocklayout.c
··· 964 964 }; 965 965 966 966 static const struct rpc_pipe_ops bl_upcall_ops = { 967 - .upcall = bl_pipe_upcall, 967 + .upcall = rpc_pipe_generic_upcall, 968 968 .downcall = bl_pipe_downcall, 969 969 .destroy_msg = bl_pipe_destroy_msg, 970 970 };
-2
fs/nfs/blocklayout/blocklayout.h
··· 169 169 #define BL_DEVICE_REQUEST_ERR 0x2 /* User level process fails */ 170 170 171 171 /* blocklayoutdev.c */ 172 - ssize_t bl_pipe_upcall(struct file *, struct rpc_pipe_msg *, 173 - char __user *, size_t); 174 172 ssize_t bl_pipe_downcall(struct file *, const char __user *, size_t); 175 173 void bl_pipe_destroy_msg(struct rpc_pipe_msg *); 176 174 struct block_device *nfs4_blkdev_get(dev_t dev);
-22
fs/nfs/blocklayout/blocklayoutdev.c
··· 79 79 return blkdev_put(bdev, FMODE_READ); 80 80 } 81 81 82 - /* 83 - * Shouldn't there be a rpc_generic_upcall() to do this for us? 84 - */ 85 - ssize_t bl_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, 86 - char __user *dst, size_t buflen) 87 - { 88 - char *data = (char *)msg->data + msg->copied; 89 - size_t mlen = min(msg->len - msg->copied, buflen); 90 - unsigned long left; 91 - 92 - left = copy_to_user(dst, data, mlen); 93 - if (left == mlen) { 94 - msg->errno = -EFAULT; 95 - return -EFAULT; 96 - } 97 - 98 - mlen -= left; 99 - msg->copied += mlen; 100 - msg->errno = 0; 101 - return mlen; 102 - } 103 - 104 82 static struct bl_dev_msg bl_mount_reply; 105 83 106 84 ssize_t bl_pipe_downcall(struct file *filp, const char __user *src,
+1 -24
fs/nfs/idmap.c
··· 336 336 struct idmap_hashtable idmap_group_hash; 337 337 }; 338 338 339 - static ssize_t idmap_pipe_upcall(struct file *, struct rpc_pipe_msg *, 340 - char __user *, size_t); 341 339 static ssize_t idmap_pipe_downcall(struct file *, const char __user *, 342 340 size_t); 343 341 static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *); ··· 343 345 static unsigned int fnvhash32(const void *, size_t); 344 346 345 347 static const struct rpc_pipe_ops idmap_upcall_ops = { 346 - .upcall = idmap_pipe_upcall, 348 + .upcall = rpc_pipe_generic_upcall, 347 349 .downcall = idmap_pipe_downcall, 348 350 .destroy_msg = idmap_pipe_destroy_msg, 349 351 }; ··· 591 593 mutex_unlock(&idmap->idmap_im_lock); 592 594 mutex_unlock(&idmap->idmap_lock); 593 595 return ret; 594 - } 595 - 596 - /* RPC pipefs upcall/downcall routines */ 597 - static ssize_t 598 - idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, 599 - char __user *dst, size_t buflen) 600 - { 601 - char *data = (char *)msg->data + msg->copied; 602 - size_t mlen = min(msg->len, buflen); 603 - unsigned long left; 604 - 605 - left = copy_to_user(dst, data, mlen); 606 - if (left == mlen) { 607 - msg->errno = -EFAULT; 608 - return -EFAULT; 609 - } 610 - 611 - mlen -= left; 612 - msg->copied += mlen; 613 - msg->errno = 0; 614 - return mlen; 615 596 } 616 597 617 598 static ssize_t
+2
include/linux/sunrpc/rpc_pipe_fs.h
··· 44 44 return container_of(inode, struct rpc_inode, vfs_inode); 45 45 } 46 46 47 + extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, 48 + char __user *, size_t); 47 49 extern int rpc_queue_upcall(struct inode *, struct rpc_pipe_msg *); 48 50 49 51 struct rpc_clnt;
+2 -22
net/sunrpc/auth_gss/auth_gss.c
··· 603 603 return err; 604 604 } 605 605 606 - static ssize_t 607 - gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, 608 - char __user *dst, size_t buflen) 609 - { 610 - char *data = (char *)msg->data + msg->copied; 611 - size_t mlen = min(msg->len, buflen); 612 - unsigned long left; 613 - 614 - left = copy_to_user(dst, data, mlen); 615 - if (left == mlen) { 616 - msg->errno = -EFAULT; 617 - return -EFAULT; 618 - } 619 - 620 - mlen -= left; 621 - msg->copied += mlen; 622 - msg->errno = 0; 623 - return mlen; 624 - } 625 - 626 606 #define MSG_BUF_MAXSIZE 1024 627 607 628 608 static ssize_t ··· 1570 1590 }; 1571 1591 1572 1592 static const struct rpc_pipe_ops gss_upcall_ops_v0 = { 1573 - .upcall = gss_pipe_upcall, 1593 + .upcall = rpc_pipe_generic_upcall, 1574 1594 .downcall = gss_pipe_downcall, 1575 1595 .destroy_msg = gss_pipe_destroy_msg, 1576 1596 .open_pipe = gss_pipe_open_v0, ··· 1578 1598 }; 1579 1599 1580 1600 static const struct rpc_pipe_ops gss_upcall_ops_v1 = { 1581 - .upcall = gss_pipe_upcall, 1601 + .upcall = rpc_pipe_generic_upcall, 1582 1602 .downcall = gss_pipe_downcall, 1583 1603 .destroy_msg = gss_pipe_destroy_msg, 1584 1604 .open_pipe = gss_pipe_open_v1,
+20
net/sunrpc/rpc_pipe.c
··· 77 77 rpc_purge_list(rpci, &free_list, destroy_msg, -ETIMEDOUT); 78 78 } 79 79 80 + ssize_t rpc_pipe_generic_upcall(struct file *filp, struct rpc_pipe_msg *msg, 81 + char __user *dst, size_t buflen) 82 + { 83 + char *data = (char *)msg->data + msg->copied; 84 + size_t mlen = min(msg->len - msg->copied, buflen); 85 + unsigned long left; 86 + 87 + left = copy_to_user(dst, data, mlen); 88 + if (left == mlen) { 89 + msg->errno = -EFAULT; 90 + return -EFAULT; 91 + } 92 + 93 + mlen -= left; 94 + msg->copied += mlen; 95 + msg->errno = 0; 96 + return mlen; 97 + } 98 + EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall); 99 + 80 100 /** 81 101 * rpc_queue_upcall - queue an upcall message to userspace 82 102 * @inode: inode of upcall pipe on which to queue given message