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) { }