All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: core: Add a helper for retry scsi cmnd
@ 2022-12-08  9:03 Wu Bo
  0 siblings, 0 replies; only message in thread
From: Wu Bo @ 2022-12-08  9:03 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen, linux-scsi
  Cc: qiuchangqi.qiu, wubo40

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 --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",
-- 
2.33.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-08  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08  9:03 [PATCH] scsi: core: Add a helper for retry scsi cmnd Wu Bo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.