History

io_uring/notif: remove notif registration

We're going to remove the userspace exposed zerocopy notification API, remove notification registration.

Pavel Begunkov committed 4 years ago

Commit 57f33221 parent d9808ce5 files · +1 −103Browse files

Unified · Split

5 files
  1. include/uapi/linux/io_uring.h +0 −8
  2. io_uring/io_uring.c +0 −10
  3. io_uring/net.c +1 −3
  4. io_uring/notif.c +0 −71
  5. io_uring/notif.h +0 −11
include/uapi/linux/io_uring.h+0−8
@@ -279,14 +279,10 @@ enum io_uring_op { · 278 unmodified lines
279279 *
280280 * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in
281281 * the buf_index field.
282− *
283− * IORING_RECVSEND_NOTIF_FLUSH Flush a notification after a successful
284− * successful. Only for zerocopy sends.
285282 */
286283 #define IORING_RECVSEND_POLL_FIRST (1U << 0)
287284 #define IORING_RECV_MULTISHOT (1U << 1)
288285 #define IORING_RECVSEND_FIXED_BUF (1U << 2)
289−#define IORING_RECVSEND_NOTIF_FLUSH (1U << 3)
290286
291287 /*
292288 * accept flags stored in sqe->ioprio
@@ -474,10 +470,6 @@ enum { · 181 unmodified lines
474470 /* register a range of fixed file slots for automatic slot allocation */
475471 IORING_REGISTER_FILE_ALLOC_RANGE = 25,
476472
477− /* zerocopy notification API */
478− IORING_REGISTER_NOTIFIERS = 26,
479− IORING_UNREGISTER_NOTIFIERS = 27,
480−
481473 /* this goes last */
482474 IORING_REGISTER_LAST
483475 };
io_uring/io_uring.c+0−10
@@ -2640,7 +2640,6 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) · 2639 unmodified lines
26402640 io_unregister_personality(ctx, index);
26412641 if (ctx->rings)
26422642 io_poll_remove_all(ctx, NULL, true);
2643− io_notif_unregister(ctx);
26442643 mutex_unlock(&ctx->uring_lock);
26452644
26462645 /* 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
38393838 break;
38403839 ret = io_register_file_alloc_range(ctx, arg);
38413840 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;
38513841 default:
38523842 ret = -EINVAL;
38533843 break;
io_uring/net.c+1−3
@@ -889,7 +889,7 @@ int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) · 888 unmodified lines
889889
890890 zc->flags = READ_ONCE(sqe->ioprio);
891891 if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST |
892− IORING_RECVSEND_FIXED_BUF | IORING_RECVSEND_NOTIF_FLUSH))
892+ IORING_RECVSEND_FIXED_BUF))
893893 return -EINVAL;
894894 if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
895895 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
10631063 if (ret == -ERESTARTSYS)
10641064 ret = -EINTR;
10651065 req_set_fail(req);
1066− } else if (zc->flags & IORING_RECVSEND_NOTIF_FLUSH) {
1067− io_notif_slot_flush_submit(notif_slot, 0);
10681066 }
10691067
10701068 if (ret >= 0)
io_uring/notif.c+0−71
@@ -86,74 +86,3 @@ void io_notif_slot_flush(struct io_notif_slot *slot) · 85 unmodified lines
8686 io_req_task_work_add(notif);
8787 }
8888 }
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(&reg, 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−}
io_uring/notif.h+0−11
@@ -8,7 +8,6 @@ · 7 unmodified lines
88 #include "rsrc.h"
99
1010 #define IO_NOTIF_SPLICE_BATCH 32
11−#define IORING_MAX_NOTIF_SLOTS (1U << 15)
1211
1312 struct io_notif_data {
1413 struct file *file;
@@ -36,10 +35,6 @@ struct io_notif_slot { · 21 unmodified lines
3635 u32 seq;
3736 };
3837
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−
4338 void io_notif_slot_flush(struct io_notif_slot *slot);
4439 struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
4540 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
6762 return &ctx->notif_slots[idx];
6863 }
6964
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−
7665 static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len)
7766 {
7867 struct io_ring_ctx *ctx = notif->ctx;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t