Read/Write with meta buffer
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): CGME20240322185729epcas5p350c5054b5b519a6aa9d1b35ba3709563@epcas5p3.samsung.com
cover Read/Write with meta buffer
This patchset is aimed at getting the feedback on a new io_uring interface that userspace can use to exchange meta buffer along with read/write.
Two new opcodes for that: IORING_OP_READ_META and IORING_OP_WRITE_META. The leftover space in the SQE is used to send meta buffer pointer and its length. Patch #2 for this.
The interface is supported for block direct IO. Patch #4 for this. Other two are prep patches.
It has been tried not to touch the hot read/write path, as much as possible. Performance for non-meta IO is same after the patches [2]. There is some code in the cold path (worker-based async) though.
Moderately tested by modifying the fio [1] to use this interface (only for NVMe block devices)
[1] https://github.com/OpenMPDK/fio/tree/feat/test-meta
[2]
without this:
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4 /dev/nvme0n1 /dev/nvme1n1 submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31
With this:
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4 /dev/nvme0n1 /dev/nvme1n1 submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31
Anuj Gupta (3):
io_uring/rw: Get rid of flags field in struct io_rw io_uring/rw: support read/write with metadata
block: modify bio_integrity_map_user to accept iov_iter as argument
Kanchan Joshi (1):
block: add support to pass the meta buffer
block/bio-integrity.c | 27 ++++++--- block/fops.c | 9 +++ block/t10-pi.c | 6 ++ drivers/nvme/host/ioctl.c | 11 +++- include/linux/bio.h | 13 +++- include/linux/fs.h | 1 + include/uapi/linux/io_uring.h | 6 ++ io_uring/io_uring.c | 2 + io_uring/opdef.c | 29 +++++++++ io_uring/rw.c | 108 +++++++++++++++++++++++++++++----- io_uring/rw.h | 8 +++ 11 files changed, 193 insertions(+), 27 deletions(-)
base-commit: 6f0974eccbf78baead1735722c4f1ee3eb9422cd
Signature · 1 line
2.25.1
RFC PATCH 1/4 io_uring/rw: Get rid of flags field in struct io_rw
From: Anuj Gupta <[email protected]>
Get rid of the flags field in io_rw. Flags can be set in kiocb->flags during prep rather than doing it while issuing the I/O in io_read/io_write.
--- io_uring/rw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
io_uring/rw.c +11 -11
@@ -27,7 +27,6 @@ struct io_rw {struct kiocb kiocb;u64 addr;u32 len; -rwf_t flags; };static inline bool io_file_supports_nowait (struct io_kiocb *req)
@@ -78,10 +77,16 @@ static int io_iov_buffer_select_prep(struct io_kiocb *req)int io_prep_rw (struct io_kiocb *req,const struct io_uring_sqe *sqe) { struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); +struct kiocb *kiocb = &rw->kiocb;unsigned ioprio;int ret; - rw->kiocb.ki_pos =READ_ONCE (sqe->off); + kiocb->ki_flags =0 ; + ret =kiocb_set_rw_flags (kiocb,READ_ONCE (sqe->rw_flags)); +if (unlikely (ret)) +return ret; + + kiocb->ki_pos =READ_ONCE (sqe->off);/* used for fixed read/write too - just read unconditionally */ req->buf_index =READ_ONCE (sqe->buf_index);
@@ -91,15 +96,14 @@ int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe)if (ret)return ret; - rw->kiocb.ki_ioprio = ioprio; + kiocb->ki_ioprio = ioprio; }else { - rw->kiocb.ki_ioprio =get_current_ioprio (); + kiocb->ki_ioprio =get_current_ioprio (); } - rw->kiocb.dio_complete =NULL ; + kiocb->dio_complete =NULL ; rw->addr =READ_ONCE (sqe->addr); rw->len =READ_ONCE (sqe->len); - rw->flags =READ_ONCE (sqe->rw_flags);return 0 ; }
@@ -720,7 +724,6 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)struct kiocb *kiocb = &rw->kiocb;struct io_ring_ctx *ctx = req->ctx;struct file *file = req->file; -int ret;if (unlikely (!(file->f_mode & mode)))return -EBADF ;
@@ -728,10 +731,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)if (!(req->flags &REQ_F_FIXED_FILE )) req->flags |=io_file_get_flags (file); - kiocb->ki_flags = file->f_iocb_flags; - ret =kiocb_set_rw_flags (kiocb, rw->flags); -if (unlikely (ret)) -return ret; + kiocb->ki_flags |= file->f_iocb_flags; kiocb->ki_flags |=IOCB_ALLOC_CACHE ;/*
Signature · 1 line
2.25.1
Re: [RFC PATCH 1/4] io_uring/rw: Get rid of flags field in struct io_rw
Quoted 9 lines · Kanchan Joshi
From: Anuj Gupta <[email protected]>
Get rid of the flags field in
io_rw. Flags can be set inkiocb->flagsduring prep rather than doing it while issuing the I/O in io_read/io_write.Signed-off-by Anuj Gupta <[email protected]>--- io_uring/rw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
This patch looks fine and is a no-op on its own, but I think there is a subtle semantic change. If the rw_flags is invalid (i.e. kiocb_set_rw_flags() returns an err) and prep() fails, then the remaining submissions won't be submitted unless IORING_SETUP_SUBMIT_ALL is set.
Currently if kiocb_set_rw_flags() fails in prep(), only the request will fail.
Re: [RFC PATCH 1/4] io_uring/rw: Get rid of flags field in struct io_rw
Quoted 11 lines · David Wei
Quoted 9 lines · Kanchan Joshi
From: Anuj Gupta <[email protected]>
Get rid of the flags field in
io_rw. Flags can be set inkiocb->flagsduring prep rather than doing it while issuing the I/O in io_read/io_write.Signed-off-by Anuj Gupta <[email protected]>--- io_uring/rw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
Quoted 8 lines
This patch looks fine and is a no-op on its own, but I think there is a subtle semantic change. If the
rw_flagsis invalid (i.e.kiocb_set_rw_flags()returns an err) andprep()fails, then the remaining submissions won't be submitted unlessIORING_SETUP_SUBMIT_ALLis set.Currently if
kiocb_set_rw_flags()fails inprep(), only the request will fail.
Sorry, that should say fails in _issue()_.
RFC PATCH 2/4 io_uring/rw: support read/write with metadata
In reply to Kanchan JoshiFrom: Anuj Gupta <[email protected]>
This patch introduces IORING_OP_READ_META and IORING_OP_WRITE_META opcodes which allow sending a meta buffer along with read/write.
Application can do that by using the newly added meta_buf and meta-len fields of the SQE.
These opcodes are supported only for direct IO.
--- include/linux/fs.h | 1 + include/uapi/linux/io_uring.h | 6 +++ io_uring/io_uring.c | 2 + io_uring/opdef.c | 29 ++++++++++++ io_uring/rw.c | 86 +++++++++++++++++++++++++++++++++-- io_uring/rw.h | 8 ++++ 6 files changed, 129 insertions(+), 3 deletions(-)
include/linux/fs.h +1 -0
@@ -327,6 +327,7 @@ struct readahead_control;#define IOCB_NOIO (1 << 20)/* can use bio alloc cache */ #define IOCB_ALLOC_CACHE (1 << 21) +#define IOCB_USE_META (1 << 22)/* * IOCB_DIO_CALLER_COMP can be set by the iocb owner, to indicate that the * iocb completion can be passed back to the owner for execution from a safe
include/uapi/linux/io_uring.h +6 -0
@@ -97,6 +97,10 @@ struct io_uring_sqe {__u64 addr3;__u64 __pad2[1 ]; }; +struct { +__u64 meta_addr; +__u32 meta_len; + };__u64 optval;/* * If the ring is initialized with IORING_SETUP_SQE128, then
@@ -256,6 +260,8 @@ enum io_uring_op {IORING_OP_FUTEX_WAITV ,IORING_OP_FIXED_FD_INSTALL ,IORING_OP_FTRUNCATE , +IORING_OP_READ_META , +IORING_OP_WRITE_META ,/* this goes last, obviously */ IORING_OP_LAST,
io_uring/io_uring.c +2 -0
@@ -4134,7 +4134,9 @@ static int __init io_uring_init(void)BUILD_BUG_SQE_ELEM (44 , __u16, addr_len);BUILD_BUG_SQE_ELEM (46 , __u16, __pad3[0 ]);BUILD_BUG_SQE_ELEM (48 , __u64, addr3); +BUILD_BUG_SQE_ELEM (48 , __u64, meta_addr);BUILD_BUG_SQE_ELEM_SIZE (48 ,0 , cmd); +BUILD_BUG_SQE_ELEM (56 , __u32, meta_len);BUILD_BUG_SQE_ELEM (56 , __u64, __pad2); BUILD_BUG_ON(sizeof(struct io_uring_files_update) !=
io_uring/opdef.c +29 -0
@@ -146,6 +146,26 @@ const struct io_issue_def io_issue_defs[] = { .prep = io_eopnotsupp_prep,#endif }, + [IORING_OP_READ_META] = { + .needs_file = 1, + .plug = 1, + .audit_skip = 1, + .ioprio = 1, + .iopoll = 1, + .iopoll_queue = 1, + .prep = io_prep_rw_meta, + .issue = io_rw_meta, + }, + [IORING_OP_WRITE_META] = { + .needs_file = 1, + .plug = 1, + .audit_skip = 1, + .ioprio = 1, + .iopoll = 1, + .iopoll_queue = 1, + .prep = io_prep_rw_meta, + .issue = io_rw_meta, + }, [IORING_OP_RECVMSG] = { .needs_file = 1, .unbound_nonreg_file = 1,
@@ -501,6 +521,15 @@ const struct io_cold_def io_cold_defs[] = { .cleanup = io_readv_writev_cleanup, .fail = io_rw_fail, }, + [IORING_OP_READ_META] = { + .async_size = sizeof(struct io_async_rw), + .name = "READ_META", + .fail = io_rw_fail, + }, + [IORING_OP_WRITE_META] = { + .async_size = sizeof(struct io_async_rw), + .name = "WRITE_META", + }, [IORING_OP_FSYNC] = { .name = "FSYNC", },
io_uring/rw.c +83 -3
155 lines not on this page · raw message
io_uring/rw.h +8 -0
@@ -8,19 +8,27 @@ struct io_rw_state {struct iovec fast_iov[UIO_FASTIOV ]; }; +struct io_rw_state_meta { +struct iov_iter iter_meta; +struct iov_iter_state iter_state_meta; +}; +struct io_async_rw {struct io_rw_state s; +struct io_rw_state_meta s_meta;const struct iovec *free_iovec;size_t bytes_done;struct wait_page_queue wpq; };int io_prep_rw (struct io_kiocb *req,const struct io_uring_sqe *sqe); +int io_prep_rw_meta (struct io_kiocb *req,const struct io_uring_sqe *sqe);int io_prep_rwv (struct io_kiocb *req,const struct io_uring_sqe *sqe);int io_prep_rw_fixed (struct io_kiocb *req,const struct io_uring_sqe *sqe);int io_read (struct io_kiocb *req,unsigned int issue_flags);int io_readv_prep_async (struct io_kiocb *req);int io_write (struct io_kiocb *req,unsigned int issue_flags); +int io_rw_meta (struct io_kiocb *req,unsigned int issue_flags);int io_writev_prep_async (struct io_kiocb *req);void io_readv_writev_cleanup (struct io_kiocb *req);void io_rw_fail (struct io_kiocb *req);
Signature · 1 line
2.25.1
kernel test robot
build botRe: [RFC PATCH 2/4] io_uring/rw: support read/write with metadata
kernel test robot noticed the following build warnings:
Hi Kanchan,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on 6f0974eccbf78baead1735722c4f1ee3eb9422cd]
url: https://github.com/intel-lab-lkp/linux/commits/Kanchan-Joshi/io_uring-rw-Get-rid-of-flags-field-in-struct-io_rw/20240323-025900 base: 6f0974eccbf78baead1735722c4f1ee3eb9422cd patch link: https://lore.kernel.org/r/20240322185023.131697-3-joshi.k%40samsung.com patch subject: [RFC PATCH 2/4] io_uring/rw: support read/write with metadata config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240323/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240323/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from include/linux/bitops.h:7,
from include/linux/kernel.h:23,
from io_uring/rw.c:2:
io_uring/rw.c: In function 'io_rw_meta':
>> io_uring/rw.c:1160:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1160 | void __user *meta_addr = u64_to_user_ptr((u64)rw->kiocb.private);
| ^
include/linux/typecheck.h:11:16: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2; \
| ^
io_uring/rw.c:1160:34: note: in expansion of macro 'u64_to_user_ptr'
1160 | void __user *meta_addr = u64_to_user_ptr((u64)rw->kiocb.private);
| ^~~~~~~~~~~~~~~
>> io_uring/rw.c:1160:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1160 | void __user *meta_addr = u64_to_user_ptr((u64)rw->kiocb.private);
| ^
include/linux/kernel.h:59:36: note: in definition of macro 'u64_to_user_ptr'
59 | (void __user *)(uintptr_t)(x); \
| ^vim +1160 io_uring/rw.c
1156
1157 int io_rw_meta(struct io_kiocb *req, unsigned int issue_flags)
1158 {
1159 struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
> 1160 void __user *meta_addr = u64_to_user_ptr((u64)rw->kiocb.private);
1161 struct io_rw_state_meta __sm, *sm = &__sm;
1162 struct kiocb *kiocb = &rw->kiocb;
1163 int ret;
1164
1165 if (!(req->file->f_flags & O_DIRECT))
1166 return -EOPNOTSUPP;
1167 /* prepare iter for meta-buffer */
1168 if (!req_has_async_data(req)) {
1169 ret = import_ubuf(ITER_SOURCE, meta_addr, rw->meta_len, &sm->iter_meta);
1170 iov_iter_save_state(&sm->iter_meta, &sm->iter_state_meta);
1171 if (unlikely(ret < 0))
1172 return ret;
1173 } else {
1174 struct io_async_rw *io = req->async_data;
1175
1176 sm = &io->s_meta;
1177 iov_iter_restore(&sm->iter_meta, &sm->iter_state_meta);
1178 }
1179 /* Store iter for meta-buf in private, will be used later*/
1180 kiocb->private = sm;
1181 if (req->opcode == IORING_OP_READ_META) {
1182 ret = __io_read(req, issue_flags);
1183 if (ret >= 0)
1184 return kiocb_done(req, ret, issue_flags);
1185 } else {
1186 ret = io_write(req, issue_flags);
1187 }
1188 if (ret == -EAGAIN)
1189 kiocb->private = meta_addr;
1190 return ret;
1191
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
RFC PATCH 3/4 block: modify bio_integrity_map_user to accept iov_iter as argument
In reply to Kanchan JoshiFrom: Anuj Gupta <[email protected]>
Refactor bio_integrity_map_user to accept iov_iter as argument. This is a prep patch.
--- block/bio-integrity.c | 14 ++++++-------- drivers/nvme/host/ioctl.c | 11 +++++++++-- include/linux/bio.h | 7 ++++--- 3 files changed, 19 insertions(+), 13 deletions(-)
block/bio-integrity.c +6 -8
@@ -308,17 +308,16 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages,return nr_bvecs; } -int bio_integrity_map_user (struct bio *bio,void __user *ubuf,ssize_t bytes, -u32 seed) +int bio_integrity_map_user (struct bio *bio,struct iov_iter *iter, +u32 seed) {struct request_queue *q =bdev_get_queue (bio->bi_bdev);unsigned int align = q->dma_pad_mask |queue_dma_alignment (q);struct page *stack_pages[UIO_FASTIOV ], **pages = stack_pages;struct bio_vec stack_vec[UIO_FASTIOV ], *bvec = stack_vec; +size_t offset, bytes = iter->count;unsigned int direction, nr_bvecs; -struct iov_iter iter;int ret, nr_vecs; -size_t offset;bool copy;if (bio_integrity (bio))
@@ -331,8 +330,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes,else direction =ITER_SOURCE ; -iov_iter_ubuf (&iter, direction, ubuf, bytes); - nr_vecs =iov_iter_npages (&iter,BIO_MAX_VECS +1 ); + nr_vecs =iov_iter_npages (iter,BIO_MAX_VECS +1 );if (nr_vecs >BIO_MAX_VECS )return -E2BIG ;if (nr_vecs >UIO_FASTIOV ) {
@@ -342,8 +340,8 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, pages =NULL ; } - copy = !iov_iter_is_aligned (&iter, align, align); - ret =iov_iter_extract_pages (&iter, &pages, bytes, nr_vecs,0 , &offset); + copy = !iov_iter_is_aligned (iter, align, align); + ret =iov_iter_extract_pages (iter, &pages, bytes, nr_vecs,0 , &offset);if (unlikely (ret <0 )) goto free_bvec;
drivers/nvme/host/ioctl.c +9 -2
@@ -145,8 +145,15 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,if (bdev) {bio_set_dev (bio, bdev);if (meta_buffer && meta_len) { - ret =bio_integrity_map_user (bio, meta_buffer, meta_len, - meta_seed); +struct iov_iter iter; +unsigned int direction; + +if (bio_data_dir (bio) ==READ ) + direction =ITER_DEST ; +else + direction =ITER_SOURCE ; +iov_iter_ubuf (&iter, direction, meta_buffer, meta_len); + ret =bio_integrity_map_user (bio, &iter, meta_seed);if (ret) goto out_unmap; req->cmd_flags |=REQ_INTEGRITY ;
include/linux/bio.h +4 -3
@@ -723,7 +723,7 @@ static inline bool bioset_initialized(struct bio_set *bs) for_each_bio(_bio) \ bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) -int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len, u32 seed); +int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); extern bool bio_integrity_prep(struct bio *);
@@ -795,8 +795,9 @@ static inline int bio_integrity_add_page(struct bio *bio, struct page *page,return 0 ; } -static inline int bio_integrity_map_user (struct bio *bio,void __user *ubuf, -ssize_t len,u32 seed) +static inline int bio_integrity_map_user (struct bio *bio,struct iov_iter *iter, +u32 seed) + {return -EINVAL ; }
Signature · 1 line
2.25.1
RFC PATCH 4/4 block: add support to pass the meta buffer
In reply to Kanchan JoshiIf IOCB_USE_META flag is set, iocb->private points to iov_iter corresponding to the meta-buffer.
Use it to prepare the bip and attach that to the bio that we send down.
Make sure that block-integrity checks are skipped for this user-owned meta buffer.
--- block/bio-integrity.c | 13 +++++++++++++ block/fops.c | 9 +++++++++ block/t10-pi.c | 6 ++++++ include/linux/bio.h | 6 ++++++ 4 files changed, 34 insertions(+)
block/bio-integrity.c +13 -0
@@ -308,6 +308,19 @@ static unsigned int bvec_from_pages(struct bio_vec *bvec, struct page **pages,return nr_bvecs; } +int bio_integrity_map_iter (struct bio *bio,struct iov_iter *iter) +{ +struct blk_integrity *bi =blk_get_integrity (bio->bi_bdev->bd_disk); + +if (!bi) +return -EINVAL ; + +if (iter->count <bio_integrity_bytes (bi,bio_sectors (bio))) +return -EINVAL ; + +return bio_integrity_map_user (bio, iter,0 ); +} +int bio_integrity_map_user (struct bio *bio,struct iov_iter *iter,u32 seed) {
block/fops.c +9 -0
@@ -353,6 +353,15 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,task_io_account_write (bio->bi_iter.bi_size); } +if (unlikely (iocb->ki_flags &IOCB_USE_META )) { + ret =bio_integrity_map_iter (bio, iocb->private); +WRITE_ONCE (iocb->private,NULL ); +if (unlikely (ret)) { +bio_put (bio); +return ret; + } + } +if (iocb->ki_flags &IOCB_NOWAIT ) bio->bi_opf |=REQ_NOWAIT ;
block/t10-pi.c +6 -0
@@ -156,6 +156,8 @@ static void t10_pi_type1_prepare(struct request *rq)/* Already remapped? */ if (bip->bip_flags &BIP_MAPPED_INTEGRITY )break ; +if (bip->bip_flags &BIP_INTEGRITY_USER ) +break ;bip_for_each_vec (iv, bip, iter) {unsigned int j;
@@ -205,6 +207,8 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes)struct bio_vec iv;struct bvec_iter iter; +if (bip->bip_flags &BIP_INTEGRITY_USER ) +break ;bip_for_each_vec (iv, bip, iter) {unsigned int j;void *p;
@@ -408,6 +412,8 @@ static void ext_pi_type1_prepare(struct request *rq)/* Already remapped? */ if (bip->bip_flags &BIP_MAPPED_INTEGRITY )break ; +if (bip->bip_flags &BIP_INTEGRITY_USER ) +break ;bip_for_each_vec (iv, bip, iter) {unsigned int j;
include/linux/bio.h +6 -0
@@ -723,6 +723,7 @@ static inline bool bioset_initialized(struct bio_set *bs) for_each_bio(_bio) \ bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) +int bio_integrity_map_iter(struct bio *bio, struct iov_iter *iter); int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, u32 seed); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
@@ -802,6 +803,11 @@ static inline int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter, return -EINVAL; } +static inline int bio_integrity_map_iter (struct bio *bio,struct iov_iter *iter) +{ +return -EINVAL ; +} +#endif /* CONFIG_BLK_DEV_INTEGRITY */ /*
Signature · 1 line
2.25.1
Jens Axboe
maintainerQuoted 8 lines · Kanchan Joshi
This patchset is aimed at getting the feedback on a new
io_uringinterface that userspace can use to exchange meta buffer along with read/write.Two new opcodes for that:
IORING_OP_READ_METAandIORING_OP_WRITE_META. The leftover space in the SQE is used to send meta buffer pointer and its length. Patch #2 for this.
Quoted 7 lines
The interface is supported for block direct IO. Patch #4 for this. Other two are prep patches.
It has been tried not to touch the hot read/write path, as much as possible. Performance for non-meta IO is same after the patches [2]. There is some code in the cold path (worker-based async) though.
This patchset should look cleaner if you rebase it on top of the current for-6.10/io_uring branch, as it gets rid of the async nastiness. Since that'll need doing anyway, could you repost a v2 where it's rebased on top of that?
Also in terms of the cover letter, would be good with a bit more of a description of what this enables. It's a bit scant on detail on what exactly this gives you.
Quoted 8 lines
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4
/dev/nvme0n1/dev/nvme1n1submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31
Quoted 8 lines
With this:
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4/dev/nvme0n1/dev/nvme1n1submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31
Not that I don't believe you, but that looks like you pasted the same stuff in there twice? It's the exact same perf and pids.
Signature · 1 line
Jens Axboe
Quoted 4 lines · Jens Axboe
This patchset should look cleaner if you rebase it on top of the current for-6.10/io_uring branch, as it gets rid of the async nastiness. Since that'll need doing anyway, could you repost a v2 where it's rebased on top of that?
Yes, next iteration will use that as the base.
Quoted 3 lines
Also in terms of the cover letter, would be good with a bit more of a description of what this enables. It's a bit scant on detail on what exactly this gives you.
Will fix that.
But currently the only thing it gives is - pass meta buffer to/from the block-device.
It keeps things simple, and fine for PI type 0 (normal unprotected IO). For other PI types, exposing few knobs may help. Using "sqe->rw_flags" if there is no other way.
Quoted 17 lines
Quoted 8 lines
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4
/dev/nvme0n1/dev/nvme1n1submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31Quoted 8 lines
With this:
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4/dev/nvme0n1/dev/nvme1n1submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31
Quoted 2 lines
Not that I don't believe you, but that looks like you pasted the same stuff in there twice? It's the exact same perf and pids.
Indeed :-(
Made a goof-up while pasting stuff [1] to the cover letter.
[1]
Before the patch:
# taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4 /dev/nvme0n1 /dev/nvme1n1 submitter=1, tid=2453, file=/dev/nvme1n1, node=-1 submitter=0, tid=2452, file=/dev/nvme0n1, node=-1 polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128 Engine=io_uring, sq_ring=128, cq_ring=128 IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31 IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31 IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31 Exiting on timeout Maximum IOPS=10.04M
After the patch:
# taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4 /dev/nvme0n1 /dev/nvme1n1 submitter=1, tid=2412, file=/dev/nvme1n1, node=-1 submitter=0, tid=2411, file=/dev/nvme0n1, node=-1 polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128 Engine=io_uring, sq_ring=128, cq_ring=128 IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31 IOPS=10.03M, BW=4.90GiB/s, IOS/call=31/31 IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31 Exiting on timeout Maximum IOPS=10.04M
Quoted 7 lines · Kanchan Joshi
This patchset is aimed at getting the feedback on a new
io_uringinterface that userspace can use to exchange meta buffer along with read/write.Two new opcodes for that:
IORING_OP_READ_METAandIORING_OP_WRITE_META. The leftover space in the SQE is used to send meta buffer pointer and its length. Patch #2 for this.
I do remember there were back and forth design discussions about that back when some other guy attempted to implement it, but have you tried to do it not as a separate opcode?
It reads like all read/write opcodes might benefit from it, and it'd be unfortunate to then be adding IORING_OP_READ_META_FIXED and multiplicatively all other variants.
Quoted 56 lines
The interface is supported for block direct IO. Patch #4 for this. Other two are prep patches.
It has been tried not to touch the hot read/write path, as much as possible. Performance for non-meta IO is same after the patches [2]. There is some code in the cold path (worker-based async) though.
Moderately tested by modifying the fio [1] to use this interface (only for NVMe block devices)
[1] https://github.com/OpenMPDK/fio/tree/feat/test-meta
[2]
without this:taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4
/dev/nvme0n1/dev/nvme1n1submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31With this:
taskset -c 2,5 t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -B1 -n2 -r4/dev/nvme0n1/dev/nvme1n1submitter=1, tid=2453, file=/dev/nvme1n1, node=-1
submitter=0, tid=2452, file=/dev/nvme0n1, node=-1
polled=1, fixedbufs=1, register_files=1, buffered=0, QD=128
Engine=io_uring, sq_ring=128, cq_ring=128
IOPS=10.02M, BW=4.89GiB/s, IOS/call=31/31
IOPS=10.04M, BW=4.90GiB/s, IOS/call=31/31Anuj Gupta (3):
io_uring/rw: Get rid of flags field in structio_rwio_uring/rw: support read/write with metadata
block: modifybio_integrity_map_userto acceptiov_iteras argumentKanchan Joshi (1):
block: add support to pass the meta bufferblock/bio-integrity.c | 27 ++++++--- block/fops.c | 9 +++ block/t10-pi.c | 6 ++ drivers/nvme/host/ioctl.c | 11 +++- include/linux/bio.h | 13 +++- include/linux/fs.h | 1 + include/uapi/linux/io_uring.h | 6 ++ io_uring/io_uring.c | 2 + io_uring/opdef.c | 29 +++++++++ io_uring/rw.c | 108 +++++++++++++++++++++++++++++----- io_uring/rw.h | 8 +++ 11 files changed, 193 insertions(+), 27 deletions(-)base-commit:
6f0974eccbf78baead1735722c4f1ee3eb9422cd
Signature · 1 line
Pavel Begunkov
Quoted 5 lines · Pavel Begunkov
Quoted 4 lines · Kanchan Joshi
This patchset is aimed at getting the feedback on a new
io_uringinterface that userspace can use to exchange meta buffer along with read/write.
Quoted 7 lines
Quoted 3 lines
Two new opcodes for that:
IORING_OP_READ_METAandIORING_OP_WRITE_META. The leftover space in the SQE is used to send meta buffer pointer and its length. Patch #2 for this.I do remember there were back and forth design discussions about that back when some other guy attempted to implement it, but have you tried to do it not as a separate opcode?
Did not try that in the first cut, thinking it would help in not touching the hot (non-meta) io path. But open to this.
Quoted 3 lines
It reads like all read/write opcodes might benefit from it, and it'd be unfortunate to then be adding
IORING_OP_READ_META_FIXEDand multiplicatively all other variants.
Right, that's a good point.