diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h index 23b8891d5704..aa4d5477f859 100644 --- a/include/linux/io_uring_types.h +++ b/include/linux/io_uring_types.h @@ -290,6 +290,8 @@ enum { IO_RING_F_IOWQ_LIMITS_SET = BIT(12), }; +struct iou_ctx {}; + struct io_ring_ctx { /* const or read-mostly hot data */ struct { @@ -366,7 +368,7 @@ struct io_ring_ctx { struct io_alloc_cache rw_cache; struct io_alloc_cache cmd_cache; - int (*loop_step)(struct io_ring_ctx *ctx, + int (*loop_step)(struct iou_ctx *, struct iou_loop_params *); /* diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c index 937e48bef40b..5a50f0675fe5 100644 --- a/io_uring/bpf-ops.c +++ b/io_uring/bpf-ops.c @@ -14,15 +14,18 @@ static const struct btf_type *loop_params_type; __bpf_kfunc_start_defs(); -__bpf_kfunc int bpf_io_uring_submit_sqes(struct io_ring_ctx *ctx, u32 nr) +__bpf_kfunc int bpf_io_uring_submit_sqes(struct iou_ctx *loop_ctx, u32 nr) { + struct io_ring_ctx *ctx = io_loop_demangle_ctx(loop_ctx); + return io_submit_sqes(ctx, nr); } __bpf_kfunc -__u8 *bpf_io_uring_get_region(struct io_ring_ctx *ctx, __u32 region_id, +__u8 *bpf_io_uring_get_region(struct iou_ctx *loop_ctx, __u32 region_id, const size_t rdwr_buf_size) { + struct io_ring_ctx *ctx = io_loop_demangle_ctx(loop_ctx); struct io_mapped_region *r; lockdep_assert_held(&ctx->uring_lock); @@ -58,7 +61,7 @@ static const struct btf_kfunc_id_set bpf_io_uring_kfunc_set = { .set = &io_uring_kfunc_set, }; -static int io_bpf_ops__loop_step(struct io_ring_ctx *ctx, +static int io_bpf_ops__loop_step(struct iou_ctx *ctx, struct iou_loop_params *lp) { return IOU_LOOP_STOP; diff --git a/io_uring/bpf-ops.h b/io_uring/bpf-ops.h index b39b3fd3acda..0b6d7894915e 100644 --- a/io_uring/bpf-ops.h +++ b/io_uring/bpf-ops.h @@ -11,7 +11,7 @@ enum { }; struct io_uring_bpf_ops { - int (*loop_step)(struct io_ring_ctx *ctx, struct iou_loop_params *lp); + int (*loop_step)(struct iou_ctx *, struct iou_loop_params *lp); __u32 ring_fd; void *priv; diff --git a/io_uring/loop.c b/io_uring/loop.c index 31843cc3e451..bbbb6ef14e6a 100644 --- a/io_uring/loop.c +++ b/io_uring/loop.c @@ -49,7 +49,7 @@ static int __io_run_loop(struct io_ring_ctx *ctx) if (unlikely(!ctx->loop_step)) return -EFAULT; - step_res = ctx->loop_step(ctx, &lp); + step_res = ctx->loop_step(io_loop_mangle_ctx(ctx), &lp); if (step_res == IOU_LOOP_STOP) break; if (step_res != IOU_LOOP_CONTINUE) diff --git a/io_uring/loop.h b/io_uring/loop.h index d7718b9ce61e..4dd4fb3aefef 100644 --- a/io_uring/loop.h +++ b/io_uring/loop.h @@ -24,4 +24,14 @@ static inline bool io_has_loop_ops(struct io_ring_ctx *ctx) int io_run_loop(struct io_ring_ctx *ctx); +static inline struct iou_ctx *io_loop_mangle_ctx(struct io_ring_ctx *ctx) +{ + return (struct iou_ctx *)ctx; +} + +static inline struct io_ring_ctx *io_loop_demangle_ctx(struct iou_ctx *ctx) +{ + return (struct io_ring_ctx *)ctx; +} + #endif