[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 4 Apr 2018 15:17:51 -0400
From: jglisse@...hat.com
To: linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
linux-block@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Jérôme Glisse <jglisse@...hat.com>,
Eric Biggers <ebiggers@...gle.com>,
Kees Cook <keescook@...omium.org>,
Joe Lawrence <joe.lawrence@...hat.com>,
Willy Tarreau <w@....eu>,
Andrew Morton <akpm@...ux-foundation.org>,
Tejun Heo <tj@...nel.org>, Jan Kara <jack@...e.cz>,
Josef Bacik <jbacik@...com>,
Mel Gorman <mgorman@...hsingularity.net>,
Jeff Layton <jlayton@...hat.com>
Subject: [RFC PATCH 04/79] pipe: add inode field to struct pipe_inode_info
From: Jérôme Glisse <jglisse@...hat.com>
Pipes are associated with a file and thus an inode, store a pointer
back to the inode in struct pipe_inode_info, this will be use when
testing pages haven't been truncated.
Signed-off-by: Jérôme Glisse <jglisse@...hat.com>
Cc: Eric Biggers <ebiggers@...gle.com>
Cc: Kees Cook <keescook@...omium.org>
Cc: Joe Lawrence <joe.lawrence@...hat.com>
Cc: Willy Tarreau <w@....eu>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-fsdevel@...r.kernel.org
Cc: Tejun Heo <tj@...nel.org>
Cc: Jan Kara <jack@...e.cz>
Cc: Josef Bacik <jbacik@...com>
Cc: Mel Gorman <mgorman@...hsingularity.net>
Cc: Jeff Layton <jlayton@...hat.com>
---
fs/pipe.c | 2 ++
fs/splice.c | 1 +
include/linux/pipe_fs_i.h | 2 ++
3 files changed, 5 insertions(+)
diff --git a/fs/pipe.c b/fs/pipe.c
index 7b1954caf388..41e115b0bde7 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -715,6 +715,7 @@ static struct inode * get_pipe_inode(void)
inode->i_pipe = pipe;
pipe->files = 2;
+ pipe->inode = inode;
pipe->readers = pipe->writers = 1;
inode->i_fop = &pipefifo_fops;
@@ -903,6 +904,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
pipe = alloc_pipe_info();
if (!pipe)
return -ENOMEM;
+ pipe->inode = inode;
pipe->files = 1;
spin_lock(&inode->i_lock);
if (unlikely(inode->i_pipe)) {
diff --git a/fs/splice.c b/fs/splice.c
index 39e2dc01ac12..acab52a7fe56 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -927,6 +927,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
* PIPE_READERS appropriately.
*/
pipe->readers = 1;
+ pipe->inode = file_inode(in);
current->splice_pipe = pipe;
}
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 5a3bb3b7c9ad..171aa78ebbf0 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -44,6 +44,7 @@ struct pipe_buffer {
* @fasync_writers: writer side fasync
* @bufs: the circular array of pipe buffers
* @user: the user who created this pipe
+ * @inode: inode this pipe is associated to
**/
struct pipe_inode_info {
struct mutex mutex;
@@ -60,6 +61,7 @@ struct pipe_inode_info {
struct fasync_struct *fasync_writers;
struct pipe_buffer *bufs;
struct user_struct *user;
+ struct inode *inode;
};
/*
--
2.14.3
Powered by blists - more mailing lists