[PATCH 05/12] io_uring: use __anon_inode_getfd

From
Christoph Hellwig <hch@lst.de>
Date
2020-05-08 15:36:54
Also in
bpf, io-uring, kvm, linux-fsdevel, linux-gpio, linux-integrity, linux-rdma, lkml
Reply to
Christoph Hellwig, 2020-05-08
Use __anon_inode_getfd instead of opencoding the logic using
get_unused_fd_flags + anon_inode_getfile.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/io_uring.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5190bfb6a6657..4104f8a45d11e 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7709,18 +7709,11 @@ static int io_uring_get_fd(struct io_ring_ctx *ctx)
 		return ret;
 #endif
 
-	ret = get_unused_fd_flags(O_RDWR | O_CLOEXEC);
+	ret = __anon_inode_getfd("[io_uring]", &io_uring_fops, ctx,
+			O_RDWR | O_CLOEXEC, &file);
 	if (ret < 0)
 		goto err;
 
-	file = anon_inode_getfile("[io_uring]", &io_uring_fops, ctx,
-					O_RDWR | O_CLOEXEC);
-	if (IS_ERR(file)) {
-		put_unused_fd(ret);
-		ret = PTR_ERR(file);
-		goto err;
-	}
-
 #if defined(CONFIG_UNIX)
 	ctx->ring_sock->file = file;
 #endif
-- 
2.26.2
Thread (16 messages) 16 messages, 4 authors, last reply 2020-05-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help