]>
Commit | Line | Data |
---|---|---|
4bc507ef GKH |
1 | From c1225158a8dad9e9d5eee8a17dbbd9c7cda05ab9 Mon Sep 17 00:00:00 2001 |
2 | From: Peng Tao <bergwolf@gmail.com> | |
3 | Date: Thu, 22 Sep 2011 21:50:10 -0400 | |
4 | Subject: SUNRPC/NFS: make rpc pipe upcall generic | |
5 | ||
6 | From: Peng Tao <bergwolf@gmail.com> | |
7 | ||
8 | commit c1225158a8dad9e9d5eee8a17dbbd9c7cda05ab9 upstream. | |
9 | ||
10 | The same function is used by idmap, gss and blocklayout code. Make it | |
11 | generic. | |
12 | ||
13 | Signed-off-by: Peng Tao <peng_tao@emc.com> | |
14 | Signed-off-by: Jim Rees <rees@umich.edu> | |
15 | Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> | |
16 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
17 | ||
18 | --- | |
19 | fs/nfs/blocklayout/blocklayout.c | 2 +- | |
20 | fs/nfs/blocklayout/blocklayout.h | 2 -- | |
21 | fs/nfs/blocklayout/blocklayoutdev.c | 22 ---------------------- | |
22 | fs/nfs/idmap.c | 25 +------------------------ | |
23 | include/linux/sunrpc/rpc_pipe_fs.h | 2 ++ | |
24 | net/sunrpc/auth_gss/auth_gss.c | 24 ++---------------------- | |
25 | net/sunrpc/rpc_pipe.c | 20 ++++++++++++++++++++ | |
26 | 7 files changed, 26 insertions(+), 71 deletions(-) | |
27 | ||
28 | --- a/fs/nfs/blocklayout/blocklayout.c | |
29 | +++ b/fs/nfs/blocklayout/blocklayout.c | |
30 | @@ -960,7 +960,7 @@ static struct pnfs_layoutdriver_type blo | |
31 | }; | |
32 | ||
33 | static const struct rpc_pipe_ops bl_upcall_ops = { | |
34 | - .upcall = bl_pipe_upcall, | |
35 | + .upcall = rpc_pipe_generic_upcall, | |
36 | .downcall = bl_pipe_downcall, | |
37 | .destroy_msg = bl_pipe_destroy_msg, | |
38 | }; | |
39 | --- a/fs/nfs/blocklayout/blocklayout.h | |
40 | +++ b/fs/nfs/blocklayout/blocklayout.h | |
41 | @@ -169,8 +169,6 @@ extern wait_queue_head_t bl_wq; | |
42 | #define BL_DEVICE_REQUEST_ERR 0x2 /* User level process fails */ | |
43 | ||
44 | /* blocklayoutdev.c */ | |
45 | -ssize_t bl_pipe_upcall(struct file *, struct rpc_pipe_msg *, | |
46 | - char __user *, size_t); | |
47 | ssize_t bl_pipe_downcall(struct file *, const char __user *, size_t); | |
48 | void bl_pipe_destroy_msg(struct rpc_pipe_msg *); | |
49 | struct block_device *nfs4_blkdev_get(dev_t dev); | |
50 | --- a/fs/nfs/blocklayout/blocklayoutdev.c | |
51 | +++ b/fs/nfs/blocklayout/blocklayoutdev.c | |
52 | @@ -79,28 +79,6 @@ int nfs4_blkdev_put(struct block_device | |
53 | return blkdev_put(bdev, FMODE_READ); | |
54 | } | |
55 | ||
56 | -/* | |
57 | - * Shouldn't there be a rpc_generic_upcall() to do this for us? | |
58 | - */ | |
59 | -ssize_t bl_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, | |
60 | - char __user *dst, size_t buflen) | |
61 | -{ | |
62 | - char *data = (char *)msg->data + msg->copied; | |
63 | - size_t mlen = min(msg->len - msg->copied, buflen); | |
64 | - unsigned long left; | |
65 | - | |
66 | - left = copy_to_user(dst, data, mlen); | |
67 | - if (left == mlen) { | |
68 | - msg->errno = -EFAULT; | |
69 | - return -EFAULT; | |
70 | - } | |
71 | - | |
72 | - mlen -= left; | |
73 | - msg->copied += mlen; | |
74 | - msg->errno = 0; | |
75 | - return mlen; | |
76 | -} | |
77 | - | |
78 | static struct bl_dev_msg bl_mount_reply; | |
79 | ||
80 | ssize_t bl_pipe_downcall(struct file *filp, const char __user *src, | |
81 | --- a/fs/nfs/idmap.c | |
82 | +++ b/fs/nfs/idmap.c | |
83 | @@ -336,8 +336,6 @@ struct idmap { | |
84 | struct idmap_hashtable idmap_group_hash; | |
85 | }; | |
86 | ||
87 | -static ssize_t idmap_pipe_upcall(struct file *, struct rpc_pipe_msg *, | |
88 | - char __user *, size_t); | |
89 | static ssize_t idmap_pipe_downcall(struct file *, const char __user *, | |
90 | size_t); | |
91 | static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *); | |
92 | @@ -345,7 +343,7 @@ static void idmap_pipe_destroy_msg(struc | |
93 | static unsigned int fnvhash32(const void *, size_t); | |
94 | ||
95 | static const struct rpc_pipe_ops idmap_upcall_ops = { | |
96 | - .upcall = idmap_pipe_upcall, | |
97 | + .upcall = rpc_pipe_generic_upcall, | |
98 | .downcall = idmap_pipe_downcall, | |
99 | .destroy_msg = idmap_pipe_destroy_msg, | |
100 | }; | |
101 | @@ -595,27 +593,6 @@ nfs_idmap_name(struct idmap *idmap, stru | |
102 | return ret; | |
103 | } | |
104 | ||
105 | -/* RPC pipefs upcall/downcall routines */ | |
106 | -static ssize_t | |
107 | -idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, | |
108 | - char __user *dst, size_t buflen) | |
109 | -{ | |
110 | - char *data = (char *)msg->data + msg->copied; | |
111 | - size_t mlen = min(msg->len, buflen); | |
112 | - unsigned long left; | |
113 | - | |
114 | - left = copy_to_user(dst, data, mlen); | |
115 | - if (left == mlen) { | |
116 | - msg->errno = -EFAULT; | |
117 | - return -EFAULT; | |
118 | - } | |
119 | - | |
120 | - mlen -= left; | |
121 | - msg->copied += mlen; | |
122 | - msg->errno = 0; | |
123 | - return mlen; | |
124 | -} | |
125 | - | |
126 | static ssize_t | |
127 | idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |
128 | { | |
129 | --- a/include/linux/sunrpc/rpc_pipe_fs.h | |
130 | +++ b/include/linux/sunrpc/rpc_pipe_fs.h | |
131 | @@ -44,6 +44,8 @@ RPC_I(struct inode *inode) | |
132 | return container_of(inode, struct rpc_inode, vfs_inode); | |
133 | } | |
134 | ||
135 | +extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, | |
136 | + char __user *, size_t); | |
137 | extern int rpc_queue_upcall(struct inode *, struct rpc_pipe_msg *); | |
138 | ||
139 | struct rpc_clnt; | |
140 | --- a/net/sunrpc/auth_gss/auth_gss.c | |
141 | +++ b/net/sunrpc/auth_gss/auth_gss.c | |
142 | @@ -603,26 +603,6 @@ out: | |
143 | return err; | |
144 | } | |
145 | ||
146 | -static ssize_t | |
147 | -gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, | |
148 | - char __user *dst, size_t buflen) | |
149 | -{ | |
150 | - char *data = (char *)msg->data + msg->copied; | |
151 | - size_t mlen = min(msg->len, buflen); | |
152 | - unsigned long left; | |
153 | - | |
154 | - left = copy_to_user(dst, data, mlen); | |
155 | - if (left == mlen) { | |
156 | - msg->errno = -EFAULT; | |
157 | - return -EFAULT; | |
158 | - } | |
159 | - | |
160 | - mlen -= left; | |
161 | - msg->copied += mlen; | |
162 | - msg->errno = 0; | |
163 | - return mlen; | |
164 | -} | |
165 | - | |
166 | #define MSG_BUF_MAXSIZE 1024 | |
167 | ||
168 | static ssize_t | |
169 | @@ -1590,7 +1570,7 @@ static const struct rpc_credops gss_null | |
170 | }; | |
171 | ||
172 | static const struct rpc_pipe_ops gss_upcall_ops_v0 = { | |
173 | - .upcall = gss_pipe_upcall, | |
174 | + .upcall = rpc_pipe_generic_upcall, | |
175 | .downcall = gss_pipe_downcall, | |
176 | .destroy_msg = gss_pipe_destroy_msg, | |
177 | .open_pipe = gss_pipe_open_v0, | |
178 | @@ -1598,7 +1578,7 @@ static const struct rpc_pipe_ops gss_upc | |
179 | }; | |
180 | ||
181 | static const struct rpc_pipe_ops gss_upcall_ops_v1 = { | |
182 | - .upcall = gss_pipe_upcall, | |
183 | + .upcall = rpc_pipe_generic_upcall, | |
184 | .downcall = gss_pipe_downcall, | |
185 | .destroy_msg = gss_pipe_destroy_msg, | |
186 | .open_pipe = gss_pipe_open_v1, | |
187 | --- a/net/sunrpc/rpc_pipe.c | |
188 | +++ b/net/sunrpc/rpc_pipe.c | |
189 | @@ -77,6 +77,26 @@ rpc_timeout_upcall_queue(struct work_str | |
190 | rpc_purge_list(rpci, &free_list, destroy_msg, -ETIMEDOUT); | |
191 | } | |
192 | ||
193 | +ssize_t rpc_pipe_generic_upcall(struct file *filp, struct rpc_pipe_msg *msg, | |
194 | + char __user *dst, size_t buflen) | |
195 | +{ | |
196 | + char *data = (char *)msg->data + msg->copied; | |
197 | + size_t mlen = min(msg->len - msg->copied, buflen); | |
198 | + unsigned long left; | |
199 | + | |
200 | + left = copy_to_user(dst, data, mlen); | |
201 | + if (left == mlen) { | |
202 | + msg->errno = -EFAULT; | |
203 | + return -EFAULT; | |
204 | + } | |
205 | + | |
206 | + mlen -= left; | |
207 | + msg->copied += mlen; | |
208 | + msg->errno = 0; | |
209 | + return mlen; | |
210 | +} | |
211 | +EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall); | |
212 | + | |
213 | /** | |
214 | * rpc_queue_upcall - queue an upcall message to userspace | |
215 | * @inode: inode of upcall pipe on which to queue given message |