From 04e9eb82e88368f930d0fb8970c2b3e30ffd4321 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 3 Apr 2018 20:16:36 +0800 Subject: [PATCH] glusterfs: always allocate io_u->engine_data When the iodepth is greater then 1 some io_us in fio_gf_io_u_init() can be fooled into thinking their .engine_data has already been set when it hasn't. This happens because .index and .engine_data are part of the same union and .index can be set to non-zero values: static int init_io_u(struct thread_data *td) ... for (i = 0; i < max_units; i++) { ... io_u->index = i; ... if (td->io_ops->io_u_init) { int ret = td->io_ops->io_u_init(td, io_u); which means io_u->engine_data != 0 in fio_gf_io_u_init(). Fix the issue by removing the initial check of io_u->engine_data. Signed-off-by: Simon Gao --- engines/glusterfs_async.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/engines/glusterfs_async.c b/engines/glusterfs_async.c index 97271d67..eb8df453 100644 --- a/engines/glusterfs_async.c +++ b/engines/glusterfs_async.c @@ -70,20 +70,17 @@ static void fio_gf_io_u_free(struct thread_data *td, struct io_u *io_u) static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u) { + struct fio_gf_iou *io; dprint(FD_FILE, "%s\n", __FUNCTION__); - - if (!io_u->engine_data) { - struct fio_gf_iou *io; - - io = malloc(sizeof(struct fio_gf_iou)); - if (!io) { - td_verror(td, errno, "malloc"); - return 1; - } - io->io_complete = 0; - io->io_u = io_u; - io_u->engine_data = io; - } + + io = malloc(sizeof(struct fio_gf_iou)); + if (!io) { + td_verror(td, errno, "malloc"); + return 1; + } + io->io_complete = 0; + io->io_u = io_u; + io_u->engine_data = io; return 0; } -- 2.25.1