diff mbox series

scsi: core: Add a helper for retry scsi cmnd

Message ID 1670490204-10239-1-git-send-email-wubo40@huawei.com
State New
Headers show
Series scsi: core: Add a helper for retry scsi cmnd | expand

Commit Message

Wu Bo Dec. 8, 2022, 9:03 a.m. UTC
From: Wu Bo <wubo40@huawei.com>

Without any functional modifications,
just adding a helper function for retry scsi cmnd.

Signed-off-by: Wu Bo <wubo40@huawei.com>
---
 drivers/scsi/scsi_error.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 6995c8979230..8fde072192dd 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -133,6 +133,16 @@  static bool scsi_eh_should_retry_cmd(struct scsi_cmnd *cmd)
 	return true;
 }
 
+static bool scsi_need_retry_cmd(struct scsi_cmnd *scmd)
+{
+	if (!scsi_noretry_cmd(scmd) &&
+	    scsi_cmd_retry_allowed(scmd) &&
+	    scsi_eh_should_retry_cmd(scmd))
+		return true;
+
+	return false;
+}
+
 /**
  * scmd_eh_abort_handler - Handle command aborts
  * @work:	command to be aborted.
@@ -195,9 +205,7 @@  scmd_eh_abort_handler(struct work_struct *work)
 
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
-	if (!scsi_noretry_cmd(scmd) &&
-	    scsi_cmd_retry_allowed(scmd) &&
-	    scsi_eh_should_retry_cmd(scmd)) {
+	if (scsi_need_retry_cmd(scmd)) {
 		SCSI_LOG_ERROR_RECOVERY(3,
 			scmd_printk(KERN_WARNING, scmd,
 				    "retry aborted command\n"));
@@ -2149,8 +2157,7 @@  void scsi_eh_flush_done_q(struct list_head *done_q)
 	list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
 		list_del_init(&scmd->eh_entry);
 		if (scsi_device_online(scmd->device) &&
-		    !scsi_noretry_cmd(scmd) && scsi_cmd_retry_allowed(scmd) &&
-			scsi_eh_should_retry_cmd(scmd)) {
+		    scsi_need_retry_cmd(scmd)) {
 			SCSI_LOG_ERROR_RECOVERY(3,
 				scmd_printk(KERN_INFO, scmd,
 					     "%s: flush retry cmd\n",