Unverified Commit 88dd04ca authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12449 scsi: core: Avoid leaving shost->last_reset with stale value if EH does not run

Merge Pull Request from: @ci-robot 
 
PR sync from: Li Lingfeng <lilingfeng3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/EQOKDK4FA2OJG7POTACM6VAZ3RSIB2NJ/ 
Reset shost->last_reset if EH does not run and fix kabi broken.

Ewan D. Milne (1):
  scsi: core: Avoid leaving shost->last_reset with stale value if EH
    does not run

Li Lingfeng (1):
  scsi: fix kabi broken


-- 
2.31.1
 
https://gitee.com/openeuler/kernel/issues/IAZLRK 
 
Link:https://gitee.com/openeuler/kernel/pulls/12449

 

Reviewed-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents c8b75210 fc8455d1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -392,6 +392,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
	shost->shost_state = SHOST_CREATED;
	INIT_LIST_HEAD(&shost->__devices);
	INIT_LIST_HEAD(&shost->__targets);
	INIT_LIST_HEAD(&shost->eh_abort_list);
	INIT_LIST_HEAD(&shost->eh_cmd_q);
	INIT_LIST_HEAD(&shost->starved_list);
	init_waitqueue_head(&shost->host_wait);
+25 −0
Original line number Diff line number Diff line
@@ -124,6 +124,23 @@ static bool scsi_cmd_retry_allowed(struct scsi_cmnd *cmd)
	return ++cmd->retries <= cmd->allowed;
}

static void scsi_eh_complete_abort(struct scsi_cmnd *scmd, struct Scsi_Host *shost)
{
	unsigned long flags;

	spin_lock_irqsave(shost->host_lock, flags);
	list_del_init(&scmd->eh_entry);
	/*
	 * If the abort succeeds, and there is no further
	 * EH action, clear the ->last_reset time.
	 */
	if (list_empty(&shost->eh_abort_list) &&
	    list_empty(&shost->eh_cmd_q))
		if (shost->eh_deadline != -1)
			shost->last_reset = 0;
	spin_unlock_irqrestore(shost->host_lock, flags);
}

/**
 * scmd_eh_abort_handler - Handle command aborts
 * @work:	command to be aborted.
@@ -141,6 +158,7 @@ scmd_eh_abort_handler(struct work_struct *work)
		container_of(work, struct scsi_cmnd, abort_work.work);
	struct scsi_device *sdev = scmd->device;
	int rtn;
	unsigned long flags;

	if (scsi_host_eh_past_deadline(sdev->host)) {
		SCSI_LOG_ERROR_RECOVERY(3,
@@ -163,12 +181,14 @@ scmd_eh_abort_handler(struct work_struct *work)
				SCSI_LOG_ERROR_RECOVERY(3,
					scmd_printk(KERN_WARNING, scmd,
						    "retry aborted command\n"));
				scsi_eh_complete_abort(scmd, sdev->host);
				scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
				return;
			} else {
				SCSI_LOG_ERROR_RECOVERY(3,
					scmd_printk(KERN_WARNING, scmd,
						    "finish aborted command\n"));
				scsi_eh_complete_abort(scmd, sdev->host);
				scsi_finish_command(scmd);
				return;
			}
@@ -181,6 +201,9 @@ scmd_eh_abort_handler(struct work_struct *work)
		}
	}

	spin_lock_irqsave(sdev->host->host_lock, flags);
	list_del_init(&scmd->eh_entry);
	spin_unlock_irqrestore(sdev->host->host_lock, flags);
	scsi_eh_scmd_add(scmd);
}

@@ -211,6 +234,8 @@ scsi_abort_command(struct scsi_cmnd *scmd)
	spin_lock_irqsave(shost->host_lock, flags);
	if (shost->eh_deadline != -1 && !shost->last_reset)
		shost->last_reset = jiffies;
	BUG_ON(!list_empty(&scmd->eh_entry));
	list_add_tail(&scmd->eh_entry, &shost->eh_abort_list);
	spin_unlock_irqrestore(shost->host_lock, flags);

	scmd->eh_eflags |= SCSI_EH_ABORT_SCHEDULED;
+1 −0
Original line number Diff line number Diff line
@@ -1168,6 +1168,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
	cmd->sense_buffer = buf;
	cmd->prot_sdb = prot;
	cmd->flags = flags;
	INIT_LIST_HEAD(&cmd->eh_entry);
	INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
	cmd->jiffies_at_alloc = jiffies_at_alloc;
	cmd->retries = retries;
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ struct scsi_pointer {
struct scsi_cmnd {
	struct scsi_request req;
	struct scsi_device *device;
	struct list_head eh_entry; /* entry for the host eh_cmd_q */
	struct list_head eh_entry; /* entry for the host eh_abort_list/eh_cmd_q */
	struct delayed_work abort_work;

	struct rcu_head rcu;
+2 −2
Original line number Diff line number Diff line
@@ -699,8 +699,8 @@ struct Scsi_Host {
	struct device *dma_dev;

	KABI_USE(1, bool is_builtin)
	KABI_RESERVE(2)
	KABI_RESERVE(3)
	KABI_REPLACE(_KABI_RESERVE(2); _KABI_RESERVE(3),
			struct list_head eh_abort_list)
	KABI_RESERVE(4)
	KABI_RESERVE(5)
	KABI_RESERVE(6)