We're going to remove the userspace exposed zerocopy notification API, remove notification registration.
Unified · Split
| @@ -279,14 +279,10 @@ enum io_uring_op { · 278 unmodified lines | |||
| 279 | * | 279 | * |
| 280 | * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in | 280 | * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in |
| 281 | * the buf_index field. | 281 | * the buf_index field. |
| 282 | * | ||
| 283 | * IORING_RECVSEND_NOTIF_FLUSH Flush a notification after a successful | ||
| 284 | * successful. Only for zerocopy sends. | ||
| 285 | */ | 282 | */ |
| 286 | #define IORING_RECVSEND_POLL_FIRST (1U << 0) | 283 | #define IORING_RECVSEND_POLL_FIRST (1U << 0) |
| 287 | #define IORING_RECV_MULTISHOT (1U << 1) | 284 | #define IORING_RECV_MULTISHOT (1U << 1) |
| 288 | #define IORING_RECVSEND_FIXED_BUF (1U << 2) | 285 | #define IORING_RECVSEND_FIXED_BUF (1U << 2) |
| 289 | #define IORING_RECVSEND_NOTIF_FLUSH (1U << 3) | ||
| 290 | 286 | ||
| 291 | /* | 287 | /* |
| 292 | * accept flags stored in sqe->ioprio | 288 | * accept flags stored in sqe->ioprio |
| @@ -474,10 +470,6 @@ enum { · 181 unmodified lines | |||
| 474 | /* register a range of fixed file slots for automatic slot allocation */ | 470 | /* register a range of fixed file slots for automatic slot allocation */ |
| 475 | IORING_REGISTER_FILE_ALLOC_RANGE = 25, | 471 | IORING_REGISTER_FILE_ALLOC_RANGE = 25, |
| 476 | 472 | ||
| 477 | /* zerocopy notification API */ | ||
| 478 | IORING_REGISTER_NOTIFIERS = 26, | ||
| 479 | IORING_UNREGISTER_NOTIFIERS = 27, | ||
| 480 | |||
| 481 | /* this goes last */ | 473 | /* this goes last */ |
| 482 | IORING_REGISTER_LAST | 474 | IORING_REGISTER_LAST |
| 483 | }; | 475 | }; |
| @@ -2640,7 +2640,6 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) · 2639 unmodified lines | |||
| 2640 | io_unregister_personality(ctx, index); | 2640 | io_unregister_personality(ctx, index); |
| 2641 | if (ctx->rings) | 2641 | if (ctx->rings) |
| 2642 | io_poll_remove_all(ctx, NULL, true); | 2642 | io_poll_remove_all(ctx, NULL, true); |
| 2643 | io_notif_unregister(ctx); | ||
| 2644 | mutex_unlock(&ctx->uring_lock); | 2643 | mutex_unlock(&ctx->uring_lock); |
| 2645 | 2644 | ||
| 2646 | /* failed during ring init, it couldn't have issued any requests */ | 2645 | /* failed during ring init, it couldn't have issued any requests */ |
| @@ -3839,15 +3838,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, · 1192 unmodified lines | |||
| 3839 | break; | 3838 | break; |
| 3840 | ret = io_register_file_alloc_range(ctx, arg); | 3839 | ret = io_register_file_alloc_range(ctx, arg); |
| 3841 | break; | 3840 | break; |
| 3842 | case IORING_REGISTER_NOTIFIERS: | ||
| 3843 | ret = io_notif_register(ctx, arg, nr_args); | ||
| 3844 | break; | ||
| 3845 | case IORING_UNREGISTER_NOTIFIERS: | ||
| 3846 | ret = -EINVAL; | ||
| 3847 | if (arg || nr_args) | ||
| 3848 | break; | ||
| 3849 | ret = io_notif_unregister(ctx); | ||
| 3850 | break; | ||
| 3851 | default: | 3841 | default: |
| 3852 | ret = -EINVAL; | 3842 | ret = -EINVAL; |
| 3853 | break; | 3843 | break; |
| @@ -889,7 +889,7 @@ int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) · 888 unmodified lines | |||
| 889 | 889 | ||
| 890 | zc->flags = READ_ONCE(sqe->ioprio); | 890 | zc->flags = READ_ONCE(sqe->ioprio); |
| 891 | if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST | | 891 | if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST | |
| 892 | IORING_RECVSEND_FIXED_BUF | IORING_RECVSEND_NOTIF_FLUSH)) | 892 | IORING_RECVSEND_FIXED_BUF)) |
| 893 | return -EINVAL; | 893 | return -EINVAL; |
| 894 | if (zc->flags & IORING_RECVSEND_FIXED_BUF) { | 894 | if (zc->flags & IORING_RECVSEND_FIXED_BUF) { |
| 895 | unsigned idx = READ_ONCE(sqe->buf_index); | 895 | unsigned idx = READ_ONCE(sqe->buf_index); |
| @@ -1063,8 +1063,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags) · 167 unmodified lines | |||
| 1063 | if (ret == -ERESTARTSYS) | 1063 | if (ret == -ERESTARTSYS) |
| 1064 | ret = -EINTR; | 1064 | ret = -EINTR; |
| 1065 | req_set_fail(req); | 1065 | req_set_fail(req); |
| 1066 | } else if (zc->flags & IORING_RECVSEND_NOTIF_FLUSH) { | ||
| 1067 | io_notif_slot_flush_submit(notif_slot, 0); | ||
| 1068 | } | 1066 | } |
| 1069 | 1067 | ||
| 1070 | if (ret >= 0) | 1068 | if (ret >= 0) |
| @@ -86,74 +86,3 @@ void io_notif_slot_flush(struct io_notif_slot *slot) · 85 unmodified lines | |||
| 86 | io_req_task_work_add(notif); | 86 | io_req_task_work_add(notif); |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | |||
| 90 | __cold int io_notif_unregister(struct io_ring_ctx *ctx) | ||
| 91 | __must_hold(&ctx->uring_lock) | ||
| 92 | { | ||
| 93 | int i; | ||
| 94 | |||
| 95 | if (!ctx->notif_slots) | ||
| 96 | return -ENXIO; | ||
| 97 | |||
| 98 | for (i = 0; i < ctx->nr_notif_slots; i++) { | ||
| 99 | struct io_notif_slot *slot = &ctx->notif_slots[i]; | ||
| 100 | struct io_kiocb *notif = slot->notif; | ||
| 101 | struct io_notif_data *nd; | ||
| 102 | |||
| 103 | if (!notif) | ||
| 104 | continue; | ||
| 105 | nd = io_notif_to_data(notif); | ||
| 106 | slot->notif = NULL; | ||
| 107 | if (!refcount_dec_and_test(&nd->uarg.refcnt)) | ||
| 108 | continue; | ||
| 109 | notif->io_task_work.func = __io_notif_complete_tw; | ||
| 110 | io_req_task_work_add(notif); | ||
| 111 | } | ||
| 112 | |||
| 113 | kvfree(ctx->notif_slots); | ||
| 114 | ctx->notif_slots = NULL; | ||
| 115 | ctx->nr_notif_slots = 0; | ||
| 116 | return 0; | ||
| 117 | } | ||
| 118 | |||
| 119 | __cold int io_notif_register(struct io_ring_ctx *ctx, | ||
| 120 | void __user *arg, unsigned int size) | ||
| 121 | __must_hold(&ctx->uring_lock) | ||
| 122 | { | ||
| 123 | struct io_uring_notification_slot __user *slots; | ||
| 124 | struct io_uring_notification_slot slot; | ||
| 125 | struct io_uring_notification_register reg; | ||
| 126 | unsigned i; | ||
| 127 | |||
| 128 | if (ctx->nr_notif_slots) | ||
| 129 | return -EBUSY; | ||
| 130 | if (size != sizeof(reg)) | ||
| 131 | return -EINVAL; | ||
| 132 | if (copy_from_user(®, arg, sizeof(reg))) | ||
| 133 | return -EFAULT; | ||
| 134 | if (!reg.nr_slots || reg.nr_slots > IORING_MAX_NOTIF_SLOTS) | ||
| 135 | return -EINVAL; | ||
| 136 | if (reg.resv || reg.resv2 || reg.resv3) | ||
| 137 | return -EINVAL; | ||
| 138 | |||
| 139 | slots = u64_to_user_ptr(reg.data); | ||
| 140 | ctx->notif_slots = kvcalloc(reg.nr_slots, sizeof(ctx->notif_slots[0]), | ||
| 141 | GFP_KERNEL_ACCOUNT); | ||
| 142 | if (!ctx->notif_slots) | ||
| 143 | return -ENOMEM; | ||
| 144 | |||
| 145 | for (i = 0; i < reg.nr_slots; i++, ctx->nr_notif_slots++) { | ||
| 146 | struct io_notif_slot *notif_slot = &ctx->notif_slots[i]; | ||
| 147 | |||
| 148 | if (copy_from_user(&slot, &slots[i], sizeof(slot))) { | ||
| 149 | io_notif_unregister(ctx); | ||
| 150 | return -EFAULT; | ||
| 151 | } | ||
| 152 | if (slot.resv[0] | slot.resv[1] | slot.resv[2]) { | ||
| 153 | io_notif_unregister(ctx); | ||
| 154 | return -EINVAL; | ||
| 155 | } | ||
| 156 | notif_slot->tag = slot.tag; | ||
| 157 | } | ||
| 158 | return 0; | ||
| 159 | } | ||
| @@ -8,7 +8,6 @@ · 7 unmodified lines | |||
| 8 | #include "rsrc.h" | 8 | #include "rsrc.h" |
| 9 | 9 | ||
| 10 | #define IO_NOTIF_SPLICE_BATCH 32 | 10 | #define IO_NOTIF_SPLICE_BATCH 32 |
| 11 | #define IORING_MAX_NOTIF_SLOTS (1U << 15) | ||
| 12 | 11 | ||
| 13 | struct io_notif_data { | 12 | struct io_notif_data { |
| 14 | struct file *file; | 13 | struct file *file; |
| @@ -36,10 +35,6 @@ struct io_notif_slot { · 21 unmodified lines | |||
| 36 | u32 seq; | 35 | u32 seq; |
| 37 | }; | 36 | }; |
| 38 | 37 | ||
| 39 | int io_notif_register(struct io_ring_ctx *ctx, | ||
| 40 | void __user *arg, unsigned int size); | ||
| 41 | int io_notif_unregister(struct io_ring_ctx *ctx); | ||
| 42 | |||
| 43 | void io_notif_slot_flush(struct io_notif_slot *slot); | 38 | void io_notif_slot_flush(struct io_notif_slot *slot); |
| 44 | struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx, | 39 | struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx, |
| 45 | struct io_notif_slot *slot); | 40 | struct io_notif_slot *slot); |
| @@ -67,12 +62,6 @@ static inline struct io_notif_slot *io_get_notif_slot(struct io_ring_ctx *ctx, · 21 unmodified lines | |||
| 67 | return &ctx->notif_slots[idx]; | 62 | return &ctx->notif_slots[idx]; |
| 68 | } | 63 | } |
| 69 | 64 | ||
| 70 | static inline void io_notif_slot_flush_submit(struct io_notif_slot *slot, | ||
| 71 | unsigned int issue_flags) | ||
| 72 | { | ||
| 73 | io_notif_slot_flush(slot); | ||
| 74 | } | ||
| 75 | |||
| 76 | static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len) | 65 | static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len) |
| 77 | { | 66 | { |
| 78 | struct io_ring_ctx *ctx = notif->ctx; | 67 | struct io_ring_ctx *ctx = notif->ctx; |