Prepare to reuse io_mapped_ubuf for feeding fused command kbuf(bvec based buffer) to io_uring OP. Meantime rename ->ubuf as ->buf, and -ubuf_end as ->buf_end, both are actually just used for figuring out buffer offset & length only. Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- include/linux/io_uring_types.h | 6 +++--- io_uring/fdinfo.c | 6 +++--- io_uring/io_uring.c | 2 +- io_uring/rsrc.c | 26 +++++++++++++------------- io_uring/rsrc.h | 10 +++++----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h index 87342649d2c3..7a27b1d3e2ea 100644 --- a/include/linux/io_uring_types.h +++ b/include/linux/io_uring_types.h @@ -244,7 +244,7 @@ struct io_ring_ctx { struct io_file_table file_table; unsigned nr_user_files; unsigned nr_user_bufs; - struct io_mapped_ubuf **user_bufs; + struct io_mapped_buf **user_bufs; struct io_submit_state submit_state; @@ -326,7 +326,7 @@ struct io_ring_ctx { /* slow path rsrc auxilary data, used by update/register */ struct io_rsrc_node *rsrc_backup_node; - struct io_mapped_ubuf *dummy_ubuf; + struct io_mapped_buf *dummy_ubuf; struct io_rsrc_data *file_data; struct io_rsrc_data *buf_data; @@ -541,7 +541,7 @@ struct io_kiocb { union { /* store used ubuf, so we can prevent reloading */ - struct io_mapped_ubuf *imu; + struct io_mapped_buf *imu; /* stores selected buf, valid IFF REQ_F_BUFFER_SELECTED is set */ struct io_buffer *kbuf; diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c index 882bd56b01ed..2f663a795411 100644 --- a/io_uring/fdinfo.c +++ b/io_uring/fdinfo.c @@ -157,10 +157,10 @@ static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, } seq_printf(m, "UserBufs:\t%u\n", ctx->nr_user_bufs); for (i = 0; has_lock && i < ctx->nr_user_bufs; i++) { - struct io_mapped_ubuf *buf = ctx->user_bufs[i]; - unsigned int len = buf->ubuf_end - buf->ubuf; + struct io_mapped_buf *buf = ctx->user_bufs[i]; + unsigned int len = buf->buf_end - buf->buf; - seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->ubuf, len); + seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->buf, len); } if (has_lock && !xa_empty(&ctx->personalities)) { unsigned long index; diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 09cc5eaec4ab..3df66fddda5a 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -298,7 +298,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) if (!ctx->dummy_ubuf) goto err; /* set invalid range, so io_import_fixed() fails meeting it */ - ctx->dummy_ubuf->ubuf = -1UL; + ctx->dummy_ubuf->buf = -1UL; if (percpu_ref_init(&ctx->refs, io_ring_ctx_ref_free, 0, GFP_KERNEL)) diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index c41edd197b0a..26c07b28e8bb 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -24,7 +24,7 @@ struct io_rsrc_update { }; static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, - struct io_mapped_ubuf **pimu, + struct io_mapped_buf **pimu, struct page **last_hpage); #define IO_RSRC_REF_BATCH 100 @@ -136,9 +136,9 @@ static int io_buffer_validate(struct iovec *iov) return 0; } -static void io_buffer_unmap(struct io_ring_ctx *ctx, struct io_mapped_ubuf **slot) +static void io_buffer_unmap(struct io_ring_ctx *ctx, struct io_mapped_buf **slot) { - struct io_mapped_ubuf *imu = *slot; + struct io_mapped_buf *imu = *slot; unsigned int i; if (imu != ctx->dummy_ubuf) { @@ -542,7 +542,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx, return -EINVAL; for (done = 0; done < nr_args; done++) { - struct io_mapped_ubuf *imu; + struct io_mapped_buf *imu; int offset = up->offset + done; u64 tag = 0; @@ -1092,7 +1092,7 @@ static bool headpage_already_acct(struct io_ring_ctx *ctx, struct page **pages, /* check previously registered pages */ for (i = 0; i < ctx->nr_user_bufs; i++) { - struct io_mapped_ubuf *imu = ctx->user_bufs[i]; + struct io_mapped_buf *imu = ctx->user_bufs[i]; for (j = 0; j < imu->nr_bvecs; j++) { if (!PageCompound(imu->bvec[j].bv_page)) @@ -1106,7 +1106,7 @@ static bool headpage_already_acct(struct io_ring_ctx *ctx, struct page **pages, } static int io_buffer_account_pin(struct io_ring_ctx *ctx, struct page **pages, - int nr_pages, struct io_mapped_ubuf *imu, + int nr_pages, struct io_mapped_buf *imu, struct page **last_hpage) { int i, ret; @@ -1199,10 +1199,10 @@ struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages) } static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, - struct io_mapped_ubuf **pimu, + struct io_mapped_buf **pimu, struct page **last_hpage) { - struct io_mapped_ubuf *imu = NULL; + struct io_mapped_buf *imu = NULL; struct page **pages = NULL; unsigned long off; size_t size; @@ -1242,8 +1242,8 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, size -= vec_len; } /* store original address for later verification */ - imu->ubuf = (unsigned long) iov->iov_base; - imu->ubuf_end = imu->ubuf + iov->iov_len; + imu->buf = (unsigned long) iov->iov_base; + imu->buf_end = imu->buf + iov->iov_len; imu->nr_bvecs = nr_pages; imu->bvec = imu->__bvec; *pimu = imu; @@ -1321,7 +1321,7 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg, } int io_import_fixed(int ddir, struct iov_iter *iter, - struct io_mapped_ubuf *imu, + struct io_mapped_buf *imu, u64 buf_addr, size_t len) { u64 buf_end; @@ -1332,14 +1332,14 @@ int io_import_fixed(int ddir, struct iov_iter *iter, if (unlikely(check_add_overflow(buf_addr, (u64)len, &buf_end))) return -EFAULT; /* not inside the mapped region */ - if (unlikely(buf_addr < imu->ubuf || buf_end > imu->ubuf_end)) + if (unlikely(buf_addr < imu->buf || buf_end > imu->buf_end)) return -EFAULT; /* * May not be a start of buffer, set size appropriately * and advance us to the beginning. */ - offset = buf_addr - imu->ubuf; + offset = buf_addr - imu->buf; iov_iter_bvec(iter, ddir, imu->bvec, imu->nr_bvecs, offset + len); if (offset) { diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h index 24329eca49ef..5da54702cad1 100644 --- a/io_uring/rsrc.h +++ b/io_uring/rsrc.h @@ -19,7 +19,7 @@ struct io_rsrc_put { union { void *rsrc; struct file *file; - struct io_mapped_ubuf *buf; + struct io_mapped_buf *buf; }; }; @@ -45,9 +45,9 @@ struct io_rsrc_node { bool done; }; -struct io_mapped_ubuf { - u64 ubuf; - u64 ubuf_end; +struct io_mapped_buf { + u64 buf; + u64 buf_end; unsigned int nr_bvecs; unsigned int acct_pages; struct bio_vec *bvec; @@ -67,7 +67,7 @@ void io_rsrc_node_switch(struct io_ring_ctx *ctx, struct io_rsrc_data *data_to_kill); int io_import_fixed(int ddir, struct iov_iter *iter, - struct io_mapped_ubuf *imu, + struct io_mapped_buf *imu, u64 buf_addr, size_t len); void __io_sqe_buffers_unregister(struct io_ring_ctx *ctx); -- 2.31.1