Protection information support for xnvme ioengine
A message that is not in the archive (sent off-list or not yet received): CGME20240213101603epcas5p226dc1964544edfb1549fba7734884151@epcas5p2.samsung.com
cover Protection information support for xnvme ioengine
This series enables protection information support with xnvme ioengine. The support is provided with the kernel backends that can handle passthrough commands via nvme character device (/dev/ngXnY), or with user space nvme drivers such as SPDK and libvfn.
The initial patch adds support for metadata buffer. As we are unaware of metadata size during metadata buffer allocation, we provide an option md_per_io_size. This must be used to specify metadata size for single IO, if namespace is formatted with separate metadata buffer.
This then enables the protection information support with and without PRACT bit set for both DIF and DIX cases. The support only covers 16-bit and 64-bit guard protection information format, without storage tags.
For the sake of consistency metadata and protection information specific options are the same as the ones used by io_uring_cmd ioengine and SPDK's external ioengine.
Ankit Kumar (5):
engines/xnvme: allocate iovecs only if vectored I/O is enabled engines/xnvme: add support for metadata
engines:xnvme: add support for end to end data protection engines/xnvme: add checks for verify, block size and metadata size
examples: add PI example with xnvme ioengine
HOWTO.rst | 10 +- configure | 2 +- engines/xnvme.c | 331 +++++++++++++++++++++++++++++++++++++++--- examples/xnvme-pi.fio | 53 +++++++ examples/xnvme-pi.png | Bin 0 -> 71285 bytes fio.1 | 10 +- 6 files changed, 378 insertions(+), 28 deletions(-) create mode 100644 examples/xnvme-pi.fio create mode 100644 examples/xnvme-pi.png
Signature · 1 line
2.25.1
PATCH 1/5 engines/xnvme: allocate iovecs only if vectored I/O is enabled
--- engines/xnvme.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
engines/xnvme.c +9 -6
@@ -325,6 +325,7 @@ failure:static int xnvme_fioe_init (struct thread_data *td) {struct xnvme_fioe_data *xd =NULL ; +struct xnvme_fioe_options *o = td->eo;struct fio_file *f;unsigned int i;
@@ -347,12 +348,14 @@ static int xnvme_fioe_init(struct thread_data *td)return 1 ; } - xd->iovec =calloc (td->o.iodepth,sizeof (*xd->iovec)); -if (!xd->iovec) { -free (xd->iocq); -free (xd); -log_err ("ioeng->init(): !calloc(xd->iovec), err(%d)\n" , errno); -return 1 ; +if (o->xnvme_iovec) { + xd->iovec =calloc (td->o.iodepth,sizeof (*xd->iovec)); +if (!xd->iovec) { +free (xd->iocq); +free (xd); +log_err ("ioeng->init(): !calloc(xd->iovec), err(%d)\n" , errno); +return 1 ; + } } xd->prev =-1 ;
Signature · 1 line
2.25.1
PATCH 2/5 engines/xnvme: add support for metadata
In reply to Ankit KumarThis enables support for separate metadata buffers with xnvme ioengine. This is done by providing xnvme specific option md_per_io_size, which for the sake of consistency is the same option used by io_uring_cmd engine and SPDK's external ioengine.
Bump up the required xnvme support to v0.7.4
--- HOWTO.rst | 2 +- configure | 2 +- engines/xnvme.c | 122 +++++++++++++++++++++++++++++++++++++++++++----- fio.1 | 2 +- 4 files changed, 114 insertions(+), 14 deletions(-)
HOWTO.rst +1 -1
@@ -2491,7 +2491,7 @@ with the caveat that when used on the command line, they must come after the want fio to use placement identifier only at indices 0, 2 and 5 specify ``fdp_pli=0,2,5``. -.. option:: md_per_io_size=int : [io_uring_cmd] +.. option:: md_per_io_size=int : [io_uring_cmd] [xnvme] Size in bytes for separate metadata buffer per IO. Default: 0.
configure +1 -1
@@ -2697,7 +2697,7 @@ fi ########################################## # Check if we have xnvme if test "$xnvme" != "no" ; then - if check_min_lib_version xnvme 0.7.0; then + if check_min_lib_version xnvme 0.7.4; then xnvme="yes" xnvme_cflags=$(pkg-config --cflags xnvme) xnvme_libs=$(pkg-config --libs xnvme)
engines/xnvme.c +111 -11
208 lines not on this page · raw message
fio.1 +1 -1
@@ -2251,7 +2251,7 @@ By default, the job will cycle through all available Placement IDs, so use this to isolate these identifiers to specific jobs. If you want fio to use placement identifier only at indices 0, 2 and 5 specify, you would set `fdp_pli=0,2,5`. .TP -.BI (io_uring_cmd)md_per_io_size \fR=\fPint +.BI (io_uring_cmd,xnvme)md_per_io_size \fR=\fPint Size in bytes for separate metadata buffer per IO. Default: 0. .TP .BI (io_uring_cmd)pi_act \fR=\fPint
Signature · 1 line
2.25.1
PATCH 3/5 engines:xnvme: add support for end to end data protection
In reply to Ankit KumarThis patch enables support for protection information to xnvme ioengine.
This adds 4 new ioengine specific options
* pi_act - Protection information action. Default: 1
* pi_chk - Can be set to GUARD, APPTAG or REFTAG
* apptag - Sets apptag field of command dword 15
* apptag_mask - Sets apptag_mask field of command dword 15
For the sake of consistency these options are the same as the ones used by io_uring_cmd ioengine and SPDK's external ioengine.
--- HOWTO.rst | 8 +-- engines/xnvme.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++ fio.1 | 8 +-- 3 files changed, 153 insertions(+), 8 deletions(-)
HOWTO.rst +4 -4
@@ -2495,7 +2495,7 @@ with the caveat that when used on the command line, they must come after the Size in bytes for separate metadata buffer per IO. Default: 0. -.. option:: pi_act=int : [io_uring_cmd] +.. option:: pi_act=int : [io_uring_cmd] [xnvme] Action to take when nvme namespace is formatted with protection information. If this is set to 1 and namespace is formatted with
@@ -2511,7 +2511,7 @@ with the caveat that when used on the command line, they must come after the it will use the default slower generator. (see: https://github.com/intel/isa-l) -.. option:: pi_chk=str[,str][,str] : [io_uring_cmd] +.. option:: pi_chk=str[,str][,str] : [io_uring_cmd] [xnvme] Controls the protection information check. This can take one or more of these values. Default: none.
@@ -2524,12 +2524,12 @@ with the caveat that when used on the command line, they must come after the **APPTAG** Enables protection information checking of application tag field. -.. option:: apptag=int : [io_uring_cmd] +.. option:: apptag=int : [io_uring_cmd] [xnvme] Specifies logical block application tag value, if namespace is formatted to use end to end protection information. Default: 0x1234. -.. option:: apptag_mask=int : [io_uring_cmd] +.. option:: apptag_mask=int : [io_uring_cmd] [xnvme] Specifies logical block application tag mask value, if namespace is formatted to use end to end protection information. Default: 0xffff.
engines/xnvme.c +145 -0
205 lines not on this page · raw message
fio.1 +4 -4
@@ -2254,7 +2254,7 @@ identifier only at indices 0, 2 and 5 specify, you would set `fdp_pli=0,2,5`. .BI (io_uring_cmd,xnvme)md_per_io_size \fR=\fPint Size in bytes for separate metadata buffer per IO. Default: 0. .TP -.BI (io_uring_cmd)pi_act \fR=\fPint +.BI (io_uring_cmd,xnvme)pi_act \fR=\fPint Action to take when nvme namespace is formatted with protection information. If this is set to 1 and namespace is formatted with metadata size equal to protection information size, fio won't use separate metadata buffer or extended
@@ -2268,7 +2268,7 @@ For 16 bit CRC generation fio will use isa-l if available otherwise it will use the default slower generator. (see: https://github.com/intel/isa-l) .TP -.BI (io_uring_cmd)pi_chk \fR=\fPstr[,str][,str] +.BI (io_uring_cmd,xnvme)pi_chk \fR=\fPstr[,str][,str] Controls the protection information check. This can take one or more of these values. Default: none. .RS
@@ -2285,11 +2285,11 @@ Enables protection information checking of application tag field. .RE .RE .TP -.BI (io_uring_cmd)apptag \fR=\fPint +.BI (io_uring_cmd,xnvme)apptag \fR=\fPint Specifies logical block application tag value, if namespace is formatted to use end to end protection information. Default: 0x1234. .TP -.BI (io_uring_cmd)apptag_mask \fR=\fPint +.BI (io_uring_cmd,xnvme)apptag_mask \fR=\fPint Specifies logical block application tag mask value, if namespace is formatted to use end to end protection information. Default: 0xffff. .TP
Signature · 1 line
2.25.1
PATCH 4/5 engines/xnvme: add checks for verify, block size and metadata size
In reply to Ankit KumarAdd checks to ensure that the correct block size and metadata size is passed by the user.
Disable normal verify checks when end to end data protection checks are enabled because of CRC conflict.
--- engines/xnvme.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
engines/xnvme.c +49 -0
@@ -11,6 +11,7 @@#include <assert.h> #include <libxnvme.h> #include "fio.h" +#include "verify.h" #include "zbd_types.h" #include "fdp.h" #include "optgroup.h"
@@ -345,6 +346,49 @@ static void xnvme_fioe_cleanup(struct thread_data *td) td->io_ops_data =NULL ; } +static int _verify_options (struct thread_data *td,struct fio_file *f, +struct xnvme_fioe_fwrap *fwrap) +{ +struct xnvme_fioe_options *o = td->eo; +unsigned int correct_md_size; + +for_each_rw_ddir (ddir) { +if (td->o.min_bs[ddir] % fwrap->lba_nbytes || td->o.max_bs[ddir] % fwrap->lba_nbytes) { +if (!fwrap->lba_pow2) { +log_err ("ioeng->_verify_options(%s): block size must be a multiple of %u " +"(LBA data size + Metadata size)\n" , f->file_name, fwrap->lba_nbytes); + }else { +log_err ("ioeng->_verify_options(%s): block size must be a multiple of LBA data size\n" , + f->file_name); + } +return 1 ; + } +if (ddir ==DDIR_TRIM ) +continue ; + + correct_md_size = (td->o.max_bs[ddir] / fwrap->lba_nbytes) * fwrap->md_nbytes; +if (fwrap->md_nbytes && fwrap->lba_pow2 && (o->md_per_io_size < correct_md_size)) { +log_err ("ioeng->_verify_options(%s): md_per_io_size should be at least %u bytes\n" , + f->file_name, correct_md_size); +return 1 ; + } + } + +/* +* For extended logical block sizes we cannot use verify when +* end to end data protection checks are enabled, as the PI +* section of data buffer conflicts with verify. +*/ +if (fwrap->md_nbytes && fwrap->geo->pi_type && !fwrap->lba_pow2 && + td->o.verify !=VERIFY_NONE ) { +log_err ("ioeng->_verify_options(%s): for extended LBA, verify cannot be used when E2E data protection is enabled\n" , + f->file_name); +return 1 ; + } + +return 0 ; +} +/** * Helper function setting up device handles as addressed by the naming * convention of the given `fio_file` filename.
@@ -411,6 +455,11 @@ static int _dev_open(struct thread_data *td, struct fio_file *f) fwrap->md_nbytes =0 ; } +if (_verify_options (td, f, fwrap)) { +td_verror (td,EINVAL ,"_dev_open" ); + goto failure; + } + fwrap->fio_file = f; fwrap->fio_file->filetype =FIO_TYPE_BLOCK ; fwrap->fio_file->real_file_size = fwrap->geo->tbytes;
Signature · 1 line
2.25.1
Re: [PATCH 4/5] engines/xnvme: add checks for verify, block size and metadata size
Quoted 24 lines · Ankit Kumar
Add checks to ensure that the correct block size and metadata size is passed by the user.
Disable normal verify checks when end to end data protection checks are enabled because of CRC conflict.Signed-off-by Ankit Kumar <[email protected]>--- engines/xnvme.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)engines/xnvme.c +1
-0@@ -11,6 +11,7 @@#include <assert.h> #include <libxnvme.h> #include "fio.h" +#include "verify.h" #include "zbd_types.h" #include "fdp.h" #include "optgroup.h" @@ -345,6 +346,49 @@ static void xnvme_fioe_cleanup(struct thread_data *td) td->io_ops_data =NULL ;
engines/xnvme.c static void xnvme_fioe_cleanup(struct thread_data *td) · line 356
Quoted 10 lines
engines/xnvme.c +8
-0} +static int _verify_options (struct thread_data *td,struct fio_file *f, +struct xnvme_fioe_fwrap *fwrap) +{ +struct xnvme_fioe_options *o = td->eo; +unsigned int correct_md_size; + +for_each_rw_ddir (ddir) { +if (td->o.min_bs[ddir] % fwrap->lba_nbytes || td->o.max_bs[ddir] % fwrap->lba_nbytes) {
I thought this was wrong at first but I tried it on a device formatted in extended LBA mode (4096+64) and indeed lba_nbytes was 4160. I also checked the xNVMe source code and found where this can be set to be the sum of the LBA data and metadata sizes. It would be helpful to improve the xNVMe documentaion to make explicit what this value is.
Vincent
Re: [PATCH 4/5] engines/xnvme: add checks for verify, block size and metadata size
Quoted 9 lines · Vincent Fu
I thought this was wrong at first but I tried it on a device formatted in extended LBA mode (4096+64) and indeed
lba_nbyteswas 4160. I also checked the xNVMe source code and found where this can be set to be the sum of the LBA data and metadata sizes. It would be helpful to improve the xNVMe documentaion to make explicit what this value is.Vincent
Thanks for pointing it out, we will update the xNVMe documentation accordingly.
PATCH 5/5 examples: add PI example with xnvme ioengine
In reply to Ankit Kumar--- examples/xnvme-pi.fio | 53 ++++++++++++++++++++++++++++++++++++++++++ examples/xnvme-pi.png | Bin 0 -> 71285 bytes 2 files changed, 53 insertions(+) create mode 100644 examples/xnvme-pi.fio create mode 100644 examples/xnvme-pi.png
examples/xnvme-pi.fio new file +53 -0
@@ -0,0 +1,53 @@ +; README +; +; This job-file is intended to be used either as: +; +; # Use the xNVMe io-engine engine io_uring_cmd async. impl. +; fio examples/xnvme-pi.fio \ +; --ioengine=xnvme \ +; --xnvme_async=io_uring_cmd \ +; --filename=/dev/ng0n1 +; +; # Use the xNVMe io-engine engine with nvme sync. impl. +; fio examples/xnvme-pi.fio \ +; --ioengine=xnvme \ +; --xnvme_sync=nvme \ +; --filename=/dev/ng0n1 +; +; # Use the xNVMe io-engine engine with SPDK backend, note that you have to set the Namespace-id +; fio examples/xnvme-pi.fio \ +; --ioengine=xnvme \ +; --xnvme_dev_nsid=1 \ +; --filename=0000\\:01\\:00.0 +; +; NOTE: The URI encoded in the filename above, the ":" must be escaped. +; +; On the command-line using two "\\": +; +; --filename=0000\\:01\\:00.0 +; +; Within a fio-script using a single "\": +; +; filename=0000\:01\:00.0 +; +; NOTE: This example configuration assumes that the NVMe device is formatted +; with a separate metadata buffer. If you want to run on an extended LBA format +; update the "bs" accordingly. +; +[global] +size=100M +iodepth=16 +bs=4K +md_per_io_size=64 +pi_act=0 +pi_chk=GUARD,APPTAG,REFTAG +apptag=0x0234 +apptag_mask=0xFFFF +thread=1 +stonewall=1 + +[write] +rw=write + +[read] +rw=read
examples/xnvme-pi.png new file binary +0 -0
Signature · 1 line
2.25.1
Quoted 32 lines · Ankit Kumar
This series enables protection information support with xnvme ioengine. The support is provided with the kernel backends that can handle passthrough commands via nvme character device (
/dev/ngXnY), or with user space nvme drivers such as SPDK and libvfn.The initial patch adds support for metadata buffer. As we are unaware of metadata size during metadata buffer allocation, we provide an option
md_per_io_size. This must be used to specify metadata size for single IO, if namespace is formatted with separate metadata buffer.This then enables the protection information support with and without PRACT bit set for both DIF and DIX cases. The support only covers 16-bit and 64-bit guard protection information format, without storage tags.
For the sake of consistency metadata and protection information specific options are the same as the ones used by
io_uring_cmdioengine and SPDK's external ioengine.Ankit Kumar (5):
engines/xnvme: allocate iovecs only if vectored I/O is enabled engines/xnvme: add support for metadata
engines:xnvme: add support for end to end data protection engines/xnvme: add checks for verify, block size and metadata size
examples: add PI example with xnvme ioengineHOWTO.rst | 10 +- configure | 2 +- engines/xnvme.c | 331 +++++++++++++++++++++++++++++++++++++++--- examples/xnvme-pi.fio | 53 +++++++ examples/xnvme-pi.png | Bin 0 -> 71285 bytes fio.1 | 10 +- 6 files changed, 378 insertions(+), 28 deletions(-)
Quoted 3 lines
create mode 100644 examples/xnvme-pi.fio
create mode 100644 examples/xnvme-pi.png
These patches look good to me. I'll wait a bit in case Jens or anyone else has feedback.
Vincent
Jens Axboe
Reviewed-byQuoted 37 lines · Vincent Fu
Quoted 32 lines · Ankit Kumar
This series enables protection information support with xnvme ioengine. The support is provided with the kernel backends that can handle passthrough commands via nvme character device (
/dev/ngXnY), or with user space nvme drivers such as SPDK and libvfn.The initial patch adds support for metadata buffer. As we are unaware of metadata size during metadata buffer allocation, we provide an option
md_per_io_size. This must be used to specify metadata size for single IO, if namespace is formatted with separate metadata buffer.This then enables the protection information support with and without PRACT bit set for both DIF and DIX cases. The support only covers 16-bit and 64-bit guard protection information format, without storage tags.
For the sake of consistency metadata and protection information specific options are the same as the ones used by
io_uring_cmdioengine and SPDK's external ioengine.Ankit Kumar (5):
engines/xnvme: allocate iovecs only if vectored I/O is enabled engines/xnvme: add support for metadata
engines:xnvme: add support for end to end data protection engines/xnvme: add checks for verify, block size and metadata size
examples: add PI example with xnvme ioengineHOWTO.rst | 10 +- configure | 2 +- engines/xnvme.c | 331 +++++++++++++++++++++++++++++++++++++++--- examples/xnvme-pi.fio | 53 +++++++ examples/xnvme-pi.png | Bin 0 -> 71285 bytes fio.1 | 10 +- 6 files changed, 378 insertions(+), 28 deletions(-)Quoted 3 lines
create mode 100644 examples/xnvme-pi.fio
create mode 100644 examples/xnvme-pi.png
Quoted 2 lines
These patches look good to me. I'll wait a bit in case Jens or anyone else has feedback.
Looks OK to me:
Signature · 1 line
Jens Axboe
Quoted 38 lines · Jens Axboe
Quoted 37 lines · Vincent Fu
Quoted 35 lines · Ankit Kumar
This series enables protection information support with xnvme ioengine. The support is provided with the kernel backends that can handle passthrough commands via nvme character device (
/dev/ngXnY), or with user space nvme drivers such as SPDK and libvfn.The initial patch adds support for metadata buffer. As we are unaware of metadata size during metadata buffer allocation, we provide an option
md_per_io_size. This must be used to specify metadata size for single IO, if namespace is formatted with separate metadata buffer.This then enables the protection information support with and without PRACT bit set for both DIF and DIX cases. The support only covers 16-bit and 64-bit guard protection information format, without storage tags.
For the sake of consistency metadata and protection information specific options are the same as the ones used by
io_uring_cmdioengine and SPDK's external ioengine.Ankit Kumar (5):
engines/xnvme: allocate iovecs only if vectored I/O is enabled engines/xnvme: add support for metadata
engines:xnvme: add support for end to end data protection engines/xnvme: add checks for verify, block size and metadata size
examples: add PI example with xnvme ioengineHOWTO.rst | 10 +- configure | 2 +- engines/xnvme.c | 331 +++++++++++++++++++++++++++++++++++++++--- examples/xnvme-pi.fio | 53 +++++++ examples/xnvme-pi.png | Bin 0 -> 71285 bytes fio.1 | 10 +- 6 files changed, 378 insertions(+), 28 deletions(-)create mode 100644 examples/xnvme-pi.fio
create mode 100644 examples/xnvme-pi.png
Quoted 7 lines
Quoted 2 lines
These patches look good to me. I'll wait a bit in case Jens or anyone else has feedback.
Looks OK to me:
Reviewed-by Jens Axboe <[email protected]>
In that case, applied. Thanks!
Vincent