linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	 Jeff Layton <jlayton@kernel.org>,
	Amir Goldstein <amir73il@gmail.com>,
	 Jens Axboe <axboe@kernel.dk>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	 linux-fsdevel@vger.kernel.org,
	Christian Brauner <brauner@kernel.org>
Subject: [PATCH RFC v2 12/48] eventpoll: convert do_epoll_create() to FD_PREPARE()
Date: Thu, 20 Nov 2025 23:32:09 +0100	[thread overview]
Message-ID: <20251120-work-fd-prepare-v2-12-fef6ebda05d3@kernel.org> (raw)
In-Reply-To: <20251120-work-fd-prepare-v2-0-fef6ebda05d3@kernel.org>

Placeholder commit message.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/eventpoll.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ee7c4b683ec3..908525e5061e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -2165,9 +2165,8 @@ static void clear_tfile_check_list(void)
  */
 static int do_epoll_create(int flags)
 {
-	int error, fd;
-	struct eventpoll *ep = NULL;
-	struct file *file;
+	int error;
+	struct eventpoll *ep;
 
 	/* Check the EPOLL_* constant for consistency.  */
 	BUILD_BUG_ON(EPOLL_CLOEXEC != O_CLOEXEC);
@@ -2184,26 +2183,17 @@ static int do_epoll_create(int flags)
 	 * Creates all the items needed to setup an eventpoll file. That is,
 	 * a file structure and a free file descriptor.
 	 */
-	fd = get_unused_fd_flags(O_RDWR | (flags & O_CLOEXEC));
-	if (fd < 0) {
-		error = fd;
-		goto out_free_ep;
-	}
-	file = anon_inode_getfile("[eventpoll]", &eventpoll_fops, ep,
-				 O_RDWR | (flags & O_CLOEXEC));
-	if (IS_ERR(file)) {
-		error = PTR_ERR(file);
-		goto out_free_fd;
+	FD_PREPARE(fdf, O_RDWR | (flags & O_CLOEXEC),
+		   anon_inode_getfile("[eventpoll]", &eventpoll_fops, ep,
+				      O_RDWR | (flags & O_CLOEXEC))) {
+		if (fd_prepare_failed(fdf)) {
+			ep_clear_and_put(ep);
+			return fd_prepare_error(fdf);
+		}
+
+		ep->file = fd_prepare_file(fdf);
+		return fd_publish(fdf);
 	}
-	ep->file = file;
-	fd_install(fd, file);
-	return fd;
-
-out_free_fd:
-	put_unused_fd(fd);
-out_free_ep:
-	ep_clear_and_put(ep);
-	return error;
 }
 
 SYSCALL_DEFINE1(epoll_create1, int, flags)

-- 
2.47.3


  parent reply	other threads:[~2025-11-20 22:32 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 22:31 [PATCH RFC v2 00/48] file: add and convert to FD_PREPARE() Christian Brauner
2025-11-20 22:31 ` [PATCH RFC v2 01/48] file: add FD_PREPARE() Christian Brauner
2025-11-20 22:31 ` [PATCH RFC v2 02/48] anon_inodes: convert __anon_inode_getfd() to FD_PREPARE() Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 03/48] eventfd: convert do_eventfd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 04/48] fhandle: convert do_handle_open() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 05/48] namespace: convert open_tree() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 06/48] namespace: convert open_tree_attr() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 07/48] namespace: convert fsmount() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 08/48] fanotify: convert fanotify_init() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 09/48] nsfs: convert open_namespace() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 10/48] nsfs: convert ns_ioctl() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 11/48] autofs: convert autofs_dev_ioctl_open_mountpoint() " Christian Brauner
2025-11-20 22:32 ` Christian Brauner [this message]
2025-11-20 22:32 ` [PATCH RFC v2 13/48] open: convert do_sys_openat2() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 14/48] signalfd: convert do_signalfd4() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 15/48] timerfd: convert timerfd_create() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 16/48] userfaultfd: convert new_userfaultfd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 17/48] xfs: convert xfs_open_by_handle() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 18/48] drm: convert drm_mode_create_lease_ioctl() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 19/48] dma: convert dma_buf_fd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 20/48] af_unix: convert unix_file_open() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 21/48] dma: convert sync_file_ioctl_merge() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 22/48] exec: convert begin_new_exec() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 23/48] ipc: convert do_mq_open() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 24/48] bpf: convert bpf_iter_new_fd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 25/48] bpf: convert bpf_token_create() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 26/48] memfd: convert memfd_create() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 27/48] secretmem: convert memfd_secret() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 28/48] net/handshake: convert handshake_nl_accept_doit() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 29/48] net/kcm: convert kcm_ioctl() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 30/48] net/sctp: convert sctp_getsockopt_peeloff_common() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 31/48] net/socket: convert sock_map_fd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 32/48] net/socket: convert __sys_accept4_file() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 33/48] spufs: convert spufs_context_open() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 34/48] papr-hvpipe: convert papr_hvpipe_dev_create_handle() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 35/48] spufs: convert spufs_gang_open() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 36/48] pseries: convert papr_platform_dump_create_handle() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 37/48] pseries: port papr_rtas_setup_file_interface() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 38/48] dma: port sw_sync_ioctl_create_fence() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 39/48] gpio: convert linehandle_create() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 40/48] hv: convert mshv_ioctl_create_partition() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 41/48] media: convert media_request_alloc() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 42/48] ntsync: convert ntsync_obj_get_fd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 43/48] tty: convert ptm_open_peer() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 44/48] vfio: convert vfio_group_ioctl_get_device_fd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 45/48] file: convert replace_fd() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 46/48] io_uring: convert io_create_mock_file() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 47/48] kvm: convert kvm_arch_supports_gmem_init_shared() " Christian Brauner
2025-11-20 22:32 ` [PATCH RFC v2 48/48] kvm: convert kvm_vcpu_ioctl_get_stats_fd() " Christian Brauner
2025-11-20 23:08 ` [PATCH RFC v2 00/48] file: add and convert " Linus Torvalds
2025-11-20 23:28   ` Linus Torvalds
2025-11-21 17:55     ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251120-work-fd-prepare-v2-12-fef6ebda05d3@kernel.org \
    --to=brauner@kernel.org \
    --cc=amir73il@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).