2016-04-13 00:58:29 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
2019-10-09 06:40:31 +00:00
|
|
|
* Copyright (c) Intel Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
|
2016-04-13 00:58:29 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-04-13 00:58:29 +00:00
|
|
|
|
|
|
|
#include "spdk/nvme.h"
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
#include "spdk/nvme_zns.h"
|
2019-06-05 13:29:22 +00:00
|
|
|
#include "spdk/vmd.h"
|
2016-08-10 17:41:12 +00:00
|
|
|
#include "spdk/env.h"
|
2016-04-13 00:58:29 +00:00
|
|
|
#include "spdk/string.h"
|
2017-03-27 05:33:06 +00:00
|
|
|
#include "spdk/log.h"
|
2018-06-11 08:26:40 +00:00
|
|
|
#include "spdk/endian.h"
|
2019-01-21 05:39:57 +00:00
|
|
|
#include "spdk/dif.h"
|
2019-02-26 09:02:10 +00:00
|
|
|
#include "spdk/util.h"
|
2016-04-13 00:58:29 +00:00
|
|
|
|
|
|
|
#include "config-host.h"
|
|
|
|
#include "fio.h"
|
|
|
|
#include "optgroup.h"
|
|
|
|
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
#ifdef for_each_rw_ddir
|
|
|
|
#define FIO_HAS_ZBD (FIO_IOOPS_VERSION >= 26)
|
|
|
|
#else
|
|
|
|
#define FIO_HAS_ZBD (0)
|
|
|
|
#endif
|
|
|
|
|
2019-06-14 11:41:21 +00:00
|
|
|
/* FreeBSD is missing CLOCK_MONOTONIC_RAW,
|
|
|
|
* so alternative is provided. */
|
|
|
|
#ifndef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */
|
|
|
|
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
|
|
|
|
#endif
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
#define NVME_IO_ALIGN 4096
|
|
|
|
|
2019-01-21 04:20:16 +00:00
|
|
|
static bool g_spdk_env_initialized;
|
|
|
|
static int g_spdk_enable_sgl = 0;
|
2019-01-08 21:56:39 +00:00
|
|
|
static uint32_t g_spdk_sge_size = 4096;
|
2020-03-26 04:30:04 +00:00
|
|
|
static uint32_t g_spdk_bit_bucket_data_len = 0;
|
2019-01-21 04:20:16 +00:00
|
|
|
static uint32_t g_spdk_pract_flag;
|
|
|
|
static uint32_t g_spdk_prchk_flags;
|
2019-02-26 09:02:10 +00:00
|
|
|
static uint32_t g_spdk_md_per_io_size = 4096;
|
2019-02-27 14:41:54 +00:00
|
|
|
static uint16_t g_spdk_apptag;
|
|
|
|
static uint16_t g_spdk_apptag_mask;
|
2017-06-27 21:21:07 +00:00
|
|
|
|
|
|
|
struct spdk_fio_options {
|
|
|
|
void *pad; /* off1 used in option descriptions may not be 0 */
|
2020-06-03 11:42:35 +00:00
|
|
|
int enable_wrr;
|
|
|
|
int arbitration_burst;
|
|
|
|
int low_weight;
|
|
|
|
int medium_weight;
|
|
|
|
int high_weight;
|
|
|
|
int wrr_priority;
|
2017-06-27 21:21:07 +00:00
|
|
|
int mem_size;
|
|
|
|
int shm_id;
|
2018-04-11 06:35:39 +00:00
|
|
|
int enable_sgl;
|
2019-01-08 21:56:39 +00:00
|
|
|
int sge_size;
|
2020-03-26 04:30:04 +00:00
|
|
|
int bit_bucket_data_len;
|
2018-06-15 22:56:08 +00:00
|
|
|
char *hostnqn;
|
2018-06-11 08:26:40 +00:00
|
|
|
int pi_act;
|
|
|
|
char *pi_chk;
|
2019-02-26 09:02:10 +00:00
|
|
|
int md_per_io_size;
|
2019-02-27 14:41:54 +00:00
|
|
|
int apptag;
|
|
|
|
int apptag_mask;
|
2018-11-30 01:46:55 +00:00
|
|
|
char *digest_enable;
|
2019-06-05 13:29:22 +00:00
|
|
|
int enable_vmd;
|
2020-10-28 14:46:26 +00:00
|
|
|
int initial_zone_reset;
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
int zone_append;
|
2021-02-11 20:14:10 +00:00
|
|
|
int print_qid_mappings;
|
2017-06-27 21:21:07 +00:00
|
|
|
};
|
2017-04-20 05:19:05 +00:00
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
struct spdk_fio_request {
|
|
|
|
struct io_u *io;
|
2018-04-11 06:35:39 +00:00
|
|
|
/** Offset in current iovec, fio only uses 1 vector */
|
2019-01-21 05:39:57 +00:00
|
|
|
uint32_t iov_offset;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-03-26 04:30:04 +00:00
|
|
|
/** Amount of data used for Bit Bucket SGL */
|
|
|
|
uint32_t bit_bucket_data_len;
|
|
|
|
|
2019-01-21 05:39:57 +00:00
|
|
|
/** Context for NVMe PI */
|
|
|
|
struct spdk_dif_ctx dif_ctx;
|
2019-02-26 09:02:10 +00:00
|
|
|
/** Separate metadata buffer pointer */
|
|
|
|
void *md_buf;
|
2018-06-11 08:26:40 +00:00
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
struct spdk_fio_thread *fio_thread;
|
2019-03-07 13:55:16 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair;
|
2016-04-13 00:58:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct spdk_fio_ctrlr {
|
2017-03-27 05:33:06 +00:00
|
|
|
struct spdk_nvme_transport_id tr_id;
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_nvme_ctrlr_opts opts;
|
2017-03-27 05:33:06 +00:00
|
|
|
struct spdk_nvme_ctrlr *ctrlr;
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_ENTRY(spdk_fio_ctrlr) link;
|
2017-05-02 04:25:50 +00:00
|
|
|
};
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
static TAILQ_HEAD(, spdk_fio_ctrlr) g_ctrlrs = TAILQ_HEAD_INITIALIZER(g_ctrlrs);
|
2019-01-21 04:20:16 +00:00
|
|
|
static int g_td_count;
|
2018-06-15 21:54:56 +00:00
|
|
|
static pthread_t g_ctrlr_thread_id = 0;
|
2019-01-21 04:20:16 +00:00
|
|
|
static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
|
2017-11-09 07:03:32 +00:00
|
|
|
static bool g_error;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_fio_qpair {
|
2020-09-28 00:14:00 +00:00
|
|
|
struct fio_file *f;
|
|
|
|
struct spdk_nvme_qpair *qpair;
|
|
|
|
struct spdk_nvme_ns *ns;
|
|
|
|
uint32_t io_flags;
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
bool zone_append_enabled;
|
2020-09-28 00:14:00 +00:00
|
|
|
bool nvme_pi_enabled;
|
2020-01-19 02:28:07 +00:00
|
|
|
/* True for DIF and false for DIX, and this is valid only if nvme_pi_enabled is true. */
|
2020-09-28 00:14:00 +00:00
|
|
|
bool extended_lba;
|
2019-03-14 08:44:10 +00:00
|
|
|
/* True for protection info transferred at start of metadata,
|
|
|
|
* false for protection info transferred at end of metadata, and
|
2020-01-19 02:28:07 +00:00
|
|
|
* this is valid only if nvme_pi_enabled is true.
|
2019-03-14 08:44:10 +00:00
|
|
|
*/
|
2020-09-28 00:14:00 +00:00
|
|
|
bool md_start;
|
|
|
|
TAILQ_ENTRY(spdk_fio_qpair) link;
|
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr;
|
2016-04-13 00:58:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct spdk_fio_thread {
|
2020-09-28 00:14:00 +00:00
|
|
|
struct thread_data *td;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_HEAD(, spdk_fio_qpair) fio_qpair;
|
|
|
|
struct spdk_fio_qpair *fio_qpair_current; /* the current fio_qpair to be handled. */
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
struct io_u **iocq; /* io completion queue */
|
|
|
|
unsigned int iocq_count; /* number of iocq entries filled by last getevents */
|
|
|
|
unsigned int iocq_size; /* number of iocq entries allocated */
|
|
|
|
struct fio_file *current_f; /* fio_file given by user */
|
2016-04-13 00:58:29 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-06-15 21:54:56 +00:00
|
|
|
static void *
|
|
|
|
spdk_fio_poll_ctrlrs(void *arg)
|
|
|
|
{
|
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr;
|
|
|
|
int oldstate;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Loop until the thread is cancelled */
|
|
|
|
while (true) {
|
|
|
|
rc = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
|
|
|
|
if (rc != 0) {
|
|
|
|
SPDK_ERRLOG("Unable to set cancel state disabled on g_init_thread (%d): %s\n",
|
|
|
|
rc, spdk_strerror(rc));
|
|
|
|
}
|
|
|
|
|
2019-01-21 04:20:16 +00:00
|
|
|
pthread_mutex_lock(&g_mutex);
|
2018-06-15 21:54:56 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_FOREACH(fio_ctrlr, &g_ctrlrs, link) {
|
2018-06-15 21:54:56 +00:00
|
|
|
spdk_nvme_ctrlr_process_admin_completions(fio_ctrlr->ctrlr);
|
|
|
|
}
|
|
|
|
|
2019-01-21 04:20:16 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2018-06-15 21:54:56 +00:00
|
|
|
|
|
|
|
rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
|
|
|
if (rc != 0) {
|
|
|
|
SPDK_ERRLOG("Unable to set cancel state enabled on g_init_thread (%d): %s\n",
|
|
|
|
rc, spdk_strerror(rc));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is a pthread cancellation point and cannot be removed. */
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
static bool
|
2016-12-09 22:09:28 +00:00
|
|
|
probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
2016-10-31 23:55:14 +00:00
|
|
|
struct spdk_nvme_ctrlr_opts *opts)
|
2016-04-13 00:58:29 +00:00
|
|
|
{
|
2018-06-15 22:56:08 +00:00
|
|
|
struct thread_data *td = cb_ctx;
|
|
|
|
struct spdk_fio_options *fio_options = td->eo;
|
|
|
|
|
|
|
|
if (fio_options->hostnqn) {
|
|
|
|
snprintf(opts->hostnqn, sizeof(opts->hostnqn), "%s", fio_options->hostnqn);
|
|
|
|
}
|
|
|
|
|
2020-06-03 11:42:35 +00:00
|
|
|
if (fio_options->enable_wrr) {
|
|
|
|
opts->arb_mechanism = SPDK_NVME_CC_AMS_WRR;
|
|
|
|
opts->arbitration_burst = fio_options->arbitration_burst;
|
|
|
|
opts->low_priority_weight = fio_options->low_weight;
|
|
|
|
opts->medium_priority_weight = fio_options->medium_weight;
|
|
|
|
opts->high_priority_weight = fio_options->high_weight;
|
|
|
|
}
|
|
|
|
|
2018-11-30 01:46:55 +00:00
|
|
|
if (fio_options->digest_enable) {
|
|
|
|
if (strcasecmp(fio_options->digest_enable, "HEADER") == 0) {
|
|
|
|
opts->header_digest = true;
|
|
|
|
} else if (strcasecmp(fio_options->digest_enable, "DATA") == 0) {
|
|
|
|
opts->data_digest = true;
|
|
|
|
} else if (strcasecmp(fio_options->digest_enable, "BOTH") == 0) {
|
|
|
|
opts->header_digest = true;
|
|
|
|
opts->data_digest = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-27 05:33:06 +00:00
|
|
|
return true;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
2017-05-02 04:25:50 +00:00
|
|
|
static struct spdk_fio_ctrlr *
|
|
|
|
get_fio_ctrlr(const struct spdk_nvme_transport_id *trid)
|
|
|
|
{
|
2020-09-28 00:14:00 +00:00
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(fio_ctrlr, &g_ctrlrs, link) {
|
2017-05-02 04:25:50 +00:00
|
|
|
if (spdk_nvme_transport_id_compare(trid, &fio_ctrlr->tr_id) == 0) {
|
|
|
|
return fio_ctrlr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
/**
|
|
|
|
* Returns the fio_qpair matching the given fio_file and has an associated ns
|
|
|
|
*/
|
|
|
|
static struct spdk_fio_qpair *
|
|
|
|
get_fio_qpair(struct spdk_fio_thread *fio_thread, struct fio_file *f)
|
|
|
|
{
|
|
|
|
struct spdk_fio_qpair *fio_qpair;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(fio_qpair, &fio_thread->fio_qpair, link) {
|
|
|
|
if ((fio_qpair->f == f) && fio_qpair->ns) {
|
|
|
|
return fio_qpair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-10-28 14:44:37 +00:00
|
|
|
|
2021-05-17 10:23:34 +00:00
|
|
|
#if FIO_HAS_ZBD
|
2020-10-28 14:44:37 +00:00
|
|
|
/**
|
|
|
|
* Callback function to use while processing completions until completion-indicator turns non-zero
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
pcu_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
|
|
|
|
{
|
|
|
|
int *completed = ctx;
|
|
|
|
|
|
|
|
*completed = spdk_nvme_cpl_is_error(cpl) ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process Completions Until the given 'completed' indicator turns non-zero or an error occurs
|
|
|
|
*/
|
|
|
|
static int32_t
|
|
|
|
pcu(struct spdk_nvme_qpair *qpair, int *completed)
|
|
|
|
{
|
|
|
|
int32_t ret;
|
|
|
|
|
|
|
|
while (!*completed) {
|
|
|
|
ret = spdk_nvme_qpair_process_completions(qpair, 1);
|
|
|
|
if (ret < 0) {
|
|
|
|
log_err("spdk/nvme: process_compl(): ret: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
#endif
|
|
|
|
|
2021-03-09 04:56:59 +00:00
|
|
|
static inline uint32_t
|
|
|
|
_nvme_get_host_buffer_sector_size(struct spdk_nvme_ns *ns, uint32_t io_flags)
|
|
|
|
{
|
|
|
|
bool md_excluded_from_xfer = false;
|
|
|
|
uint32_t md_size;
|
|
|
|
uint32_t ns_flags;
|
|
|
|
|
|
|
|
ns_flags = spdk_nvme_ns_get_flags(ns);
|
|
|
|
md_size = spdk_nvme_ns_get_md_size(ns);
|
|
|
|
|
|
|
|
/* For extended LBA format, if the metadata size is 8 bytes and PRACT is
|
|
|
|
* enabled(controller inserts/strips PI), we should reduce metadata size
|
|
|
|
* from block size.
|
|
|
|
*/
|
|
|
|
md_excluded_from_xfer = ((io_flags & SPDK_NVME_IO_FLAGS_PRACT) &&
|
|
|
|
(ns_flags & SPDK_NVME_NS_EXTENDED_LBA_SUPPORTED) &&
|
|
|
|
(ns_flags & SPDK_NVME_NS_DPS_PI_SUPPORTED) &&
|
|
|
|
(md_size == 8));
|
|
|
|
|
|
|
|
return md_excluded_from_xfer ? spdk_nvme_ns_get_sector_size(ns) :
|
|
|
|
spdk_nvme_ns_get_extended_sector_size(ns);
|
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
static void
|
2016-12-09 22:09:28 +00:00
|
|
|
attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
2016-10-31 23:55:14 +00:00
|
|
|
struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
2016-04-13 00:58:29 +00:00
|
|
|
{
|
2018-03-02 19:49:36 +00:00
|
|
|
struct thread_data *td = cb_ctx;
|
2016-09-06 23:08:14 +00:00
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
2016-04-13 00:58:29 +00:00
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr;
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair;
|
|
|
|
struct spdk_nvme_ns *ns;
|
2020-01-19 02:28:07 +00:00
|
|
|
const struct spdk_nvme_ns_data *nsdata;
|
2017-03-27 05:33:06 +00:00
|
|
|
struct fio_file *f = fio_thread->current_f;
|
|
|
|
uint32_t ns_id;
|
|
|
|
char *p;
|
2019-01-23 00:31:40 +00:00
|
|
|
long int tmp;
|
2021-03-09 04:56:59 +00:00
|
|
|
uint32_t block_size;
|
2020-06-03 11:42:35 +00:00
|
|
|
struct spdk_fio_options *fio_options = td->eo;
|
2017-03-27 05:33:06 +00:00
|
|
|
|
|
|
|
p = strstr(f->file_name, "ns=");
|
2020-06-04 17:20:35 +00:00
|
|
|
if (p != NULL) {
|
|
|
|
tmp = spdk_strtol(p + 3, 10);
|
|
|
|
if (tmp <= 0) {
|
|
|
|
SPDK_ERRLOG("namespace id should be >=1, but was invalid: %ld\n", tmp);
|
|
|
|
g_error = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ns_id = (uint32_t)tmp;
|
|
|
|
} else {
|
|
|
|
ns_id = spdk_nvme_ctrlr_get_first_active_ns(ctrlr);
|
|
|
|
if (ns_id == 0) {
|
|
|
|
/* The ctrlr has no active namespaces and we didn't specify any so nothing to do. */
|
|
|
|
return;
|
|
|
|
}
|
2017-03-27 05:33:06 +00:00
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_lock(&g_mutex);
|
2017-05-02 04:25:50 +00:00
|
|
|
fio_ctrlr = get_fio_ctrlr(trid);
|
2017-03-27 05:33:06 +00:00
|
|
|
/* it is a new ctrlr and needs to be added */
|
2017-05-02 04:25:50 +00:00
|
|
|
if (!fio_ctrlr) {
|
2017-03-27 05:33:06 +00:00
|
|
|
/* Create an fio_ctrlr and add it to the list */
|
|
|
|
fio_ctrlr = calloc(1, sizeof(*fio_ctrlr));
|
|
|
|
if (!fio_ctrlr) {
|
|
|
|
SPDK_ERRLOG("Cannot allocate space for fio_ctrlr\n");
|
2017-11-09 07:03:32 +00:00
|
|
|
g_error = true;
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2017-03-27 05:33:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-02 04:25:50 +00:00
|
|
|
fio_ctrlr->opts = *opts;
|
2017-03-27 05:33:06 +00:00
|
|
|
fio_ctrlr->ctrlr = ctrlr;
|
|
|
|
fio_ctrlr->tr_id = *trid;
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_INSERT_TAIL(&g_ctrlrs, fio_ctrlr, link);
|
2017-03-27 05:33:06 +00:00
|
|
|
}
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-05-02 04:25:50 +00:00
|
|
|
ns = spdk_nvme_ctrlr_get_ns(fio_ctrlr->ctrlr, ns_id);
|
|
|
|
if (ns == NULL) {
|
|
|
|
SPDK_ERRLOG("Cannot get namespace by ns_id=%d\n", ns_id);
|
2017-11-09 07:03:32 +00:00
|
|
|
g_error = true;
|
2017-05-02 04:25:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-10 04:55:26 +00:00
|
|
|
if (!spdk_nvme_ns_is_active(ns)) {
|
|
|
|
SPDK_ERRLOG("Inactive namespace by ns_id=%d\n", ns_id);
|
|
|
|
g_error = true;
|
|
|
|
return;
|
|
|
|
}
|
2020-01-19 02:28:07 +00:00
|
|
|
nsdata = spdk_nvme_ns_get_data(ns);
|
2018-02-10 04:55:26 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_FOREACH(fio_qpair, &fio_thread->fio_qpair, link) {
|
2017-08-25 20:12:52 +00:00
|
|
|
if ((fio_qpair->f == f) ||
|
|
|
|
((spdk_nvme_transport_id_compare(trid, &fio_qpair->fio_ctrlr->tr_id) == 0) &&
|
|
|
|
(spdk_nvme_ns_get_id(fio_qpair->ns) == ns_id))) {
|
2017-11-09 07:03:32 +00:00
|
|
|
/* Not the error case. Avoid duplicated connection */
|
2017-03-27 05:33:06 +00:00
|
|
|
return;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
2017-03-27 05:33:06 +00:00
|
|
|
}
|
|
|
|
|
2017-05-02 04:25:50 +00:00
|
|
|
/* create a new qpair */
|
|
|
|
fio_qpair = calloc(1, sizeof(*fio_qpair));
|
|
|
|
if (!fio_qpair) {
|
2017-11-09 07:03:32 +00:00
|
|
|
g_error = true;
|
2017-05-02 04:25:50 +00:00
|
|
|
SPDK_ERRLOG("Cannot allocate space for fio_qpair\n");
|
2017-03-27 05:33:06 +00:00
|
|
|
return;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
2017-11-09 07:03:32 +00:00
|
|
|
|
2021-04-19 18:36:29 +00:00
|
|
|
f->engine_data = fio_qpair;
|
2017-05-02 04:25:50 +00:00
|
|
|
fio_qpair->ns = ns;
|
|
|
|
fio_qpair->f = f;
|
2017-08-25 20:12:52 +00:00
|
|
|
fio_qpair->fio_ctrlr = fio_ctrlr;
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_INSERT_TAIL(&fio_thread->fio_qpair, fio_qpair, link);
|
2017-03-27 05:33:06 +00:00
|
|
|
|
2018-06-11 08:26:40 +00:00
|
|
|
if (spdk_nvme_ns_get_flags(ns) & SPDK_NVME_NS_DPS_PI_SUPPORTED) {
|
2020-01-19 02:28:07 +00:00
|
|
|
assert(spdk_nvme_ns_get_pi_type(ns) != SPDK_NVME_FMT_NVM_PROTECTION_DISABLE);
|
2019-01-21 04:20:16 +00:00
|
|
|
fio_qpair->io_flags = g_spdk_pract_flag | g_spdk_prchk_flags;
|
2020-01-19 02:28:07 +00:00
|
|
|
fio_qpair->nvme_pi_enabled = true;
|
|
|
|
fio_qpair->md_start = nsdata->dps.md_start;
|
|
|
|
fio_qpair->extended_lba = spdk_nvme_ns_supports_extended_lba(ns);
|
|
|
|
fprintf(stdout, "PI type%u enabled with %s\n", spdk_nvme_ns_get_pi_type(ns),
|
|
|
|
fio_qpair->extended_lba ? "extended lba" : "separate metadata");
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 04:56:59 +00:00
|
|
|
block_size = _nvme_get_host_buffer_sector_size(ns, fio_qpair->io_flags);
|
|
|
|
if (td->o.bs[DDIR_READ] % block_size != 0 || td->o.bs[DDIR_WRITE] % block_size != 0) {
|
|
|
|
if (spdk_nvme_ns_supports_extended_lba(ns)) {
|
|
|
|
SPDK_ERRLOG("--bs has to be a multiple of (LBA data size + Metadata size)\n");
|
|
|
|
} else {
|
|
|
|
SPDK_ERRLOG("--bs has to be a multiple of LBA data size\n");
|
|
|
|
}
|
2020-12-13 18:43:47 +00:00
|
|
|
g_error = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:03:28 +00:00
|
|
|
if (fio_options->zone_append && spdk_nvme_ns_get_csi(ns) == SPDK_NVME_CSI_ZNS) {
|
|
|
|
if (spdk_nvme_ctrlr_get_flags(ctrlr) & SPDK_NVME_CTRLR_ZONE_APPEND_SUPPORTED) {
|
2021-05-07 08:06:40 +00:00
|
|
|
SPDK_DEBUGLOG(fio_nvme, "Using zone appends instead of writes on: '%s'\n",
|
|
|
|
f->file_name);
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
fio_qpair->zone_append_enabled = true;
|
|
|
|
} else {
|
2021-04-26 10:03:28 +00:00
|
|
|
SPDK_WARNLOG("Falling back to writes on: '%s' - ns lacks zone append cmd\n",
|
2021-05-07 08:06:40 +00:00
|
|
|
f->file_name);
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 13:51:47 +00:00
|
|
|
if (fio_options->initial_zone_reset == 1 && spdk_nvme_ns_get_csi(ns) == SPDK_NVME_CSI_ZNS) {
|
|
|
|
#if FIO_HAS_ZBD
|
|
|
|
struct spdk_nvme_qpair *tmp_qpair;
|
|
|
|
int completed = 0, err;
|
|
|
|
|
|
|
|
/* qpair has not been allocated yet (it gets allocated in spdk_fio_open()).
|
|
|
|
* Create a temporary qpair in order to perform the initial zone reset.
|
|
|
|
*/
|
|
|
|
assert(!fio_qpair->qpair);
|
|
|
|
|
|
|
|
tmp_qpair = spdk_nvme_ctrlr_alloc_io_qpair(ctrlr, NULL, 0);
|
|
|
|
if (!tmp_qpair) {
|
|
|
|
SPDK_ERRLOG("Cannot allocate a temporary qpair\n");
|
|
|
|
g_error = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = spdk_nvme_zns_reset_zone(ns, tmp_qpair, 0x0, true, pcu_cb, &completed);
|
|
|
|
if (err || pcu(tmp_qpair, &completed) || completed < 0) {
|
|
|
|
log_err("spdk/nvme: warn: initial_zone_reset: err: %d, cpl: %d\n",
|
|
|
|
err, completed);
|
|
|
|
}
|
|
|
|
|
|
|
|
spdk_nvme_ctrlr_free_io_qpair(tmp_qpair);
|
|
|
|
#else
|
|
|
|
log_err("spdk/nvme: ZBD/ZNS is not supported\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-05-02 04:25:50 +00:00
|
|
|
f->real_file_size = spdk_nvme_ns_get_size(fio_qpair->ns);
|
2017-03-27 05:33:06 +00:00
|
|
|
if (f->real_file_size <= 0) {
|
2017-11-09 07:03:32 +00:00
|
|
|
g_error = true;
|
2017-05-02 04:25:50 +00:00
|
|
|
SPDK_ERRLOG("Cannot get namespace size by ns=%p\n", ns);
|
2017-03-27 05:33:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
f->filetype = FIO_TYPE_BLOCK;
|
|
|
|
fio_file_set_size_known(f);
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 08:26:40 +00:00
|
|
|
static void parse_prchk_flags(const char *prchk_str)
|
|
|
|
{
|
|
|
|
if (!prchk_str) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strstr(prchk_str, "GUARD") != NULL) {
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_prchk_flags = SPDK_NVME_IO_FLAGS_PRCHK_GUARD;
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
if (strstr(prchk_str, "REFTAG") != NULL) {
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
if (strstr(prchk_str, "APPTAG") != NULL) {
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_APPTAG;
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-26 01:38:19 +00:00
|
|
|
static void parse_pract_flag(int pract)
|
|
|
|
{
|
|
|
|
if (pract == 1) {
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_pract_flag = SPDK_NVME_IO_FLAGS_PRACT;
|
2018-10-26 01:38:19 +00:00
|
|
|
} else {
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_pract_flag = 0;
|
2018-10-26 01:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
/* Called once at initialization. This is responsible for gathering the size of
|
|
|
|
* each "file", which in our case are in the form
|
2017-03-27 05:33:06 +00:00
|
|
|
* 'key=value [key=value] ... ns=value'
|
|
|
|
* For example, For local PCIe NVMe device - 'trtype=PCIe traddr=0000.04.00.0 ns=1'
|
|
|
|
* For remote exported by NVMe-oF target, 'trtype=RDMA adrfam=IPv4 traddr=192.168.100.8 trsvcid=4420 ns=1' */
|
2016-04-13 00:58:29 +00:00
|
|
|
static int spdk_fio_setup(struct thread_data *td)
|
|
|
|
{
|
|
|
|
struct spdk_fio_thread *fio_thread;
|
2017-06-27 21:21:07 +00:00
|
|
|
struct spdk_fio_options *fio_options = td->eo;
|
2017-01-12 18:25:17 +00:00
|
|
|
struct spdk_env_opts opts;
|
2017-03-27 05:33:06 +00:00
|
|
|
struct fio_file *f;
|
|
|
|
char *p;
|
2017-11-09 07:03:32 +00:00
|
|
|
int rc = 0;
|
2017-03-27 05:33:06 +00:00
|
|
|
struct spdk_nvme_transport_id trid;
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr;
|
2017-03-27 05:33:06 +00:00
|
|
|
char *trid_info;
|
|
|
|
unsigned int i;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-02-05 16:38:47 +00:00
|
|
|
/* we might be running in a daemonized FIO instance where standard
|
|
|
|
* input and output were closed and fds 0, 1, and 2 are reused
|
|
|
|
* for something important by FIO. We can't ensure we won't print
|
|
|
|
* anything (and so will our dependencies, e.g. DPDK), so abort early.
|
|
|
|
* (is_backend is an fio global variable)
|
|
|
|
*/
|
|
|
|
if (is_backend) {
|
|
|
|
char buf[1024];
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
"SPDK FIO plugin won't work with daemonized FIO server.");
|
|
|
|
fio_server_text_output(FIO_LOG_ERR, buf, sizeof(buf));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-04-04 15:35:10 +00:00
|
|
|
if (!td->o.use_thread) {
|
|
|
|
log_err("spdk: must set thread=1 when using spdk plugin\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-21 04:20:16 +00:00
|
|
|
pthread_mutex_lock(&g_mutex);
|
2017-05-10 23:07:33 +00:00
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
fio_thread = calloc(1, sizeof(*fio_thread));
|
|
|
|
assert(fio_thread != NULL);
|
|
|
|
|
2016-09-06 23:08:14 +00:00
|
|
|
td->io_ops_data = fio_thread;
|
2016-04-13 00:58:29 +00:00
|
|
|
fio_thread->td = td;
|
|
|
|
|
2017-03-15 23:20:08 +00:00
|
|
|
fio_thread->iocq_size = td->o.iodepth;
|
|
|
|
fio_thread->iocq = calloc(fio_thread->iocq_size, sizeof(struct io_u *));
|
2016-04-13 00:58:29 +00:00
|
|
|
assert(fio_thread->iocq != NULL);
|
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_INIT(&fio_thread->fio_qpair);
|
|
|
|
|
2019-01-21 04:20:16 +00:00
|
|
|
if (!g_spdk_env_initialized) {
|
2017-04-20 05:19:05 +00:00
|
|
|
spdk_env_opts_init(&opts);
|
|
|
|
opts.name = "fio";
|
2017-06-27 21:21:07 +00:00
|
|
|
opts.mem_size = fio_options->mem_size;
|
|
|
|
opts.shm_id = fio_options->shm_id;
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_enable_sgl = fio_options->enable_sgl;
|
2019-01-08 21:56:39 +00:00
|
|
|
g_spdk_sge_size = fio_options->sge_size;
|
2020-03-26 04:30:04 +00:00
|
|
|
g_spdk_bit_bucket_data_len = fio_options->bit_bucket_data_len;
|
2018-10-26 01:38:19 +00:00
|
|
|
parse_pract_flag(fio_options->pi_act);
|
2019-02-26 09:02:10 +00:00
|
|
|
g_spdk_md_per_io_size = spdk_max(fio_options->md_per_io_size, 4096);
|
2019-02-27 14:41:54 +00:00
|
|
|
g_spdk_apptag = (uint16_t)fio_options->apptag;
|
|
|
|
g_spdk_apptag_mask = (uint16_t)fio_options->apptag_mask;
|
2018-06-11 08:26:40 +00:00
|
|
|
parse_prchk_flags(fio_options->pi_chk);
|
2017-12-18 19:57:01 +00:00
|
|
|
if (spdk_env_init(&opts) < 0) {
|
|
|
|
SPDK_ERRLOG("Unable to initialize SPDK env\n");
|
|
|
|
free(fio_thread->iocq);
|
|
|
|
free(fio_thread);
|
|
|
|
fio_thread = NULL;
|
2019-01-21 04:20:16 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2017-12-18 19:57:01 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2019-01-21 04:20:16 +00:00
|
|
|
g_spdk_env_initialized = true;
|
2017-06-22 19:48:33 +00:00
|
|
|
spdk_unaffinitize_thread();
|
2018-06-15 21:54:56 +00:00
|
|
|
|
|
|
|
/* Spawn a thread to continue polling the controllers */
|
|
|
|
rc = pthread_create(&g_ctrlr_thread_id, NULL, &spdk_fio_poll_ctrlrs, NULL);
|
|
|
|
if (rc != 0) {
|
|
|
|
SPDK_ERRLOG("Unable to spawn a thread to poll admin queues. They won't be polled.\n");
|
|
|
|
}
|
2019-06-05 13:29:22 +00:00
|
|
|
|
|
|
|
if (fio_options->enable_vmd && spdk_vmd_init()) {
|
|
|
|
SPDK_ERRLOG("Failed to initialize VMD. Some NVMe devices can be unavailable.\n");
|
|
|
|
}
|
2017-04-20 05:19:05 +00:00
|
|
|
}
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-03-27 05:33:06 +00:00
|
|
|
for_each_file(td, f, i) {
|
|
|
|
memset(&trid, 0, sizeof(trid));
|
|
|
|
|
|
|
|
trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
|
|
|
|
|
|
|
p = strstr(f->file_name, " ns=");
|
2020-06-04 17:20:35 +00:00
|
|
|
if (p != NULL) {
|
|
|
|
trid_info = strndup(f->file_name, p - f->file_name);
|
|
|
|
} else {
|
|
|
|
trid_info = strndup(f->file_name, strlen(f->file_name));
|
2017-03-27 05:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!trid_info) {
|
|
|
|
SPDK_ERRLOG("Failed to allocate space for trid_info\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = spdk_nvme_transport_id_parse(&trid, trid_info);
|
|
|
|
if (rc < 0) {
|
|
|
|
SPDK_ERRLOG("Failed to parse given str: %s\n", trid_info);
|
|
|
|
free(trid_info);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
free(trid_info);
|
|
|
|
|
|
|
|
if (trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
|
|
|
struct spdk_pci_addr pci_addr;
|
|
|
|
if (spdk_pci_addr_parse(&pci_addr, trid.traddr) < 0) {
|
2017-05-23 19:51:03 +00:00
|
|
|
SPDK_ERRLOG("Invalid traddr=%s\n", trid.traddr);
|
2017-03-27 05:33:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
spdk_pci_addr_fmt(trid.traddr, sizeof(trid.traddr), &pci_addr);
|
2017-06-27 23:56:28 +00:00
|
|
|
} else {
|
2017-03-27 05:33:06 +00:00
|
|
|
if (trid.subnqn[0] == '\0') {
|
|
|
|
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s",
|
|
|
|
SPDK_NVMF_DISCOVERY_NQN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fio_thread->current_f = f;
|
|
|
|
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_lock(&g_mutex);
|
2017-05-02 04:25:50 +00:00
|
|
|
fio_ctrlr = get_fio_ctrlr(&trid);
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2017-05-02 04:25:50 +00:00
|
|
|
if (fio_ctrlr) {
|
|
|
|
attach_cb(td, &trid, fio_ctrlr->ctrlr, &fio_ctrlr->opts);
|
|
|
|
} else {
|
|
|
|
/* Enumerate all of the controllers */
|
|
|
|
if (spdk_nvme_probe(&trid, td, probe_cb, attach_cb, NULL) != 0) {
|
|
|
|
SPDK_ERRLOG("spdk_nvme_probe() failed\n");
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-27 05:33:06 +00:00
|
|
|
}
|
2017-11-09 07:03:32 +00:00
|
|
|
|
|
|
|
if (g_error) {
|
|
|
|
log_err("Failed to initialize spdk fio plugin\n");
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-23 16:53:18 +00:00
|
|
|
pthread_mutex_lock(&g_mutex);
|
2019-01-21 04:20:16 +00:00
|
|
|
g_td_count++;
|
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2017-05-10 23:07:33 +00:00
|
|
|
|
2017-11-09 07:03:32 +00:00
|
|
|
return rc;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int spdk_fio_open(struct thread_data *td, struct fio_file *f)
|
|
|
|
{
|
2021-04-19 18:36:29 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair = f->engine_data;
|
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr = fio_qpair->fio_ctrlr;
|
|
|
|
struct spdk_fio_options *fio_options = td->eo;
|
|
|
|
struct spdk_nvme_io_qpair_opts qpopts;
|
|
|
|
|
|
|
|
spdk_nvme_ctrlr_get_default_io_qpair_opts(fio_ctrlr->ctrlr, &qpopts, sizeof(qpopts));
|
|
|
|
qpopts.delay_cmd_submit = true;
|
|
|
|
if (fio_options->enable_wrr) {
|
|
|
|
qpopts.qprio = fio_options->wrr_priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
fio_qpair->qpair = spdk_nvme_ctrlr_alloc_io_qpair(fio_ctrlr->ctrlr, &qpopts, sizeof(qpopts));
|
|
|
|
if (!fio_qpair->qpair) {
|
|
|
|
SPDK_ERRLOG("Cannot allocate nvme io_qpair any more\n");
|
|
|
|
g_error = true;
|
|
|
|
free(fio_qpair);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fio_options->print_qid_mappings == 1) {
|
|
|
|
log_info("job %s: %s qid %d\n", td->o.name, f->file_name,
|
|
|
|
spdk_nvme_qpair_get_id(fio_qpair->qpair));
|
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int spdk_fio_close(struct thread_data *td, struct fio_file *f)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int spdk_fio_iomem_alloc(struct thread_data *td, size_t total_mem)
|
|
|
|
{
|
2017-05-25 18:21:30 +00:00
|
|
|
td->orig_buffer = spdk_dma_zmalloc(total_mem, NVME_IO_ALIGN, NULL);
|
2016-04-13 00:58:29 +00:00
|
|
|
return td->orig_buffer == NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spdk_fio_iomem_free(struct thread_data *td)
|
|
|
|
{
|
2017-05-25 18:21:30 +00:00
|
|
|
spdk_dma_free(td->orig_buffer);
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int spdk_fio_io_u_init(struct thread_data *td, struct io_u *io_u)
|
|
|
|
{
|
2016-09-06 23:08:14 +00:00
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
2016-04-13 00:58:29 +00:00
|
|
|
struct spdk_fio_request *fio_req;
|
|
|
|
|
2019-10-31 21:33:36 +00:00
|
|
|
io_u->engine_data = NULL;
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
fio_req = calloc(1, sizeof(*fio_req));
|
|
|
|
if (fio_req == NULL) {
|
|
|
|
return 1;
|
|
|
|
}
|
2019-02-26 09:02:10 +00:00
|
|
|
|
|
|
|
fio_req->md_buf = spdk_dma_zmalloc(g_spdk_md_per_io_size, NVME_IO_ALIGN, NULL);
|
|
|
|
if (fio_req->md_buf == NULL) {
|
|
|
|
fprintf(stderr, "Allocate %u metadata failed\n", g_spdk_md_per_io_size);
|
|
|
|
free(fio_req);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
fio_req->io = io_u;
|
|
|
|
fio_req->fio_thread = fio_thread;
|
|
|
|
|
|
|
|
io_u->engine_data = fio_req;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spdk_fio_io_u_free(struct thread_data *td, struct io_u *io_u)
|
|
|
|
{
|
|
|
|
struct spdk_fio_request *fio_req = io_u->engine_data;
|
|
|
|
|
|
|
|
if (fio_req) {
|
|
|
|
assert(fio_req->io == io_u);
|
2019-02-26 09:02:10 +00:00
|
|
|
spdk_dma_free(fio_req->md_buf);
|
2016-04-13 00:58:29 +00:00
|
|
|
free(fio_req);
|
|
|
|
io_u->engine_data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
static inline uint64_t
|
|
|
|
fio_offset_to_zslba(unsigned long long offset, struct spdk_nvme_ns *ns)
|
|
|
|
{
|
|
|
|
return (offset / spdk_nvme_zns_ns_get_zone_size(ns)) * spdk_nvme_zns_ns_get_zone_size_sectors(ns);
|
|
|
|
}
|
|
|
|
|
2019-03-11 00:17:33 +00:00
|
|
|
static int
|
2018-06-11 08:26:40 +00:00
|
|
|
fio_extended_lba_setup_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
|
|
|
|
{
|
2019-01-21 05:39:57 +00:00
|
|
|
struct spdk_nvme_ns *ns = fio_qpair->ns;
|
2018-06-11 08:26:40 +00:00
|
|
|
struct spdk_fio_request *fio_req = io_u->engine_data;
|
2019-01-21 05:39:57 +00:00
|
|
|
uint32_t md_size, extended_lba_size, lba_count;
|
2018-06-11 08:26:40 +00:00
|
|
|
uint64_t lba;
|
2019-01-21 05:39:57 +00:00
|
|
|
struct iovec iov;
|
|
|
|
int rc;
|
2018-06-11 08:26:40 +00:00
|
|
|
|
2020-01-19 02:28:07 +00:00
|
|
|
/* Set appmask and apptag when PRACT is enabled */
|
|
|
|
if (fio_qpair->io_flags & SPDK_NVME_IO_FLAGS_PRACT) {
|
|
|
|
fio_req->dif_ctx.apptag_mask = g_spdk_apptag_mask;
|
|
|
|
fio_req->dif_ctx.app_tag = g_spdk_apptag;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-21 05:39:57 +00:00
|
|
|
extended_lba_size = spdk_nvme_ns_get_extended_sector_size(ns);
|
2018-06-11 08:26:40 +00:00
|
|
|
md_size = spdk_nvme_ns_get_md_size(ns);
|
|
|
|
lba = io_u->offset / extended_lba_size;
|
|
|
|
lba_count = io_u->xfer_buflen / extended_lba_size;
|
|
|
|
|
2019-01-21 05:39:57 +00:00
|
|
|
rc = spdk_dif_ctx_init(&fio_req->dif_ctx, extended_lba_size, md_size,
|
2019-03-14 08:44:10 +00:00
|
|
|
true, fio_qpair->md_start,
|
2019-01-21 05:39:57 +00:00
|
|
|
(enum spdk_dif_type)spdk_nvme_ns_get_pi_type(ns),
|
2019-06-04 05:52:24 +00:00
|
|
|
fio_qpair->io_flags, lba, g_spdk_apptag_mask, g_spdk_apptag, 0, 0);
|
2019-01-21 05:39:57 +00:00
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "Initialization of DIF context failed\n");
|
2019-03-11 00:17:33 +00:00
|
|
|
return rc;
|
2019-01-21 05:39:57 +00:00
|
|
|
}
|
2018-06-11 08:26:40 +00:00
|
|
|
|
2019-09-11 02:15:11 +00:00
|
|
|
if (io_u->ddir != DDIR_WRITE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-21 05:39:57 +00:00
|
|
|
iov.iov_base = io_u->buf;
|
|
|
|
iov.iov_len = io_u->xfer_buflen;
|
|
|
|
rc = spdk_dif_generate(&iov, 1, lba_count, &fio_req->dif_ctx);
|
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "Generation of DIF failed\n");
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
2019-03-11 00:17:33 +00:00
|
|
|
|
|
|
|
return rc;
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 09:02:10 +00:00
|
|
|
static int
|
|
|
|
fio_separate_md_setup_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
|
|
|
|
{
|
|
|
|
struct spdk_nvme_ns *ns = fio_qpair->ns;
|
|
|
|
struct spdk_fio_request *fio_req = io_u->engine_data;
|
|
|
|
uint32_t md_size, block_size, lba_count;
|
|
|
|
uint64_t lba;
|
|
|
|
struct iovec iov, md_iov;
|
|
|
|
int rc;
|
|
|
|
|
2020-01-19 02:28:07 +00:00
|
|
|
/* Set appmask and apptag when PRACT is enabled */
|
|
|
|
if (fio_qpair->io_flags & SPDK_NVME_IO_FLAGS_PRACT) {
|
|
|
|
fio_req->dif_ctx.apptag_mask = g_spdk_apptag_mask;
|
|
|
|
fio_req->dif_ctx.app_tag = g_spdk_apptag;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-26 09:02:10 +00:00
|
|
|
block_size = spdk_nvme_ns_get_sector_size(ns);
|
|
|
|
md_size = spdk_nvme_ns_get_md_size(ns);
|
|
|
|
lba = io_u->offset / block_size;
|
|
|
|
lba_count = io_u->xfer_buflen / block_size;
|
|
|
|
|
|
|
|
rc = spdk_dif_ctx_init(&fio_req->dif_ctx, block_size, md_size,
|
2019-03-14 08:44:10 +00:00
|
|
|
false, fio_qpair->md_start,
|
2019-02-26 09:02:10 +00:00
|
|
|
(enum spdk_dif_type)spdk_nvme_ns_get_pi_type(ns),
|
2019-06-04 05:52:24 +00:00
|
|
|
fio_qpair->io_flags, lba, g_spdk_apptag_mask, g_spdk_apptag, 0, 0);
|
2019-02-26 09:02:10 +00:00
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "Initialization of DIF context failed\n");
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2019-09-11 02:15:11 +00:00
|
|
|
if (io_u->ddir != DDIR_WRITE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-26 09:02:10 +00:00
|
|
|
iov.iov_base = io_u->buf;
|
|
|
|
iov.iov_len = io_u->xfer_buflen;
|
|
|
|
md_iov.iov_base = fio_req->md_buf;
|
|
|
|
md_iov.iov_len = spdk_min(md_size * lba_count, g_spdk_md_per_io_size);
|
|
|
|
rc = spdk_dix_generate(&iov, 1, &md_iov, lba_count, &fio_req->dif_ctx);
|
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "Generation of DIX failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2019-03-11 00:17:33 +00:00
|
|
|
static int
|
2018-06-11 08:26:40 +00:00
|
|
|
fio_extended_lba_verify_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
|
|
|
|
{
|
2019-01-21 05:39:57 +00:00
|
|
|
struct spdk_nvme_ns *ns = fio_qpair->ns;
|
|
|
|
struct spdk_fio_request *fio_req = io_u->engine_data;
|
|
|
|
uint32_t lba_count;
|
|
|
|
struct iovec iov;
|
|
|
|
struct spdk_dif_error err_blk = {};
|
|
|
|
int rc;
|
2018-06-11 08:26:40 +00:00
|
|
|
|
2020-01-19 02:28:07 +00:00
|
|
|
/* Do nothing when PRACT is enabled */
|
|
|
|
if (fio_qpair->io_flags & SPDK_NVME_IO_FLAGS_PRACT) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-21 05:39:57 +00:00
|
|
|
iov.iov_base = io_u->buf;
|
|
|
|
iov.iov_len = io_u->xfer_buflen;
|
|
|
|
lba_count = io_u->xfer_buflen / spdk_nvme_ns_get_extended_sector_size(ns);
|
2018-06-11 08:26:40 +00:00
|
|
|
|
2019-01-21 05:39:57 +00:00
|
|
|
rc = spdk_dif_verify(&iov, 1, lba_count, &fio_req->dif_ctx, &err_blk);
|
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "DIF error detected. type=%d, offset=%" PRIu32 "\n",
|
|
|
|
err_blk.err_type, err_blk.err_offset);
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
2019-03-11 00:17:33 +00:00
|
|
|
|
|
|
|
return rc;
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 09:02:10 +00:00
|
|
|
static int
|
|
|
|
fio_separate_md_verify_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
|
|
|
|
{
|
|
|
|
struct spdk_nvme_ns *ns = fio_qpair->ns;
|
|
|
|
struct spdk_fio_request *fio_req = io_u->engine_data;
|
|
|
|
uint32_t md_size, lba_count;
|
|
|
|
struct iovec iov, md_iov;
|
|
|
|
struct spdk_dif_error err_blk = {};
|
|
|
|
int rc;
|
|
|
|
|
2020-01-19 02:28:07 +00:00
|
|
|
/* Do nothing when PRACT is enabled */
|
|
|
|
if (fio_qpair->io_flags & SPDK_NVME_IO_FLAGS_PRACT) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-26 09:02:10 +00:00
|
|
|
iov.iov_base = io_u->buf;
|
|
|
|
iov.iov_len = io_u->xfer_buflen;
|
|
|
|
lba_count = io_u->xfer_buflen / spdk_nvme_ns_get_sector_size(ns);
|
|
|
|
md_size = spdk_nvme_ns_get_md_size(ns);
|
|
|
|
md_iov.iov_base = fio_req->md_buf;
|
|
|
|
md_iov.iov_len = spdk_min(md_size * lba_count, g_spdk_md_per_io_size);
|
|
|
|
|
|
|
|
rc = spdk_dix_verify(&iov, 1, &md_iov, lba_count, &fio_req->dif_ctx, &err_blk);
|
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "DIX error detected. type=%d, offset=%" PRIu32 "\n",
|
|
|
|
err_blk.err_type, err_blk.err_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
static void spdk_fio_completion_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
|
|
|
|
{
|
|
|
|
struct spdk_fio_request *fio_req = ctx;
|
|
|
|
struct spdk_fio_thread *fio_thread = fio_req->fio_thread;
|
2019-03-07 13:55:16 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair = fio_req->fio_qpair;
|
2019-03-11 00:17:33 +00:00
|
|
|
int rc;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-01-19 02:28:07 +00:00
|
|
|
if (fio_qpair->nvme_pi_enabled && fio_req->io->ddir == DDIR_READ) {
|
2019-02-26 09:02:10 +00:00
|
|
|
if (fio_qpair->extended_lba) {
|
|
|
|
rc = fio_extended_lba_verify_pi(fio_qpair, fio_req->io);
|
|
|
|
} else {
|
|
|
|
rc = fio_separate_md_verify_pi(fio_qpair, fio_req->io);
|
|
|
|
}
|
2019-03-11 00:17:33 +00:00
|
|
|
if (rc != 0) {
|
|
|
|
fio_req->io->error = abs(rc);
|
|
|
|
}
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2021-04-22 18:21:28 +00:00
|
|
|
if (spdk_nvme_cpl_is_error(cpl)) {
|
|
|
|
fio_req->io->error = EIO;
|
|
|
|
}
|
|
|
|
|
2017-03-15 23:20:08 +00:00
|
|
|
assert(fio_thread->iocq_count < fio_thread->iocq_size);
|
|
|
|
fio_thread->iocq[fio_thread->iocq_count++] = fio_req->io;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-11 06:35:39 +00:00
|
|
|
static void
|
|
|
|
spdk_nvme_io_reset_sgl(void *ref, uint32_t sgl_offset)
|
|
|
|
{
|
|
|
|
struct spdk_fio_request *fio_req = (struct spdk_fio_request *)ref;
|
|
|
|
|
|
|
|
fio_req->iov_offset = sgl_offset;
|
2020-03-26 04:30:04 +00:00
|
|
|
fio_req->bit_bucket_data_len = 0;
|
2018-04-11 06:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spdk_nvme_io_next_sge(void *ref, void **address, uint32_t *length)
|
|
|
|
{
|
|
|
|
struct spdk_fio_request *fio_req = (struct spdk_fio_request *)ref;
|
|
|
|
struct io_u *io_u = fio_req->io;
|
2019-01-08 21:56:39 +00:00
|
|
|
uint32_t iov_len;
|
2020-03-26 04:30:04 +00:00
|
|
|
uint32_t bit_bucket_len;
|
2018-04-11 06:35:39 +00:00
|
|
|
|
|
|
|
*address = io_u->buf;
|
|
|
|
|
|
|
|
if (fio_req->iov_offset) {
|
|
|
|
assert(fio_req->iov_offset <= io_u->xfer_buflen);
|
|
|
|
*address += fio_req->iov_offset;
|
|
|
|
}
|
|
|
|
|
2019-01-08 21:56:39 +00:00
|
|
|
iov_len = io_u->xfer_buflen - fio_req->iov_offset;
|
|
|
|
if (iov_len > g_spdk_sge_size) {
|
|
|
|
iov_len = g_spdk_sge_size;
|
|
|
|
}
|
|
|
|
|
2020-06-01 23:56:07 +00:00
|
|
|
if ((fio_req->bit_bucket_data_len < g_spdk_bit_bucket_data_len) && (io_u->ddir == DDIR_READ)) {
|
2020-03-26 04:30:04 +00:00
|
|
|
assert(g_spdk_bit_bucket_data_len < io_u->xfer_buflen);
|
|
|
|
*address = (void *)UINT64_MAX;
|
|
|
|
bit_bucket_len = g_spdk_bit_bucket_data_len - fio_req->bit_bucket_data_len;
|
|
|
|
if (iov_len > bit_bucket_len) {
|
|
|
|
iov_len = bit_bucket_len;
|
|
|
|
}
|
|
|
|
fio_req->bit_bucket_data_len += iov_len;
|
|
|
|
}
|
|
|
|
|
2019-01-08 21:56:39 +00:00
|
|
|
fio_req->iov_offset += iov_len;
|
|
|
|
*length = iov_len;
|
2020-03-26 04:30:04 +00:00
|
|
|
|
2018-04-11 06:35:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-05 09:11:24 +00:00
|
|
|
#if FIO_IOOPS_VERSION >= 24
|
|
|
|
typedef enum fio_q_status fio_q_status_t;
|
|
|
|
#else
|
|
|
|
typedef int fio_q_status_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static fio_q_status_t
|
|
|
|
spdk_fio_queue(struct thread_data *td, struct io_u *io_u)
|
2016-04-13 00:58:29 +00:00
|
|
|
{
|
|
|
|
int rc = 1;
|
2016-09-06 23:08:14 +00:00
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
2016-04-13 00:58:29 +00:00
|
|
|
struct spdk_fio_request *fio_req = io_u->engine_data;
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair;
|
|
|
|
struct spdk_nvme_ns *ns = NULL;
|
2019-07-11 05:22:35 +00:00
|
|
|
void *md_buf = NULL;
|
2019-01-21 05:39:57 +00:00
|
|
|
struct spdk_dif_ctx *dif_ctx = &fio_req->dif_ctx;
|
2017-06-26 19:26:26 +00:00
|
|
|
uint32_t block_size;
|
|
|
|
uint64_t lba;
|
|
|
|
uint32_t lba_count;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2021-05-17 10:23:34 +00:00
|
|
|
fio_qpair = get_fio_qpair(fio_thread, io_u->file);
|
|
|
|
if (fio_qpair == NULL) {
|
2017-07-14 20:32:50 +00:00
|
|
|
return -ENXIO;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
2021-05-17 10:23:34 +00:00
|
|
|
ns = fio_qpair->ns;
|
|
|
|
|
2020-01-19 02:28:07 +00:00
|
|
|
if (fio_qpair->nvme_pi_enabled && !fio_qpair->extended_lba) {
|
2019-07-11 05:22:35 +00:00
|
|
|
md_buf = fio_req->md_buf;
|
|
|
|
}
|
2019-03-07 13:55:16 +00:00
|
|
|
fio_req->fio_qpair = fio_qpair;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2021-03-09 04:56:59 +00:00
|
|
|
block_size = _nvme_get_host_buffer_sector_size(ns, fio_qpair->io_flags);
|
2017-06-26 19:26:26 +00:00
|
|
|
lba = io_u->offset / block_size;
|
|
|
|
lba_count = io_u->xfer_buflen / block_size;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2018-10-29 03:18:22 +00:00
|
|
|
/* TODO: considering situations that fio will randomize and verify io_u */
|
2020-01-19 02:28:07 +00:00
|
|
|
if (fio_qpair->nvme_pi_enabled) {
|
2019-02-26 09:02:10 +00:00
|
|
|
if (fio_qpair->extended_lba) {
|
|
|
|
rc = fio_extended_lba_setup_pi(fio_qpair, io_u);
|
|
|
|
} else {
|
|
|
|
rc = fio_separate_md_setup_pi(fio_qpair, io_u);
|
|
|
|
}
|
2019-03-11 00:17:33 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
io_u->error = -rc;
|
|
|
|
return FIO_Q_COMPLETED;
|
|
|
|
}
|
2018-06-11 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
switch (io_u->ddir) {
|
|
|
|
case DDIR_READ:
|
2019-01-21 04:20:16 +00:00
|
|
|
if (!g_spdk_enable_sgl) {
|
2019-07-11 05:22:35 +00:00
|
|
|
rc = spdk_nvme_ns_cmd_read_with_md(ns, fio_qpair->qpair, io_u->buf, md_buf, lba, lba_count,
|
2018-06-11 08:26:40 +00:00
|
|
|
spdk_fio_completion_cb, fio_req,
|
2019-09-11 03:44:25 +00:00
|
|
|
fio_qpair->io_flags, dif_ctx->apptag_mask, dif_ctx->app_tag);
|
2018-04-11 06:35:39 +00:00
|
|
|
} else {
|
2018-06-11 08:26:40 +00:00
|
|
|
rc = spdk_nvme_ns_cmd_readv_with_md(ns, fio_qpair->qpair, lba,
|
2019-09-11 03:44:25 +00:00
|
|
|
lba_count, spdk_fio_completion_cb, fio_req, fio_qpair->io_flags,
|
2019-07-11 05:22:35 +00:00
|
|
|
spdk_nvme_io_reset_sgl, spdk_nvme_io_next_sge, md_buf,
|
2019-01-21 05:39:57 +00:00
|
|
|
dif_ctx->apptag_mask, dif_ctx->app_tag);
|
2018-04-11 06:35:39 +00:00
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
break;
|
|
|
|
case DDIR_WRITE:
|
2019-01-21 04:20:16 +00:00
|
|
|
if (!g_spdk_enable_sgl) {
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
if (!fio_qpair->zone_append_enabled) {
|
|
|
|
rc = spdk_nvme_ns_cmd_write_with_md(ns, fio_qpair->qpair, io_u->buf, md_buf, lba,
|
|
|
|
lba_count,
|
|
|
|
spdk_fio_completion_cb, fio_req,
|
|
|
|
fio_qpair->io_flags, dif_ctx->apptag_mask, dif_ctx->app_tag);
|
|
|
|
} else {
|
2021-05-17 10:23:34 +00:00
|
|
|
uint64_t zslba = fio_offset_to_zslba(io_u->offset, ns);
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
rc = spdk_nvme_zns_zone_append_with_md(ns, fio_qpair->qpair, io_u->buf, md_buf, zslba,
|
|
|
|
lba_count,
|
|
|
|
spdk_fio_completion_cb, fio_req,
|
|
|
|
fio_qpair->io_flags, dif_ctx->apptag_mask, dif_ctx->app_tag);
|
|
|
|
}
|
2018-04-11 06:35:39 +00:00
|
|
|
} else {
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
if (!fio_qpair->zone_append_enabled) {
|
|
|
|
rc = spdk_nvme_ns_cmd_writev_with_md(ns, fio_qpair->qpair, lba,
|
|
|
|
lba_count, spdk_fio_completion_cb, fio_req, fio_qpair->io_flags,
|
|
|
|
spdk_nvme_io_reset_sgl, spdk_nvme_io_next_sge, md_buf,
|
|
|
|
dif_ctx->apptag_mask, dif_ctx->app_tag);
|
|
|
|
} else {
|
2021-05-17 10:23:34 +00:00
|
|
|
uint64_t zslba = fio_offset_to_zslba(io_u->offset, ns);
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
rc = spdk_nvme_zns_zone_appendv_with_md(ns, fio_qpair->qpair, zslba,
|
|
|
|
lba_count, spdk_fio_completion_cb, fio_req, fio_qpair->io_flags,
|
|
|
|
spdk_nvme_io_reset_sgl, spdk_nvme_io_next_sge, md_buf,
|
|
|
|
dif_ctx->apptag_mask, dif_ctx->app_tag);
|
|
|
|
}
|
2018-04-11 06:35:39 +00:00
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-07-14 20:32:50 +00:00
|
|
|
/* NVMe read/write functions return -ENOMEM if there are no free requests. */
|
|
|
|
if (rc == -ENOMEM) {
|
|
|
|
return FIO_Q_BUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != 0) {
|
2019-03-11 00:17:33 +00:00
|
|
|
io_u->error = abs(rc);
|
|
|
|
return FIO_Q_COMPLETED;
|
2017-07-14 20:32:50 +00:00
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-07-14 20:32:50 +00:00
|
|
|
return FIO_Q_QUEUED;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct io_u *spdk_fio_event(struct thread_data *td, int event)
|
|
|
|
{
|
2016-09-06 23:08:14 +00:00
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-03-15 23:20:08 +00:00
|
|
|
assert(event >= 0);
|
|
|
|
assert((unsigned)event < fio_thread->iocq_count);
|
|
|
|
return fio_thread->iocq[event];
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int spdk_fio_getevents(struct thread_data *td, unsigned int min,
|
|
|
|
unsigned int max, const struct timespec *t)
|
|
|
|
{
|
2016-09-06 23:08:14 +00:00
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
2017-08-25 08:25:57 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair = NULL;
|
2016-04-13 00:58:29 +00:00
|
|
|
struct timespec t0, t1;
|
|
|
|
uint64_t timeout = 0;
|
|
|
|
|
|
|
|
if (t) {
|
|
|
|
timeout = t->tv_sec * 1000000000L + t->tv_nsec;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &t0);
|
|
|
|
}
|
|
|
|
|
2017-03-15 23:20:08 +00:00
|
|
|
fio_thread->iocq_count = 0;
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-08-25 08:25:57 +00:00
|
|
|
/* fetch the next qpair */
|
|
|
|
if (fio_thread->fio_qpair_current) {
|
2020-09-28 00:14:00 +00:00
|
|
|
fio_qpair = TAILQ_NEXT(fio_thread->fio_qpair_current, link);
|
2017-08-25 08:25:57 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
for (;;) {
|
2017-08-25 08:25:57 +00:00
|
|
|
if (fio_qpair == NULL) {
|
2020-09-28 00:14:00 +00:00
|
|
|
fio_qpair = TAILQ_FIRST(&fio_thread->fio_qpair);
|
2017-08-25 08:25:57 +00:00
|
|
|
}
|
|
|
|
|
2017-05-02 04:25:50 +00:00
|
|
|
while (fio_qpair != NULL) {
|
|
|
|
spdk_nvme_qpair_process_completions(fio_qpair->qpair, max - fio_thread->iocq_count);
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2017-03-15 23:20:08 +00:00
|
|
|
if (fio_thread->iocq_count >= min) {
|
2017-08-25 08:25:57 +00:00
|
|
|
/* reset the currrent handling qpair */
|
|
|
|
fio_thread->fio_qpair_current = fio_qpair;
|
2017-03-15 23:20:08 +00:00
|
|
|
return fio_thread->iocq_count;
|
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
fio_qpair = TAILQ_NEXT(fio_qpair, link);
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (t) {
|
2017-06-26 19:26:26 +00:00
|
|
|
uint64_t elapse;
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &t1);
|
2017-06-26 19:26:26 +00:00
|
|
|
elapse = ((t1.tv_sec - t0.tv_sec) * 1000000000L)
|
|
|
|
+ t1.tv_nsec - t0.tv_nsec;
|
2016-04-13 00:58:29 +00:00
|
|
|
if (elapse > timeout) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-25 08:25:57 +00:00
|
|
|
/* reset the currrent handling qpair */
|
|
|
|
fio_thread->fio_qpair_current = fio_qpair;
|
2017-03-15 23:20:08 +00:00
|
|
|
return fio_thread->iocq_count;
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int spdk_fio_invalidate(struct thread_data *td, struct fio_file *f)
|
|
|
|
{
|
|
|
|
/* TODO: This should probably send a flush to the device, but for now just return successful. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
#if FIO_HAS_ZBD
|
|
|
|
static int
|
|
|
|
spdk_fio_get_zoned_model(struct thread_data *td, struct fio_file *f, enum zbd_zoned_model *model)
|
|
|
|
{
|
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
|
|
|
struct spdk_fio_qpair *fio_qpair = NULL;
|
2020-10-27 10:09:30 +00:00
|
|
|
const struct spdk_nvme_zns_ns_data *zns_data = NULL;
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
|
|
|
|
*model = ZBD_IGNORE;
|
|
|
|
|
|
|
|
if (f->filetype != FIO_TYPE_FILE && \
|
|
|
|
f->filetype != FIO_TYPE_BLOCK && \
|
|
|
|
f->filetype != FIO_TYPE_CHAR) {
|
|
|
|
log_info("spdk/nvme: ignoring filetype: %d\n", f->filetype);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fio_qpair = get_fio_qpair(fio_thread, f);
|
|
|
|
if (!fio_qpair) {
|
|
|
|
log_err("spdk/nvme: no ns/qpair or file_name: '%s'\n", f->file_name);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (spdk_nvme_ns_get_csi(fio_qpair->ns)) {
|
|
|
|
case SPDK_NVME_CSI_NVM:
|
|
|
|
*model = ZBD_NONE;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case SPDK_NVME_CSI_KV:
|
|
|
|
log_err("spdk/nvme: KV namespace is currently not supported\n");
|
|
|
|
return -ENOSYS;
|
|
|
|
|
|
|
|
case SPDK_NVME_CSI_ZNS:
|
2020-10-27 10:09:30 +00:00
|
|
|
zns_data = spdk_nvme_zns_ns_get_data(fio_qpair->ns);
|
|
|
|
if (!zns_data) {
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
log_err("spdk/nvme: file_name: '%s', ZNS is not enabled\n", f->file_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*model = ZBD_HOST_MANAGED;
|
2020-10-27 10:09:30 +00:00
|
|
|
|
|
|
|
/** Unlimited open resources, skip checking 'max_open_zones' */
|
|
|
|
if (0xFFFFFFFF == zns_data->mor) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!td->o.max_open_zones) {
|
|
|
|
td->o.max_open_zones = spdk_min(ZBD_MAX_OPEN_ZONES, zns_data->mor + 1);
|
|
|
|
log_info("spdk/nvme: parameter 'max_open_zones' was unset; assigned: %d.\n",
|
|
|
|
td->o.max_open_zones);
|
|
|
|
} else if (td->o.max_open_zones < 0) {
|
|
|
|
log_err("spdk/nvme: invalid parameter 'max_open_zones': %d\n",
|
|
|
|
td->o.max_open_zones);
|
|
|
|
return -EINVAL;
|
|
|
|
} else if (td->o.max_open_zones > ZBD_MAX_OPEN_ZONES) {
|
|
|
|
log_err("spdk/nvme: parameter 'max_open_zones': %d exceeds fio-limit: %d\n",
|
|
|
|
td->o.max_open_zones, ZBD_MAX_OPEN_ZONES);
|
|
|
|
return -EINVAL;
|
|
|
|
} else if ((uint32_t)td->o.max_open_zones > (zns_data->mor + 1)) {
|
|
|
|
log_err("spdk/nvme: parameter 'max_open_zones': %d exceeds dev-limit: %u\n",
|
|
|
|
td->o.max_open_zones, zns_data->mor + 1);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spdk_fio_report_zones(struct thread_data *td, struct fio_file *f, uint64_t offset,
|
|
|
|
struct zbd_zone *zbdz, unsigned int nr_zones)
|
|
|
|
{
|
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
|
|
|
struct spdk_fio_qpair *fio_qpair = NULL;
|
|
|
|
const struct spdk_nvme_zns_ns_data *zns = NULL;
|
|
|
|
struct spdk_nvme_zns_zone_report *report;
|
nvme/fio_plugin: fix report_zones
Commit f69367c7881b ("fio_nvme: defer qpair allocation to file_open
callback") moved the qpair allocation from spdk_fio_setup() to
spdk_fio_open(). This broke spdk_fio_report_zones(), which needs a
qpair in order to get the initial state of the zones.
setup_files() in FIO calls td->io_ops->setup() (spdk_fio_setup()),
followed by zbd_init_files(), which calls zbd_init_zone_info(),
which calls zbd_create_zone_info(), which calls parse_zone_info(),
which calls zbd_report_zones(), which calls td->io_ops->report_zones()
(spdk_fio_report_zones()).
i.e. spdk_fio_report_zones() will always be called directly after
spdk_fio_setup(). .report_zones() is even called before the per
thread ioengine .init() callback.
Therefore, spdk_fio_report_zones() is called before the ioengine
.open_file() callback.
This is done in order to ensure that all threads will share the same
zbd_info struct, which contains the per zone locks.
Since SPDK nvme ioengine no longer initializes the qpairs in .setup(),
create a temporary qpair in .report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ic376ac7844e40fceff092900ae7e4714bccf38e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7590
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-04-23 16:48:12 +00:00
|
|
|
struct spdk_nvme_qpair *tmp_qpair;
|
2020-10-30 16:23:24 +00:00
|
|
|
uint32_t report_nzones = 0, report_nzones_max, report_nbytes, mdts_nbytes;
|
|
|
|
uint64_t zsze_nbytes, ns_nzones, lba_nbytes;
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
int completed = 0, err;
|
|
|
|
|
|
|
|
fio_qpair = get_fio_qpair(fio_thread, f);
|
|
|
|
if (!fio_qpair) {
|
|
|
|
log_err("spdk/nvme: no ns/qpair or file_name: '%s'\n", f->file_name);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
zns = spdk_nvme_zns_ns_get_data(fio_qpair->ns);
|
|
|
|
if (!zns) {
|
|
|
|
log_err("spdk/nvme: file_name: '%s', zns is not enabled\n", f->file_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
nvme/fio_plugin: fix report_zones
Commit f69367c7881b ("fio_nvme: defer qpair allocation to file_open
callback") moved the qpair allocation from spdk_fio_setup() to
spdk_fio_open(). This broke spdk_fio_report_zones(), which needs a
qpair in order to get the initial state of the zones.
setup_files() in FIO calls td->io_ops->setup() (spdk_fio_setup()),
followed by zbd_init_files(), which calls zbd_init_zone_info(),
which calls zbd_create_zone_info(), which calls parse_zone_info(),
which calls zbd_report_zones(), which calls td->io_ops->report_zones()
(spdk_fio_report_zones()).
i.e. spdk_fio_report_zones() will always be called directly after
spdk_fio_setup(). .report_zones() is even called before the per
thread ioengine .init() callback.
Therefore, spdk_fio_report_zones() is called before the ioengine
.open_file() callback.
This is done in order to ensure that all threads will share the same
zbd_info struct, which contains the per zone locks.
Since SPDK nvme ioengine no longer initializes the qpairs in .setup(),
create a temporary qpair in .report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ic376ac7844e40fceff092900ae7e4714bccf38e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7590
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-04-23 16:48:12 +00:00
|
|
|
/* qpair has not been allocated yet (it gets allocated in spdk_fio_open()).
|
|
|
|
* Create a temporary qpair in order to perform report zones.
|
|
|
|
*/
|
|
|
|
assert(!fio_qpair->qpair);
|
|
|
|
|
|
|
|
tmp_qpair = spdk_nvme_ctrlr_alloc_io_qpair(fio_qpair->fio_ctrlr->ctrlr, NULL, 0);
|
|
|
|
if (!tmp_qpair) {
|
|
|
|
log_err("spdk/nvme: cannot allocate a temporary qpair\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
/** Retrieve device parameters */
|
2020-10-30 16:23:24 +00:00
|
|
|
mdts_nbytes = spdk_nvme_ns_get_max_io_xfer_size(fio_qpair->ns);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
lba_nbytes = spdk_nvme_ns_get_sector_size(fio_qpair->ns);
|
|
|
|
zsze_nbytes = spdk_nvme_zns_ns_get_zone_size(fio_qpair->ns);
|
|
|
|
ns_nzones = spdk_nvme_zns_ns_get_num_zones(fio_qpair->ns);
|
|
|
|
|
|
|
|
/** Allocate report-buffer without exceeding mdts, zbdz-storage, and what is needed */
|
|
|
|
report_nzones_max = (mdts_nbytes - sizeof(*report)) / sizeof(report->descs[0]);
|
|
|
|
report_nzones_max = spdk_min(spdk_min(report_nzones_max, nr_zones), ns_nzones);
|
|
|
|
report_nbytes = sizeof(report->descs[0]) * report_nzones_max + sizeof(*report);
|
2021-03-23 08:59:05 +00:00
|
|
|
report = calloc(1, report_nbytes);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
if (!report) {
|
|
|
|
log_err("spdk/nvme: failed report_zones(): ENOMEM\n");
|
nvme/fio_plugin: fix report_zones
Commit f69367c7881b ("fio_nvme: defer qpair allocation to file_open
callback") moved the qpair allocation from spdk_fio_setup() to
spdk_fio_open(). This broke spdk_fio_report_zones(), which needs a
qpair in order to get the initial state of the zones.
setup_files() in FIO calls td->io_ops->setup() (spdk_fio_setup()),
followed by zbd_init_files(), which calls zbd_init_zone_info(),
which calls zbd_create_zone_info(), which calls parse_zone_info(),
which calls zbd_report_zones(), which calls td->io_ops->report_zones()
(spdk_fio_report_zones()).
i.e. spdk_fio_report_zones() will always be called directly after
spdk_fio_setup(). .report_zones() is even called before the per
thread ioengine .init() callback.
Therefore, spdk_fio_report_zones() is called before the ioengine
.open_file() callback.
This is done in order to ensure that all threads will share the same
zbd_info struct, which contains the per zone locks.
Since SPDK nvme ioengine no longer initializes the qpairs in .setup(),
create a temporary qpair in .report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ic376ac7844e40fceff092900ae7e4714bccf38e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7590
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-04-23 16:48:12 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
}
|
|
|
|
|
nvme/fio_plugin: fix report_zones
Commit f69367c7881b ("fio_nvme: defer qpair allocation to file_open
callback") moved the qpair allocation from spdk_fio_setup() to
spdk_fio_open(). This broke spdk_fio_report_zones(), which needs a
qpair in order to get the initial state of the zones.
setup_files() in FIO calls td->io_ops->setup() (spdk_fio_setup()),
followed by zbd_init_files(), which calls zbd_init_zone_info(),
which calls zbd_create_zone_info(), which calls parse_zone_info(),
which calls zbd_report_zones(), which calls td->io_ops->report_zones()
(spdk_fio_report_zones()).
i.e. spdk_fio_report_zones() will always be called directly after
spdk_fio_setup(). .report_zones() is even called before the per
thread ioengine .init() callback.
Therefore, spdk_fio_report_zones() is called before the ioengine
.open_file() callback.
This is done in order to ensure that all threads will share the same
zbd_info struct, which contains the per zone locks.
Since SPDK nvme ioengine no longer initializes the qpairs in .setup(),
create a temporary qpair in .report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ic376ac7844e40fceff092900ae7e4714bccf38e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7590
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-04-23 16:48:12 +00:00
|
|
|
err = spdk_nvme_zns_report_zones(fio_qpair->ns, tmp_qpair, report, report_nbytes,
|
examples/nvme_fio_plugin: fix zone reporting
All zone management receive helper functions (including
spdk_nvme_zns_report_zones()) are implemented to match the parameters of
the zone management receive function in the ZNS specification.
The documentation for spdk_nvme_zns_report_zones() states:
"param partial_report If true, nr_zones field in the zone report indicates
the number of zone descriptors that were successfully written to the zone
report. If false, nr_zones field in the zone report indicates the number
of zone descriptors that match the report_opts criteria."
This matches the description of the "Partial Report" bit in the ZNS spec.
Since the FIO function parse_zone_info() calls the io_ops->report_zones()
function multiple times, until all zones have been reported, it expects
the return from this function to represent the number of zones that were
successfully reported.
By setting the partial_report bit to false, the controller will return
the total number of zones, and since spdk_fio_report_zones() loops until
idx < report->nr_zones, and writes to zbdz[idx], the current code will
overwrite heap memory, since idx will take on index values that are out
of bounds for the memory allocated by the FIO function parse_zone_info().
Therefore, spdk_fio_report_zones() has to set the partial_report bit to
true when calling the NVMe level function spdk_nvme_zns_report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I8846711bfed4faadac0315b450158293cefa36f4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4871
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Simon A. F. Lund <simon.lund@samsung.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-26 10:09:39 +00:00
|
|
|
offset / lba_nbytes, SPDK_NVME_ZRA_LIST_ALL, true, pcu_cb,
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
&completed);
|
nvme/fio_plugin: fix report_zones
Commit f69367c7881b ("fio_nvme: defer qpair allocation to file_open
callback") moved the qpair allocation from spdk_fio_setup() to
spdk_fio_open(). This broke spdk_fio_report_zones(), which needs a
qpair in order to get the initial state of the zones.
setup_files() in FIO calls td->io_ops->setup() (spdk_fio_setup()),
followed by zbd_init_files(), which calls zbd_init_zone_info(),
which calls zbd_create_zone_info(), which calls parse_zone_info(),
which calls zbd_report_zones(), which calls td->io_ops->report_zones()
(spdk_fio_report_zones()).
i.e. spdk_fio_report_zones() will always be called directly after
spdk_fio_setup(). .report_zones() is even called before the per
thread ioengine .init() callback.
Therefore, spdk_fio_report_zones() is called before the ioengine
.open_file() callback.
This is done in order to ensure that all threads will share the same
zbd_info struct, which contains the per zone locks.
Since SPDK nvme ioengine no longer initializes the qpairs in .setup(),
create a temporary qpair in .report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ic376ac7844e40fceff092900ae7e4714bccf38e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7590
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-04-23 16:48:12 +00:00
|
|
|
if (err || pcu(tmp_qpair, &completed) || completed < 0) {
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
log_err("spdk/nvme: report_zones(): err: %d, cpl: %d\n", err, completed);
|
|
|
|
err = err ? err : -EIO;
|
|
|
|
goto exit;
|
|
|
|
}
|
examples/nvme_fio_plugin: fix zone reporting
All zone management receive helper functions (including
spdk_nvme_zns_report_zones()) are implemented to match the parameters of
the zone management receive function in the ZNS specification.
The documentation for spdk_nvme_zns_report_zones() states:
"param partial_report If true, nr_zones field in the zone report indicates
the number of zone descriptors that were successfully written to the zone
report. If false, nr_zones field in the zone report indicates the number
of zone descriptors that match the report_opts criteria."
This matches the description of the "Partial Report" bit in the ZNS spec.
Since the FIO function parse_zone_info() calls the io_ops->report_zones()
function multiple times, until all zones have been reported, it expects
the return from this function to represent the number of zones that were
successfully reported.
By setting the partial_report bit to false, the controller will return
the total number of zones, and since spdk_fio_report_zones() loops until
idx < report->nr_zones, and writes to zbdz[idx], the current code will
overwrite heap memory, since idx will take on index values that are out
of bounds for the memory allocated by the FIO function parse_zone_info().
Therefore, spdk_fio_report_zones() has to set the partial_report bit to
true when calling the NVMe level function spdk_nvme_zns_report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I8846711bfed4faadac0315b450158293cefa36f4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4871
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Simon A. F. Lund <simon.lund@samsung.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-26 10:09:39 +00:00
|
|
|
assert(report->nr_zones <= report_nzones_max);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
report_nzones = report->nr_zones;
|
|
|
|
|
|
|
|
for (uint64_t idx = 0; idx < report->nr_zones; ++idx) {
|
|
|
|
struct spdk_nvme_zns_zone_desc *zdesc = &report->descs[idx];
|
|
|
|
|
|
|
|
zbdz[idx].start = zdesc->zslba * lba_nbytes;
|
|
|
|
zbdz[idx].len = zsze_nbytes;
|
|
|
|
zbdz[idx].capacity = zdesc->zcap * lba_nbytes;
|
|
|
|
zbdz[idx].wp = zdesc->wp * lba_nbytes;
|
|
|
|
|
|
|
|
switch (zdesc->zt) {
|
|
|
|
case SPDK_NVME_ZONE_TYPE_SEQWR:
|
|
|
|
zbdz[idx].type = ZBD_ZONE_TYPE_SWR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-10-27 12:20:12 +00:00
|
|
|
log_err("spdk/nvme: %s: inv. zone-type: 0x%x\n", f->file_name, zdesc->zt);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
err = -EIO;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (zdesc->zs) {
|
|
|
|
case SPDK_NVME_ZONE_STATE_EMPTY:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_EMPTY;
|
|
|
|
break;
|
|
|
|
case SPDK_NVME_ZONE_STATE_IOPEN:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_IMP_OPEN;
|
|
|
|
break;
|
|
|
|
case SPDK_NVME_ZONE_STATE_EOPEN:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_EXP_OPEN;
|
|
|
|
break;
|
|
|
|
case SPDK_NVME_ZONE_STATE_CLOSED:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_CLOSED;
|
|
|
|
break;
|
|
|
|
case SPDK_NVME_ZONE_STATE_RONLY:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_READONLY;
|
|
|
|
break;
|
|
|
|
case SPDK_NVME_ZONE_STATE_FULL:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_FULL;
|
|
|
|
break;
|
|
|
|
case SPDK_NVME_ZONE_STATE_OFFLINE:
|
|
|
|
zbdz[idx].cond = ZBD_ZONE_COND_OFFLINE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-10-27 12:20:12 +00:00
|
|
|
log_err("spdk/nvme: %s: inv. zone-state: 0x%x\n", f->file_name, zdesc->zs);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
err = -EIO;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
nvme/fio_plugin: fix report_zones
Commit f69367c7881b ("fio_nvme: defer qpair allocation to file_open
callback") moved the qpair allocation from spdk_fio_setup() to
spdk_fio_open(). This broke spdk_fio_report_zones(), which needs a
qpair in order to get the initial state of the zones.
setup_files() in FIO calls td->io_ops->setup() (spdk_fio_setup()),
followed by zbd_init_files(), which calls zbd_init_zone_info(),
which calls zbd_create_zone_info(), which calls parse_zone_info(),
which calls zbd_report_zones(), which calls td->io_ops->report_zones()
(spdk_fio_report_zones()).
i.e. spdk_fio_report_zones() will always be called directly after
spdk_fio_setup(). .report_zones() is even called before the per
thread ioengine .init() callback.
Therefore, spdk_fio_report_zones() is called before the ioengine
.open_file() callback.
This is done in order to ensure that all threads will share the same
zbd_info struct, which contains the per zone locks.
Since SPDK nvme ioengine no longer initializes the qpairs in .setup(),
create a temporary qpair in .report_zones().
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ic376ac7844e40fceff092900ae7e4714bccf38e6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7590
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2021-04-23 16:48:12 +00:00
|
|
|
spdk_nvme_ctrlr_free_io_qpair(tmp_qpair);
|
2021-03-23 08:59:05 +00:00
|
|
|
free(report);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
|
|
|
|
return err ? err : (int)report_nzones;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spdk_fio_reset_wp(struct thread_data *td, struct fio_file *f, uint64_t offset, uint64_t length)
|
|
|
|
{
|
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
|
|
|
struct spdk_fio_qpair *fio_qpair = NULL;
|
|
|
|
const struct spdk_nvme_zns_ns_data *zns = NULL;
|
|
|
|
uint64_t zsze_nbytes, lba_nbytes;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
fio_qpair = get_fio_qpair(fio_thread, f);
|
|
|
|
if (!fio_qpair) {
|
|
|
|
log_err("spdk/nvme: no ns/qpair or file_name: '%s'\n", f->file_name);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
zns = spdk_nvme_zns_ns_get_data(fio_qpair->ns);
|
|
|
|
if (!zns) {
|
|
|
|
log_err("spdk/nvme: file_name: '%s', zns is not enabled\n", f->file_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
zsze_nbytes = spdk_nvme_zns_ns_get_zone_size(fio_qpair->ns);
|
|
|
|
lba_nbytes = spdk_nvme_ns_get_sector_size(fio_qpair->ns);
|
|
|
|
|
2020-10-27 11:48:30 +00:00
|
|
|
/** check the assumption that offset is valid zone-start lba */
|
|
|
|
if (offset % zsze_nbytes) {
|
|
|
|
log_err("spdk/nvme: offset: %zu is not a valid zslba\n", offset);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
for (uint64_t cur = offset; cur < offset + length; cur += zsze_nbytes) {
|
2020-10-27 11:48:30 +00:00
|
|
|
int completed = 0;
|
|
|
|
|
|
|
|
err = spdk_nvme_zns_reset_zone(fio_qpair->ns, fio_qpair->qpair, cur / lba_nbytes,
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
false, pcu_cb, &completed);
|
|
|
|
if (err || pcu(fio_qpair->qpair, &completed) || completed < 0) {
|
2020-10-27 12:20:12 +00:00
|
|
|
log_err("spdk/nvme: zns_reset_zone(): err: %d, cpl: %d\n", err, completed);
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
err = err ? err : -EIO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
static void spdk_fio_cleanup(struct thread_data *td)
|
|
|
|
{
|
2016-09-06 23:08:14 +00:00
|
|
|
struct spdk_fio_thread *fio_thread = td->io_ops_data;
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_fio_qpair *fio_qpair, *fio_qpair_tmp;
|
2020-01-27 11:09:36 +00:00
|
|
|
struct spdk_fio_options *fio_options = td->eo;
|
2017-05-02 04:25:50 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_FOREACH_SAFE(fio_qpair, &fio_thread->fio_qpair, link, fio_qpair_tmp) {
|
|
|
|
TAILQ_REMOVE(&fio_thread->fio_qpair, fio_qpair, link);
|
2017-05-02 04:25:50 +00:00
|
|
|
spdk_nvme_ctrlr_free_io_qpair(fio_qpair->qpair);
|
|
|
|
free(fio_qpair);
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
2019-06-03 12:47:50 +00:00
|
|
|
free(fio_thread->iocq);
|
2016-04-13 00:58:29 +00:00
|
|
|
free(fio_thread);
|
2017-05-02 04:25:50 +00:00
|
|
|
|
2019-01-21 04:20:16 +00:00
|
|
|
pthread_mutex_lock(&g_mutex);
|
|
|
|
g_td_count--;
|
|
|
|
if (g_td_count == 0) {
|
2017-05-02 04:25:50 +00:00
|
|
|
struct spdk_fio_ctrlr *fio_ctrlr, *fio_ctrlr_tmp;
|
2020-10-15 23:51:35 +00:00
|
|
|
struct spdk_nvme_detach_ctx *detach_ctx = NULL;
|
2018-07-26 17:19:41 +00:00
|
|
|
|
2020-09-28 00:14:00 +00:00
|
|
|
TAILQ_FOREACH_SAFE(fio_ctrlr, &g_ctrlrs, link, fio_ctrlr_tmp) {
|
|
|
|
TAILQ_REMOVE(&g_ctrlrs, fio_ctrlr, link);
|
2020-10-15 23:51:35 +00:00
|
|
|
spdk_nvme_detach_async(fio_ctrlr->ctrlr, &detach_ctx);
|
2017-05-02 04:25:50 +00:00
|
|
|
free(fio_ctrlr);
|
|
|
|
}
|
2020-01-27 11:09:36 +00:00
|
|
|
|
2020-10-15 23:51:35 +00:00
|
|
|
while (detach_ctx && spdk_nvme_detach_poll_async(detach_ctx) == -EAGAIN) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2020-01-27 11:09:36 +00:00
|
|
|
if (fio_options->enable_vmd) {
|
|
|
|
spdk_vmd_fini();
|
|
|
|
}
|
2017-05-02 04:25:50 +00:00
|
|
|
}
|
2019-01-21 04:20:16 +00:00
|
|
|
pthread_mutex_unlock(&g_mutex);
|
2020-09-28 00:14:00 +00:00
|
|
|
if (TAILQ_EMPTY(&g_ctrlrs)) {
|
2018-07-26 17:19:41 +00:00
|
|
|
if (pthread_cancel(g_ctrlr_thread_id) == 0) {
|
|
|
|
pthread_join(g_ctrlr_thread_id, NULL);
|
|
|
|
}
|
|
|
|
}
|
2016-04-13 00:58:29 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 22:38:42 +00:00
|
|
|
/* This function enables addition of SPDK parameters to the fio config
|
|
|
|
* Adding new parameters by defining them here and defining a callback
|
|
|
|
* function to read the parameter value. */
|
|
|
|
static struct fio_option options[] = {
|
2020-06-03 11:42:35 +00:00
|
|
|
{
|
|
|
|
.name = "enable_wrr",
|
|
|
|
.lname = "Enable weighted round robin (WRR) for IO submission queues",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, enable_wrr),
|
|
|
|
.def = "0",
|
|
|
|
.help = "Enable weighted round robin (WRR) for IO submission queues",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "arbitration_burst",
|
|
|
|
.lname = "Arbitration Burst",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, arbitration_burst),
|
|
|
|
.def = "0",
|
|
|
|
.help = "Arbitration Burst used for WRR (valid range from 0 - 7)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "low_weight",
|
|
|
|
.lname = "low_weight for WRR",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, low_weight),
|
|
|
|
.def = "0",
|
|
|
|
.help = "low_weight used for WRR (valid range from 0 - 255)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "medium_weight",
|
|
|
|
.lname = "medium_weight for WRR",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, medium_weight),
|
|
|
|
.def = "0",
|
|
|
|
.help = "medium weight used for WRR (valid range from 0 - 255)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "high_weight",
|
|
|
|
.lname = "high_weight for WRR",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, high_weight),
|
|
|
|
.def = "0",
|
|
|
|
.help = "high weight used for WRR (valid range from 0 - 255)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "wrr_priority",
|
|
|
|
.lname = "priority used for WRR",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, wrr_priority),
|
|
|
|
.def = "0",
|
|
|
|
.help = "priority used for WRR (valid range from 0-3)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2017-06-15 22:38:42 +00:00
|
|
|
{
|
|
|
|
.name = "mem_size_mb",
|
|
|
|
.lname = "Memory size in MB",
|
2017-06-27 21:21:07 +00:00
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, mem_size),
|
2018-12-07 20:23:02 +00:00
|
|
|
.def = "0",
|
2018-09-27 13:19:10 +00:00
|
|
|
.help = "Memory Size for SPDK (MB)",
|
2017-06-27 21:21:07 +00:00
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "shm_id",
|
|
|
|
.lname = "shared memory ID",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, shm_id),
|
|
|
|
.def = "-1",
|
2018-09-27 13:19:10 +00:00
|
|
|
.help = "Shared Memory ID",
|
2017-06-15 22:38:42 +00:00
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2018-04-11 06:35:39 +00:00
|
|
|
{
|
|
|
|
.name = "enable_sgl",
|
|
|
|
.lname = "SGL used for I/O commands",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, enable_sgl),
|
|
|
|
.def = "0",
|
2018-09-27 13:19:10 +00:00
|
|
|
.help = "SGL Used for I/O Commands (enable_sgl=1 or enable_sgl=0)",
|
2018-04-11 06:35:39 +00:00
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2019-01-08 21:56:39 +00:00
|
|
|
{
|
|
|
|
.name = "sge_size",
|
|
|
|
.lname = "SGL size used for I/O commands",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, sge_size),
|
|
|
|
.def = "4096",
|
|
|
|
.help = "SGL size in bytes for I/O Commands (default 4096)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2020-03-26 04:30:04 +00:00
|
|
|
{
|
|
|
|
.name = "bit_bucket_data_len",
|
|
|
|
.lname = "Amount of data used for Bit Bucket",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, bit_bucket_data_len),
|
|
|
|
.def = "0",
|
|
|
|
.help = "Bit Bucket Data Length for READ commands (disabled by default)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2018-06-15 22:56:08 +00:00
|
|
|
{
|
|
|
|
.name = "hostnqn",
|
|
|
|
.lname = "Host NQN to use when connecting to controllers.",
|
|
|
|
.type = FIO_OPT_STR_STORE,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, hostnqn),
|
|
|
|
.help = "Host NQN",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2018-06-11 08:26:40 +00:00
|
|
|
{
|
|
|
|
.name = "pi_act",
|
|
|
|
.lname = "Protection Information Action",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, pi_act),
|
|
|
|
.def = "1",
|
|
|
|
.help = "Protection Information Action bit (pi_act=1 or pi_act=0)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "pi_chk",
|
|
|
|
.lname = "Protection Information Check(GUARD|REFTAG|APPTAG)",
|
|
|
|
.type = FIO_OPT_STR_STORE,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, pi_chk),
|
|
|
|
.def = NULL,
|
|
|
|
.help = "Control of Protection Information Checking (pi_chk=GUARD|REFTAG|APPTAG)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2019-02-26 09:02:10 +00:00
|
|
|
{
|
|
|
|
.name = "md_per_io_size",
|
|
|
|
.lname = "Separate Metadata Buffer Size per I/O",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, md_per_io_size),
|
|
|
|
.def = "4096",
|
|
|
|
.help = "Size of separate metadata buffer per I/O (Default: 4096)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2019-02-27 14:41:54 +00:00
|
|
|
{
|
|
|
|
.name = "apptag",
|
|
|
|
.lname = "Application Tag used in Protection Information",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, apptag),
|
|
|
|
.def = "0x1234",
|
|
|
|
.help = "Application Tag used in Protection Information field (Default: 0x1234)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "apptag_mask",
|
|
|
|
.lname = "Application Tag Mask",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, apptag_mask),
|
|
|
|
.def = "0xffff",
|
|
|
|
.help = "Application Tag Mask used with Application Tag (Default: 0xffff)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2018-11-30 01:46:55 +00:00
|
|
|
{
|
|
|
|
.name = "digest_enable",
|
|
|
|
.lname = "PDU digest choice for NVMe/TCP Transport(NONE|HEADER|DATA|BOTH)",
|
|
|
|
.type = FIO_OPT_STR_STORE,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, digest_enable),
|
|
|
|
.def = NULL,
|
|
|
|
.help = "Control the NVMe/TCP control(digest_enable=NONE|HEADER|DATA|BOTH)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
|
|
|
},
|
2019-06-05 13:29:22 +00:00
|
|
|
{
|
|
|
|
.name = "enable_vmd",
|
|
|
|
.lname = "Enable VMD enumeration",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, enable_vmd),
|
|
|
|
.def = "0",
|
|
|
|
.help = "Enable VMD enumeration (enable_vmd=1 or enable_vmd=0)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
2020-10-28 14:46:26 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "initial_zone_reset",
|
|
|
|
.lname = "Reset Zones on initialization",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, initial_zone_reset),
|
|
|
|
.def = "0",
|
|
|
|
.help = "Reset Zones on initialization (0=disable, 1=Reset All Zones)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "zone_append",
|
|
|
|
.lname = "Use zone append instead of write",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, zone_append),
|
|
|
|
.def = "0",
|
2021-05-07 08:06:40 +00:00
|
|
|
.help = "Use zone append instead of write (1=zone append, 0=write)",
|
examples/nvme_fio_plugin: add support for zone append
Now when we have support for spdk_nvme_zns_zone_append() and
spdk_nvme_zns_zone_appendv(), hook them up in the nvme fio plugin.
Note that fio itself does not have support for zone append,
since unlike SPDK, there is no user facing zone append API in
Linux. Therefore, this new option simply replaces writes with
zone appends in the SPDK fio backend.
This is however still useful for the following reasons:
-Provides a way to test zone append in SPDK.
-By using zone append, we can test with iodepth > 1.
With regular writes, the user can only specify iodepth=1.
This is because for zone namespaces, writes have to target
the write pointer. Having more than one write in flight, per
zone, will lead to I/O errors.
In Linux, it is possible to use fio with iodepth > 1
on zoned namespaces, simply because of the mq-deadline
scheduler, which throttles writes such that there is only
one write in flight, per zone, even if user space has
queued up more.
Since a user might not want to use zone append unconditionally,
even on a namespace that supports it, make this an option
rather than enabling it unconditionally.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I028b79f6445bc63b68c97d1370c6f8139779666d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6330
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2021-02-08 13:39:31 +00:00
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
2021-02-11 20:14:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "print_qid_mappings",
|
|
|
|
.lname = "Print job-to-qid mappings",
|
|
|
|
.type = FIO_OPT_INT,
|
|
|
|
.off1 = offsetof(struct spdk_fio_options, print_qid_mappings),
|
|
|
|
.def = "0",
|
|
|
|
.help = "Print job-to-qid mappings (0=disable, 1=enable)",
|
|
|
|
.category = FIO_OPT_C_ENGINE,
|
|
|
|
.group = FIO_OPT_G_INVALID,
|
2019-06-05 13:29:22 +00:00
|
|
|
},
|
2017-06-15 22:38:42 +00:00
|
|
|
{
|
|
|
|
.name = NULL,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-04-13 00:58:29 +00:00
|
|
|
/* FIO imports this structure using dlsym */
|
|
|
|
struct ioengine_ops ioengine = {
|
2017-06-13 18:50:32 +00:00
|
|
|
.name = "spdk",
|
2016-04-13 00:58:29 +00:00
|
|
|
.version = FIO_IOOPS_VERSION,
|
|
|
|
.queue = spdk_fio_queue,
|
|
|
|
.getevents = spdk_fio_getevents,
|
|
|
|
.event = spdk_fio_event,
|
|
|
|
.cleanup = spdk_fio_cleanup,
|
|
|
|
.open_file = spdk_fio_open,
|
|
|
|
.close_file = spdk_fio_close,
|
|
|
|
.invalidate = spdk_fio_invalidate,
|
|
|
|
.iomem_alloc = spdk_fio_iomem_alloc,
|
|
|
|
.iomem_free = spdk_fio_iomem_free,
|
|
|
|
.setup = spdk_fio_setup,
|
|
|
|
.io_u_init = spdk_fio_io_u_init,
|
|
|
|
.io_u_free = spdk_fio_io_u_free,
|
examples/nvme_fio_plugin: add initial support for ZNS
This adds initial support for ZNS by aligning the NVMe spec. defined ZNS
structures and commands with the fio Zone representation and
implementation of the following io-engine functions:
get_zoned_model() / spdk_fio_get_zoned_model(), when namespace is ZNS
and the Zoned-Command-Set is enabled, then this function informs fio
that the device is ZBD_HOST_MANAGED.
report_zones() / spdk_fio_report_zones(), submits a single
zone-mgmt-recv and waits for its completion, converts the spec-defined
zone-descriptors to the fio ZBD_ZONE representation and returns the
number of zones in the converted report.
reset_wp() / spdk_fio_reset_wp(), submits multiple zone-mgmt-send,
covering the range [offset, offset+length] and waits for their
completion.
Four helper-functions are added to assist in the above implementations.
get_fio_qpair(), this helper is added to retrieve the namespace matching
the given fio-file, ensuring that management commands reach the correct
namespace.
spdk_fio_qpair_mdts_nbytes(), this helper is added to assist
report_zones() retrieve the zone-report within the bounds of the
maximum-data-transfer of the device.
The functions pcu() and pcu_cb() provide a means to submit
management-commands and waiting for their completions. They are needed
since, although mgmt-send/recv are IO-commands in the context of NVMe,
then for fio they are not part of the regular queue/event/getevents but
utilized in a synchronous/blocking manner.
Note, in the fio-zone-representation, then the start/len/capacity/wp
fields are in units of bytes, whereas the corresponding values in NVMe
are in lbas/sectors. It is worth noting as the offset <-> lba
conversions do not take NVMe configurations with extended-lba format
into account. Thus, the implementation is initial support for ZNS as
more work is needed to support pi/extended-lba configurations.
Note, a guard FIO_HAS_ZBD checks for the required io-engine ops version
and indirectly testing for available of fio Zone representation by
testing for a macro introduced in the same fio-release as the required
fio Zone representation.
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: Id3d1d61a52db2e55019032c724197df4d559271a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4836
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-10-22 14:24:13 +00:00
|
|
|
#if FIO_HAS_ZBD
|
|
|
|
.get_zoned_model = spdk_fio_get_zoned_model,
|
|
|
|
.report_zones = spdk_fio_report_zones,
|
|
|
|
.reset_wp = spdk_fio_reset_wp,
|
|
|
|
#endif
|
2016-04-13 00:58:29 +00:00
|
|
|
.flags = FIO_RAWIO | FIO_NOEXTEND | FIO_NODISKUTIL | FIO_MEMALIGN,
|
2017-06-15 22:38:42 +00:00
|
|
|
.options = options,
|
2017-06-27 21:21:07 +00:00
|
|
|
.option_struct_size = sizeof(struct spdk_fio_options),
|
2016-04-13 00:58:29 +00:00
|
|
|
};
|
2017-06-13 18:50:32 +00:00
|
|
|
|
|
|
|
static void fio_init fio_spdk_register(void)
|
|
|
|
{
|
|
|
|
register_ioengine(&ioengine);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fio_exit fio_spdk_unregister(void)
|
|
|
|
{
|
|
|
|
unregister_ioengine(&ioengine);
|
|
|
|
}
|
2021-05-07 08:06:40 +00:00
|
|
|
|
|
|
|
SPDK_LOG_REGISTER_COMPONENT(fio_nvme)
|