We might want to create an area without having an instance of struct io_uring_zcrx_ifq_reg. Extract a helper that doesn't have the ifq registration structure as an argument but takes the buf length explicitly. Signed-off-by: Pavel Begunkov --- io_uring/zcrx.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c index 5b46e1335079..a142d6035f7e 100644 --- a/io_uring/zcrx.c +++ b/io_uring/zcrx.c @@ -459,21 +459,22 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq, return 0; } -static int io_zcrx_create_area(struct io_zcrx_ifq *ifq, +static int __zcrx_create_area(struct io_zcrx_ifq *ifq, struct io_uring_zcrx_area_reg *area_reg, - struct io_uring_zcrx_ifq_reg *reg) + u32 rx_buf_len) { int buf_size_shift = PAGE_SHIFT; struct io_zcrx_area *area; unsigned nr_iovs; int i, ret; - if (reg->rx_buf_len) { - if (!is_power_of_2(reg->rx_buf_len) || - reg->rx_buf_len < PAGE_SIZE) + if (rx_buf_len) { + if (!is_power_of_2(rx_buf_len) || rx_buf_len < PAGE_SIZE) return -EINVAL; - buf_size_shift = ilog2(reg->rx_buf_len); + buf_size_shift = ilog2(rx_buf_len); } + if (WARN_ON_ONCE(ifq->niov_shift)) + return -EINVAL; if (!ifq->dev && buf_size_shift != PAGE_SHIFT) return -EOPNOTSUPP; @@ -543,6 +544,13 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq, return ret; } +static int io_zcrx_create_area(struct io_zcrx_ifq *ifq, + struct io_uring_zcrx_area_reg *area_reg, + struct io_uring_zcrx_ifq_reg *reg) +{ + return __zcrx_create_area(ifq, area_reg, reg->rx_buf_len); +} + static struct io_zcrx_ifq *io_zcrx_ifq_alloc(struct io_ring_ctx *ctx) { struct io_zcrx_ifq *ifq; -- 2.54.0