Commit d54cdcb1 authored by Kou Jiawei's avatar Kou Jiawei Committed by Tomasz Zawadzki
Browse files

lun.c: Correctly handle bdev failure during LUN reset



Previously, the LUN reset completion logic did not correctly handle
the case where the underlying bdev reset operation itself failed.
The task response was not being set correctly, which could lead to
the `scsi_lun_complete_reset` function improperly proceeding to
check for outstanding tasks even after a failed reset.

This patch corrects the behavior by:
1. Setting the task response to `SPDK_SCSI_TASK_MGMT_RESP_COMPLETE`
   when the bdev reset operation is unsuccessful.
2. Ensuring that the poller to check for outstanding tasks is only
   registered if the reset operation was successful (`SUCCESS`).

This prevents incorrect logic execution paths and ensures that
management tasks are completed with the proper status.

Change-Id: Ie64b65d0988df60919fde3a71b2fbf460212cbaa
Signed-off-by: default avatarKou Jiawei <kou.jiawei@zte.com.cn>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26436


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Community-CI: Mellanox Build Bot
parent e91bb736
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ scsi_lun_reset_check_outstanding_tasks(void *arg)
void
scsi_lun_complete_reset_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *task)
{
	if (task->status == SPDK_SCSI_STATUS_GOOD) {
	if (task->response == SPDK_SCSI_TASK_MGMT_RESP_SUCCESS) {
		if (scsi_lun_has_outstanding_tasks(lun)) {
			lun->reset_poller =
				SPDK_POLLER_REGISTER(scsi_lun_reset_check_outstanding_tasks,
+2 −0
Original line number Diff line number Diff line
@@ -1145,6 +1145,8 @@ bdev_scsi_task_complete_reset(struct spdk_bdev_io *bdev_io, bool success,

	if (success) {
		task->response = SPDK_SCSI_TASK_MGMT_RESP_SUCCESS;
	} else {
		task->response = SPDK_SCSI_TASK_MGMT_RESP_COMPLETE;
	}

	scsi_lun_complete_reset_task(task->lun, task);