From: Hannes Reinecke <hare@suse.de>
Subject: Always send STPG for explicit tgps mode
Patch-mainline: not yet

When we are in explicit tgps mode we should always send an STPG
command to enable the active/optimized mode.

Signed-off-by: Hannes Reinecke <hare@suse.de>

---
 drivers/scsi/device_handler/scsi_dh_alua.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -602,13 +602,11 @@ static int alua_activate(struct scsi_dev
 	struct alua_dh_data *h = get_alua_data(sdev);
 	int err = SCSI_DH_OK;
 
-	if (h->group_id != -1) {
-		err = alua_rtpg(sdev, h);
-		if (err != SCSI_DH_OK)
-			goto out;
-	}
+	err = alua_rtpg(sdev, h);
+	if (err != SCSI_DH_OK)
+		goto out;
 
-	if (h->tpgs & TPGS_MODE_EXPLICIT &&
+	if ((h->tpgs & TPGS_MODE_EXPLICIT) &&
	    h->state != TPGS_STATE_OPTIMIZED &&
	    h->state != TPGS_STATE_LBA_DEPENDENT) {
 		h->callback_fn = fn;
