]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: scsi_dh_alua: always use a 2 second delay before retrying RTPG
authorHannes Reinecke <hare@suse.de>
Fri, 12 Jul 2019 06:53:47 +0000 (08:53 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 17 Sep 2019 16:02:18 +0000 (18:02 +0200)
BugLink: https://bugs.launchpad.net/bugs/1840520
[ Upstream commit 20122994e38aef0ae50555884d287adde6641c94 ]

Retrying immediately after we've received a 'transitioning' sense code is
pretty much pointless, we should always use a delay before retrying.  So
ensure the default delay is applied before retrying.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Tested-by: Zhangguanghui <zhang.guanghui@h3c.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/scsi/device_handler/scsi_dh_alua.c

index b5437f348925328a03f4b3c0840531cfada01560..b13081d323c4a9b7b671105c3e33628999b1e9ba 100644 (file)
@@ -53,6 +53,7 @@
 #define ALUA_FAILOVER_TIMEOUT          60
 #define ALUA_FAILOVER_RETRIES          5
 #define ALUA_RTPG_DELAY_MSECS          5
+#define ALUA_RTPG_RETRY_DELAY          2
 
 /* device handler flags */
 #define ALUA_OPTIMIZE_STPG             0x01
@@ -677,7 +678,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
        case SCSI_ACCESS_STATE_TRANSITIONING:
                if (time_before(jiffies, pg->expiry)) {
                        /* State transition, retry */
-                       pg->interval = 2;
+                       pg->interval = ALUA_RTPG_RETRY_DELAY;
                        err = SCSI_DH_RETRY;
                } else {
                        struct alua_dh_data *h;
@@ -802,6 +803,8 @@ static void alua_rtpg_work(struct work_struct *work)
                                spin_lock_irqsave(&pg->lock, flags);
                                pg->flags &= ~ALUA_PG_RUNNING;
                                pg->flags |= ALUA_PG_RUN_RTPG;
+                               if (!pg->interval)
+                                       pg->interval = ALUA_RTPG_RETRY_DELAY;
                                spin_unlock_irqrestore(&pg->lock, flags);
                                queue_delayed_work(kaluad_wq, &pg->rtpg_work,
                                                   pg->interval * HZ);
@@ -813,6 +816,8 @@ static void alua_rtpg_work(struct work_struct *work)
                spin_lock_irqsave(&pg->lock, flags);
                if (err == SCSI_DH_RETRY || pg->flags & ALUA_PG_RUN_RTPG) {
                        pg->flags &= ~ALUA_PG_RUNNING;
+                       if (!pg->interval && !(pg->flags & ALUA_PG_RUN_RTPG))
+                               pg->interval = ALUA_RTPG_RETRY_DELAY;
                        pg->flags |= ALUA_PG_RUN_RTPG;
                        spin_unlock_irqrestore(&pg->lock, flags);
                        queue_delayed_work(kaluad_wq, &pg->rtpg_work,