Re: [RFC v3 3/3] file, epoll: Implement do_replace() and eventpoll_replace()

From: Matthew Wilcox
Date: Fri Mar 24 2023 - 01:26:23 EST


On Fri, Mar 24, 2023 at 05:15:26AM +0000, aloktiagi wrote:
> diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
> index 3337745d81bd..38904fce3840 100644
> --- a/include/linux/eventpoll.h
> +++ b/include/linux/eventpoll.h
> @@ -25,6 +25,8 @@ struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd, unsigned long t
> /* Used to release the epoll bits inside the "struct file" */
> void eventpoll_release_file(struct file *file);
>
> +void eventpoll_replace_file(struct file *toreplace, struct file *file);
> +
> /*
> * This is called from inside fs/file_table.c:__fput() to unlink files
> * from the eventpoll interface. We need to have this facility to cleanup
> @@ -53,6 +55,22 @@ static inline void eventpoll_release(struct file *file)
> eventpoll_release_file(file);
> }
>
> +
> +/*
> + * This is called from fs/file.c:do_replace() to replace a linked file in the
> + * epoll interface with a new file received from another process. This is useful
> + * in cases where a process is trying to install a new file for an existing one
> + * that is linked in the epoll interface
> + */
> +static inline void eventpoll_replace(struct file *toreplace, struct file *file)
> +{
> + /*
> + * toreplace is the file being replaced. Install the new file for the
> + * existing one that is linked in the epoll interface
> + */
> + eventpoll_replace_file(toreplace, file);
> +}

Why do we have both eventpoll_replace() and eventpoll_replace_file()?
They seem identical?

> diff --git a/include/linux/file.h b/include/linux/file.h
> index 39704eae83e2..80e56b2b44fb 100644
> --- a/include/linux/file.h
> +++ b/include/linux/file.h
> @@ -36,6 +36,7 @@ struct fd {
> struct file *file;
> unsigned int flags;
> };
> +
> #define FDPUT_FPUT 1
> #define FDPUT_POS_UNLOCK 2
>

You should drop this hunk of the patch.