fio: add fdp support for io_uring_cmd nvme engine
PATCH v2 1/1 fio: add fdp support for io_uring_cmd nvme engine
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's io_uring_cmd ioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands. The user can limit which placement identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.
Setting up your namespace for FDP is outside the scope of 'fio', so this assumes the namespace is already properly configured for the mode.
---v1->v2:
Actually 'git add' the new source files (Vincent, Ankit)
Added HOWTO and fio.1 documentation on new options (Jens)
Fix whitespace (Jens)
Bump FIO_IOOPS_VERSION (Damien)
Dropped the unnecessary fdp checks and infrastructure for it, relying only on the iomgmt to provide fdp state.
HOWTO.rst | 10 +++ Makefile | 2 +- engines/io_uring.c | 23 +++++++ engines/nvme.c | 39 +++++++++++- engines/nvme.h | 20 ++++++ examples/uring-cmd-fdp.fio | 37 ++++++++++++ fdp.c | 121 +++++++++++++++++++++++++++++++++++++ fdp.h | 16 +++++ file.h | 3 + filesetup.c | 7 +++ fio.1 | 8 +++ io_u.c | 3 + io_u.h | 3 + ioengines.h | 5 +- options.c | 49 +++++++++++++++ thread_options.h | 7 +++ 16 files changed, 350 insertions(+), 3 deletions(-) create mode 100644 examples/uring-cmd-fdp.fio create mode 100644 fdp.c create mode 100644 fdp.h
HOWTO.rst +10 -0
@@ -2431,6 +2431,16 @@ with the caveat that when used on the command line, they must come after the For direct I/O, requests will only succeed if cache invalidation isn't required, file blocks are fully allocated and the disk request could be issued immediately. +.. option:: fdp=bool : [io_uring_cmd] + + Enable Flexible Data Placement mode for write commands. + +.. option:: fdp_pli=int[,int][,int] : [io_uring_cmd] + + Select which Placement ID Index/Indicies this job is allowed to use for + writes. By default, the job will cycle through all available Placement + IDs, so use this to isolate these identifiers to specific jobs.. + .. option:: cpuload=int : [cpuio] Attempt to use the specified percentage of CPU cycles. This is a mandatory
Makefile +1 -1
@@ -62,7 +62,7 @@ SOURCE := $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \ gettime-thread.c helpers.c json.c idletime.c td_error.c \ profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \ workqueue.c rate-submit.c optgroup.c helper_thread.c \ - steadystate.c zone-dist.c zbd.c dedupe.c + steadystate.c zone-dist.c zbd.c dedupe.c fdp.c ifdef CONFIG_LIBHDFS HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
engines/io_uring.c +23 -0
@@ -1262,6 +1262,28 @@ static int fio_ioring_cmd_get_max_open_zones(struct thread_data *td,return fio_nvme_get_max_open_zones (td, f, max_open_zones); } +static int fio_ioring_cmd_fetch_ruhs (struct thread_data *td,struct fio_file *f, +struct fio_ruhs_info *fruhs_info) +{ +struct nvme_fdp_ruh_status *ruhs; +int bytes, ret, i; + + bytes =sizeof (*ruhs) +1024 *sizeof (struct nvme_fdp_ruh_status_desc ); + ruhs =malloc (bytes); +memset (ruhs,0 , bytes); + + ret =fio_nvme_iomgmt_ruhs (td, f, ruhs, bytes); +if (ret) + goto free; + + fruhs_info->nr_ruhs =le16_to_cpu (ruhs->nruhsd); +for (i =0 ; i < fruhs_info->nr_ruhs; i++) + fruhs_info->plis[i] =le16_to_cpu (ruhs->ruhss[i].pid); +free: +free (ruhs); +return ret; +} +static struct ioengine_ops ioengine_uring = { .name ="io_uring" , .version =FIO_IOOPS_VERSION ,
@@ -1307,6 +1329,7 @@ static struct ioengine_ops ioengine_uring_cmd = { .get_max_open_zones = fio_ioring_cmd_get_max_open_zones, .options = options, .option_struct_size = sizeof(struct ioring_options), + .fdp_fetch_ruhs = fio_ioring_cmd_fetch_ruhs, }; static void fio_init fio_ioring_register(void)
engines/nvme.c +38 -1
@@ -28,7 +28,8 @@ int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u, cmd->cdw10 = slba &0xffffffff ; cmd->cdw11 = slba >>32 ;/* cdw12 represent number of lba's for read/write */ - cmd->cdw12 = nlb; + cmd->cdw12 = nlb | (io_u->dtype <<20 ); + cmd->cdw13 = io_u->dspec <<16 ;if (iov) { iov->iov_base = io_u->xfer_buf; iov->iov_len = io_u->xfer_buflen;
@@ -345,3 +346,39 @@ out:close (fd);return ret; } + +static inline int nvme_fdp_reclaim_unit_handle_status (int fd,__u32 nsid, +__u32 data_len,void *data) +{ +struct nvme_passthru_cmd cmd = { + .opcode = nvme_cmd_io_mgmt_recv, + .nsid = nsid, + .addr = (__u64 )(uintptr_t )data, + .data_len = data_len, + .cdw10 =1 , + .cdw11 = (data_len >>2 ) -1 , + }; + +return ioctl (fd,NVME_IOCTL_IO_CMD , &cmd); +} + +int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes) +{ +struct nvme_data *data =FILE_ENG_DATA (f); +int fd, ret; + + fd =open (f->file_name,O_RDONLY |O_LARGEFILE ); +if (fd <0 ) +return -errno; + + ret =nvme_fdp_reclaim_unit_handle_status (fd, data->nsid, bytes, ruhs); +if (ret) { +log_err ("%s: nvme_fdp_reclaim_unit_handle_status failed, err=%d\n" , + f->file_name, ret); + errno =ENOTSUP ; + } + +close (fd); +return -errno; +}
engines/nvme.h +20 -0
@@ -67,6 +67,7 @@ enum nvme_admin_opcode {enum nvme_io_opcode { nvme_cmd_write =0x01 , nvme_cmd_read =0x02 , + nvme_cmd_io_mgmt_recv =0x12 , nvme_zns_cmd_mgmt_send =0x79 , nvme_zns_cmd_mgmt_recv =0x7a , };
@@ -192,6 +193,25 @@ struct nvme_zone_report {struct nvme_zns_desc entries[]; }; +struct nvme_fdp_ruh_status_desc { +__u16 pid; +__u16 ruhid; +__u32 earutr; +__u64 ruamw; +__u8 rsvd16[16 ]; +}; + +struct nvme_fdp_ruh_status { +__u8 rsvd0[14 ]; +__le16 nruhsd; +struct nvme_fdp_ruh_status_desc ruhss[]; +}; + +int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes); + +int fio_nvme_is_fdp (struct thread_data *td,struct fio_file *f,bool *fdp); +int fio_nvme_get_info (struct fio_file *f,__u32 *nsid,__u32 *lba_sz,__u64 *nlba);
examples/uring-cmd-fdp.fio new file +37 -0
@@ -0,0 +1,37 @@ +# io_uring_cmd I/O engine for nvme-ns generic character device with FDP enabled +# This assumes the namespace is already configured with FDP support and has at +# least 8 available reclaim units. +# +# Each job targets different ranges of LBAs with different placement +# identifiers, and has different write intensity. + +[global] +filename=/dev/ng0n1 +ioengine=io_uring_cmd +cmd_type=nvme +iodepth=32 +bs=4K +fdp=1 +time_based=1 +runtime=1000 + +[write-heavy] +rw=randrw +rwmixwrite=90 +fdp_pli=0,1,2,3 +offset=0% +size=30% + +[write-mid] +rw=randrw +rwmixwrite=30 +fdp_pli=4,5 +offset=30% +size=30% + +[write-light] +rw=randrw +rwmixwrite=10 +fdp_pli=6 +offset=60% +size=30%
fdp.c new file +121 -0
121 lines not on this page · raw message
fdp.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef FIO_FDP_H +#define FIO_FDP_H + +#include "io_u.h" + +struct fio_ruhs_info { +uint32_t nr_ruhs; +uint32_t pli_loc; +uint16_t plis[]; +}; + +int fdp_init (struct thread_data *td); +void fdp_free_ruhs_info (struct fio_file *f); +void fdp_fill_dspec_data (struct thread_data *td,struct io_u *io_u); + +#endif /* FIO_FDP_H */
file.h +3 -0
@@ -12,6 +12,7 @@/* Forward declarations */ struct zoned_block_device_info ; +struct fdp_ruh_info ;/* * The type of object we are working on
@@ -101,6 +102,8 @@ struct fio_file {uint64_t file_offset;uint64_t io_size; +struct fio_ruhs_info *ruhs_info; +/* * Zoned block device information. See also zonemode=zbd. */
filesetup.c +7 -0
@@ -1417,6 +1417,12 @@ done:td_restore_runstate (td, old_state); +if (td->o.fdp) { + err =fdp_init (td); +if (err) + goto err_out; + } +return 0 ; err_offset:
@@ -1627,6 +1633,7 @@ void close_and_free_files(struct thread_data *td) }zbd_close_file (f); +fdp_free_ruhs_info (f);fio_file_free (f); }
fio.1 +8 -0
@@ -2192,6 +2192,14 @@ cached data. Currently the RWF_NOWAIT flag does not supported for cached write. For direct I/O, requests will only succeed if cache invalidation isn't required, file blocks are fully allocated and the disk request could be issued immediately. .TP +.BI (io_uring_cmd)fdp \fR=\fPbool +Enable Flexible Data Placement mode for write commands. +.TP +.BI (io_uring_cmd)fdp_pli \fR=\fPint[,int][,int] +Select which Placement ID Index/Indicies this job is allowed to use for writes. +By default, the job will cycle through all available Placement IDs, so use this +to isolate these identifiers to specific jobs. +.TP .BI (cpuio)cpuload \fR=\fPint Attempt to use the specified percentage of CPU cycles. This is a mandatory option when using cpuio I/O engine.
io_u.c +3 -0
@@ -988,6 +988,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)return 1 ; } +if (td->o.fdp) +fdp_fill_dspec_data (td, io_u); +if (io_u->offset + io_u->buflen > io_u->file->real_file_size) { dprint(FD_IO, "io_u %p, off=0x%llx + len=0x%llx exceeds file size=0x%llx\n", io_u,
io_u.h +3 -0
@@ -117,6 +117,9 @@ struct io_u {*/ int (*end_io)(struct thread_data *,struct io_u **); +uint32_t dtype; +uint32_t dspec; +union {#ifdef CONFIG_LIBAIO struct iocb iocb;
ioengines.h +4 -1
@@ -7,8 +7,9 @@#include "flist.h" #include "io_u.h" #include "zbd_types.h" +#include "fdp.h" -#define FIO_IOOPS_VERSION 31 +#define FIO_IOOPS_VERSION 32#ifndef CONFIG_DYNAMIC_ENGINES #define FIO_STATIC static
@@ -63,6 +64,8 @@ struct ioengine_ops { unsigned int *);int (*finish_zone)(struct thread_data *,struct fio_file *,uint64_t ,uint64_t ); +int (*fdp_fetch_ruhs)(struct thread_data *,struct fio_file *, +struct fio_ruhs_info *);int option_struct_size;struct fio_option *options; };
options.c +49 -0
61 lines not on this page · raw message
thread_options.h +7 -0
@@ -386,6 +386,11 @@ struct thread_options {fio_fp64_t zrt;fio_fp64_t zrf; +#define FIO_MAX_PLIS 16 +unsigned int fdp; +unsigned int fdp_plis[FIO_MAX_PLIS ]; +unsigned int fdp_nrpli; +unsigned int log_entries;unsigned int log_prio; };
@@ -698,6 +703,8 @@ struct thread_options_pack {uint32_t log_entries;uint32_t log_prio; +uint32_t fdp; +/* * verify_pattern followed by buffer_pattern from the unpacked struct */
Signature · 1 line
2.30.2
Quoted 11 lines · Keith Busch
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's
io_uring_cmdioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands. The user can limit which placement identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.
Quoted 6 lines
Setting up your namespace for FDP is outside the scope of 'fio', so this assumes the namespace is already properly configured for the mode.
Based-on-a-patch-by Ankit Kumar <[email protected]>Signed-off-by Keith Busch <[email protected]>---
I haven't looked at the patch yet but it does pass the main tests we have set up with GitHub Actions:
https://github.com/fiotestbot/fio/actions/runs/4137029644
Vincent
Quoted 56 lines · Keith Busch
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's
io_uring_cmdioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands. The user can limit which placement identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.Setting up your namespace for FDP is outside the scope of 'fio', so this assumes the namespace is already properly configured for the mode.
Based-on-a-patch-by Ankit Kumar <[email protected]>Signed-off-by Keith Busch <[email protected]>---
v1->v2:Actually 'git add' the new source files (Vincent, Ankit)
Added HOWTO and fio.1 documentation on new options (Jens)
Fix whitespace (Jens)
Bump
FIO_IOOPS_VERSION(Damien)Dropped the unnecessary fdp checks and infrastructure for it, relying only on the iomgmt to provide fdp state.
HOWTO.rst | 10 +++ Makefile | 2 +- engines/io_uring.c | 23 +++++++ engines/nvme.c | 39 +++++++++++- engines/nvme.h | 20 ++++++ examples/uring-cmd-fdp.fio | 37 ++++++++++++ fdp.c | 121 +++++++++++++++++++++++++++++++++++++ fdp.h | 16 +++++ file.h | 3 + filesetup.c | 7 +++ fio.1 | 8 +++ io_u.c | 3 + io_u.h | 3 + ioengines.h | 5 +- options.c | 49 +++++++++++++++ thread_options.h | 7 +++ 16 files changed, 350 insertions(+), 3 deletions(-) create mode 100644 examples/uring-cmd-fdp.fio create mode 100644 fdp.c create mode 100644 fdp.hHOWTO.rst +0
-0
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2438
Quoted 8 lines
HOWTO.rst +5
-0@@ -2431,6 +2431,16 @@ with the caveat that when used on the command line, they must come after the For direct I/O, requests will only succeed if cache invalidation isn't required, file blocks are fully allocated and the disk request could be issued immediately. +.. option:: fdp=bool : [io_uring_cmd] + + Enable Flexible Data Placement mode for write commands. + +.. option:: fdp_pli=int[,int][,int] : [io_uring_cmd]
I think it probably should just be "fdp_pli=str" Kind of similar to the fio "option cpus_allowed=str"
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2442
Quoted 4 lines
HOWTO.rst +4
-0+ + Select which Placement ID Index/Indicies this job is allowed to use for + writes. By default, the job will cycle through all available Placement + IDs, so use this to isolate these identifiers to specific jobs..
Maybe we can also add one line description something like this:
If you want fio to use placement identifier only at indices 0,2 and 5 specify ``fdp_pli=0,2,5``.
Quoted 101 lines
HOWTO.rst +1
-0+ .. option:: cpuload=int : [cpuio] Attempt to use the specified percentage of CPU cycles. This is a mandatoryMakefile +1
-1@@ -62,7 +62,7 @@ SOURCE := $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \ gettime-thread.c helpers.c json.c idletime.c td_error.c \ profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \ workqueue.c rate-submit.c optgroup.c helper_thread.c \ - steadystate.c zone-dist.c zbd.c dedupe.c + steadystate.c zone-dist.c zbd.c dedupe.c fdp.c ifdef CONFIG_LIBHDFS HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)engines/io_uring.c +23
-0@@ -1262,6 +1262,28 @@ static int fio_ioring_cmd_get_max_open_zones(struct thread_data *td,return fio_nvme_get_max_open_zones (td, f, max_open_zones); } +static int fio_ioring_cmd_fetch_ruhs (struct thread_data *td,struct fio_file *f, +struct fio_ruhs_info *fruhs_info) +{ +struct nvme_fdp_ruh_status *ruhs; +int bytes, ret, i; + + bytes =sizeof (*ruhs) +1024 *sizeof (struct nvme_fdp_ruh_status_desc ); + ruhs =malloc (bytes); +memset (ruhs,0 , bytes); + + ret =fio_nvme_iomgmt_ruhs (td, f, ruhs, bytes); +if (ret) + goto free; + + fruhs_info->nr_ruhs =le16_to_cpu (ruhs->nruhsd); +for (i =0 ; i < fruhs_info->nr_ruhs; i++) + fruhs_info->plis[i] =le16_to_cpu (ruhs->ruhss[i].pid); +free: +free (ruhs); +return ret; +} +static struct ioengine_ops ioengine_uring = { .name ="io_uring" , .version =FIO_IOOPS_VERSION ,@@ -1307,6 +1329,7 @@ static struct ioengine_ops ioengine_uring_cmd = { .get_max_open_zones = fio_ioring_cmd_get_max_open_zones, .options = options, .option_struct_size = sizeof(struct ioring_options), + .fdp_fetch_ruhs = fio_ioring_cmd_fetch_ruhs, }; static void fio_init fio_ioring_register(void)engines/nvme.c +27
-1@@ -28,7 +28,8 @@ int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u, cmd->cdw10 = slba &0xffffffff ; cmd->cdw11 = slba >>32 ;/* cdw12 represent number of lba's for read/write */ - cmd->cdw12 = nlb; + cmd->cdw12 = nlb | (io_u->dtype <<20 ); + cmd->cdw13 = io_u->dspec <<16 ;if (iov) { iov->iov_base = io_u->xfer_buf; iov->iov_len = io_u->xfer_buflen;@@ -345,3 +346,39 @@ out:close (fd);return ret; } + +static inline int nvme_fdp_reclaim_unit_handle_status (int fd,__u32 nsid, +__u32 data_len,void *data) +{ +struct nvme_passthru_cmd cmd = { + .opcode = nvme_cmd_io_mgmt_recv, + .nsid = nsid, + .addr = (__u64 )(uintptr_t )data, + .data_len = data_len, + .cdw10 =1 , + .cdw11 = (data_len >>2 ) -1 , + }; + +return ioctl (fd,NVME_IOCTL_IO_CMD , &cmd); +} + +int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes) +{ +struct nvme_data *data =FILE_ENG_DATA (f); +int fd, ret; + + fd =open (f->file_name,O_RDONLY |O_LARGEFILE ); +if (fd <0 ) +return -errno;
engines/nvme.c out: · line 383
Quoted 10 lines
engines/nvme.c +10
-0+ + ret =nvme_fdp_reclaim_unit_handle_status (fd, data->nsid, bytes, ruhs); +if (ret) { +log_err ("%s: nvme_fdp_reclaim_unit_handle_status failed, err=%d\n" , + f->file_name, ret); + errno =ENOTSUP ; + } + +close (fd); +return -errno;
should be "return ret;"
Quoted 94 lines
engines/nvme.c +1
-0+}engines/nvme.h +20
-0@@ -67,6 +67,7 @@ enum nvme_admin_opcode {enum nvme_io_opcode { nvme_cmd_write =0x01 , nvme_cmd_read =0x02 , + nvme_cmd_io_mgmt_recv =0x12 , nvme_zns_cmd_mgmt_send =0x79 , nvme_zns_cmd_mgmt_recv =0x7a , };@@ -192,6 +193,25 @@ struct nvme_zone_report {struct nvme_zns_desc entries[]; }; +struct nvme_fdp_ruh_status_desc { +__u16 pid; +__u16 ruhid; +__u32 earutr; +__u64 ruamw; +__u8 rsvd16[16 ]; +}; + +struct nvme_fdp_ruh_status { +__u8 rsvd0[14 ]; +__le16 nruhsd; +struct nvme_fdp_ruh_status_desc ruhss[]; +}; + +int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes); + +int fio_nvme_is_fdp (struct thread_data *td,struct fio_file *f,bool *fdp); +int fio_nvme_get_info (struct fio_file *f,__u32 *nsid,__u32 *lba_sz,__u64 *nlba);examples/uring-cmd-fdp.fio new file +37
-0@@ -0,0 +1,37 @@ +# io_uring_cmd I/O engine for nvme-ns generic character device with FDP enabled +# This assumes the namespace is already configured with FDP support and has at +# least 8 available reclaim units. +# +# Each job targets different ranges of LBAs with different placement +# identifiers, and has different write intensity. + +[global] +filename=/dev/ng0n1 +ioengine=io_uring_cmd +cmd_type=nvme +iodepth=32 +bs=4K +fdp=1 +time_based=1 +runtime=1000 + +[write-heavy] +rw=randrw +rwmixwrite=90 +fdp_pli=0,1,2,3 +offset=0% +size=30% + +[write-mid] +rw=randrw +rwmixwrite=30 +fdp_pli=4,5 +offset=30% +size=30% + +[write-light] +rw=randrw +rwmixwrite=10 +fdp_pli=6 +offset=60% +size=30%fdp.c new file +6
-0@@ -0,0 +1,121 @@ +/* +* Note: This is similar to a very basic setup +* of ZBD devices +* +* Specify fdp=1 (With char devices /dev/ng0n1) +*/
fdp.c line 16
Quoted 10 lines
fdp.c new file +10
-0+ +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include "file.h" +#include "fio.h" + +#include "pshared.h" +#include <fdp.h>
#include "fdp.h"
fdp.c line 21
Quoted 5 lines
fdp.c new file +5
-0+ +/* +* Maximum number of RUHS to fetch +* TODO: Revisit this so that we can work with more than 1024 RUH's +*/
For me, I will send a fix once these changes get merged.
Quoted 174 lines
fdp.c new file +100
-0+#define FDP_FETCH_RUHS_MAX 1024U + +static int fdp_ruh_info (struct thread_data *td,struct fio_file *f, +struct fio_ruhs_info *ruhs) +{ +int ret = -EINVAL ; + +if (td->io_ops && td->io_ops->fdp_fetch_ruhs) + ret = td->io_ops->fdp_fetch_ruhs (td, f, ruhs); +else +log_err ("%s: engine (%s) lacks fetch ruhs.\n" , + f->file_name, td->io_ops->name); +if (ret <0 ) { +td_verror (td, errno,"fdp fetch ruhs failed" ); +log_err ("%s: fdp fetch ruhs failed (%d).\n" , + f->file_name, errno); + } + +return ret; +} + +static int init_ruh_info (struct thread_data *td,struct fio_file *f) +{ +struct fio_ruhs_info *ruhs, *tmp; +int i, ret; + + ruhs =calloc (1 ,sizeof (*ruhs) + +FDP_FETCH_RUHS_MAX *sizeof (*ruhs->plis)); +if (!ruhs) +return -ENOMEM ; + + ret =fdp_ruh_info (td, f, ruhs); +if (ret) { +log_info ("fio: ruh info failed for %s (%d).\n" , + f->file_name, -ret); + goto out; + } + +if (ruhs->nr_ruhs >FDP_FETCH_RUHS_MAX ) + ruhs->nr_ruhs =FDP_FETCH_RUHS_MAX ; + +if (td->o.fdp_nrpli ==0 ) { + f->ruhs_info = ruhs; +return 0 ; + } + +for (i =0 ; i < td->o.fdp_nrpli; i++) { +if (td->o.fdp_plis[i] > ruhs->nr_ruhs) { + ret = -EINVAL ; + goto out; + } + } + + tmp =calloc (1 ,sizeof (*tmp) + ruhs->nr_ruhs *sizeof (*tmp->plis)); + tmp->nr_ruhs = td->o.fdp_nrpli; +for (i =0 ; i < td->o.fdp_nrpli; i++) + tmp->plis[i] = ruhs->plis[td->o.fdp_plis[i]]; + f->ruhs_info = tmp; +out: +free (ruhs); +return ret; +} + +int fdp_init (struct thread_data *td) +{ +struct fio_file *f; +int i, ret =0 ; + +for_each_file (td, f, i) { + ret =init_ruh_info (td, f); +if (ret) +break ; + } +return ret; +} + +void fdp_free_ruhs_info (struct fio_file *f) +{ +if (!f->ruhs_info) +return ; +free (f->ruhs_info); + f->ruhs_info =NULL ; +} + +void fdp_fill_dspec_data (struct thread_data *td,struct io_u *io_u) +{ +struct fio_file *f = io_u->file; +struct fio_ruhs_info *ruhs = f->ruhs_info; +int dspec; + +if (!ruhs || io_u->ddir !=DDIR_WRITE ) { + io_u->dtype =0 ; + io_u->dspec =0 ; +return ; + } + + dspec = ruhs->plis[ruhs->pli_loc++ % ruhs->nr_ruhs]; + io_u->dtype =2 ; + io_u->dspec = dspec; +}fdp.h new file +16
-0@@ -0,0 +1,16 @@ +#ifndef FIO_FDP_H +#define FIO_FDP_H + +#include "io_u.h" + +struct fio_ruhs_info { +uint32_t nr_ruhs; +uint32_t pli_loc; +uint16_t plis[]; +}; + +int fdp_init (struct thread_data *td); +void fdp_free_ruhs_info (struct fio_file *f); +void fdp_fill_dspec_data (struct thread_data *td,struct io_u *io_u); + +#endif /* FIO_FDP_H */ file.h +3
-0@@ -12,6 +12,7 @@/* Forward declarations */ struct zoned_block_device_info ; +struct fdp_ruh_info ;/* * The type of object we are working on @@ -101,6 +102,8 @@ struct fio_file {uint64_t file_offset;uint64_t io_size; +struct fio_ruhs_info *ruhs_info; +/* * Zoned block device information. See also zonemode=zbd. */ filesetup.c +7
-0@@ -1417,6 +1417,12 @@ done:td_restore_runstate (td, old_state); +if (td->o.fdp) { + err =fdp_init (td); +if (err) + goto err_out; + } +return 0 ; err_offset:@@ -1627,6 +1633,7 @@ void close_and_free_files(struct thread_data *td) }zbd_close_file (f); +fdp_free_ruhs_info (f);fio_file_free (f); }fio.1 +0
-0@@ -2192,6 +2192,14 @@ cached data. Currently the RWF_NOWAIT flag does not supported for cached write. For direct I/O, requests will only succeed if cache invalidation isn't required,
fio.1 cached data. Currently the RWF_NOWAIT flag does not supported for cached write. · line 2202
Quoted 10 lines
fio.1 +8
-0file blocks are fully allocated and the disk request could be issued immediately. .TP +.BI (io_uring_cmd)fdp \fR=\fPbool +Enable Flexible Data Placement mode for write commands. +.TP +.BI (io_uring_cmd)fdp_pli \fR=\fPint[,int][,int] +Select which Placement ID Index/Indicies this job is allowed to use for writes. +By default, the job will cycle through all available Placement IDs, so use this +to isolate these identifiers to specific jobs. +.TP
Same comments from HOWTO
Quoted 139 lines
fio.1 +0
-0.BI (cpuio)cpuload \fR=\fPint Attempt to use the specified percentage of CPU cycles. This is a mandatory option when using cpuio I/O engine.io_u.c +3
-0@@ -988,6 +988,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)return 1 ; } +if (td->o.fdp) +fdp_fill_dspec_data (td, io_u); +if (io_u->offset + io_u->buflen > io_u->file->real_file_size) { dprint(FD_IO, "io_u %p, off=0x%llx + len=0x%llx exceeds file size=0x%llx\n", io_u,io_u.h +3
-0@@ -117,6 +117,9 @@ struct io_u {*/ int (*end_io)(struct thread_data *,struct io_u **); +uint32_t dtype; +uint32_t dspec; +union {#ifdef CONFIG_LIBAIO struct iocb iocb;ioengines.h +4
-1@@ -7,8 +7,9 @@#include "flist.h" #include "io_u.h" #include "zbd_types.h" +#include "fdp.h" -#define FIO_IOOPS_VERSION 31 +#define FIO_IOOPS_VERSION 32#ifndef CONFIG_DYNAMIC_ENGINES #define FIO_STATIC static@@ -63,6 +64,8 @@ struct ioengine_ops { unsigned int *);int (*finish_zone)(struct thread_data *,struct fio_file *,uint64_t ,uint64_t ); +int (*fdp_fetch_ruhs)(struct thread_data *,struct fio_file *, +struct fio_ruhs_info *);int option_struct_size;struct fio_option *options; };options.c +49
-0@@ -251,6 +251,34 @@ int str_split_parse(struct thread_data *td, char *str,return ret; } +static int fio_fdp_cmp (const void *p1,const void *p2) +{ +const uint16_t *t1 = p1; +const uint16_t *t2 = p2; + +return *t1 - *t2; +} + +static int str_fdp_pli_cb (void *data,const char *input) +{ +struct thread_data *td =cb_data_to_td (data); +char *str, *p, *v; +int i =0 ; + + p = str =strdup (input); +strip_blank_front (&str); +strip_blank_end (str); + +while ((v =strsep (&str,"," )) !=NULL && i <FIO_MAX_PLIS ) + td->o.fdp_plis[i++] =strtoll (v,NULL ,0 ); +free (p); + +qsort (td->o.fdp_plis, i,sizeof (*td->o.fdp_plis), fio_fdp_cmp); + td->o.fdp_nrpli = i; + +return 0 ; +} +static int str_bssplit_cb (void *data,const char *input) {struct thread_data *td =cb_data_to_td (data);@@ -3649,6 +3677,27 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_IO, .group = FIO_OPT_G_ZONE, }, + { + .name = "fdp", + .lname = "Flexible data placement", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct thread_options, fdp), + .help = "Use Data placement directive (FDP)", + .def = "0", + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, + }, + { + .name = "fdp_pli", + .lname = "FDP Placement ID indicies", + .type = FIO_OPT_STR, + .cb = str_fdp_pli_cb, + .off1 = offsetof(struct thread_options, fdp_plis), + .help = "Sets which placement ids to use (defaults to all)", + .hide = 1, + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, + }, { .name = "lockmem", .lname = "Lock memory",thread_options.h +5
-0@@ -386,6 +386,11 @@ struct thread_options {fio_fp64_t zrt;fio_fp64_t zrf; +#define FIO_MAX_PLIS 16 +unsigned int fdp; +unsigned int fdp_plis[FIO_MAX_PLIS ]; +unsigned int fdp_nrpli; +unsigned int log_entries;unsigned int log_prio; };
thread_options.h struct thread_options_pack { · line 706
Quoted 4 lines
thread_options.h +1
-0@@ -698,6 +703,8 @@ struct thread_options_pack {uint32_t log_entries;uint32_t log_prio; +uint32_t fdp;
we need change in cconv.c for this option.
Quoted 8 lines
thread_options.h +1
-0+/* * verify_pattern followed by buffer_pattern from the unpacked struct */ Signature · 1 line
2.30.2
Quoted 215 lines · Ankit Kumar
Quoted 56 lines · Keith Busch
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's
io_uring_cmdioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands. The user can limit which placement identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.Setting up your namespace for FDP is outside the scope of 'fio', so this assumes the namespace is already properly configured for the mode.
Based-on-a-patch-by Ankit Kumar <[email protected]>Signed-off-by Keith Busch <[email protected]>---
v1->v2:Actually 'git add' the new source files (Vincent, Ankit)
Added HOWTO and fio.1 documentation on new options (Jens)
Fix whitespace (Jens)
Bump
FIO_IOOPS_VERSION(Damien)Dropped the unnecessary fdp checks and infrastructure for it, relying only on the iomgmt to provide fdp state.
HOWTO.rst | 10 +++ Makefile | 2 +- engines/io_uring.c | 23 +++++++ engines/nvme.c | 39 +++++++++++- engines/nvme.h | 20 ++++++ examples/uring-cmd-fdp.fio | 37 ++++++++++++ fdp.c | 121 +++++++++++++++++++++++++++++++++++++ fdp.h | 16 +++++ file.h | 3 + filesetup.c | 7 +++ fio.1 | 8 +++ io_u.c | 3 + io_u.h | 3 + ioengines.h | 5 +- options.c | 49 +++++++++++++++ thread_options.h | 7 +++ 16 files changed, 350 insertions(+), 3 deletions(-) create mode 100644 examples/uring-cmd-fdp.fio create mode 100644 fdp.c create mode 100644 fdp.hHOWTO.rst +0
-0HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2438
Quoted 8 lines
HOWTO.rst +5
-0@@ -2431,6 +2431,16 @@ with the caveat that when used on the command line, they must come after the For direct I/O, requests will only succeed if cache invalidation isn't required, file blocks are fully allocated and the disk request could be issued immediately. +.. option:: fdp=bool : [io_uring_cmd] + + Enable Flexible Data Placement mode for write commands. + +.. option:: fdp_pli=int[,int][,int] : [io_uring_cmd]I think it probably should just be "fdp_pli=str" Kind of similar to the fio "option cpus_allowed=str"
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2442
Quoted 4 lines
HOWTO.rst +4
-0+ + Select which Placement ID Index/Indicies this job is allowed to use for + writes. By default, the job will cycle through all available Placement + IDs, so use this to isolate these identifiers to specific jobs..Maybe we can also add one line description something like this:
If you want fio to use placement identifier only at indices 0,2 and 5 specify ``fdp_pli=0,2,5``.Quoted 101 lines
HOWTO.rst +1
-0+ .. option:: cpuload=int : [cpuio] Attempt to use the specified percentage of CPU cycles. This is a mandatoryMakefile +1
-1@@ -62,7 +62,7 @@ SOURCE := $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \ gettime-thread.c helpers.c json.c idletime.c td_error.c \ profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \ workqueue.c rate-submit.c optgroup.c helper_thread.c \ - steadystate.c zone-dist.c zbd.c dedupe.c + steadystate.c zone-dist.c zbd.c dedupe.c fdp.c ifdef CONFIG_LIBHDFS HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)engines/io_uring.c +23
-0@@ -1262,6 +1262,28 @@ static int fio_ioring_cmd_get_max_open_zones(struct thread_data *td,return fio_nvme_get_max_open_zones (td, f, max_open_zones); } +static int fio_ioring_cmd_fetch_ruhs (struct thread_data *td,struct fio_file *f, +struct fio_ruhs_info *fruhs_info) +{ +struct nvme_fdp_ruh_status *ruhs; +int bytes, ret, i; + + bytes =sizeof (*ruhs) +1024 *sizeof (struct nvme_fdp_ruh_status_desc ); + ruhs =malloc (bytes); +memset (ruhs,0 , bytes); + + ret =fio_nvme_iomgmt_ruhs (td, f, ruhs, bytes); +if (ret) + goto free; + + fruhs_info->nr_ruhs =le16_to_cpu (ruhs->nruhsd); +for (i =0 ; i < fruhs_info->nr_ruhs; i++) + fruhs_info->plis[i] =le16_to_cpu (ruhs->ruhss[i].pid); +free: +free (ruhs); +return ret; +} +static struct ioengine_ops ioengine_uring = { .name ="io_uring" , .version =FIO_IOOPS_VERSION ,@@ -1307,6 +1329,7 @@ static struct ioengine_ops ioengine_uring_cmd = { .get_max_open_zones = fio_ioring_cmd_get_max_open_zones, .options = options, .option_struct_size = sizeof(struct ioring_options), + .fdp_fetch_ruhs = fio_ioring_cmd_fetch_ruhs, }; static void fio_init fio_ioring_register(void)engines/nvme.c +27
-1@@ -28,7 +28,8 @@ int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u, cmd->cdw10 = slba &0xffffffff ; cmd->cdw11 = slba >>32 ;/* cdw12 represent number of lba's for read/write */ - cmd->cdw12 = nlb; + cmd->cdw12 = nlb | (io_u->dtype <<20 ); + cmd->cdw13 = io_u->dspec <<16 ;if (iov) { iov->iov_base = io_u->xfer_buf; iov->iov_len = io_u->xfer_buflen;@@ -345,3 +346,39 @@ out:close (fd);return ret; } + +static inline int nvme_fdp_reclaim_unit_handle_status (int fd,__u32 nsid, +__u32 data_len,void *data) +{ +struct nvme_passthru_cmd cmd = { + .opcode = nvme_cmd_io_mgmt_recv, + .nsid = nsid, + .addr = (__u64 )(uintptr_t )data, + .data_len = data_len, + .cdw10 =1 , + .cdw11 = (data_len >>2 ) -1 , + }; + +return ioctl (fd,NVME_IOCTL_IO_CMD , &cmd); +} + +int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes) +{ +struct nvme_data *data =FILE_ENG_DATA (f); +int fd, ret; + + fd =open (f->file_name,O_RDONLY |O_LARGEFILE ); +if (fd <0 ) +return -errno;engines/nvme.c out: · line 383
Quoted 10 lines
engines/nvme.c +10
-0+ + ret =nvme_fdp_reclaim_unit_handle_status (fd, data->nsid, bytes, ruhs); +if (ret) { +log_err ("%s: nvme_fdp_reclaim_unit_handle_status failed, err=%d\n" , + f->file_name, ret); + errno =ENOTSUP ; + } + +close (fd); +return -errno;should be "return ret;"
Quoted 28 lines
engines/nvme.c +1
-0+}engines/nvme.h +12
-0@@ -67,6 +67,7 @@ enum nvme_admin_opcode {enum nvme_io_opcode { nvme_cmd_write =0x01 , nvme_cmd_read =0x02 , + nvme_cmd_io_mgmt_recv =0x12 , nvme_zns_cmd_mgmt_send =0x79 , nvme_zns_cmd_mgmt_recv =0x7a , };@@ -192,6 +193,25 @@ struct nvme_zone_report {struct nvme_zns_desc entries[]; }; +struct nvme_fdp_ruh_status_desc { +__u16 pid; +__u16 ruhid; +__u32 earutr; +__u64 ruamw; +__u8 rsvd16[16 ]; +}; + +struct nvme_fdp_ruh_status { +__u8 rsvd0[14 ]; +__le16 nruhsd;
Quoted 8 lines
engines/nvme.h struct nvme_zone_report { · line 214
Quoted 8 lines
engines/nvme.h +8
-0+struct nvme_fdp_ruh_status_desc ruhss[]; +}; + +int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes); + +int fio_nvme_is_fdp (struct thread_data *td,struct fio_file *f,bool *fdp); +
Missed the first time, this function prototype should also be removed.
Quoted 412 lines
Quoted 58 lines
engines/nvme.h +0
-0int fio_nvme_get_info (struct fio_file *f,__u32 *nsid,__u32 *lba_sz,__u64 *nlba);examples/uring-cmd-fdp.fio new file +37
-0@@ -0,0 +1,37 @@ +# io_uring_cmd I/O engine for nvme-ns generic character device with FDP enabled +# This assumes the namespace is already configured with FDP support and has at +# least 8 available reclaim units. +# +# Each job targets different ranges of LBAs with different placement +# identifiers, and has different write intensity. + +[global] +filename=/dev/ng0n1 +ioengine=io_uring_cmd +cmd_type=nvme +iodepth=32 +bs=4K +fdp=1 +time_based=1 +runtime=1000 + +[write-heavy] +rw=randrw +rwmixwrite=90 +fdp_pli=0,1,2,3 +offset=0% +size=30% + +[write-mid] +rw=randrw +rwmixwrite=30 +fdp_pli=4,5 +offset=30% +size=30% + +[write-light] +rw=randrw +rwmixwrite=10 +fdp_pli=6 +offset=60% +size=30%fdp.c new file +6
-0@@ -0,0 +1,121 @@ +/* +* Note: This is similar to a very basic setup +* of ZBD devices +* +* Specify fdp=1 (With char devices /dev/ng0n1) +*/ fdp.c line 16
Quoted 10 lines
fdp.c new file +10
-0+ +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include "file.h" +#include "fio.h" + +#include "pshared.h" +#include <fdp.h> #include "
fdp.h"fdp.c line 21
Quoted 5 lines
fdp.c new file +5
-0+ +/* +* Maximum number of RUHS to fetch +* TODO: Revisit this so that we can work with more than 1024 RUH's +*/ For me, I will send a fix once these changes get merged.
Quoted 174 lines
fdp.c new file +100
-0+#define FDP_FETCH_RUHS_MAX 1024U + +static int fdp_ruh_info (struct thread_data *td,struct fio_file *f, +struct fio_ruhs_info *ruhs) +{ +int ret = -EINVAL ; + +if (td->io_ops && td->io_ops->fdp_fetch_ruhs) + ret = td->io_ops->fdp_fetch_ruhs (td, f, ruhs); +else +log_err ("%s: engine (%s) lacks fetch ruhs.\n" , + f->file_name, td->io_ops->name); +if (ret <0 ) { +td_verror (td, errno,"fdp fetch ruhs failed" ); +log_err ("%s: fdp fetch ruhs failed (%d).\n" , + f->file_name, errno); + } + +return ret; +} + +static int init_ruh_info (struct thread_data *td,struct fio_file *f) +{ +struct fio_ruhs_info *ruhs, *tmp; +int i, ret; + + ruhs =calloc (1 ,sizeof (*ruhs) + +FDP_FETCH_RUHS_MAX *sizeof (*ruhs->plis)); +if (!ruhs) +return -ENOMEM ; + + ret =fdp_ruh_info (td, f, ruhs); +if (ret) { +log_info ("fio: ruh info failed for %s (%d).\n" , + f->file_name, -ret); + goto out; + } + +if (ruhs->nr_ruhs >FDP_FETCH_RUHS_MAX ) + ruhs->nr_ruhs =FDP_FETCH_RUHS_MAX ; + +if (td->o.fdp_nrpli ==0 ) { + f->ruhs_info = ruhs; +return 0 ; + } + +for (i =0 ; i < td->o.fdp_nrpli; i++) { +if (td->o.fdp_plis[i] > ruhs->nr_ruhs) { + ret = -EINVAL ; + goto out; + } + } + + tmp =calloc (1 ,sizeof (*tmp) + ruhs->nr_ruhs *sizeof (*tmp->plis)); + tmp->nr_ruhs = td->o.fdp_nrpli; +for (i =0 ; i < td->o.fdp_nrpli; i++) + tmp->plis[i] = ruhs->plis[td->o.fdp_plis[i]]; + f->ruhs_info = tmp; +out: +free (ruhs); +return ret; +} + +int fdp_init (struct thread_data *td) +{ +struct fio_file *f; +int i, ret =0 ; + +for_each_file (td, f, i) { + ret =init_ruh_info (td, f); +if (ret) +break ; + } +return ret; +} + +void fdp_free_ruhs_info (struct fio_file *f) +{ +if (!f->ruhs_info) +return ; +free (f->ruhs_info); + f->ruhs_info =NULL ; +} + +void fdp_fill_dspec_data (struct thread_data *td,struct io_u *io_u) +{ +struct fio_file *f = io_u->file; +struct fio_ruhs_info *ruhs = f->ruhs_info; +int dspec; + +if (!ruhs || io_u->ddir !=DDIR_WRITE ) { + io_u->dtype =0 ; + io_u->dspec =0 ; +return ; + } + + dspec = ruhs->plis[ruhs->pli_loc++ % ruhs->nr_ruhs]; + io_u->dtype =2 ; + io_u->dspec = dspec; +}fdp.h new file +16
-0@@ -0,0 +1,16 @@ +#ifndef FIO_FDP_H +#define FIO_FDP_H + +#include "io_u.h" + +struct fio_ruhs_info { +uint32_t nr_ruhs; +uint32_t pli_loc; +uint16_t plis[]; +}; + +int fdp_init (struct thread_data *td); +void fdp_free_ruhs_info (struct fio_file *f); +void fdp_fill_dspec_data (struct thread_data *td,struct io_u *io_u); + +#endif /* FIO_FDP_H */ file.h +3
-0@@ -12,6 +12,7 @@/* Forward declarations */ struct zoned_block_device_info ; +struct fdp_ruh_info ;/* * The type of object we are working on @@ -101,6 +102,8 @@ struct fio_file {uint64_t file_offset;uint64_t io_size; +struct fio_ruhs_info *ruhs_info; +/* * Zoned block device information. See also zonemode=zbd. */ filesetup.c +7
-0@@ -1417,6 +1417,12 @@ done:td_restore_runstate (td, old_state); +if (td->o.fdp) { + err =fdp_init (td); +if (err) + goto err_out; + } +return 0 ; err_offset:@@ -1627,6 +1633,7 @@ void close_and_free_files(struct thread_data *td) }zbd_close_file (f); +fdp_free_ruhs_info (f);fio_file_free (f); }fio.1 +0
-0@@ -2192,6 +2192,14 @@ cached data. Currently the RWF_NOWAIT flag does not supported for cached write. For direct I/O, requests will only succeed if cache invalidation isn't required,fio.1 cached data. Currently the RWF_NOWAIT flag does not supported for cached write. · line 2202
Quoted 10 lines
fio.1 +8
-0file blocks are fully allocated and the disk request could be issued immediately. .TP +.BI (io_uring_cmd)fdp \fR=\fPbool +Enable Flexible Data Placement mode for write commands. +.TP +.BI (io_uring_cmd)fdp_pli \fR=\fPint[,int][,int] +Select which Placement ID Index/Indicies this job is allowed to use for writes. +By default, the job will cycle through all available Placement IDs, so use this +to isolate these identifiers to specific jobs. +.TPSame comments from HOWTO
Quoted 139 lines
fio.1 +0
-0.BI (cpuio)cpuload \fR=\fPint Attempt to use the specified percentage of CPU cycles. This is a mandatory option when using cpuio I/O engine.io_u.c +3
-0@@ -988,6 +988,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)return 1 ; } +if (td->o.fdp) +fdp_fill_dspec_data (td, io_u); +if (io_u->offset + io_u->buflen > io_u->file->real_file_size) { dprint(FD_IO, "io_u %p, off=0x%llx + len=0x%llx exceeds file size=0x%llx\n", io_u,io_u.h +3
-0@@ -117,6 +117,9 @@ struct io_u {*/ int (*end_io)(struct thread_data *,struct io_u **); +uint32_t dtype; +uint32_t dspec; +union {#ifdef CONFIG_LIBAIO struct iocb iocb;ioengines.h +4
-1@@ -7,8 +7,9 @@#include "flist.h" #include "io_u.h" #include "zbd_types.h" +#include "fdp.h" -#define FIO_IOOPS_VERSION 31 +#define FIO_IOOPS_VERSION 32#ifndef CONFIG_DYNAMIC_ENGINES #define FIO_STATIC static@@ -63,6 +64,8 @@ struct ioengine_ops { unsigned int *);int (*finish_zone)(struct thread_data *,struct fio_file *,uint64_t ,uint64_t ); +int (*fdp_fetch_ruhs)(struct thread_data *,struct fio_file *, +struct fio_ruhs_info *);int option_struct_size;struct fio_option *options; };options.c +49
-0@@ -251,6 +251,34 @@ int str_split_parse(struct thread_data *td, char *str,return ret; } +static int fio_fdp_cmp (const void *p1,const void *p2) +{ +const uint16_t *t1 = p1; +const uint16_t *t2 = p2; + +return *t1 - *t2; +} + +static int str_fdp_pli_cb (void *data,const char *input) +{ +struct thread_data *td =cb_data_to_td (data); +char *str, *p, *v; +int i =0 ; + + p = str =strdup (input); +strip_blank_front (&str); +strip_blank_end (str); + +while ((v =strsep (&str,"," )) !=NULL && i <FIO_MAX_PLIS ) + td->o.fdp_plis[i++] =strtoll (v,NULL ,0 ); +free (p); + +qsort (td->o.fdp_plis, i,sizeof (*td->o.fdp_plis), fio_fdp_cmp); + td->o.fdp_nrpli = i; + +return 0 ; +} +static int str_bssplit_cb (void *data,const char *input) {struct thread_data *td =cb_data_to_td (data);@@ -3649,6 +3677,27 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_IO, .group = FIO_OPT_G_ZONE, }, + { + .name = "fdp", + .lname = "Flexible data placement", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct thread_options, fdp), + .help = "Use Data placement directive (FDP)", + .def = "0", + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, + }, + { + .name = "fdp_pli", + .lname = "FDP Placement ID indicies", + .type = FIO_OPT_STR, + .cb = str_fdp_pli_cb, + .off1 = offsetof(struct thread_options, fdp_plis), + .help = "Sets which placement ids to use (defaults to all)", + .hide = 1, + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, + }, { .name = "lockmem", .lname = "Lock memory",thread_options.h +5
-0@@ -386,6 +386,11 @@ struct thread_options {fio_fp64_t zrt;fio_fp64_t zrf; +#define FIO_MAX_PLIS 16 +unsigned int fdp; +unsigned int fdp_plis[FIO_MAX_PLIS ]; +unsigned int fdp_nrpli; +unsigned int log_entries;unsigned int log_prio; };thread_options.h struct thread_options_pack { · line 706
Quoted 4 lines
thread_options.h +1
-0@@ -698,6 +703,8 @@ struct thread_options_pack {uint32_t log_entries;uint32_t log_prio; +uint32_t fdp;we need change in
cconv.cfor this option.Quoted 8 lines
thread_options.h +1
-1+/* * verify_pattern followed by buffer_pattern from the unpacked struct */ --2.30.2
Quoted 7 lines · Ankit Kumar
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2438
Quoted 5 lines
+.. option:: fdp=bool : [
io_uring_cmd]HOWTO.rst +4
-0+ + Enable Flexible Data Placement mode for write commands. + +.. option:: fdp_pli=int[,int][,int] : [io_uring_cmd]I think it probably should just be "fdp_pli=str" Kind of similar to the fio "option cpus_allowed=str"
...
Quoted 6 lines
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2442
Quoted 3 lines
HOWTO.rst +3
-0+ Select which Placement ID Index/Indicies this job is allowed to use for + writes. By default, the job will cycle through all available Placement + IDs, so use this to isolate these identifiers to specific jobs..Maybe we can also add one line description something like this:
If you want fio to use placement identifier only at indices 0,2 and 5 specify ``fdp_pli=0,2,5``.
Sure, definitely don't need to be sequential. Also, like cpus_allowed, perhaps ranges are desirable (ex: 0-2,5).
Quoted 12 lines
Quoted 12 lines
engines/nvme.c +12
-0+int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes) +{ +struct nvme_data *data =FILE_ENG_DATA (f); +int fd, ret; + + fd =open (f->file_name,O_RDONLY |O_LARGEFILE ); +if (fd <0 ) +return -errno; + + ret =nvme_fdp_reclaim_unit_handle_status (fd, data->nsid, bytes, ruhs); +if (ret) {
Quoted 8 lines
engines/nvme.c out: · line 383
Quoted 7 lines
engines/nvme.c +7
-0+log_err ("%s: nvme_fdp_reclaim_unit_handle_status failed, err=%d\n" , + f->file_name, ret); + errno =ENOTSUP ; + } + +close (fd); +return -errno;should be "return ret;"
The return needs to be a negative number, and 'ret' can sometimes be positive or negative.
Quoted 5 lines
Quoted 4 lines
+/*
+ * Maximum number of RUHS to fetch
+ * TODO: Revisit this so that we can work with more than 1024 RUH's
+ */For me, I will send a fix once these changes get merged.
Could you help clarify some spec confusion on my side? The Namespace Management command allows you to specify at most 128 placement handles when you create the namespace, so why would we need more than that? Under what conditions could the namespaces' IO Mgmt Recv RUH Status ever return more than 128 descriptors?
And speaking of that, since 128 is the largest value, it seems odd the spec folks gave this field two bytes.
Quoted 40 lines · Keith Busch
Quoted 7 lines · Ankit Kumar
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2438
Quoted 5 lines
+.. option:: fdp=bool : [
io_uring_cmd]HOWTO.rst +4
-0+ + Enable Flexible Data Placement mode for write commands. + +.. option:: fdp_pli=int[,int][,int] : [io_uring_cmd]I think it probably should just be "fdp_pli=str" Kind of similar to the fio "option cpus_allowed=str"
...
Quoted 6 lines
HOWTO.rst with the caveat that when used on the command line, they must come after the · line 2442
Quoted 3 lines
HOWTO.rst +3
-0+ Select which Placement ID Index/Indicies this job is allowed to use for + writes. By default, the job will cycle through all available Placement + IDs, so use this to isolate these identifiers to specific jobs..Maybe we can also add one line description something like this:
If you want fio to use placement identifier only at indices 0,2 and 5 specify ``fdp_pli=0,2,5``.Sure, definitely don't need to be sequential. Also, like
cpus_allowed, perhaps ranges are desirable (ex: 0-2,5).Quoted 12 lines
Quoted 12 lines
engines/nvme.c +12
-0+int fio_nvme_iomgmt_ruhs (struct thread_data *td,struct fio_file *f, +struct nvme_fdp_ruh_status *ruhs,__u32 bytes) +{ +struct nvme_data *data =FILE_ENG_DATA (f); +int fd, ret; + + fd =open (f->file_name,O_RDONLY |O_LARGEFILE ); +if (fd <0 ) +return -errno; + + ret =nvme_fdp_reclaim_unit_handle_status (fd, data->nsid, bytes, ruhs); +if (ret) {Quoted 8 lines
engines/nvme.c out: · line 383
Quoted 7 lines
engines/nvme.c +7
-0+log_err ("%s: nvme_fdp_reclaim_unit_handle_status failed, err=%d\n" , + f->file_name, ret); + errno =ENOTSUP ; + } + +close (fd); +return -errno;should be "return ret;"
Quoted 2 lines
The return needs to be a negative number, and 'ret' can sometimes be positive or negative.
ok, in that case errno should be set to 0, before you call nvme_fdp_reclaim_unit_handle_status.
As I see from the caller function (io_uring.c)
+ ret = fio_nvme_iomgmt_ruhs(td, f, ruhs, bytes);
+ if (ret)
+ goto free;
Currently when I try I get:
/dev/ng0n1: fdp fetch ruhs failed (17).
fio: ruh info failed for /dev/ng0n1 (17).
fio: pid=0, err=17/file:fdp.c:35, func=fdp fetch ruhs failed, error=File exists
Quoted 11 lines
Quoted 6 lines
Quoted 5 lines
+/*
+ * Maximum number of RUHS to fetch
+ * TODO: Revisit this so that we can work with more than 1024 RUH's
+ */For me, I will send a fix once these changes get merged.
Could you help clarify some spec confusion on my side? The Namespace Management command allows you to specify at most 128 placement handles when you create the namespace, so why would we need more than that? Under what conditions could the namespaces' IO Mgmt Recv RUH Status ever return more than 128 descriptors?
Frankly, I never thought of this. I have only tried with qemu setup which can return more than 128 descriptors (I even got more than 1024).
In that case, should it just be limited to 128?
Quoted 4 lines
And speaking of that, since 128 is the largest value, it seems odd the spec folks gave this field two bytes.
Certainly seems odd.
Quoted 7 lines · Keith Busch
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's
io_uring_cmdioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands.
Technically, the namespace has Placement *Handles* associated and when writing, a Placement *Identifier* is used to also specify the Reclaim Group.
Quoted 4 lines
The user can limit which placement
identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.
With the above in mind, it might make sense to align with the spec and call this "fdp_pids" instead. As far as I can tell, fio won't cycle through reclaim groups and create the pid on its own, without fdp_plis explicitly indicating it?
Quoted 9 lines · Klaus Jensen
Quoted 7 lines · Keith Busch
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's
io_uring_cmdioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands.
Quoted 3 lines
Technically, the namespace has Placement *Handles* associated and when writing, a Placement *Identifier* is used to also specify the Reclaim Group.
Yep. The details can get a bit confusing, but the placement id is really all fio needs to construct the write command.
Quoted 7 lines
Quoted 4 lines
The user can limit which placement
identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.With the above in mind, it might make sense to align with the spec and call this "
fdp_pids" instead.
In this implementation, you're just specifying the indices from which to pull the pids rather than providing a direct list of them, so didn't want to call it "pids".
Quoted 2 lines
As far as I can tell, fio won't cycle through reclaim groups and create the pid on its own, without
fdp_plisexplicitly indicating it?
If you don't specify any, fio will use all the placement identifiers. The code handling that in this patch is bit subtle.
Quoted 17 lines · Keith Busch
From: Keith Busch <[email protected]>
Add support for NVMe TP4146 Flexible Data Placemen, allowing placement identifiers in write commands. The user can enabled this with the new "fdp=1" parameter for fio's
io_uring_cmdioengine. By default, the fio jobs will cycle through all the namespace's available placement identifiers for write commands. The user can limit which placement identifiers can be used with additional parameter, "fdp_plis=<list,>", which can be used to separate write intensive jobs from less intensive ones.Setting up your namespace for FDP is outside the scope of 'fio', so this assumes the namespace is already properly configured for the mode.
Based-on-a-patch-by Ankit Kumar <[email protected]>Signed-off-by Keith Busch <[email protected]>---
<snip>
Quoted 7 lines
engines/io_uring.c +0
-0@@ -1262,6 +1262,28 @@ static int fio_ioring_cmd_get_max_open_zones(struct thread_data *td,return fio_nvme_get_max_open_zones (td, f, max_open_zones); }
engines/io_uring.c static int fio_ioring_cmd_get_max_open_zones(struct thread_data *td, · line 1273
Quoted 10 lines
engines/io_uring.c +9
-0+static int fio_ioring_cmd_fetch_ruhs (struct thread_data *td,struct fio_file *f, +struct fio_ruhs_info *fruhs_info) +{ +struct nvme_fdp_ruh_status *ruhs; +int bytes, ret, i; + + bytes =sizeof (*ruhs) +1024 *sizeof (struct nvme_fdp_ruh_status_desc ); + ruhs =malloc (bytes); +memset (ruhs,0 , bytes);
calloc?
<snip>
Quoted 17 lines
thread_options.h +5
-0@@ -386,6 +386,11 @@ struct thread_options {fio_fp64_t zrt;fio_fp64_t zrf; +#define FIO_MAX_PLIS 16 +unsigned int fdp; +unsigned int fdp_plis[FIO_MAX_PLIS ]; +unsigned int fdp_nrpli; +unsigned int log_entries;unsigned int log_prio; };
thread_options.h struct thread_options_pack { · line 710
Quoted 8 lines
thread_options.h +2
-0@@ -698,6 +703,8 @@ struct thread_options_pack {uint32_t log_entries;uint32_t log_prio; +uint32_t fdp; +/* * verify_pattern followed by buffer_pattern from the unpacked struct */
struct thread_options_pack also needs fdp_plis[] and fdp_nrpli members. In addition to the cconv.c changes that Ankit mentioned FIO_SERVER_VER should also be bumped so that these options can be properly transmitted when fio is run in client/server mode.
Vincent