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.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9a881138fead..16d9b9a701a4 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -83,12 +83,11 @@ rpc_timeout_upcall_queue(struct work_struct *work)
83 LIST_HEAD(free_list); 83 LIST_HEAD(free_list);
84 struct rpc_inode *rpci = 84 struct rpc_inode *rpci =
85 container_of(work, struct rpc_inode, queue_timeout.work); 85 container_of(work, struct rpc_inode, queue_timeout.work);
86 struct inode *inode = &rpci->vfs_inode;
87 void (*destroy_msg)(struct rpc_pipe_msg *); 86 void (*destroy_msg)(struct rpc_pipe_msg *);
88 87
89 spin_lock(&inode->i_lock); 88 spin_lock(&rpci->lock);
90 if (rpci->ops == NULL) { 89 if (rpci->ops == NULL) {
91 spin_unlock(&inode->i_lock); 90 spin_unlock(&rpci->lock);
92 return; 91 return;
93 } 92 }
94 destroy_msg = rpci->ops->destroy_msg; 93 destroy_msg = rpci->ops->destroy_msg;
@@ -96,7 +95,7 @@ rpc_timeout_upcall_queue(struct work_struct *work)
96 list_splice_init(&rpci->pipe, &free_list); 95 list_splice_init(&rpci->pipe, &free_list);
97 rpci->pipelen = 0; 96 rpci->pipelen = 0;
98 } 97 }
99 spin_unlock(&inode->i_lock); 98 spin_unlock(&rpci->lock);
100 rpc_purge_list(rpci, &free_list, destroy_msg, -ETIMEDOUT); 99 rpc_purge_list(rpci, &free_list, destroy_msg, -ETIMEDOUT);
101} 100}
102 101
@@ -136,7 +135,7 @@ rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
136 struct rpc_inode *rpci = RPC_I(inode); 135 struct rpc_inode *rpci = RPC_I(inode);
137 int res = -EPIPE; 136 int res = -EPIPE;
138 137
139 spin_lock(&inode->i_lock); 138 spin_lock(&rpci->lock);
140 if (rpci->ops == NULL) 139 if (rpci->ops == NULL)
141 goto out; 140 goto out;
142 if (rpci->nreaders) { 141 if (rpci->nreaders) {
@@ -153,7 +152,7 @@ rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
153 res = 0; 152 res = 0;
154 } 153 }
155out: 154out:
156 spin_unlock(&inode->i_lock); 155 spin_unlock(&rpci->lock);
157 wake_up(&rpci->waitq); 156 wake_up(&rpci->waitq);
158 return res; 157 return res;
159} 158}
@@ -176,14 +175,14 @@ rpc_close_pipes(struct inode *inode)
176 ops = rpci->ops; 175 ops = rpci->ops;
177 if (ops != NULL) { 176 if (ops != NULL) {
178 LIST_HEAD(free_list); 177 LIST_HEAD(free_list);
179 spin_lock(&inode->i_lock); 178 spin_lock(&rpci->lock);
180 need_release = rpci->nreaders != 0 || rpci->nwriters != 0; 179 need_release = rpci->nreaders != 0 || rpci->nwriters != 0;
181 rpci->nreaders = 0; 180 rpci->nreaders = 0;
182 list_splice_init(&rpci->in_upcall, &free_list); 181 list_splice_init(&rpci->in_upcall, &free_list);
183 list_splice_init(&rpci->pipe, &free_list); 182 list_splice_init(&rpci->pipe, &free_list);
184 rpci->pipelen = 0; 183 rpci->pipelen = 0;
185 rpci->ops = NULL; 184 rpci->ops = NULL;
186 spin_unlock(&inode->i_lock); 185 spin_unlock(&rpci->lock);
187 rpc_purge_list(rpci, &free_list, ops->destroy_msg, -EPIPE); 186 rpc_purge_list(rpci, &free_list, ops->destroy_msg, -EPIPE);
188 rpci->nwriters = 0; 187 rpci->nwriters = 0;
189 if (need_release && ops->release_pipe) 188 if (need_release && ops->release_pipe)
@@ -255,10 +254,10 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
255 goto out; 254 goto out;
256 msg = filp->private_data; 255 msg = filp->private_data;
257 if (msg != NULL) { 256 if (msg != NULL) {
258 spin_lock(&inode->i_lock); 257 spin_lock(&rpci->lock);
259 msg->errno = -EAGAIN; 258 msg->errno = -EAGAIN;
260 list_del_init(&msg->list); 259 list_del_init(&msg->list);
261 spin_unlock(&inode->i_lock); 260 spin_unlock(&rpci->lock);
262 rpci->ops->destroy_msg(msg); 261 rpci->ops->destroy_msg(msg);
263 } 262 }
264 if (filp->f_mode & FMODE_WRITE) 263 if (filp->f_mode & FMODE_WRITE)
@@ -267,10 +266,10 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
267 rpci->nreaders --; 266 rpci->nreaders --;
268 if (rpci->nreaders == 0) { 267 if (rpci->nreaders == 0) {
269 LIST_HEAD(free_list); 268 LIST_HEAD(free_list);
270 spin_lock(&inode->i_lock); 269 spin_lock(&rpci->lock);
271 list_splice_init(&rpci->pipe, &free_list); 270 list_splice_init(&rpci->pipe, &free_list);
272 rpci->pipelen = 0; 271 rpci->pipelen = 0;
273 spin_unlock(&inode->i_lock); 272 spin_unlock(&rpci->lock);
274 rpc_purge_list(rpci, &free_list, 273 rpc_purge_list(rpci, &free_list,
275 rpci->ops->destroy_msg, -EAGAIN); 274 rpci->ops->destroy_msg, -EAGAIN);
276 } 275 }
@@ -298,7 +297,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
298 } 297 }
299 msg = filp->private_data; 298 msg = filp->private_data;
300 if (msg == NULL) { 299 if (msg == NULL) {
301 spin_lock(&inode->i_lock); 300 spin_lock(&rpci->lock);
302 if (!list_empty(&rpci->pipe)) { 301 if (!list_empty(&rpci->pipe)) {
303 msg = list_entry(rpci->pipe.next, 302 msg = list_entry(rpci->pipe.next,
304 struct rpc_pipe_msg, 303 struct rpc_pipe_msg,
@@ -308,7 +307,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
308 filp->private_data = msg; 307 filp->private_data = msg;
309 msg->copied = 0; 308 msg->copied = 0;
310 } 309 }
311 spin_unlock(&inode->i_lock); 310 spin_unlock(&rpci->lock);
312 if (msg == NULL) 311 if (msg == NULL)
313 goto out_unlock; 312 goto out_unlock;
314 } 313 }
@@ -316,9 +315,9 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
316 res = rpci->ops->upcall(filp, msg, buf, len); 315 res = rpci->ops->upcall(filp, msg, buf, len);
317 if (res < 0 || msg->len == msg->copied) { 316 if (res < 0 || msg->len == msg->copied) {
318 filp->private_data = NULL; 317 filp->private_data = NULL;
319 spin_lock(&inode->i_lock); 318 spin_lock(&rpci->lock);
320 list_del_init(&msg->list); 319 list_del_init(&msg->list);
321 spin_unlock(&inode->i_lock); 320 spin_unlock(&rpci->lock);
322 rpci->ops->destroy_msg(msg); 321 rpci->ops->destroy_msg(msg);
323 } 322 }
324out_unlock: 323out_unlock:
@@ -367,9 +366,9 @@ rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
367 366
368 switch (cmd) { 367 switch (cmd) {
369 case FIONREAD: 368 case FIONREAD:
370 spin_lock(&inode->i_lock); 369 spin_lock(&rpci->lock);
371 if (rpci->ops == NULL) { 370 if (rpci->ops == NULL) {
372 spin_unlock(&inode->i_lock); 371 spin_unlock(&rpci->lock);
373 return -EPIPE; 372 return -EPIPE;
374 } 373 }
375 len = rpci->pipelen; 374 len = rpci->pipelen;
@@ -378,7 +377,7 @@ rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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(&inode->i_lock); 380 spin_unlock(&rpci->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;
@@ -1153,6 +1152,7 @@ init_once(void *foo)
1153 INIT_DELAYED_WORK(&rpci->queue_timeout, 1152 INIT_DELAYED_WORK(&rpci->queue_timeout,
1154 rpc_timeout_upcall_queue); 1153 rpc_timeout_upcall_queue);
1155 rpci->ops = NULL; 1154 rpci->ops = NULL;
1155 spin_lock_init(&rpci->lock);
1156} 1156}
1157 1157
1158int register_rpc_pipefs(void) 1158int register_rpc_pipefs(void)