aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fifo.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-04-11 07:53:33 -0400
committerJens Axboe <axboe@suse.de>2006-04-11 07:53:33 -0400
commit923f4f23940d2361e8d5c4245982163a8e9d1c91 (patch)
tree05d24681cadfd731a083b0fa3b22b6e7a6622555 /fs/fifo.c
parent9aeedfc4712ed58d9f7ae41596185c72b8dc97e8 (diff)
[PATCH] pipe.c/fifo.c code cleanups
more code cleanups after the macro conversion: - standardize on 'struct pipe_inode_info *pipe' variable names - introduce 'pipe' temporaries to reduce mass inode->i_pipe dereferencing Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'fs/fifo.c')
-rw-r--r--fs/fifo.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/fs/fifo.c b/fs/fifo.c
index 2c27f56d7304..49035b174b48 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -33,14 +33,17 @@ static void wake_up_partner(struct inode* inode)
33 33
34static int fifo_open(struct inode *inode, struct file *filp) 34static int fifo_open(struct inode *inode, struct file *filp)
35{ 35{
36 struct pipe_inode_info *pipe;
36 int ret; 37 int ret;
37 38
38 mutex_lock(&inode->i_mutex); 39 mutex_lock(&inode->i_mutex);
39 if (!inode->i_pipe) { 40 pipe = inode->i_pipe;
41 if (!pipe) {
40 ret = -ENOMEM; 42 ret = -ENOMEM;
41 inode->i_pipe = alloc_pipe_info(inode); 43 pipe = alloc_pipe_info(inode);
42 if (!inode->i_pipe) 44 if (!pipe)
43 goto err_nocleanup; 45 goto err_nocleanup;
46 inode->i_pipe = pipe;
44 } 47 }
45 filp->f_version = 0; 48 filp->f_version = 0;
46 49
@@ -55,18 +58,18 @@ static int fifo_open(struct inode *inode, struct file *filp)
55 * opened, even when there is no process writing the FIFO. 58 * opened, even when there is no process writing the FIFO.
56 */ 59 */
57 filp->f_op = &read_fifo_fops; 60 filp->f_op = &read_fifo_fops;
58 inode->i_pipe->r_counter++; 61 pipe->r_counter++;
59 if (inode->i_pipe->readers++ == 0) 62 if (pipe->readers++ == 0)
60 wake_up_partner(inode); 63 wake_up_partner(inode);
61 64
62 if (!inode->i_pipe->writers) { 65 if (!pipe->writers) {
63 if ((filp->f_flags & O_NONBLOCK)) { 66 if ((filp->f_flags & O_NONBLOCK)) {
64 /* suppress POLLHUP until we have 67 /* suppress POLLHUP until we have
65 * seen a writer */ 68 * seen a writer */
66 filp->f_version = inode->i_pipe->w_counter; 69 filp->f_version = pipe->w_counter;
67 } else 70 } else
68 { 71 {
69 wait_for_partner(inode, &inode->i_pipe->w_counter); 72 wait_for_partner(inode, &pipe->w_counter);
70 if(signal_pending(current)) 73 if(signal_pending(current))
71 goto err_rd; 74 goto err_rd;
72 } 75 }
@@ -80,16 +83,16 @@ static int fifo_open(struct inode *inode, struct file *filp)
80 * errno=ENXIO when there is no process reading the FIFO. 83 * errno=ENXIO when there is no process reading the FIFO.
81 */ 84 */
82 ret = -ENXIO; 85 ret = -ENXIO;
83 if ((filp->f_flags & O_NONBLOCK) && !inode->i_pipe->readers) 86 if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
84 goto err; 87 goto err;
85 88
86 filp->f_op = &write_fifo_fops; 89 filp->f_op = &write_fifo_fops;
87 inode->i_pipe->w_counter++; 90 pipe->w_counter++;
88 if (!inode->i_pipe->writers++) 91 if (!pipe->writers++)
89 wake_up_partner(inode); 92 wake_up_partner(inode);
90 93
91 if (!inode->i_pipe->readers) { 94 if (!pipe->readers) {
92 wait_for_partner(inode, &inode->i_pipe->r_counter); 95 wait_for_partner(inode, &pipe->r_counter);
93 if (signal_pending(current)) 96 if (signal_pending(current))
94 goto err_wr; 97 goto err_wr;
95 } 98 }
@@ -104,11 +107,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
104 */ 107 */
105 filp->f_op = &rdwr_fifo_fops; 108 filp->f_op = &rdwr_fifo_fops;
106 109
107 inode->i_pipe->readers++; 110 pipe->readers++;
108 inode->i_pipe->writers++; 111 pipe->writers++;
109 inode->i_pipe->r_counter++; 112 pipe->r_counter++;
110 inode->i_pipe->w_counter++; 113 pipe->w_counter++;
111 if (inode->i_pipe->readers == 1 || inode->i_pipe->writers == 1) 114 if (pipe->readers == 1 || pipe->writers == 1)
112 wake_up_partner(inode); 115 wake_up_partner(inode);
113 break; 116 break;
114 117
@@ -122,19 +125,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
122 return 0; 125 return 0;
123 126
124err_rd: 127err_rd:
125 if (!--inode->i_pipe->readers) 128 if (!--pipe->readers)
126 wake_up_interruptible(&inode->i_pipe->wait); 129 wake_up_interruptible(&pipe->wait);
127 ret = -ERESTARTSYS; 130 ret = -ERESTARTSYS;
128 goto err; 131 goto err;
129 132
130err_wr: 133err_wr:
131 if (!--inode->i_pipe->writers) 134 if (!--pipe->writers)
132 wake_up_interruptible(&inode->i_pipe->wait); 135 wake_up_interruptible(&pipe->wait);
133 ret = -ERESTARTSYS; 136 ret = -ERESTARTSYS;
134 goto err; 137 goto err;
135 138
136err: 139err:
137 if (!inode->i_pipe->readers && !inode->i_pipe->writers) 140 if (!pipe->readers && !pipe->writers)
138 free_pipe_info(inode); 141 free_pipe_info(inode);
139 142
140err_nocleanup: 143err_nocleanup: