Skip to content

Commit de32ec4

Browse files
author
Al Viro
committed
pipe: set file->private_data to ->i_pipe
simplify get_pipe_info(), while we are at it Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 72b0d9a commit de32ec4

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

‎fs/coredump.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,7 @@ static void coredump_finish(struct mm_struct *mm)
409409

410410
static void wait_for_dump_helpers(struct file *file)
411411
{
412-
struct pipe_inode_info *pipe;
413-
414-
pipe = file_inode(file)->i_pipe;
412+
struct pipe_inode_info *pipe = file->private_data;
415413

416414
pipe_lock(pipe);
417415
pipe->readers++;

‎fs/pipe.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
363363
unsigned long nr_segs, loff_t pos)
364364
{
365365
struct file *filp = iocb->ki_filp;
366-
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe;
366+
struct pipe_inode_info *pipe = filp->private_data;
367367
int do_wakeup;
368368
ssize_t ret;
369369
struct iovec *iov = (struct iovec *)_iov;
@@ -486,7 +486,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
486486
unsigned long nr_segs, loff_t ppos)
487487
{
488488
struct file *filp = iocb->ki_filp;
489-
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe;
489+
struct pipe_inode_info *pipe = filp->private_data;
490490
ssize_t ret;
491491
int do_wakeup;
492492
struct iovec *iov = (struct iovec *)_iov;
@@ -662,7 +662,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
662662

663663
static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
664664
{
665-
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe;
665+
struct pipe_inode_info *pipe = filp->private_data;
666666
int count, buf, nrbufs;
667667

668668
switch (cmd) {
@@ -688,7 +688,7 @@ static unsigned int
688688
pipe_poll(struct file *filp, poll_table *wait)
689689
{
690690
unsigned int mask;
691-
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe;
691+
struct pipe_inode_info *pipe = filp->private_data;
692692
int nrbufs;
693693

694694
poll_wait(filp, &pipe->wait, wait);
@@ -749,7 +749,7 @@ pipe_release(struct inode *inode, struct file *file)
749749
static int
750750
pipe_fasync(int fd, struct file *filp, int on)
751751
{
752-
struct pipe_inode_info *pipe = file_inode(filp)->i_pipe;
752+
struct pipe_inode_info *pipe = filp->private_data;
753753
int retval = 0;
754754

755755
pipe_lock(pipe);
@@ -887,12 +887,14 @@ int create_pipe_files(struct file **res, int flags)
887887
goto err_dentry;
888888

889889
f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
890+
f->private_data = inode->i_pipe;
890891

891892
res[0] = alloc_file(&path, FMODE_READ, &pipefifo_fops);
892893
if (IS_ERR(res[0]))
893894
goto err_file;
894895

895896
path_get(&path);
897+
res[0]->private_data = inode->i_pipe;
896898
res[0]->f_flags = O_RDONLY | (flags & O_NONBLOCK);
897899
res[1] = f;
898900
return 0;
@@ -1035,6 +1037,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
10351037
spin_unlock(&inode->i_lock);
10361038
}
10371039
}
1040+
filp->private_data = pipe;
10381041
/* OK, we have a pipe and it's pinned down */
10391042

10401043
pipe_lock(pipe);
@@ -1233,9 +1236,7 @@ int pipe_proc_fn(struct ctl_table *table, int write, void __user *buf,
12331236
*/
12341237
struct pipe_inode_info *get_pipe_info(struct file *file)
12351238
{
1236-
struct inode *i = file_inode(file);
1237-
1238-
return S_ISFIFO(i->i_mode) ? i->i_pipe : NULL;
1239+
return file->f_op == &pipefifo_fops ? file->private_data : NULL;
12391240
}
12401241

12411242
long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)

0 commit comments

Comments
 (0)