Commit 3669fa63 authored by Linus Torvalds's avatar Linus Torvalds

Use 'free_pipe_info()' helper function for pipe closedown.

This avoids having fs/fifo.c having to know anything about
pipe data passing details, and cleans up the code.
parent 09a141fe
...@@ -135,12 +135,8 @@ static int fifo_open(struct inode *inode, struct file *filp) ...@@ -135,12 +135,8 @@ static int fifo_open(struct inode *inode, struct file *filp)
goto err; goto err;
err: err:
if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) { if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode))
struct pipe_inode_info *info = inode->i_pipe; free_pipe_info(inode);
inode->i_pipe = NULL;
free_page((unsigned long)info->base);
kfree(info);
}
err_nocleanup: err_nocleanup:
up(PIPE_SEM(*inode)); up(PIPE_SEM(*inode));
......
...@@ -322,10 +322,7 @@ pipe_release(struct inode *inode, int decr, int decw) ...@@ -322,10 +322,7 @@ pipe_release(struct inode *inode, int decr, int decw)
PIPE_READERS(*inode) -= decr; PIPE_READERS(*inode) -= decr;
PIPE_WRITERS(*inode) -= decw; PIPE_WRITERS(*inode) -= decw;
if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) { if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
struct pipe_inode_info *info = inode->i_pipe; free_pipe_info(inode);
inode->i_pipe = NULL;
free_page((unsigned long) info->base);
kfree(info);
} else { } else {
wake_up_interruptible(PIPE_WAIT(*inode)); wake_up_interruptible(PIPE_WAIT(*inode));
kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
...@@ -530,6 +527,14 @@ struct file_operations rdwr_pipe_fops = { ...@@ -530,6 +527,14 @@ struct file_operations rdwr_pipe_fops = {
.fasync = pipe_rdwr_fasync, .fasync = pipe_rdwr_fasync,
}; };
void free_pipe_info(struct inode *inode)
{
struct pipe_inode_info *info = inode->i_pipe;
inode->i_pipe = NULL;
free_page((unsigned long)info->base);
kfree(info);
}
struct inode* pipe_new(struct inode* inode) struct inode* pipe_new(struct inode* inode)
{ {
unsigned long page; unsigned long page;
...@@ -668,9 +673,7 @@ int do_pipe(int *fd) ...@@ -668,9 +673,7 @@ int do_pipe(int *fd)
close_f12_inode_i: close_f12_inode_i:
put_unused_fd(i); put_unused_fd(i);
close_f12_inode: close_f12_inode:
free_page((unsigned long) PIPE_BASE(*inode)); free_pipe_info(inode);
kfree(inode->i_pipe);
inode->i_pipe = NULL;
iput(inode); iput(inode);
close_f12: close_f12:
put_filp(f2); put_filp(f2);
......
...@@ -44,5 +44,6 @@ struct pipe_inode_info { ...@@ -44,5 +44,6 @@ struct pipe_inode_info {
void pipe_wait(struct inode * inode); void pipe_wait(struct inode * inode);
struct inode* pipe_new(struct inode* inode); struct inode* pipe_new(struct inode* inode);
void free_pipe_info(struct inode* inode);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment