}
 }
 
+#define IO_ZC_FLAGS_COMMON (IORING_RECVSEND_POLL_FIRST | IORING_RECVSEND_FIXED_BUF)
+#define IO_ZC_FLAGS_VALID  (IO_ZC_FLAGS_COMMON | IORING_SEND_ZC_REPORT_USAGE)
+
 int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
        struct io_sr_msg *zc = io_kiocb_to_cmd(req, struct io_sr_msg);
        if (req->flags & REQ_F_CQE_SKIP)
                return -EINVAL;
 
-       zc->flags = READ_ONCE(sqe->ioprio);
-       if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST |
-                         IORING_RECVSEND_FIXED_BUF |
-                         IORING_SEND_ZC_REPORT_USAGE))
-               return -EINVAL;
        notif = zc->notif = io_alloc_notif(ctx);
        if (!notif)
                return -ENOMEM;
        notif->cqe.res = 0;
        notif->cqe.flags = IORING_CQE_F_NOTIF;
        req->flags |= REQ_F_NEED_CLEANUP;
+
+       zc->flags = READ_ONCE(sqe->ioprio);
+       if (unlikely(zc->flags & ~IO_ZC_FLAGS_COMMON)) {
+               if (zc->flags & ~IO_ZC_FLAGS_VALID)
+                       return -EINVAL;
+               if (zc->flags & IORING_SEND_ZC_REPORT_USAGE) {
+                       io_notif_set_extended(notif);
+                       io_notif_to_data(notif)->zc_report = true;
+               }
+       }
+
        if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
                unsigned idx = READ_ONCE(sqe->buf_index);
 
                req->imu = READ_ONCE(ctx->user_bufs[idx]);
                io_req_set_rsrc_node(notif, ctx, 0);
        }
-       if (zc->flags & IORING_SEND_ZC_REPORT_USAGE) {
-               io_notif_to_data(notif)->zc_report = true;
-       }
 
        if (req->opcode == IORING_OP_SEND_ZC) {
                if (READ_ONCE(sqe->__pad3[0]))
 
                __io_unaccount_mem(ctx->user, nd->account_pages);
                nd->account_pages = 0;
        }
+       io_req_task_complete(notif, locked);
+}
+
+static void io_notif_complete_tw_ext(struct io_kiocb *notif, bool *locked)
+{
+       struct io_notif_data *nd = io_notif_to_data(notif);
 
        if (nd->zc_report && (nd->zc_copied || !nd->zc_used))
                notif->cqe.res |= IORING_NOTIF_USAGE_ZC_COPIED;
 
-       io_req_task_complete(notif, locked);
+       __io_notif_complete_tw(notif, locked);
 }
 
 static void io_tx_ubuf_callback(struct sk_buff *skb, struct ubuf_info *uarg,
        struct io_notif_data *nd = container_of(uarg, struct io_notif_data, uarg);
        struct io_kiocb *notif = cmd_to_io_kiocb(nd);
 
+       if (refcount_dec_and_test(&uarg->refcnt))
+               io_req_task_work_add(notif);
+}
+
+static void io_tx_ubuf_callback_ext(struct sk_buff *skb, struct ubuf_info *uarg,
+                            bool success)
+{
+       struct io_notif_data *nd = container_of(uarg, struct io_notif_data, uarg);
+
        if (nd->zc_report) {
                if (success && !nd->zc_used && skb)
                        WRITE_ONCE(nd->zc_used, true);
                else if (!success && !nd->zc_copied)
                        WRITE_ONCE(nd->zc_copied, true);
        }
+       io_tx_ubuf_callback(skb, uarg, success);
+}
 
-       if (refcount_dec_and_test(&uarg->refcnt))
-               io_req_task_work_add(notif);
+void io_notif_set_extended(struct io_kiocb *notif)
+{
+       struct io_notif_data *nd = io_notif_to_data(notif);
+
+       nd->zc_report = false;
+       nd->zc_used = false;
+       nd->zc_copied = false;
+       notif->io_task_work.func = io_notif_complete_tw_ext;
+       io_notif_to_data(notif)->uarg.callback = io_tx_ubuf_callback_ext;
 }
 
 struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx)
        nd->account_pages = 0;
        nd->uarg.flags = SKBFL_ZEROCOPY_FRAG | SKBFL_DONT_ORPHAN;
        nd->uarg.callback = io_tx_ubuf_callback;
-       nd->zc_report = nd->zc_used = nd->zc_copied = false;
        refcount_set(&nd->uarg.refcnt, 1);
        return notif;
 }