io_uring_cmd *cmd, unsigned int index, unsigned int issue_flags); #else @@ -199,6 +202,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, + struct bio_vec *bvs, + unsigned int nr_bvecs, + unsigned int total_bytes, 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) diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 5a708cecba4a..32126c06f4c9 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -1020,6 +1020,33 @@ int io_buffer_register_request(struct io_uring_cmd *cmd, struct request *rq, } EXPORT_SYMBOL_GPL(io_buffer_register_request); +int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct bio_vec *bvs, + unsigned int nr_bvecs, unsigned int total_bytes, + 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; + int i; + + io_ring_submit_lock(ctx, issue_flags); + imu = io_kernel_buffer_init(ctx, nr_bvecs, total_bytes, dir, NULL, + NULL, index); + if (IS_ERR(imu)) { + io_ring_submit_unlock(ctx, issue_flags); + return PTR_ERR(imu); + } + + bvec = imu->bvec; + for (i = 0; i < nr_bvecs; i++) + bvec[i] = bvs[i]; + + io_ring_submit_unlock(ctx, issue_flags); + return 0; +} +EXPORT_SYMBOL_GPL(io_buffer_register_bvec); + int io_buffer_unregister(struct io_uring_cmd *cmd, unsigned int index, unsigned int issue_flags) { -- 2.47.3[PATCH v3 23/25] io_uring/rsrc: add io_buffer_register_bvec()Joanne Koong undefinedmiklos@szeredi.hu, axboe@kernel.dk undefined undefined undefined undefined undefined undefined undefined undefinedžl„Ř@