io_uring/notif: remove notif registration
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 1 Sep 2022 10:54:03 +0000 (11:54 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 1 Sep 2022 15:13:33 +0000 (09:13 -0600)
We're going to remove the userspace exposed zerocopy notification API,
remove notification registration.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/6ff00b97be99869c386958a990593c9c31cf105b.1662027856.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/uapi/linux/io_uring.h
io_uring/io_uring.c
io_uring/net.c
io_uring/notif.c
io_uring/notif.h

index 111b651..b11c57b 100644 (file)
@@ -279,14 +279,10 @@ enum io_uring_op {
  *
  * IORING_RECVSEND_FIXED_BUF   Use registered buffers, the index is stored in
  *                             the buf_index field.
- *
- * IORING_RECVSEND_NOTIF_FLUSH Flush a notification after a successful
- *                             successful. Only for zerocopy sends.
  */
 #define IORING_RECVSEND_POLL_FIRST     (1U << 0)
 #define IORING_RECV_MULTISHOT          (1U << 1)
 #define IORING_RECVSEND_FIXED_BUF      (1U << 2)
-#define IORING_RECVSEND_NOTIF_FLUSH    (1U << 3)
 
 /*
  * accept flags stored in sqe->ioprio
@@ -474,10 +470,6 @@ enum {
        /* register a range of fixed file slots for automatic slot allocation */
        IORING_REGISTER_FILE_ALLOC_RANGE        = 25,
 
-       /* zerocopy notification API */
-       IORING_REGISTER_NOTIFIERS               = 26,
-       IORING_UNREGISTER_NOTIFIERS             = 27,
-
        /* this goes last */
        IORING_REGISTER_LAST
 };
index 7761627..c2e06a3 100644 (file)
@@ -2640,7 +2640,6 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
                io_unregister_personality(ctx, index);
        if (ctx->rings)
                io_poll_remove_all(ctx, NULL, true);
-       io_notif_unregister(ctx);
        mutex_unlock(&ctx->uring_lock);
 
        /* 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,
                        break;
                ret = io_register_file_alloc_range(ctx, arg);
                break;
-       case IORING_REGISTER_NOTIFIERS:
-               ret = io_notif_register(ctx, arg, nr_args);
-               break;
-       case IORING_UNREGISTER_NOTIFIERS:
-               ret = -EINVAL;
-               if (arg || nr_args)
-                       break;
-               ret = io_notif_unregister(ctx);
-               break;
        default:
                ret = -EINVAL;
                break;
index 7a5468c..aac6997 100644 (file)
@@ -889,7 +889,7 @@ int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
        zc->flags = READ_ONCE(sqe->ioprio);
        if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST |
-                         IORING_RECVSEND_FIXED_BUF | IORING_RECVSEND_NOTIF_FLUSH))
+                         IORING_RECVSEND_FIXED_BUF))
                return -EINVAL;
        if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
                unsigned idx = READ_ONCE(sqe->buf_index);
@@ -1063,8 +1063,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
                if (ret == -ERESTARTSYS)
                        ret = -EINTR;
                req_set_fail(req);
-       } else if (zc->flags & IORING_RECVSEND_NOTIF_FLUSH) {
-               io_notif_slot_flush_submit(notif_slot, 0);
        }
 
        if (ret >= 0)
index 96f076b..11f4564 100644 (file)
@@ -86,74 +86,3 @@ void io_notif_slot_flush(struct io_notif_slot *slot)
                io_req_task_work_add(notif);
        }
 }
-
-__cold int io_notif_unregister(struct io_ring_ctx *ctx)
-       __must_hold(&ctx->uring_lock)
-{
-       int i;
-
-       if (!ctx->notif_slots)
-               return -ENXIO;
-
-       for (i = 0; i < ctx->nr_notif_slots; i++) {
-               struct io_notif_slot *slot = &ctx->notif_slots[i];
-               struct io_kiocb *notif = slot->notif;
-               struct io_notif_data *nd;
-
-               if (!notif)
-                       continue;
-               nd = io_notif_to_data(notif);
-               slot->notif = NULL;
-               if (!refcount_dec_and_test(&nd->uarg.refcnt))
-                       continue;
-               notif->io_task_work.func = __io_notif_complete_tw;
-               io_req_task_work_add(notif);
-       }
-
-       kvfree(ctx->notif_slots);
-       ctx->notif_slots = NULL;
-       ctx->nr_notif_slots = 0;
-       return 0;
-}
-
-__cold int io_notif_register(struct io_ring_ctx *ctx,
-                            void __user *arg, unsigned int size)
-       __must_hold(&ctx->uring_lock)
-{
-       struct io_uring_notification_slot __user *slots;
-       struct io_uring_notification_slot slot;
-       struct io_uring_notification_register reg;
-       unsigned i;
-
-       if (ctx->nr_notif_slots)
-               return -EBUSY;
-       if (size != sizeof(reg))
-               return -EINVAL;
-       if (copy_from_user(&reg, arg, sizeof(reg)))
-               return -EFAULT;
-       if (!reg.nr_slots || reg.nr_slots > IORING_MAX_NOTIF_SLOTS)
-               return -EINVAL;
-       if (reg.resv || reg.resv2 || reg.resv3)
-               return -EINVAL;
-
-       slots = u64_to_user_ptr(reg.data);
-       ctx->notif_slots = kvcalloc(reg.nr_slots, sizeof(ctx->notif_slots[0]),
-                               GFP_KERNEL_ACCOUNT);
-       if (!ctx->notif_slots)
-               return -ENOMEM;
-
-       for (i = 0; i < reg.nr_slots; i++, ctx->nr_notif_slots++) {
-               struct io_notif_slot *notif_slot = &ctx->notif_slots[i];
-
-               if (copy_from_user(&slot, &slots[i], sizeof(slot))) {
-                       io_notif_unregister(ctx);
-                       return -EFAULT;
-               }
-               if (slot.resv[0] | slot.resv[1] | slot.resv[2]) {
-                       io_notif_unregister(ctx);
-                       return -EINVAL;
-               }
-               notif_slot->tag = slot.tag;
-       }
-       return 0;
-}
index 80f6445..8380eef 100644 (file)
@@ -8,7 +8,6 @@
 #include "rsrc.h"
 
 #define IO_NOTIF_SPLICE_BATCH  32
-#define IORING_MAX_NOTIF_SLOTS (1U << 15)
 
 struct io_notif_data {
        struct file             *file;
@@ -36,10 +35,6 @@ struct io_notif_slot {
        u32                     seq;
 };
 
-int io_notif_register(struct io_ring_ctx *ctx,
-                     void __user *arg, unsigned int size);
-int io_notif_unregister(struct io_ring_ctx *ctx);
-
 void io_notif_slot_flush(struct io_notif_slot *slot);
 struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx,
                                struct io_notif_slot *slot);
@@ -67,12 +62,6 @@ static inline struct io_notif_slot *io_get_notif_slot(struct io_ring_ctx *ctx,
        return &ctx->notif_slots[idx];
 }
 
-static inline void io_notif_slot_flush_submit(struct io_notif_slot *slot,
-                                             unsigned int issue_flags)
-{
-       io_notif_slot_flush(slot);
-}
-
 static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len)
 {
        struct io_ring_ctx *ctx = notif->ctx;