diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2011-12-26 07:43:41 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-01-31 18:20:24 -0500 |
commit | d0fe13ba9178d3bb78bbd8577bdedc00f76b7a66 (patch) | |
tree | 365e3cae07542d2cf252fa638d00ae010eaadd61 | |
parent | ba9e097593f371ebd102580a0c5b1b2cf55636a0 (diff) |
SUNRPC: cleanup PipeFS redundant RPC inode usage
This patch removes redundant RPC inode references from PipeFS. These places are
actually where pipes operations are performed.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | net/sunrpc/rpc_pipe.c | 93 |
1 files changed, 46 insertions, 47 deletions
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index b6f6555128db..299b1a3c3e49 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -132,28 +132,28 @@ EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall); | |||
132 | int | 132 | int |
133 | rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg) | 133 | rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg) |
134 | { | 134 | { |
135 | struct rpc_inode *rpci = RPC_I(inode); | 135 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
136 | int res = -EPIPE; | 136 | int res = -EPIPE; |
137 | 137 | ||
138 | spin_lock(&rpci->pipe->lock); | 138 | spin_lock(&pipe->lock); |
139 | if (rpci->pipe->ops == NULL) | 139 | if (pipe->ops == NULL) |
140 | goto out; | 140 | goto out; |
141 | if (rpci->pipe->nreaders) { | 141 | if (pipe->nreaders) { |
142 | list_add_tail(&msg->list, &rpci->pipe->pipe); | 142 | list_add_tail(&msg->list, &pipe->pipe); |
143 | rpci->pipe->pipelen += msg->len; | 143 | pipe->pipelen += msg->len; |
144 | res = 0; | 144 | res = 0; |
145 | } else if (rpci->pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) { | 145 | } else if (pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) { |
146 | if (list_empty(&rpci->pipe->pipe)) | 146 | if (list_empty(&pipe->pipe)) |
147 | queue_delayed_work(rpciod_workqueue, | 147 | queue_delayed_work(rpciod_workqueue, |
148 | &rpci->pipe->queue_timeout, | 148 | &pipe->queue_timeout, |
149 | RPC_UPCALL_TIMEOUT); | 149 | RPC_UPCALL_TIMEOUT); |
150 | list_add_tail(&msg->list, &rpci->pipe->pipe); | 150 | list_add_tail(&msg->list, &pipe->pipe); |
151 | rpci->pipe->pipelen += msg->len; | 151 | pipe->pipelen += msg->len; |
152 | res = 0; | 152 | res = 0; |
153 | } | 153 | } |
154 | out: | 154 | out: |
155 | spin_unlock(&rpci->pipe->lock); | 155 | spin_unlock(&pipe->lock); |
156 | wake_up(&rpci->pipe->waitq); | 156 | wake_up(&pipe->waitq); |
157 | return res; | 157 | return res; |
158 | } | 158 | } |
159 | EXPORT_SYMBOL_GPL(rpc_queue_upcall); | 159 | EXPORT_SYMBOL_GPL(rpc_queue_upcall); |
@@ -220,23 +220,23 @@ rpc_destroy_inode(struct inode *inode) | |||
220 | static int | 220 | static int |
221 | rpc_pipe_open(struct inode *inode, struct file *filp) | 221 | rpc_pipe_open(struct inode *inode, struct file *filp) |
222 | { | 222 | { |
223 | struct rpc_inode *rpci = RPC_I(inode); | 223 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
224 | int first_open; | 224 | int first_open; |
225 | int res = -ENXIO; | 225 | int res = -ENXIO; |
226 | 226 | ||
227 | mutex_lock(&inode->i_mutex); | 227 | mutex_lock(&inode->i_mutex); |
228 | if (rpci->pipe->ops == NULL) | 228 | if (pipe->ops == NULL) |
229 | goto out; | 229 | goto out; |
230 | first_open = rpci->pipe->nreaders == 0 && rpci->pipe->nwriters == 0; | 230 | first_open = pipe->nreaders == 0 && pipe->nwriters == 0; |
231 | if (first_open && rpci->pipe->ops->open_pipe) { | 231 | if (first_open && pipe->ops->open_pipe) { |
232 | res = rpci->pipe->ops->open_pipe(inode); | 232 | res = pipe->ops->open_pipe(inode); |
233 | if (res) | 233 | if (res) |
234 | goto out; | 234 | goto out; |
235 | } | 235 | } |
236 | if (filp->f_mode & FMODE_READ) | 236 | if (filp->f_mode & FMODE_READ) |
237 | rpci->pipe->nreaders++; | 237 | pipe->nreaders++; |
238 | if (filp->f_mode & FMODE_WRITE) | 238 | if (filp->f_mode & FMODE_WRITE) |
239 | rpci->pipe->nwriters++; | 239 | pipe->nwriters++; |
240 | res = 0; | 240 | res = 0; |
241 | out: | 241 | out: |
242 | mutex_unlock(&inode->i_mutex); | 242 | mutex_unlock(&inode->i_mutex); |
@@ -287,39 +287,39 @@ static ssize_t | |||
287 | rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset) | 287 | rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset) |
288 | { | 288 | { |
289 | struct inode *inode = filp->f_path.dentry->d_inode; | 289 | struct inode *inode = filp->f_path.dentry->d_inode; |
290 | struct rpc_inode *rpci = RPC_I(inode); | 290 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
291 | struct rpc_pipe_msg *msg; | 291 | struct rpc_pipe_msg *msg; |
292 | int res = 0; | 292 | int res = 0; |
293 | 293 | ||
294 | mutex_lock(&inode->i_mutex); | 294 | mutex_lock(&inode->i_mutex); |
295 | if (rpci->pipe->ops == NULL) { | 295 | if (pipe->ops == NULL) { |
296 | res = -EPIPE; | 296 | res = -EPIPE; |
297 | goto out_unlock; | 297 | goto out_unlock; |
298 | } | 298 | } |
299 | msg = filp->private_data; | 299 | msg = filp->private_data; |
300 | if (msg == NULL) { | 300 | if (msg == NULL) { |
301 | spin_lock(&rpci->pipe->lock); | 301 | spin_lock(&pipe->lock); |
302 | if (!list_empty(&rpci->pipe->pipe)) { | 302 | if (!list_empty(&pipe->pipe)) { |
303 | msg = list_entry(rpci->pipe->pipe.next, | 303 | msg = list_entry(pipe->pipe.next, |
304 | struct rpc_pipe_msg, | 304 | struct rpc_pipe_msg, |
305 | list); | 305 | list); |
306 | list_move(&msg->list, &rpci->pipe->in_upcall); | 306 | list_move(&msg->list, &pipe->in_upcall); |
307 | rpci->pipe->pipelen -= msg->len; | 307 | pipe->pipelen -= msg->len; |
308 | filp->private_data = msg; | 308 | filp->private_data = msg; |
309 | msg->copied = 0; | 309 | msg->copied = 0; |
310 | } | 310 | } |
311 | spin_unlock(&rpci->pipe->lock); | 311 | spin_unlock(&pipe->lock); |
312 | if (msg == NULL) | 312 | if (msg == NULL) |
313 | goto out_unlock; | 313 | goto out_unlock; |
314 | } | 314 | } |
315 | /* NOTE: it is up to the callback to update msg->copied */ | 315 | /* NOTE: it is up to the callback to update msg->copied */ |
316 | res = rpci->pipe->ops->upcall(filp, msg, buf, len); | 316 | res = pipe->ops->upcall(filp, msg, buf, len); |
317 | if (res < 0 || msg->len == msg->copied) { | 317 | if (res < 0 || msg->len == msg->copied) { |
318 | filp->private_data = NULL; | 318 | filp->private_data = NULL; |
319 | spin_lock(&rpci->pipe->lock); | 319 | spin_lock(&pipe->lock); |
320 | list_del_init(&msg->list); | 320 | list_del_init(&msg->list); |
321 | spin_unlock(&rpci->pipe->lock); | 321 | spin_unlock(&pipe->lock); |
322 | rpci->pipe->ops->destroy_msg(msg); | 322 | pipe->ops->destroy_msg(msg); |
323 | } | 323 | } |
324 | out_unlock: | 324 | out_unlock: |
325 | mutex_unlock(&inode->i_mutex); | 325 | mutex_unlock(&inode->i_mutex); |
@@ -330,13 +330,13 @@ static ssize_t | |||
330 | rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset) | 330 | rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset) |
331 | { | 331 | { |
332 | struct inode *inode = filp->f_path.dentry->d_inode; | 332 | struct inode *inode = filp->f_path.dentry->d_inode; |
333 | struct rpc_inode *rpci = RPC_I(inode); | 333 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
334 | int res; | 334 | int res; |
335 | 335 | ||
336 | mutex_lock(&inode->i_mutex); | 336 | mutex_lock(&inode->i_mutex); |
337 | res = -EPIPE; | 337 | res = -EPIPE; |
338 | if (rpci->pipe->ops != NULL) | 338 | if (pipe->ops != NULL) |
339 | res = rpci->pipe->ops->downcall(filp, buf, len); | 339 | res = pipe->ops->downcall(filp, buf, len); |
340 | mutex_unlock(&inode->i_mutex); | 340 | mutex_unlock(&inode->i_mutex); |
341 | return res; | 341 | return res; |
342 | } | 342 | } |
@@ -344,16 +344,15 @@ rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *of | |||
344 | static unsigned int | 344 | static unsigned int |
345 | rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait) | 345 | rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait) |
346 | { | 346 | { |
347 | struct rpc_inode *rpci; | 347 | struct rpc_pipe *pipe = RPC_I(filp->f_path.dentry->d_inode)->pipe; |
348 | unsigned int mask = 0; | 348 | unsigned int mask = 0; |
349 | 349 | ||
350 | rpci = RPC_I(filp->f_path.dentry->d_inode); | 350 | poll_wait(filp, &pipe->waitq, wait); |
351 | poll_wait(filp, &rpci->pipe->waitq, wait); | ||
352 | 351 | ||
353 | mask = POLLOUT | POLLWRNORM; | 352 | mask = POLLOUT | POLLWRNORM; |
354 | if (rpci->pipe->ops == NULL) | 353 | if (pipe->ops == NULL) |
355 | mask |= POLLERR | POLLHUP; | 354 | mask |= POLLERR | POLLHUP; |
356 | if (filp->private_data || !list_empty(&rpci->pipe->pipe)) | 355 | if (filp->private_data || !list_empty(&pipe->pipe)) |
357 | mask |= POLLIN | POLLRDNORM; | 356 | mask |= POLLIN | POLLRDNORM; |
358 | return mask; | 357 | return mask; |
359 | } | 358 | } |
@@ -362,23 +361,23 @@ static long | |||
362 | rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 361 | rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
363 | { | 362 | { |
364 | struct inode *inode = filp->f_path.dentry->d_inode; | 363 | struct inode *inode = filp->f_path.dentry->d_inode; |
365 | struct rpc_inode *rpci = RPC_I(inode); | 364 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
366 | int len; | 365 | int len; |
367 | 366 | ||
368 | switch (cmd) { | 367 | switch (cmd) { |
369 | case FIONREAD: | 368 | case FIONREAD: |
370 | spin_lock(&rpci->pipe->lock); | 369 | spin_lock(&pipe->lock); |
371 | if (rpci->pipe->ops == NULL) { | 370 | if (pipe->ops == NULL) { |
372 | spin_unlock(&rpci->pipe->lock); | 371 | spin_unlock(&pipe->lock); |
373 | return -EPIPE; | 372 | return -EPIPE; |
374 | } | 373 | } |
375 | len = rpci->pipe->pipelen; | 374 | len = pipe->pipelen; |
376 | if (filp->private_data) { | 375 | if (filp->private_data) { |
377 | struct rpc_pipe_msg *msg; | 376 | struct rpc_pipe_msg *msg; |
378 | msg = filp->private_data; | 377 | msg = filp->private_data; |
379 | len += msg->len - msg->copied; | 378 | len += msg->len - msg->copied; |
380 | } | 379 | } |
381 | spin_unlock(&rpci->pipe->lock); | 380 | spin_unlock(&pipe->lock); |
382 | return put_user(len, (int __user *)arg); | 381 | return put_user(len, (int __user *)arg); |
383 | default: | 382 | default: |
384 | return -EINVAL; | 383 | return -EINVAL; |
@@ -808,7 +807,7 @@ static int rpc_rmdir_depopulate(struct dentry *dentry, | |||
808 | * @private: private data to associate with the pipe, for the caller's use | 807 | * @private: private data to associate with the pipe, for the caller's use |
809 | * @ops: operations defining the behavior of the pipe: upcall, downcall, | 808 | * @ops: operations defining the behavior of the pipe: upcall, downcall, |
810 | * release_pipe, open_pipe, and destroy_msg. | 809 | * release_pipe, open_pipe, and destroy_msg. |
811 | * @flags: rpc_inode flags | 810 | * @flags: rpc_pipe flags |
812 | * | 811 | * |
813 | * Data is made available for userspace to read by calls to | 812 | * Data is made available for userspace to read by calls to |
814 | * rpc_queue_upcall(). The actual reads will result in calls to | 813 | * rpc_queue_upcall(). The actual reads will result in calls to |