From 47fca7c7e8b27044f8c8c0b62a4173d2ec7401b6 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Tue, 8 Jan 2019 14:56:39 -0700 Subject: [PATCH] fio_plugin: add support for mocking SGL entries FIO is going to always present a contiguous buffer to us. But we can fake out the nvme driver with a couple of global variables. Change-Id: I038e70582043e1d7c1800ed065fe126aa091c290 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/439608 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- examples/nvme/fio_plugin/fio_plugin.c | 23 ++++++++++++++++++-- examples/nvme/fio_plugin/mock_sgl_config.fio | 16 ++++++++++++++ test/nvmf/host/fio.sh | 4 ++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 examples/nvme/fio_plugin/mock_sgl_config.fio diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index e069b4dda4..9bfadbee4f 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -49,6 +49,7 @@ static bool g_spdk_env_initialized; static int g_spdk_enable_sgl = 0; +static uint32_t g_spdk_sge_size = 4096; static uint32_t g_spdk_pract_flag; static uint32_t g_spdk_prchk_flags; static uint32_t g_spdk_md_per_io_size = 4096; @@ -60,6 +61,7 @@ struct spdk_fio_options { int mem_size; int shm_id; int enable_sgl; + int sge_size; char *hostnqn; int pi_act; char *pi_chk; @@ -407,6 +409,7 @@ static int spdk_fio_setup(struct thread_data *td) opts.mem_size = fio_options->mem_size; opts.shm_id = fio_options->shm_id; g_spdk_enable_sgl = fio_options->enable_sgl; + g_spdk_sge_size = fio_options->sge_size; parse_pract_flag(fio_options->pi_act); g_spdk_md_per_io_size = spdk_max(fio_options->md_per_io_size, 4096); g_spdk_apptag = (uint16_t)fio_options->apptag; @@ -708,16 +711,22 @@ 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; + uint32_t iov_len; *address = io_u->buf; - *length = io_u->xfer_buflen; if (fio_req->iov_offset) { assert(fio_req->iov_offset <= io_u->xfer_buflen); *address += fio_req->iov_offset; - *length -= fio_req->iov_offset; } + iov_len = io_u->xfer_buflen - fio_req->iov_offset; + if (iov_len > g_spdk_sge_size) { + iov_len = g_spdk_sge_size; + } + + fio_req->iov_offset += iov_len; + *length = iov_len; return 0; } @@ -956,6 +965,16 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_INVALID, }, + { + .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, + }, { .name = "hostnqn", .lname = "Host NQN to use when connecting to controllers.", diff --git a/examples/nvme/fio_plugin/mock_sgl_config.fio b/examples/nvme/fio_plugin/mock_sgl_config.fio new file mode 100644 index 0000000000..ede5bfd70f --- /dev/null +++ b/examples/nvme/fio_plugin/mock_sgl_config.fio @@ -0,0 +1,16 @@ +[global] +ioengine=spdk +thread=1 +group_reporting=1 +direct=1 +verify=0 +enable_sgl=1 +time_based=1 +ramp_time=0 +runtime=2 +iodepth=4 +rw=randrw +bs=16k + +[test] +numjobs=1 diff --git a/test/nvmf/host/fio.sh b/test/nvmf/host/fio.sh index e675e5cc7e..83bfb06ef9 100755 --- a/test/nvmf/host/fio.sh +++ b/test/nvmf/host/fio.sh @@ -50,6 +50,10 @@ PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin # Test fio_plugin as host with malloc backend LD_PRELOAD=$PLUGIN_DIR/fio_plugin /usr/src/fio/fio $PLUGIN_DIR/example_config.fio --filename="trtype=RDMA adrfam=IPv4 \ traddr=$NVMF_FIRST_TARGET_IP trsvcid=4420 ns=1" + +# second test mocking multiple SGL elements +LD_PRELOAD=$PLUGIN_DIR/fio_plugin /usr/src/fio/fio $PLUGIN_DIR/mock_sgl_config.fio --filename="trtype=RDMA adrfam=IPv4 \ +traddr=$NVMF_FIRST_TARGET_IP trsvcid=4420 ns=1" $rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1 if [ $RUN_NIGHTLY -eq 1 ]; then