aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/fifo.c49
-rw-r--r--fs/pipe.c163
2 files changed, 111 insertions, 101 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:
diff --git a/fs/pipe.c b/fs/pipe.c
index 0602fc9f7eba..b941e1951eac 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -93,7 +93,7 @@ pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len)
93 return 0; 93 return 0;
94} 94}
95 95
96static void anon_pipe_buf_release(struct pipe_inode_info *info, struct pipe_buffer *buf) 96static void anon_pipe_buf_release(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
97{ 97{
98 struct page *page = buf->page; 98 struct page *page = buf->page;
99 99
@@ -104,8 +104,8 @@ static void anon_pipe_buf_release(struct pipe_inode_info *info, struct pipe_buff
104 * temporary page, let's keep track of it as a one-deep 104 * temporary page, let's keep track of it as a one-deep
105 * allocation cache 105 * allocation cache
106 */ 106 */
107 if (page_count(page) == 1 && !info->tmp_page) { 107 if (page_count(page) == 1 && !pipe->tmp_page) {
108 info->tmp_page = page; 108 pipe->tmp_page = page;
109 return; 109 return;
110 } 110 }
111 111
@@ -115,17 +115,17 @@ static void anon_pipe_buf_release(struct pipe_inode_info *info, struct pipe_buff
115 page_cache_release(page); 115 page_cache_release(page);
116} 116}
117 117
118static void *anon_pipe_buf_map(struct file *file, struct pipe_inode_info *info, struct pipe_buffer *buf) 118static void *anon_pipe_buf_map(struct file *file, struct pipe_inode_info *pipe, struct pipe_buffer *buf)
119{ 119{
120 return kmap(buf->page); 120 return kmap(buf->page);
121} 121}
122 122
123static void anon_pipe_buf_unmap(struct pipe_inode_info *info, struct pipe_buffer *buf) 123static void anon_pipe_buf_unmap(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
124{ 124{
125 kunmap(buf->page); 125 kunmap(buf->page);
126} 126}
127 127
128static int anon_pipe_buf_steal(struct pipe_inode_info *info, 128static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
129 struct pipe_buffer *buf) 129 struct pipe_buffer *buf)
130{ 130{
131 buf->flags |= PIPE_BUF_FLAG_STOLEN; 131 buf->flags |= PIPE_BUF_FLAG_STOLEN;
@@ -145,7 +145,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
145 unsigned long nr_segs, loff_t *ppos) 145 unsigned long nr_segs, loff_t *ppos)
146{ 146{
147 struct inode *inode = filp->f_dentry->d_inode; 147 struct inode *inode = filp->f_dentry->d_inode;
148 struct pipe_inode_info *info; 148 struct pipe_inode_info *pipe;
149 int do_wakeup; 149 int do_wakeup;
150 ssize_t ret; 150 ssize_t ret;
151 struct iovec *iov = (struct iovec *)_iov; 151 struct iovec *iov = (struct iovec *)_iov;
@@ -159,12 +159,12 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
159 do_wakeup = 0; 159 do_wakeup = 0;
160 ret = 0; 160 ret = 0;
161 mutex_lock(&inode->i_mutex); 161 mutex_lock(&inode->i_mutex);
162 info = inode->i_pipe; 162 pipe = inode->i_pipe;
163 for (;;) { 163 for (;;) {
164 int bufs = info->nrbufs; 164 int bufs = pipe->nrbufs;
165 if (bufs) { 165 if (bufs) {
166 int curbuf = info->curbuf; 166 int curbuf = pipe->curbuf;
167 struct pipe_buffer *buf = info->bufs + curbuf; 167 struct pipe_buffer *buf = pipe->bufs + curbuf;
168 struct pipe_buf_operations *ops = buf->ops; 168 struct pipe_buf_operations *ops = buf->ops;
169 void *addr; 169 void *addr;
170 size_t chars = buf->len; 170 size_t chars = buf->len;
@@ -173,14 +173,14 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
173 if (chars > total_len) 173 if (chars > total_len)
174 chars = total_len; 174 chars = total_len;
175 175
176 addr = ops->map(filp, info, buf); 176 addr = ops->map(filp, pipe, buf);
177 if (IS_ERR(addr)) { 177 if (IS_ERR(addr)) {
178 if (!ret) 178 if (!ret)
179 ret = PTR_ERR(addr); 179 ret = PTR_ERR(addr);
180 break; 180 break;
181 } 181 }
182 error = pipe_iov_copy_to_user(iov, addr + buf->offset, chars); 182 error = pipe_iov_copy_to_user(iov, addr + buf->offset, chars);
183 ops->unmap(info, buf); 183 ops->unmap(pipe, buf);
184 if (unlikely(error)) { 184 if (unlikely(error)) {
185 if (!ret) ret = -EFAULT; 185 if (!ret) ret = -EFAULT;
186 break; 186 break;
@@ -190,10 +190,10 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
190 buf->len -= chars; 190 buf->len -= chars;
191 if (!buf->len) { 191 if (!buf->len) {
192 buf->ops = NULL; 192 buf->ops = NULL;
193 ops->release(info, buf); 193 ops->release(pipe, buf);
194 curbuf = (curbuf + 1) & (PIPE_BUFFERS-1); 194 curbuf = (curbuf + 1) & (PIPE_BUFFERS-1);
195 info->curbuf = curbuf; 195 pipe->curbuf = curbuf;
196 info->nrbufs = --bufs; 196 pipe->nrbufs = --bufs;
197 do_wakeup = 1; 197 do_wakeup = 1;
198 } 198 }
199 total_len -= chars; 199 total_len -= chars;
@@ -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 (!inode->i_pipe->writers) 205 if (!pipe->writers)
206 break; 206 break;
207 if (!inode->i_pipe->waiting_writers) { 207 if (!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(&inode->i_pipe->wait); 225 wake_up_interruptible_sync(&pipe->wait);
226 kill_fasync(&inode->i_pipe->fasync_writers, SIGIO, POLL_OUT); 226 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
227 } 227 }
228 pipe_wait(inode->i_pipe); 228 pipe_wait(pipe);
229 } 229 }
230 mutex_unlock(&inode->i_mutex); 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(&inode->i_pipe->wait); 233 wake_up_interruptible(&pipe->wait);
234 kill_fasync(&inode->i_pipe->fasync_writers, SIGIO, POLL_OUT); 234 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
235 } 235 }
236 if (ret > 0) 236 if (ret > 0)
237 file_accessed(filp); 237 file_accessed(filp);
@@ -250,7 +250,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
250 unsigned long nr_segs, loff_t *ppos) 250 unsigned long nr_segs, loff_t *ppos)
251{ 251{
252 struct inode *inode = filp->f_dentry->d_inode; 252 struct inode *inode = filp->f_dentry->d_inode;
253 struct pipe_inode_info *info; 253 struct pipe_inode_info *pipe;
254 ssize_t ret; 254 ssize_t ret;
255 int do_wakeup; 255 int do_wakeup;
256 struct iovec *iov = (struct iovec *)_iov; 256 struct iovec *iov = (struct iovec *)_iov;
@@ -265,9 +265,9 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
265 do_wakeup = 0; 265 do_wakeup = 0;
266 ret = 0; 266 ret = 0;
267 mutex_lock(&inode->i_mutex); 267 mutex_lock(&inode->i_mutex);
268 info = inode->i_pipe; 268 pipe = inode->i_pipe;
269 269
270 if (!inode->i_pipe->readers) { 270 if (!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;
@@ -275,23 +275,23 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
275 275
276 /* We try to merge small writes */ 276 /* We try to merge small writes */
277 chars = total_len & (PAGE_SIZE-1); /* size of the last buffer */ 277 chars = total_len & (PAGE_SIZE-1); /* size of the last buffer */
278 if (info->nrbufs && chars != 0) { 278 if (pipe->nrbufs && chars != 0) {
279 int lastbuf = (info->curbuf + info->nrbufs - 1) & (PIPE_BUFFERS-1); 279 int lastbuf = (pipe->curbuf + pipe->nrbufs - 1) & (PIPE_BUFFERS-1);
280 struct pipe_buffer *buf = info->bufs + lastbuf; 280 struct pipe_buffer *buf = pipe->bufs + lastbuf;
281 struct pipe_buf_operations *ops = buf->ops; 281 struct pipe_buf_operations *ops = buf->ops;
282 int offset = buf->offset + buf->len; 282 int offset = buf->offset + buf->len;
283 if (ops->can_merge && offset + chars <= PAGE_SIZE) { 283 if (ops->can_merge && offset + chars <= PAGE_SIZE) {
284 void *addr; 284 void *addr;
285 int error; 285 int error;
286 286
287 addr = ops->map(filp, info, buf); 287 addr = ops->map(filp, pipe, buf);
288 if (IS_ERR(addr)) { 288 if (IS_ERR(addr)) {
289 error = PTR_ERR(addr); 289 error = PTR_ERR(addr);
290 goto out; 290 goto out;
291 } 291 }
292 error = pipe_iov_copy_from_user(offset + addr, iov, 292 error = pipe_iov_copy_from_user(offset + addr, iov,
293 chars); 293 chars);
294 ops->unmap(info, buf); 294 ops->unmap(pipe, buf);
295 ret = error; 295 ret = error;
296 do_wakeup = 1; 296 do_wakeup = 1;
297 if (error) 297 if (error)
@@ -306,16 +306,16 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
306 306
307 for (;;) { 307 for (;;) {
308 int bufs; 308 int bufs;
309 if (!inode->i_pipe->readers) { 309 if (!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;
313 } 313 }
314 bufs = info->nrbufs; 314 bufs = pipe->nrbufs;
315 if (bufs < PIPE_BUFFERS) { 315 if (bufs < PIPE_BUFFERS) {
316 int newbuf = (info->curbuf + bufs) & (PIPE_BUFFERS-1); 316 int newbuf = (pipe->curbuf + bufs) & (PIPE_BUFFERS-1);
317 struct pipe_buffer *buf = info->bufs + newbuf; 317 struct pipe_buffer *buf = pipe->bufs + newbuf;
318 struct page *page = info->tmp_page; 318 struct page *page = pipe->tmp_page;
319 int error; 319 int error;
320 320
321 if (!page) { 321 if (!page) {
@@ -324,7 +324,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
324 ret = ret ? : -ENOMEM; 324 ret = ret ? : -ENOMEM;
325 break; 325 break;
326 } 326 }
327 info->tmp_page = page; 327 pipe->tmp_page = page;
328 } 328 }
329 /* Always wakeup, even if the copy fails. Otherwise 329 /* Always wakeup, even if the copy fails. Otherwise
330 * we lock up (O_NONBLOCK-)readers that sleep due to 330 * we lock up (O_NONBLOCK-)readers that sleep due to
@@ -349,8 +349,8 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
349 buf->ops = &anon_pipe_buf_ops; 349 buf->ops = &anon_pipe_buf_ops;
350 buf->offset = 0; 350 buf->offset = 0;
351 buf->len = chars; 351 buf->len = chars;
352 info->nrbufs = ++bufs; 352 pipe->nrbufs = ++bufs;
353 info->tmp_page = NULL; 353 pipe->tmp_page = NULL;
354 354
355 total_len -= chars; 355 total_len -= chars;
356 if (!total_len) 356 if (!total_len)
@@ -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(&inode->i_pipe->wait); 370 wake_up_interruptible_sync(&pipe->wait);
371 kill_fasync(&inode->i_pipe->fasync_readers, SIGIO, POLL_IN); 371 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
372 do_wakeup = 0; 372 do_wakeup = 0;
373 } 373 }
374 inode->i_pipe->waiting_writers++; 374 pipe->waiting_writers++;
375 pipe_wait(inode->i_pipe); 375 pipe_wait(pipe);
376 inode->i_pipe->waiting_writers--; 376 pipe->waiting_writers--;
377 } 377 }
378out: 378out:
379 mutex_unlock(&inode->i_mutex); 379 mutex_unlock(&inode->i_mutex);
380 if (do_wakeup) { 380 if (do_wakeup) {
381 wake_up_interruptible(&inode->i_pipe->wait); 381 wake_up_interruptible(&pipe->wait);
382 kill_fasync(&inode->i_pipe->fasync_readers, SIGIO, POLL_IN); 382 kill_fasync(&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);
@@ -411,21 +411,22 @@ pipe_ioctl(struct inode *pino, struct file *filp,
411 unsigned int cmd, unsigned long arg) 411 unsigned int cmd, unsigned long arg)
412{ 412{
413 struct inode *inode = filp->f_dentry->d_inode; 413 struct inode *inode = filp->f_dentry->d_inode;
414 struct pipe_inode_info *info; 414 struct pipe_inode_info *pipe;
415 int count, buf, nrbufs; 415 int count, buf, nrbufs;
416 416
417 switch (cmd) { 417 switch (cmd) {
418 case FIONREAD: 418 case FIONREAD:
419 mutex_lock(&inode->i_mutex); 419 mutex_lock(&inode->i_mutex);
420 info = inode->i_pipe; 420 pipe = inode->i_pipe;
421 count = 0; 421 count = 0;
422 buf = info->curbuf; 422 buf = pipe->curbuf;
423 nrbufs = info->nrbufs; 423 nrbufs = pipe->nrbufs;
424 while (--nrbufs >= 0) { 424 while (--nrbufs >= 0) {
425 count += info->bufs[buf].len; 425 count += pipe->bufs[buf].len;
426 buf = (buf+1) & (PIPE_BUFFERS-1); 426 buf = (buf+1) & (PIPE_BUFFERS-1);
427 } 427 }
428 mutex_unlock(&inode->i_mutex); 428 mutex_unlock(&inode->i_mutex);
429
429 return put_user(count, (int __user *)arg); 430 return put_user(count, (int __user *)arg);
430 default: 431 default:
431 return -EINVAL; 432 return -EINVAL;
@@ -438,17 +439,17 @@ pipe_poll(struct file *filp, poll_table *wait)
438{ 439{
439 unsigned int mask; 440 unsigned int mask;
440 struct inode *inode = filp->f_dentry->d_inode; 441 struct inode *inode = filp->f_dentry->d_inode;
441 struct pipe_inode_info *info = inode->i_pipe; 442 struct pipe_inode_info *pipe = inode->i_pipe;
442 int nrbufs; 443 int nrbufs;
443 444
444 poll_wait(filp, &inode->i_pipe->wait, wait); 445 poll_wait(filp, &pipe->wait, wait);
445 446
446 /* Reading only -- no need for acquiring the semaphore. */ 447 /* Reading only -- no need for acquiring the semaphore. */
447 nrbufs = info->nrbufs; 448 nrbufs = pipe->nrbufs;
448 mask = 0; 449 mask = 0;
449 if (filp->f_mode & FMODE_READ) { 450 if (filp->f_mode & FMODE_READ) {
450 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0; 451 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
451 if (!inode->i_pipe->writers && filp->f_version != inode->i_pipe->w_counter) 452 if (!pipe->writers && filp->f_version != pipe->w_counter)
452 mask |= POLLHUP; 453 mask |= POLLHUP;
453 } 454 }
454 455
@@ -458,7 +459,7 @@ pipe_poll(struct file *filp, poll_table *wait)
458 * Most Unices do not set POLLERR for FIFOs but on Linux they 459 * Most Unices do not set POLLERR for FIFOs but on Linux they
459 * behave exactly like pipes for poll(). 460 * behave exactly like pipes for poll().
460 */ 461 */
461 if (!inode->i_pipe->readers) 462 if (!pipe->readers)
462 mask |= POLLERR; 463 mask |= POLLERR;
463 } 464 }
464 465
@@ -468,15 +469,18 @@ pipe_poll(struct file *filp, poll_table *wait)
468static int 469static int
469pipe_release(struct inode *inode, int decr, int decw) 470pipe_release(struct inode *inode, int decr, int decw)
470{ 471{
472 struct pipe_inode_info *pipe;
473
471 mutex_lock(&inode->i_mutex); 474 mutex_lock(&inode->i_mutex);
472 inode->i_pipe->readers -= decr; 475 pipe = inode->i_pipe;
473 inode->i_pipe->writers -= decw; 476 pipe->readers -= decr;
474 if (!inode->i_pipe->readers && !inode->i_pipe->writers) { 477 pipe->writers -= decw;
478 if (!pipe->readers && !pipe->writers) {
475 free_pipe_info(inode); 479 free_pipe_info(inode);
476 } else { 480 } else {
477 wake_up_interruptible(&inode->i_pipe->wait); 481 wake_up_interruptible(&pipe->wait);
478 kill_fasync(&inode->i_pipe->fasync_readers, SIGIO, POLL_IN); 482 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
479 kill_fasync(&inode->i_pipe->fasync_writers, SIGIO, POLL_OUT); 483 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
480 } 484 }
481 mutex_unlock(&inode->i_mutex); 485 mutex_unlock(&inode->i_mutex);
482 486
@@ -679,30 +683,30 @@ static struct file_operations rdwr_pipe_fops = {
679 683
680struct pipe_inode_info * alloc_pipe_info(struct inode *inode) 684struct pipe_inode_info * alloc_pipe_info(struct inode *inode)
681{ 685{
682 struct pipe_inode_info *info; 686 struct pipe_inode_info *pipe;
683 687
684 info = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL); 688 pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
685 if (info) { 689 if (pipe) {
686 init_waitqueue_head(&info->wait); 690 init_waitqueue_head(&pipe->wait);
687 info->r_counter = info->w_counter = 1; 691 pipe->r_counter = pipe->w_counter = 1;
688 info->inode = inode; 692 pipe->inode = inode;
689 } 693 }
690 694
691 return info; 695 return pipe;
692} 696}
693 697
694void __free_pipe_info(struct pipe_inode_info *info) 698void __free_pipe_info(struct pipe_inode_info *pipe)
695{ 699{
696 int i; 700 int i;
697 701
698 for (i = 0; i < PIPE_BUFFERS; i++) { 702 for (i = 0; i < PIPE_BUFFERS; i++) {
699 struct pipe_buffer *buf = info->bufs + i; 703 struct pipe_buffer *buf = pipe->bufs + i;
700 if (buf->ops) 704 if (buf->ops)
701 buf->ops->release(info, buf); 705 buf->ops->release(pipe, buf);
702 } 706 }
703 if (info->tmp_page) 707 if (pipe->tmp_page)
704 __free_page(info->tmp_page); 708 __free_page(pipe->tmp_page);
705 kfree(info); 709 kfree(pipe);
706} 710}
707 711
708void free_pipe_info(struct inode *inode) 712void free_pipe_info(struct inode *inode)
@@ -723,15 +727,17 @@ static struct dentry_operations pipefs_dentry_operations = {
723static struct inode * get_pipe_inode(void) 727static struct inode * get_pipe_inode(void)
724{ 728{
725 struct inode *inode = new_inode(pipe_mnt->mnt_sb); 729 struct inode *inode = new_inode(pipe_mnt->mnt_sb);
730 struct pipe_inode_info *pipe;
726 731
727 if (!inode) 732 if (!inode)
728 goto fail_inode; 733 goto fail_inode;
729 734
730 inode->i_pipe = alloc_pipe_info(inode); 735 pipe = alloc_pipe_info(inode);
731 if (!inode->i_pipe) 736 if (!pipe)
732 goto fail_iput; 737 goto fail_iput;
738 inode->i_pipe = pipe;
733 739
734 inode->i_pipe->readers = inode->i_pipe->writers = 1; 740 pipe->readers = pipe->writers = 1;
735 inode->i_fop = &rdwr_pipe_fops; 741 inode->i_fop = &rdwr_pipe_fops;
736 742
737 /* 743 /*
@@ -746,6 +752,7 @@ static struct inode * get_pipe_inode(void)
746 inode->i_gid = current->fsgid; 752 inode->i_gid = current->fsgid;
747 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 753 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
748 inode->i_blksize = PAGE_SIZE; 754 inode->i_blksize = PAGE_SIZE;
755
749 return inode; 756 return inode;
750 757
751fail_iput: 758fail_iput: