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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/437903 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
fa0129c0e2
commit
70d096e775
@ -756,33 +756,41 @@ check_io(struct ns_worker_ctx *ns_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static struct perf_task *
|
||||||
submit_io(struct ns_worker_ctx *ns_ctx, int queue_depth)
|
allocate_task(struct ns_worker_ctx *ns_ctx, int queue_depth)
|
||||||
{
|
{
|
||||||
struct perf_task *task;
|
struct perf_task *task;
|
||||||
uint32_t max_io_size_bytes;
|
uint32_t max_io_size_bytes;
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
if (task->buf == NULL) {
|
||||||
|
fprintf(stderr, "task->buf spdk_dma_zmalloc failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
memset(task->buf, queue_depth % 8 + 1, max_io_size_bytes);
|
||||||
|
|
||||||
|
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) {
|
while (queue_depth-- > 0) {
|
||||||
task = calloc(1, sizeof(*task));
|
task = allocate_task(ns_ctx, queue_depth);
|
||||||
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
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
if (task->buf == NULL) {
|
|
||||||
fprintf(stderr, "task->buf spdk_dma_zmalloc failed\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
memset(task->buf, queue_depth % 8 + 1, max_io_size_bytes);
|
|
||||||
|
|
||||||
task->ns_ctx = ns_ctx;
|
|
||||||
|
|
||||||
submit_single_io(task);
|
submit_single_io(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user