Commit 70d096e7 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

nvme_perf: Factor out allocate task operation into a function



Subsequent patches will support DIF and DIX in NVMe Perf and
will make buffer management a little complex. This patch tries
to make them a little easier.

Change-Id: I3e0e3e03ca386467c7477e1ec8aa537ca47316e2
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/437903


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent fa0129c0
Loading
Loading
Loading
Loading
+28 −20
Original line number Diff line number Diff line
@@ -756,22 +756,20 @@ check_io(struct ns_worker_ctx *ns_ctx)
	}
}

static void
submit_io(struct ns_worker_ctx *ns_ctx, int queue_depth)
static struct perf_task *
allocate_task(struct ns_worker_ctx *ns_ctx, int queue_depth)
{
	struct perf_task *task;
	uint32_t max_io_size_bytes;

	while (queue_depth-- > 0) {
	task = calloc(1, sizeof(*task));
	if (task == NULL) {
		fprintf(stderr, "Out of memory allocating tasks\n");
		exit(1);
	}

		/* maximum extended lba format size from all active
		 * namespace, it's same with g_io_size_bytes for
		 * namespace without metadata
	/* maximum extended lba format size from all active namespace,
	 * it's same with g_io_size_bytes for namespace without metadata.
	 */
	max_io_size_bytes = g_io_size_bytes + g_max_io_md_size * g_max_io_size_blocks;
	task->buf = spdk_dma_zmalloc(max_io_size_bytes, g_io_align, NULL);
@@ -783,6 +781,16 @@ submit_io(struct ns_worker_ctx *ns_ctx, int queue_depth)

	task->ns_ctx = ns_ctx;

	return task;
}

static void
submit_io(struct ns_worker_ctx *ns_ctx, int queue_depth)
{
	struct perf_task *task;

	while (queue_depth-- > 0) {
		task = allocate_task(ns_ctx, queue_depth);
		submit_single_io(task);
	}
}