io_uring/rsrc: add io_buffer_register_bvec()

Add io_buffer_register_bvec() for registering a bvec array.

This is a preparatory patch for fuse-over-io-uring zero-copy.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://patch.msgid.link/20260612184840.4058966-4-joannelkoong@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Joanne Koong
2026-08-17 17:02:10 +02:00
committed by Miklos Szeredi
parent fbc32d5f44
commit bd62a2cfff
2 changed files with 48 additions and 0 deletions
+35
View File
@@ -1096,6 +1096,41 @@ unlock:
}
EXPORT_SYMBOL_GPL(io_buffer_register_request);
/*
* bvs is copied internally. caller may free it on return.
*/
int io_buffer_register_bvec(struct io_uring_cmd *cmd, const struct bio_vec *bvs,
unsigned int nr_bvecs, void (*release)(void *),
void *priv, u8 dir, unsigned int index,
unsigned int issue_flags)
{
struct io_ring_ctx *ctx = cmd_to_io_kiocb(cmd)->ctx;
struct io_mapped_ubuf *imu;
struct bio_vec *bvec;
unsigned int i, total_bytes = 0;
int ret = 0;
for (i = 0; i < nr_bvecs; i++)
total_bytes += bvs[i].bv_len;
io_ring_submit_lock(ctx, issue_flags);
imu = io_kernel_buffer_init(ctx, nr_bvecs, total_bytes, dir, release,
priv, index);
if (IS_ERR(imu)) {
ret = PTR_ERR(imu);
goto unlock;
}
bvec = imu->bvec;
for (i = 0; i < nr_bvecs; i++)
bvec[i] = bvs[i];
unlock:
io_ring_submit_unlock(ctx, issue_flags);
return ret;
}
EXPORT_SYMBOL_GPL(io_buffer_register_bvec);
int io_buffer_unregister(struct io_uring_cmd *cmd, unsigned int index,
unsigned int issue_flags)
{