Commit de32ec4c authored by Al Viro's avatar Al Viro

pipe: set file->private_data to ->i_pipe

simplify get_pipe_info(), while we are at it
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 72b0d9aa
...@@ -409,9 +409,7 @@ static void coredump_finish(struct mm_struct *mm) ...@@ -409,9 +409,7 @@ static void coredump_finish(struct mm_struct *mm)
static void wait_for_dump_helpers(struct file *file) static void wait_for_dump_helpers(struct file *file)
{ {
struct pipe_inode_info *pipe; struct pipe_inode_info *pipe = file->private_data;
pipe = file_inode(file)->i_pipe;
pipe_lock(pipe); pipe_lock(pipe);
pipe->readers++; pipe->readers++;
......
...@@ -363,7 +363,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov, ...@@ -363,7 +363,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
unsigned long nr_segs, loff_t pos) unsigned long nr_segs, loff_t pos)
{ {
struct file *filp = iocb->ki_filp; struct file *filp = iocb->ki_filp;
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe; struct pipe_inode_info *pipe = filp->private_data;
int do_wakeup; int do_wakeup;
ssize_t ret; ssize_t ret;
struct iovec *iov = (struct iovec *)_iov; struct iovec *iov = (struct iovec *)_iov;
...@@ -486,7 +486,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov, ...@@ -486,7 +486,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
unsigned long nr_segs, loff_t ppos) unsigned long nr_segs, loff_t ppos)
{ {
struct file *filp = iocb->ki_filp; struct file *filp = iocb->ki_filp;
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe; struct pipe_inode_info *pipe = filp->private_data;
ssize_t ret; ssize_t ret;
int do_wakeup; int do_wakeup;
struct iovec *iov = (struct iovec *)_iov; struct iovec *iov = (struct iovec *)_iov;
...@@ -662,7 +662,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov, ...@@ -662,7 +662,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ {
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe; struct pipe_inode_info *pipe = filp->private_data;
int count, buf, nrbufs; int count, buf, nrbufs;
switch (cmd) { switch (cmd) {
...@@ -688,7 +688,7 @@ static unsigned int ...@@ -688,7 +688,7 @@ static unsigned int
pipe_poll(struct file *filp, poll_table *wait) pipe_poll(struct file *filp, poll_table *wait)
{ {
unsigned int mask; unsigned int mask;
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe; struct pipe_inode_info *pipe = filp->private_data;
int nrbufs; int nrbufs;
poll_wait(filp, &pipe->wait, wait); poll_wait(filp, &pipe->wait, wait);
...@@ -749,7 +749,7 @@ pipe_release(struct inode *inode, struct file *file) ...@@ -749,7 +749,7 @@ pipe_release(struct inode *inode, struct file *file)
static int static int
pipe_fasync(int fd, struct file *filp, int on) pipe_fasync(int fd, struct file *filp, int on)
{ {
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe; struct pipe_inode_info *pipe = filp->private_data;
int retval = 0; int retval = 0;
pipe_lock(pipe); pipe_lock(pipe);
...@@ -887,12 +887,14 @@ int create_pipe_files(struct file **res, int flags) ...@@ -887,12 +887,14 @@ int create_pipe_files(struct file **res, int flags)
goto err_dentry; goto err_dentry;
f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)); f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
f->private_data = inode->i_pipe;
res[0] = alloc_file(&path, FMODE_READ, &pipefifo_fops); res[0] = alloc_file(&path, FMODE_READ, &pipefifo_fops);
if (IS_ERR(res[0])) if (IS_ERR(res[0]))
goto err_file; goto err_file;
path_get(&path); path_get(&path);
res[0]->private_data = inode->i_pipe;
res[0]->f_flags = O_RDONLY | (flags & O_NONBLOCK); res[0]->f_flags = O_RDONLY | (flags & O_NONBLOCK);
res[1] = f; res[1] = f;
return 0; return 0;
...@@ -1035,6 +1037,7 @@ static int fifo_open(struct inode *inode, struct file *filp) ...@@ -1035,6 +1037,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
} }
} }
filp->private_data = pipe;
/* OK, we have a pipe and it's pinned down */ /* OK, we have a pipe and it's pinned down */
pipe_lock(pipe); pipe_lock(pipe);
...@@ -1233,9 +1236,7 @@ int pipe_proc_fn(struct ctl_table *table, int write, void __user *buf, ...@@ -1233,9 +1236,7 @@ int pipe_proc_fn(struct ctl_table *table, int write, void __user *buf,
*/ */
struct pipe_inode_info *get_pipe_info(struct file *file) struct pipe_inode_info *get_pipe_info(struct file *file)
{ {
struct inode *i = file_inode(file); return file->f_op == &pipefifo_fops ? file->private_data : NULL;
return S_ISFIFO(i->i_mode) ? i->i_pipe : NULL;
} }
long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg) long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
......
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