diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-04-11 07:53:33 -0400 |
---|---|---|
committer | Jens Axboe <axboe@suse.de> | 2006-04-11 07:53:33 -0400 |
commit | 923f4f23940d2361e8d5c4245982163a8e9d1c91 (patch) | |
tree | 05d24681cadfd731a083b0fa3b22b6e7a6622555 /fs/pipe.c | |
parent | 9aeedfc4712ed58d9f7ae41596185c72b8dc97e8 (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/pipe.c')
-rw-r--r-- | fs/pipe.c | 163 |
1 files changed, 85 insertions, 78 deletions
@@ -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 | ||
96 | static void anon_pipe_buf_release(struct pipe_inode_info *info, struct pipe_buffer *buf) | 96 | static 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 | ||
118 | static void *anon_pipe_buf_map(struct file *file, struct pipe_inode_info *info, struct pipe_buffer *buf) | 118 | static 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 | ||
123 | static void anon_pipe_buf_unmap(struct pipe_inode_info *info, struct pipe_buffer *buf) | 123 | static 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 | ||
128 | static int anon_pipe_buf_steal(struct pipe_inode_info *info, | 128 | static 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 | } |
378 | out: | 378 | out: |
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) | |||
468 | static int | 469 | static int |
469 | pipe_release(struct inode *inode, int decr, int decw) | 470 | pipe_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 | ||
680 | struct pipe_inode_info * alloc_pipe_info(struct inode *inode) | 684 | struct 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 | ||
694 | void __free_pipe_info(struct pipe_inode_info *info) | 698 | void __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 | ||
708 | void free_pipe_info(struct inode *inode) | 712 | void free_pipe_info(struct inode *inode) |
@@ -723,15 +727,17 @@ static struct dentry_operations pipefs_dentry_operations = { | |||
723 | static struct inode * get_pipe_inode(void) | 727 | static 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 | ||
751 | fail_iput: | 758 | fail_iput: |