From 7145cf62c68cbf7c59b44cebf6b2e554b45ac3f6 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 12 May 2017 16:55:16 -0700 Subject: [PATCH] scsi: set free_fn in spdk_scsi_task_construct() The task free callback function is required, so make its assignment part of task construction. Change-Id: I2f5fdf73b064653ee85b4e7961cb1653a0a4107d Signed-off-by: Daniel Verkamp --- include/spdk/scsi.h | 1 + lib/iscsi/task.c | 2 +- lib/scsi/task.c | 4 ++++ lib/vhost/task.c | 3 +-- test/lib/scsi/lun/lun_ut.c | 3 +-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/spdk/scsi.h b/include/spdk/scsi.h index d2e9d2d6a..97ef2e9d6 100644 --- a/include/spdk/scsi.h +++ b/include/spdk/scsi.h @@ -213,6 +213,7 @@ const char *spdk_scsi_port_get_name(const struct spdk_scsi_port *port); void spdk_scsi_task_construct(struct spdk_scsi_task *task, uint32_t *owner_task_ctr, + void (*free_fn)(struct spdk_scsi_task *task), struct spdk_scsi_task *parent); void spdk_scsi_task_put(struct spdk_scsi_task *task); diff --git a/lib/iscsi/task.c b/lib/iscsi/task.c index 12c3e6501..f1d3c6735 100644 --- a/lib/iscsi/task.c +++ b/lib/iscsi/task.c @@ -59,11 +59,11 @@ spdk_iscsi_task_get(uint32_t *owner_task_ctr, struct spdk_iscsi_task *parent) memset(task, 0, sizeof(*task)); spdk_scsi_task_construct((struct spdk_scsi_task *)task, owner_task_ctr, + spdk_iscsi_task_free, (struct spdk_scsi_task *)parent); if (parent) { task->tag = parent->tag; } - task->scsi.free_fn = spdk_iscsi_task_free; return task; } diff --git a/lib/scsi/task.c b/lib/scsi/task.c index a00278e85..afc4f58dc 100644 --- a/lib/scsi/task.c +++ b/lib/scsi/task.c @@ -73,8 +73,12 @@ spdk_scsi_task_put(struct spdk_scsi_task *task) void spdk_scsi_task_construct(struct spdk_scsi_task *task, uint32_t *owner_task_ctr, + void (*free_fn)(struct spdk_scsi_task *task), struct spdk_scsi_task *parent) { + assert(free_fn != NULL); + task->free_fn = free_fn; + task->ref++; assert(owner_task_ctr != NULL); diff --git a/lib/vhost/task.c b/lib/vhost/task.c index 638304982..00ef01192 100644 --- a/lib/vhost/task.c +++ b/lib/vhost/task.c @@ -83,8 +83,7 @@ spdk_vhost_task_get(uint32_t *owner_task_ctr) } memset(task, 0, sizeof(*task)); - spdk_scsi_task_construct(&task->scsi, owner_task_ctr, NULL); - task->scsi.free_fn = spdk_vhost_task_free_cb; + spdk_scsi_task_construct(&task->scsi, owner_task_ctr, spdk_vhost_task_free_cb, NULL); return task; } diff --git a/test/lib/scsi/lun/lun_ut.c b/test/lib/scsi/lun/lun_ut.c index 6ff6afc6d..27e72e15f 100644 --- a/test/lib/scsi/lun/lun_ut.c +++ b/test/lib/scsi/lun/lun_ut.c @@ -86,8 +86,7 @@ spdk_get_task(uint32_t *owner_task_ctr) return NULL; } - spdk_scsi_task_construct(task, &g_task_count, NULL); - task->free_fn = spdk_lun_ut_free_task; + spdk_scsi_task_construct(task, &g_task_count, spdk_lun_ut_free_task, NULL); return task; }