1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/nospec.h>
8 #define IO_NOTIF_SPLICE_BATCH 32
9 #define IORING_MAX_NOTIF_SLOTS (1U << 10)
12 struct ubuf_info uarg;
13 struct io_ring_ctx *ctx;
14 struct io_rsrc_node *rsrc_node;
16 /* complete via tw if ->task is non-NULL, fallback to wq otherwise */
17 struct task_struct *task;
19 /* cqe->user_data, io_notif_slot::tag if not overridden */
21 /* see struct io_notif_slot::seq */
23 /* hook into ctx->notif_list and ctx->notif_list_locked */
24 struct list_head cache_node;
27 struct callback_head task_work;
28 struct work_struct commit_work;
32 struct io_notif_slot {
34 * Current/active notifier. A slot holds only one active notifier at a
35 * time and keeps one reference to it. Flush releases the reference and
36 * lazily replaces it with a new notifier.
38 struct io_notif *notif;
41 * Default ->user_data for this slot notifiers CQEs
45 * Notifiers of a slot live in generations, we create a new notifier
46 * only after flushing the previous one. Track the sequential number
47 * for all notifiers and copy it into notifiers's cqe->cflags
52 int io_notif_register(struct io_ring_ctx *ctx,
53 void __user *arg, unsigned int size);
54 int io_notif_unregister(struct io_ring_ctx *ctx);
55 void io_notif_cache_purge(struct io_ring_ctx *ctx);
57 struct io_notif *io_alloc_notif(struct io_ring_ctx *ctx,
58 struct io_notif_slot *slot);
60 static inline struct io_notif *io_get_notif(struct io_ring_ctx *ctx,
61 struct io_notif_slot *slot)
64 slot->notif = io_alloc_notif(ctx, slot);
68 static inline struct io_notif_slot *io_get_notif_slot(struct io_ring_ctx *ctx,
70 __must_hold(&ctx->uring_lock)
72 if (idx >= ctx->nr_notif_slots)
74 idx = array_index_nospec(idx, ctx->nr_notif_slots);
75 return &ctx->notif_slots[idx];