aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/pipe.c')
-rw-r--r--fs/pipe.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 66aa0b938d6a..acb030b61fb0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -44,10 +44,10 @@ void pipe_wait(struct inode * inode)
44 * is considered a noninteractive wait: 44 * is considered a noninteractive wait:
45 */ 45 */
46 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE); 46 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE);
47 up(PIPE_SEM(*inode)); 47 mutex_unlock(PIPE_MUTEX(*inode));
48 schedule(); 48 schedule();
49 finish_wait(PIPE_WAIT(*inode), &wait); 49 finish_wait(PIPE_WAIT(*inode), &wait);
50 down(PIPE_SEM(*inode)); 50 mutex_lock(PIPE_MUTEX(*inode));
51} 51}
52 52
53static inline int 53static inline int
@@ -136,7 +136,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
136 136
137 do_wakeup = 0; 137 do_wakeup = 0;
138 ret = 0; 138 ret = 0;
139 down(PIPE_SEM(*inode)); 139 mutex_lock(PIPE_MUTEX(*inode));
140 info = inode->i_pipe; 140 info = inode->i_pipe;
141 for (;;) { 141 for (;;) {
142 int bufs = info->nrbufs; 142 int bufs = info->nrbufs;
@@ -200,7 +200,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
200 } 200 }
201 pipe_wait(inode); 201 pipe_wait(inode);
202 } 202 }
203 up(PIPE_SEM(*inode)); 203 mutex_unlock(PIPE_MUTEX(*inode));
204 /* Signal writers asynchronously that there is more room. */ 204 /* Signal writers asynchronously that there is more room. */
205 if (do_wakeup) { 205 if (do_wakeup) {
206 wake_up_interruptible(PIPE_WAIT(*inode)); 206 wake_up_interruptible(PIPE_WAIT(*inode));
@@ -237,7 +237,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
237 237
238 do_wakeup = 0; 238 do_wakeup = 0;
239 ret = 0; 239 ret = 0;
240 down(PIPE_SEM(*inode)); 240 mutex_lock(PIPE_MUTEX(*inode));
241 info = inode->i_pipe; 241 info = inode->i_pipe;
242 242
243 if (!PIPE_READERS(*inode)) { 243 if (!PIPE_READERS(*inode)) {
@@ -341,7 +341,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
341 PIPE_WAITING_WRITERS(*inode)--; 341 PIPE_WAITING_WRITERS(*inode)--;
342 } 342 }
343out: 343out:
344 up(PIPE_SEM(*inode)); 344 mutex_unlock(PIPE_MUTEX(*inode));
345 if (do_wakeup) { 345 if (do_wakeup) {
346 wake_up_interruptible(PIPE_WAIT(*inode)); 346 wake_up_interruptible(PIPE_WAIT(*inode));
347 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 347 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
@@ -381,7 +381,7 @@ pipe_ioctl(struct inode *pino, struct file *filp,
381 381
382 switch (cmd) { 382 switch (cmd) {
383 case FIONREAD: 383 case FIONREAD:
384 down(PIPE_SEM(*inode)); 384 mutex_lock(PIPE_MUTEX(*inode));
385 info = inode->i_pipe; 385 info = inode->i_pipe;
386 count = 0; 386 count = 0;
387 buf = info->curbuf; 387 buf = info->curbuf;
@@ -390,7 +390,7 @@ pipe_ioctl(struct inode *pino, struct file *filp,
390 count += info->bufs[buf].len; 390 count += info->bufs[buf].len;
391 buf = (buf+1) & (PIPE_BUFFERS-1); 391 buf = (buf+1) & (PIPE_BUFFERS-1);
392 } 392 }
393 up(PIPE_SEM(*inode)); 393 mutex_unlock(PIPE_MUTEX(*inode));
394 return put_user(count, (int __user *)arg); 394 return put_user(count, (int __user *)arg);
395 default: 395 default:
396 return -EINVAL; 396 return -EINVAL;
@@ -433,7 +433,7 @@ pipe_poll(struct file *filp, poll_table *wait)
433static int 433static int
434pipe_release(struct inode *inode, int decr, int decw) 434pipe_release(struct inode *inode, int decr, int decw)
435{ 435{
436 down(PIPE_SEM(*inode)); 436 mutex_lock(PIPE_MUTEX(*inode));
437 PIPE_READERS(*inode) -= decr; 437 PIPE_READERS(*inode) -= decr;
438 PIPE_WRITERS(*inode) -= decw; 438 PIPE_WRITERS(*inode) -= decw;
439 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) { 439 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
@@ -443,7 +443,7 @@ pipe_release(struct inode *inode, int decr, int decw)
443 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 443 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
444 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT); 444 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
445 } 445 }
446 up(PIPE_SEM(*inode)); 446 mutex_unlock(PIPE_MUTEX(*inode));
447 447
448 return 0; 448 return 0;
449} 449}
@@ -454,9 +454,9 @@ pipe_read_fasync(int fd, struct file *filp, int on)
454 struct inode *inode = filp->f_dentry->d_inode; 454 struct inode *inode = filp->f_dentry->d_inode;
455 int retval; 455 int retval;
456 456
457 down(PIPE_SEM(*inode)); 457 mutex_lock(PIPE_MUTEX(*inode));
458 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode)); 458 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
459 up(PIPE_SEM(*inode)); 459 mutex_unlock(PIPE_MUTEX(*inode));
460 460
461 if (retval < 0) 461 if (retval < 0)
462 return retval; 462 return retval;
@@ -471,9 +471,9 @@ pipe_write_fasync(int fd, struct file *filp, int on)
471 struct inode *inode = filp->f_dentry->d_inode; 471 struct inode *inode = filp->f_dentry->d_inode;
472 int retval; 472 int retval;
473 473
474 down(PIPE_SEM(*inode)); 474 mutex_lock(PIPE_MUTEX(*inode));
475 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode)); 475 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
476 up(PIPE_SEM(*inode)); 476 mutex_unlock(PIPE_MUTEX(*inode));
477 477
478 if (retval < 0) 478 if (retval < 0)
479 return retval; 479 return retval;
@@ -488,14 +488,14 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
488 struct inode *inode = filp->f_dentry->d_inode; 488 struct inode *inode = filp->f_dentry->d_inode;
489 int retval; 489 int retval;
490 490
491 down(PIPE_SEM(*inode)); 491 mutex_lock(PIPE_MUTEX(*inode));
492 492
493 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode)); 493 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
494 494
495 if (retval >= 0) 495 if (retval >= 0)
496 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode)); 496 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
497 497
498 up(PIPE_SEM(*inode)); 498 mutex_unlock(PIPE_MUTEX(*inode));
499 499
500 if (retval < 0) 500 if (retval < 0)
501 return retval; 501 return retval;
@@ -534,9 +534,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
534{ 534{
535 /* We could have perhaps used atomic_t, but this and friends 535 /* We could have perhaps used atomic_t, but this and friends
536 below are the only places. So it doesn't seem worthwhile. */ 536 below are the only places. So it doesn't seem worthwhile. */
537 down(PIPE_SEM(*inode)); 537 mutex_lock(PIPE_MUTEX(*inode));
538 PIPE_READERS(*inode)++; 538 PIPE_READERS(*inode)++;
539 up(PIPE_SEM(*inode)); 539 mutex_unlock(PIPE_MUTEX(*inode));
540 540
541 return 0; 541 return 0;
542} 542}
@@ -544,9 +544,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
544static int 544static int
545pipe_write_open(struct inode *inode, struct file *filp) 545pipe_write_open(struct inode *inode, struct file *filp)
546{ 546{
547 down(PIPE_SEM(*inode)); 547 mutex_lock(PIPE_MUTEX(*inode));
548 PIPE_WRITERS(*inode)++; 548 PIPE_WRITERS(*inode)++;
549 up(PIPE_SEM(*inode)); 549 mutex_unlock(PIPE_MUTEX(*inode));
550 550
551 return 0; 551 return 0;
552} 552}
@@ -554,12 +554,12 @@ pipe_write_open(struct inode *inode, struct file *filp)
554static int 554static int
555pipe_rdwr_open(struct inode *inode, struct file *filp) 555pipe_rdwr_open(struct inode *inode, struct file *filp)
556{ 556{
557 down(PIPE_SEM(*inode)); 557 mutex_lock(PIPE_MUTEX(*inode));
558 if (filp->f_mode & FMODE_READ) 558 if (filp->f_mode & FMODE_READ)
559 PIPE_READERS(*inode)++; 559 PIPE_READERS(*inode)++;
560 if (filp->f_mode & FMODE_WRITE) 560 if (filp->f_mode & FMODE_WRITE)
561 PIPE_WRITERS(*inode)++; 561 PIPE_WRITERS(*inode)++;
562 up(PIPE_SEM(*inode)); 562 mutex_unlock(PIPE_MUTEX(*inode));
563 563
564 return 0; 564 return 0;
565} 565}