From: Ming Lei <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Cc: [email protected], Miklos Szeredi <[email protected]>,
ZiyangZhang <[email protected]>,
Xiaoguang Wang <[email protected]>,
Bernd Schubert <[email protected]>,
Ming Lei <[email protected]>
Subject: [RFC PATCH 04/12] io_uring: rename io_mapped_ubuf as io_mapped_buf
Date: Wed, 1 Mar 2023 22:06:03 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
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 <[email protected]>
---
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
next prev parent reply other threads:[~2023-03-01 14:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 14:05 [RFC PATCH 00/12] io_uring: add IORING_OP_FUSED_CMD Ming Lei
2023-03-01 14:06 ` [RFC PATCH 01/12] io_uring: increase io_kiocb->flags into 64bit Ming Lei
2023-03-01 14:06 ` [RFC PATCH 02/12] io_uring: define io_mapped_ubuf->acct_pages as unsigned integer Ming Lei
2023-03-01 14:06 ` [RFC PATCH 03/12] io_uring: extend io_mapped_ubuf to cover external bvec table Ming Lei
2023-03-01 14:06 ` Ming Lei [this message]
2023-03-01 14:06 ` [RFC PATCH 05/12] io_uring: export 'struct io_mapped_buf' for fused cmd buffer Ming Lei
2023-03-01 14:06 ` [RFC PATCH 06/12] io_uring: add IO_URING_F_FUSED and prepare for supporting OP_FUSED_CMD Ming Lei
2023-03-01 14:06 ` [RFC PATCH 07/12] io_uring: add IORING_OP_FUSED_CMD Ming Lei
2023-03-01 14:06 ` [RFC PATCH 08/12] io_uring: support OP_READ/OP_WRITE for fused slave request Ming Lei
2023-03-01 14:06 ` [RFC PATCH 09/12] io_uring: support OP_SEND_ZC/OP_RECV " Ming Lei
2023-03-01 14:06 ` [RFC PATCH 10/12] block: ublk_drv: mark device as LIVE before adding disk Ming Lei
2023-03-03 2:25 ` Ziyang Zhang
2023-03-01 14:06 ` [RFC PATCH 11/12] block: ublk_drv: add common exit handling Ming Lei
2023-03-03 2:15 ` Ziyang Zhang
2023-03-01 14:06 ` [RFC PATCH 12/12] block: ublk_drv: apply io_uring FUSED_CMD for supporting zero copy Ming Lei
2023-03-03 2:52 ` [RFC PATCH 00/12] io_uring: add IORING_OP_FUSED_CMD Ziyang Zhang
2023-03-03 3:01 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox