History

io_uring: add support for probing opcodes

The application currently has no way of knowing if a given opcode is supported or not without having to try and issue one and see if we get -EINVAL or not. And even this approach is fraught with peril, as maybe we're getting -EINVAL due to some fields being missing, or maybe it's just not that easy to issue that particular command without doing some other leg work in terms of setup first. This adds IORING_REGISTER_PROBE, which fills in a structure with info on what it supported or not. This will work even with sparse opcode fields, which may happen in the future or even today if someone backports specific features to older kernels.

Jens Axboe committed 6 years ago

Commit 66f4af91 parent 10fef4b2 files · +69 −2Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/io_uring.h+18−0
@@ -194,6 +194,7 @@ struct io_uring_params { · 193 unmodified lines
194194 #define IORING_UNREGISTER_EVENTFD 5
195195 #define IORING_REGISTER_FILES_UPDATE 6
196196 #define IORING_REGISTER_EVENTFD_ASYNC 7
197+#define IORING_REGISTER_PROBE 8
197198
198199 struct io_uring_files_update {
199200 __u32 offset;
@@ -201,4 +202,21 @@ struct io_uring_files_update { · 1 unmodified line
201202 __aligned_u64 /* __s32 * */ fds;
202203 };
203204
205+#define IO_URING_OP_SUPPORTED (1U << 0)
206+
207+struct io_uring_probe_op {
208+ __u8 op;
209+ __u8 resv;
210+ __u16 flags; /* IO_URING_OP_* flags */
211+ __u32 resv2;
212+};
213+
214+struct io_uring_probe {
215+ __u8 last_op; /* last opcode supported */
216+ __u8 ops_len; /* length of ops[] array below */
217+ __u16 resv;
218+ __u32 resv2[3];
219+ struct io_uring_probe_op ops[0];
220+};
221+
204222 #endif