mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
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:
parent
fbc32d5f44
commit
bd62a2cfff
|
|
@ -94,6 +94,10 @@ bool io_uring_mshot_cmd_post_cqe(struct io_uring_cmd *ioucmd,
|
|||
int io_buffer_register_request(struct io_uring_cmd *cmd, struct request *rq,
|
||||
void (*release)(void *), unsigned int index,
|
||||
unsigned int issue_flags);
|
||||
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);
|
||||
int io_buffer_unregister(struct io_uring_cmd *cmd, unsigned int index,
|
||||
unsigned int issue_flags);
|
||||
#else
|
||||
|
|
@ -146,6 +150,15 @@ static inline int io_buffer_register_request(struct io_uring_cmd *cmd,
|
|||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
static inline 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)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
static inline int io_buffer_unregister(struct io_uring_cmd *cmd,
|
||||
unsigned int index,
|
||||
unsigned int issue_flags)
|
||||
|
|
|
|||
|
|
@ -1096,6 +1096,41 @@ int io_buffer_register_request(struct io_uring_cmd *cmd, struct request *rq,
|
|||
}
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user