io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [liburing PATCH] io_uring: invalid fd for file-less operations
@ 2019-11-13 21:27 Pavel Begunkov
  2019-11-13 21:31 ` Pavel Begunkov
  2019-11-13 21:39 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Begunkov @ 2019-11-13 21:27 UTC (permalink / raw)
  To: Jens Axboe, io-uring

If an operation doesn't need a file, set fd to an invalid value.
This would help to spot an unwanted fdget() in the kernel, and is
conceptually more correct (though negotiable)

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 src/include/liburing.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 17bc80e..892efcf 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -240,7 +240,7 @@ static inline void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,
 static inline void io_uring_prep_poll_remove(struct io_uring_sqe *sqe,
 					     void *user_data)
 {
-	io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, 0, user_data, 0, 0);
+	io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, -1, user_data, 0, 0);
 }
 
 static inline void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
@@ -252,21 +252,21 @@ static inline void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
 
 static inline void io_uring_prep_nop(struct io_uring_sqe *sqe)
 {
-	io_uring_prep_rw(IORING_OP_NOP, sqe, 0, NULL, 0, 0);
+	io_uring_prep_rw(IORING_OP_NOP, sqe, -1, NULL, 0, 0);
 }
 
 static inline void io_uring_prep_timeout(struct io_uring_sqe *sqe,
 					 struct __kernel_timespec *ts,
 					 unsigned count, unsigned flags)
 {
-	io_uring_prep_rw(IORING_OP_TIMEOUT, sqe, 0, ts, 1, count);
+	io_uring_prep_rw(IORING_OP_TIMEOUT, sqe, -1, ts, 1, count);
 	sqe->timeout_flags = flags;
 }
 
 static inline void io_uring_prep_timeout_remove(struct io_uring_sqe *sqe,
 						__u64 user_data, unsigned flags)
 {
-	io_uring_prep_rw(IORING_OP_TIMEOUT_REMOVE, sqe, 0, (void *)user_data, 0, 0);
+	io_uring_prep_rw(IORING_OP_TIMEOUT_REMOVE, sqe, -1, (void *)user_data, 0, 0);
 	sqe->timeout_flags = flags;
 }
 
@@ -281,7 +281,7 @@ static inline void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd,
 static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, void *user_data,
 					int flags)
 {
-	io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, 0, user_data, 0, 0);
+	io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, -1, user_data, 0, 0);
 	sqe->cancel_flags = flags;
 }
 
@@ -289,7 +289,7 @@ static inline void io_uring_prep_link_timeout(struct io_uring_sqe *sqe,
 					      struct __kernel_timespec *ts,
 					      unsigned flags)
 {
-	io_uring_prep_rw(IORING_OP_LINK_TIMEOUT, sqe, 0, ts, 1, 0);
+	io_uring_prep_rw(IORING_OP_LINK_TIMEOUT, sqe, -1, ts, 1, 0);
 	sqe->timeout_flags = flags;
 }
 
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-13 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13 21:27 [liburing PATCH] io_uring: invalid fd for file-less operations Pavel Begunkov
2019-11-13 21:31 ` Pavel Begunkov
2019-11-13 21:39 ` Jens Axboe

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).