Commit b4bd6b4b authored by Max Kellermann's avatar Max Kellermann Committed by Christian Brauner

fs/pipe: move check to pipe_has_watch_queue()

This declutters the code by reducing the number of #ifdefs and makes
the watch_queue checks simpler.  This has no runtime effect; the
machine code is identical.
Signed-off-by: default avatarMax Kellermann <max.kellermann@ionos.com>
Message-Id: <20230921075755.1378787-2-max.kellermann@ionos.com>
Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 61105aab
...@@ -437,12 +437,10 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -437,12 +437,10 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
goto out; goto out;
} }
#ifdef CONFIG_WATCH_QUEUE if (pipe_has_watch_queue(pipe)) {
if (pipe->watch_queue) {
ret = -EXDEV; ret = -EXDEV;
goto out; goto out;
} }
#endif
/* /*
* If it wasn't empty we try to merge new data into * If it wasn't empty we try to merge new data into
...@@ -1325,10 +1323,8 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned int arg) ...@@ -1325,10 +1323,8 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned int arg)
unsigned int nr_slots, size; unsigned int nr_slots, size;
long ret = 0; long ret = 0;
#ifdef CONFIG_WATCH_QUEUE if (pipe_has_watch_queue(pipe))
if (pipe->watch_queue)
return -EBUSY; return -EBUSY;
#endif
size = round_pipe_size(arg); size = round_pipe_size(arg);
nr_slots = size >> PAGE_SHIFT; nr_slots = size >> PAGE_SHIFT;
...@@ -1380,10 +1376,8 @@ struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice) ...@@ -1380,10 +1376,8 @@ struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice)
if (file->f_op != &pipefifo_fops || !pipe) if (file->f_op != &pipefifo_fops || !pipe)
return NULL; return NULL;
#ifdef CONFIG_WATCH_QUEUE if (for_splice && pipe_has_watch_queue(pipe))
if (for_splice && pipe->watch_queue)
return NULL; return NULL;
#endif
return pipe; return pipe;
} }
......
...@@ -124,6 +124,22 @@ struct pipe_buf_operations { ...@@ -124,6 +124,22 @@ struct pipe_buf_operations {
bool (*get)(struct pipe_inode_info *, struct pipe_buffer *); bool (*get)(struct pipe_inode_info *, struct pipe_buffer *);
}; };
/**
* pipe_has_watch_queue - Check whether the pipe is a watch_queue,
* i.e. it was created with O_NOTIFICATION_PIPE
* @pipe: The pipe to check
*
* Return: true if pipe is a watch queue, false otherwise.
*/
static inline bool pipe_has_watch_queue(const struct pipe_inode_info *pipe)
{
#ifdef CONFIG_WATCH_QUEUE
return pipe->watch_queue != NULL;
#else
return false;
#endif
}
/** /**
* pipe_empty - Return true if the pipe is empty * pipe_empty - Return true if the pipe is empty
* @head: The pipe ring head pointer * @head: The pipe ring head pointer
......
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