mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-04 04:02:26 +00:00
pipe: use f_pipe
Pipes use f_version to defer poll notifications until a write has been observed. Since multiple file's refer to the same struct pipe_inode_info in their ->private_data moving it into their isn't feasible since we would need to introduce an additional pointer indirection. However, since pipes don't require f_pos_lock we placed a new f_pipe member into a union with f_pos_lock that pipes can use. This is similar to what we already do for struct inode where we have additional fields per file type. This will allow us to fully remove f_version in the next step. Link: https://lore.kernel.org/r/20240830-vfs-file-f_version-v1-19-6d3e4816aa7b@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
5e9b50dea9
commit
5a957bbac3
@ -686,7 +686,7 @@ pipe_poll(struct file *filp, poll_table *wait)
|
||||
if (filp->f_mode & FMODE_READ) {
|
||||
if (!pipe_empty(head, tail))
|
||||
mask |= EPOLLIN | EPOLLRDNORM;
|
||||
if (!pipe->writers && filp->f_version != pipe->w_counter)
|
||||
if (!pipe->writers && filp->f_pipe != pipe->w_counter)
|
||||
mask |= EPOLLHUP;
|
||||
}
|
||||
|
||||
@ -945,6 +945,7 @@ int create_pipe_files(struct file **res, int flags)
|
||||
}
|
||||
|
||||
f->private_data = inode->i_pipe;
|
||||
f->f_pipe = 0;
|
||||
|
||||
res[0] = alloc_file_clone(f, O_RDONLY | (flags & O_NONBLOCK),
|
||||
&pipefifo_fops);
|
||||
@ -954,6 +955,7 @@ int create_pipe_files(struct file **res, int flags)
|
||||
return PTR_ERR(res[0]);
|
||||
}
|
||||
res[0]->private_data = inode->i_pipe;
|
||||
res[0]->f_pipe = 0;
|
||||
res[1] = f;
|
||||
stream_open(inode, res[0]);
|
||||
stream_open(inode, res[1]);
|
||||
@ -1108,7 +1110,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
|
||||
bool is_pipe = inode->i_sb->s_magic == PIPEFS_MAGIC;
|
||||
int ret;
|
||||
|
||||
filp->f_version = 0;
|
||||
filp->f_pipe = 0;
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
if (inode->i_pipe) {
|
||||
@ -1155,7 +1157,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
|
||||
if ((filp->f_flags & O_NONBLOCK)) {
|
||||
/* suppress EPOLLHUP until we have
|
||||
* seen a writer */
|
||||
filp->f_version = pipe->w_counter;
|
||||
filp->f_pipe = pipe->w_counter;
|
||||
} else {
|
||||
if (wait_for_partner(pipe, &pipe->w_counter))
|
||||
goto err_rd;
|
||||
|
Loading…
Reference in New Issue
Block a user