aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pipe.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-04-11 07:53:10 -0400
committerJens Axboe <axboe@suse.de>2006-04-11 07:53:10 -0400
commit9aeedfc4712ed58d9f7ae41596185c72b8dc97e8 (patch)
treeb055bab09a86cfc6cb13506d2f25da6abd12e3c1 /fs/pipe.c
parent7480a90435673b4c717b6caf1350ec577d5f1adf (diff)
[PATCH] get rid of the PIPE_*() macros
get rid of the PIPE_*() macros. Scripted transformation. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'fs/pipe.c')
-rw-r--r--fs/pipe.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 036536f072c9..0602fc9f7eba 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -158,7 +158,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
158 158
159 do_wakeup = 0; 159 do_wakeup = 0;
160 ret = 0; 160 ret = 0;
161 mutex_lock(PIPE_MUTEX(*inode)); 161 mutex_lock(&inode->i_mutex);
162 info = inode->i_pipe; 162 info = inode->i_pipe;
163 for (;;) { 163 for (;;) {
164 int bufs = info->nrbufs; 164 int bufs = info->nrbufs;
@@ -202,9 +202,9 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
202 } 202 }
203 if (bufs) /* More to do? */ 203 if (bufs) /* More to do? */
204 continue; 204 continue;
205 if (!PIPE_WRITERS(*inode)) 205 if (!inode->i_pipe->writers)
206 break; 206 break;
207 if (!PIPE_WAITING_WRITERS(*inode)) { 207 if (!inode->i_pipe->waiting_writers) {
208 /* syscall merging: Usually we must not sleep 208 /* syscall merging: Usually we must not sleep
209 * if O_NONBLOCK is set, or if we got some data. 209 * if O_NONBLOCK is set, or if we got some data.
210 * But if a writer sleeps in kernel space, then 210 * But if a writer sleeps in kernel space, then
@@ -222,16 +222,16 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
222 break; 222 break;
223 } 223 }
224 if (do_wakeup) { 224 if (do_wakeup) {
225 wake_up_interruptible_sync(PIPE_WAIT(*inode)); 225 wake_up_interruptible_sync(&inode->i_pipe->wait);
226 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT); 226 kill_fasync(&inode->i_pipe->fasync_writers, SIGIO, POLL_OUT);
227 } 227 }
228 pipe_wait(inode->i_pipe); 228 pipe_wait(inode->i_pipe);
229 } 229 }
230 mutex_unlock(PIPE_MUTEX(*inode)); 230 mutex_unlock(&inode->i_mutex);
231 /* Signal writers asynchronously that there is more room. */ 231 /* Signal writers asynchronously that there is more room. */
232 if (do_wakeup) { 232 if (do_wakeup) {
233 wake_up_interruptible(PIPE_WAIT(*inode)); 233 wake_up_interruptible(&inode->i_pipe->wait);
234 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT); 234 kill_fasync(&inode->i_pipe->fasync_writers, SIGIO, POLL_OUT);
235 } 235 }
236 if (ret > 0) 236 if (ret > 0)
237 file_accessed(filp); 237 file_accessed(filp);
@@ -264,10 +264,10 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
264 264
265 do_wakeup = 0; 265 do_wakeup = 0;
266 ret = 0; 266 ret = 0;
267 mutex_lock(PIPE_MUTEX(*inode)); 267 mutex_lock(&inode->i_mutex);
268 info = inode->i_pipe; 268 info = inode->i_pipe;
269 269
270 if (!PIPE_READERS(*inode)) { 270 if (!inode->i_pipe->readers) {
271 send_sig(SIGPIPE, current, 0); 271 send_sig(SIGPIPE, current, 0);
272 ret = -EPIPE; 272 ret = -EPIPE;
273 goto out; 273 goto out;
@@ -306,7 +306,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
306 306
307 for (;;) { 307 for (;;) {
308 int bufs; 308 int bufs;
309 if (!PIPE_READERS(*inode)) { 309 if (!inode->i_pipe->readers) {
310 send_sig(SIGPIPE, current, 0); 310 send_sig(SIGPIPE, current, 0);
311 if (!ret) ret = -EPIPE; 311 if (!ret) ret = -EPIPE;
312 break; 312 break;
@@ -367,19 +367,19 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
367 break; 367 break;
368 } 368 }
369 if (do_wakeup) { 369 if (do_wakeup) {
370 wake_up_interruptible_sync(PIPE_WAIT(*inode)); 370 wake_up_interruptible_sync(&inode->i_pipe->wait);
371 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 371 kill_fasync(&inode->i_pipe->fasync_readers, SIGIO, POLL_IN);
372 do_wakeup = 0; 372 do_wakeup = 0;
373 } 373 }
374 PIPE_WAITING_WRITERS(*inode)++; 374 inode->i_pipe->waiting_writers++;
375 pipe_wait(inode->i_pipe); 375 pipe_wait(inode->i_pipe);
376 PIPE_WAITING_WRITERS(*inode)--; 376 inode->i_pipe->waiting_writers--;
377 } 377 }
378out: 378out:
379 mutex_unlock(PIPE_MUTEX(*inode)); 379 mutex_unlock(&inode->i_mutex);
380 if (do_wakeup) { 380 if (do_wakeup) {
381 wake_up_interruptible(PIPE_WAIT(*inode)); 381 wake_up_interruptible(&inode->i_pipe->wait);
382 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 382 kill_fasync(&inode->i_pipe->fasync_readers, SIGIO, POLL_IN);
383 } 383 }
384 if (ret > 0) 384 if (ret > 0)
385 file_update_time(filp); 385 file_update_time(filp);
@@ -416,7 +416,7 @@ pipe_ioctl(struct inode *pino, struct file *filp,
416 416
417 switch (cmd) { 417 switch (cmd) {
418 case FIONREAD: 418 case FIONREAD:
419 mutex_lock(PIPE_MUTEX(*inode)); 419 mutex_lock(&inode->i_mutex);
420 info = inode->i_pipe; 420 info = inode->i_pipe;
421 count = 0; 421 count = 0;
422 buf = info->curbuf; 422 buf = info->curbuf;
@@ -425,7 +425,7 @@ pipe_ioctl(struct inode *pino, struct file *filp,
425 count += info->bufs[buf].len; 425 count += info->bufs[buf].len;
426 buf = (buf+1) & (PIPE_BUFFERS-1); 426 buf = (buf+1) & (PIPE_BUFFERS-1);
427 } 427 }
428 mutex_unlock(PIPE_MUTEX(*inode)); 428 mutex_unlock(&inode->i_mutex);
429 return put_user(count, (int __user *)arg); 429 return put_user(count, (int __user *)arg);
430 default: 430 default:
431 return -EINVAL; 431 return -EINVAL;
@@ -441,14 +441,14 @@ pipe_poll(struct file *filp, poll_table *wait)
441 struct pipe_inode_info *info = inode->i_pipe; 441 struct pipe_inode_info *info = inode->i_pipe;
442 int nrbufs; 442 int nrbufs;
443 443
444 poll_wait(filp, PIPE_WAIT(*inode), wait); 444 poll_wait(filp, &inode->i_pipe->wait, wait);
445 445
446 /* Reading only -- no need for acquiring the semaphore. */ 446 /* Reading only -- no need for acquiring the semaphore. */
447 nrbufs = info->nrbufs; 447 nrbufs = info->nrbufs;
448 mask = 0; 448 mask = 0;
449 if (filp->f_mode & FMODE_READ) { 449 if (filp->f_mode & FMODE_READ) {
450 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0; 450 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
451 if (!PIPE_WRITERS(*inode) && filp->f_version != PIPE_WCOUNTER(*inode)) 451 if (!inode->i_pipe->writers && filp->f_version != inode->i_pipe->w_counter)
452 mask |= POLLHUP; 452 mask |= POLLHUP;
453 } 453 }
454 454
@@ -458,7 +458,7 @@ pipe_poll(struct file *filp, poll_table *wait)
458 * Most Unices do not set POLLERR for FIFOs but on Linux they 458 * Most Unices do not set POLLERR for FIFOs but on Linux they
459 * behave exactly like pipes for poll(). 459 * behave exactly like pipes for poll().
460 */ 460 */
461 if (!PIPE_READERS(*inode)) 461 if (!inode->i_pipe->readers)
462 mask |= POLLERR; 462 mask |= POLLERR;
463 } 463 }
464 464
@@ -468,17 +468,17 @@ pipe_poll(struct file *filp, poll_table *wait)
468static int 468static int
469pipe_release(struct inode *inode, int decr, int decw) 469pipe_release(struct inode *inode, int decr, int decw)
470{ 470{
471 mutex_lock(PIPE_MUTEX(*inode)); 471 mutex_lock(&inode->i_mutex);
472 PIPE_READERS(*inode) -= decr; 472 inode->i_pipe->readers -= decr;
473 PIPE_WRITERS(*inode) -= decw; 473 inode->i_pipe->writers -= decw;
474 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) { 474 if (!inode->i_pipe->readers && !inode->i_pipe->writers) {
475 free_pipe_info(inode); 475 free_pipe_info(inode);
476 } else { 476 } else {
477 wake_up_interruptible(PIPE_WAIT(*inode)); 477 wake_up_interruptible(&inode->i_pipe->wait);
478 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 478 kill_fasync(&inode->i_pipe->fasync_readers, SIGIO, POLL_IN);
479 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT); 479 kill_fasync(&inode->i_pipe->fasync_writers, SIGIO, POLL_OUT);
480 } 480 }
481 mutex_unlock(PIPE_MUTEX(*inode)); 481 mutex_unlock(&inode->i_mutex);
482 482
483 return 0; 483 return 0;
484} 484}
@@ -489,9 +489,9 @@ pipe_read_fasync(int fd, struct file *filp, int on)
489 struct inode *inode = filp->f_dentry->d_inode; 489 struct inode *inode = filp->f_dentry->d_inode;
490 int retval; 490 int retval;
491 491
492 mutex_lock(PIPE_MUTEX(*inode)); 492 mutex_lock(&inode->i_mutex);
493 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode)); 493 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
494 mutex_unlock(PIPE_MUTEX(*inode)); 494 mutex_unlock(&inode->i_mutex);
495 495
496 if (retval < 0) 496 if (retval < 0)
497 return retval; 497 return retval;
@@ -506,9 +506,9 @@ pipe_write_fasync(int fd, struct file *filp, int on)
506 struct inode *inode = filp->f_dentry->d_inode; 506 struct inode *inode = filp->f_dentry->d_inode;
507 int retval; 507 int retval;
508 508
509 mutex_lock(PIPE_MUTEX(*inode)); 509 mutex_lock(&inode->i_mutex);
510 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode)); 510 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
511 mutex_unlock(PIPE_MUTEX(*inode)); 511 mutex_unlock(&inode->i_mutex);
512 512
513 if (retval < 0) 513 if (retval < 0)
514 return retval; 514 return retval;
@@ -523,14 +523,14 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
523 struct inode *inode = filp->f_dentry->d_inode; 523 struct inode *inode = filp->f_dentry->d_inode;
524 int retval; 524 int retval;
525 525
526 mutex_lock(PIPE_MUTEX(*inode)); 526 mutex_lock(&inode->i_mutex);
527 527
528 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode)); 528 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
529 529
530 if (retval >= 0) 530 if (retval >= 0)
531 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode)); 531 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
532 532
533 mutex_unlock(PIPE_MUTEX(*inode)); 533 mutex_unlock(&inode->i_mutex);
534 534
535 if (retval < 0) 535 if (retval < 0)
536 return retval; 536 return retval;
@@ -569,9 +569,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
569{ 569{
570 /* We could have perhaps used atomic_t, but this and friends 570 /* We could have perhaps used atomic_t, but this and friends
571 below are the only places. So it doesn't seem worthwhile. */ 571 below are the only places. So it doesn't seem worthwhile. */
572 mutex_lock(PIPE_MUTEX(*inode)); 572 mutex_lock(&inode->i_mutex);
573 PIPE_READERS(*inode)++; 573 inode->i_pipe->readers++;
574 mutex_unlock(PIPE_MUTEX(*inode)); 574 mutex_unlock(&inode->i_mutex);
575 575
576 return 0; 576 return 0;
577} 577}
@@ -579,9 +579,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
579static int 579static int
580pipe_write_open(struct inode *inode, struct file *filp) 580pipe_write_open(struct inode *inode, struct file *filp)
581{ 581{
582 mutex_lock(PIPE_MUTEX(*inode)); 582 mutex_lock(&inode->i_mutex);
583 PIPE_WRITERS(*inode)++; 583 inode->i_pipe->writers++;
584 mutex_unlock(PIPE_MUTEX(*inode)); 584 mutex_unlock(&inode->i_mutex);
585 585
586 return 0; 586 return 0;
587} 587}
@@ -589,12 +589,12 @@ pipe_write_open(struct inode *inode, struct file *filp)
589static int 589static int
590pipe_rdwr_open(struct inode *inode, struct file *filp) 590pipe_rdwr_open(struct inode *inode, struct file *filp)
591{ 591{
592 mutex_lock(PIPE_MUTEX(*inode)); 592 mutex_lock(&inode->i_mutex);
593 if (filp->f_mode & FMODE_READ) 593 if (filp->f_mode & FMODE_READ)
594 PIPE_READERS(*inode)++; 594 inode->i_pipe->readers++;
595 if (filp->f_mode & FMODE_WRITE) 595 if (filp->f_mode & FMODE_WRITE)
596 PIPE_WRITERS(*inode)++; 596 inode->i_pipe->writers++;
597 mutex_unlock(PIPE_MUTEX(*inode)); 597 mutex_unlock(&inode->i_mutex);
598 598
599 return 0; 599 return 0;
600} 600}
@@ -731,7 +731,7 @@ static struct inode * get_pipe_inode(void)
731 if (!inode->i_pipe) 731 if (!inode->i_pipe)
732 goto fail_iput; 732 goto fail_iput;
733 733
734 PIPE_READERS(*inode) = PIPE_WRITERS(*inode) = 1; 734 inode->i_pipe->readers = inode->i_pipe->writers = 1;
735 inode->i_fop = &rdwr_pipe_fops; 735 inode->i_fop = &rdwr_pipe_fops;
736 736
737 /* 737 /*