From b7adc8fe835e134f5670147d275fc81edf009b87 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 26 Nov 2018 12:03:38 +0900 Subject: [PATCH] scsi: Differentiate callback function about LUN reset from other TMFs Current SPDK SCSI supports only LUN RESET in task management function. Upcoming patches will support other functions too but differentiate the callback function about LUN reset from other task management functions for now to avoid misunderstanding. Change-Id: If8f00ce413fbcc54b12dd885cbf01597f83a2af9 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/434763 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/scsi/lun.c | 14 +++++++++++--- lib/scsi/scsi_bdev.c | 9 +++++---- lib/scsi/scsi_internal.h | 2 +- test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/scsi/lun.c b/lib/scsi/lun.c index 03ecd6fab..c43f355b0 100644 --- a/lib/scsi/lun.c +++ b/lib/scsi/lun.c @@ -50,10 +50,9 @@ spdk_scsi_lun_complete_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *ta } void -spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task) +spdk_scsi_lun_complete_reset_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task) { - if (task->function == SPDK_SCSI_TASK_FUNC_LUN_RESET && - task->status == SPDK_SCSI_STATUS_GOOD) { + if (task->status == SPDK_SCSI_STATUS_GOOD) { /* * The backend LUN device was just reset. If there are active tasks * in the backend, it means that LUN reset fails, and we set failure @@ -64,6 +63,15 @@ spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_tas task->response = SPDK_SCSI_TASK_MGMT_RESP_TARGET_FAILURE; } } + + task->cpl_fn(task); +} + +static void +spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task) +{ + assert(task->function != SPDK_SCSI_TASK_FUNC_LUN_RESET); + task->cpl_fn(task); } diff --git a/lib/scsi/scsi_bdev.c b/lib/scsi/scsi_bdev.c index 5190ef1b4..4b766bd6b 100644 --- a/lib/scsi/scsi_bdev.c +++ b/lib/scsi/scsi_bdev.c @@ -1284,8 +1284,8 @@ spdk_bdev_scsi_task_complete_cmd(struct spdk_bdev_io *bdev_io, bool success, } static void -spdk_bdev_scsi_task_complete_mgmt(struct spdk_bdev_io *bdev_io, bool success, - void *cb_arg) +spdk_bdev_scsi_task_complete_reset(struct spdk_bdev_io *bdev_io, bool success, + void *cb_arg) { struct spdk_scsi_task *task = cb_arg; @@ -1295,7 +1295,7 @@ spdk_bdev_scsi_task_complete_mgmt(struct spdk_bdev_io *bdev_io, bool success, task->response = SPDK_SCSI_TASK_MGMT_RESP_SUCCESS; } - spdk_scsi_lun_complete_mgmt_task(task->lun, task); + spdk_scsi_lun_complete_reset_task(task->lun, task); } static void @@ -2111,7 +2111,8 @@ spdk_bdev_scsi_reset(struct spdk_scsi_task *task) struct spdk_scsi_lun *lun = task->lun; int rc; - rc = spdk_bdev_reset(lun->bdev_desc, lun->io_channel, spdk_bdev_scsi_task_complete_mgmt, task); + rc = spdk_bdev_reset(lun->bdev_desc, lun->io_channel, spdk_bdev_scsi_task_complete_reset, + task); if (rc == -ENOMEM) { spdk_bdev_scsi_queue_io(task, spdk_bdev_scsi_reset_resubmit, task); } diff --git a/lib/scsi/scsi_internal.h b/lib/scsi/scsi_internal.h index ac57f65a0..3afca34f3 100644 --- a/lib/scsi/scsi_internal.h +++ b/lib/scsi/scsi_internal.h @@ -139,7 +139,7 @@ void spdk_scsi_lun_destruct(struct spdk_scsi_lun *lun); void spdk_scsi_lun_execute_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task); int spdk_scsi_lun_task_mgmt_execute(struct spdk_scsi_task *task); void spdk_scsi_lun_complete_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task); -void spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task); +void spdk_scsi_lun_complete_reset_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task); bool spdk_scsi_lun_has_pending_tasks(const struct spdk_scsi_lun *lun); int _spdk_scsi_lun_allocate_io_channel(struct spdk_scsi_lun *lun); void _spdk_scsi_lun_free_io_channel(struct spdk_scsi_lun *lun); diff --git a/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c b/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c index a1737f951..60c83ac5d 100644 --- a/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c +++ b/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c @@ -128,7 +128,7 @@ spdk_scsi_lun_complete_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *ta } void -spdk_scsi_lun_complete_mgmt_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task) +spdk_scsi_lun_complete_reset_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task) { }