Commit 5115fc7e authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi_dh_alua: use common definitions for ALUA state

scsi_proto.h now contains definitions for the ALUA state, so we don't
have to carry them in the device handler.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarBart van Assche <bart.vanassche@sandisk.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 77c9df96
...@@ -31,14 +31,6 @@ ...@@ -31,14 +31,6 @@
#define ALUA_DH_NAME "alua" #define ALUA_DH_NAME "alua"
#define ALUA_DH_VER "2.0" #define ALUA_DH_VER "2.0"
#define TPGS_STATE_OPTIMIZED 0x0
#define TPGS_STATE_NONOPTIMIZED 0x1
#define TPGS_STATE_STANDBY 0x2
#define TPGS_STATE_UNAVAILABLE 0x3
#define TPGS_STATE_LBA_DEPENDENT 0x4
#define TPGS_STATE_OFFLINE 0xe
#define TPGS_STATE_TRANSITIONING 0xf
#define TPGS_SUPPORT_NONE 0x00 #define TPGS_SUPPORT_NONE 0x00
#define TPGS_SUPPORT_OPTIMIZED 0x01 #define TPGS_SUPPORT_OPTIMIZED 0x01
#define TPGS_SUPPORT_NONOPTIMIZED 0x02 #define TPGS_SUPPORT_NONOPTIMIZED 0x02
...@@ -180,7 +172,7 @@ static int submit_stpg(struct scsi_device *sdev, int group_id, ...@@ -180,7 +172,7 @@ static int submit_stpg(struct scsi_device *sdev, int group_id,
/* Prepare the data buffer */ /* Prepare the data buffer */
memset(stpg_data, 0, stpg_len); memset(stpg_data, 0, stpg_len);
stpg_data[4] = TPGS_STATE_OPTIMIZED & 0x0f; stpg_data[4] = SCSI_ACCESS_STATE_OPTIMAL;
put_unaligned_be16(group_id, &stpg_data[6]); put_unaligned_be16(group_id, &stpg_data[6]);
/* Prepare the command. */ /* Prepare the command. */
...@@ -248,7 +240,7 @@ struct alua_port_group *alua_alloc_pg(struct scsi_device *sdev, ...@@ -248,7 +240,7 @@ struct alua_port_group *alua_alloc_pg(struct scsi_device *sdev,
} }
pg->group_id = group_id; pg->group_id = group_id;
pg->tpgs = tpgs; pg->tpgs = tpgs;
pg->state = TPGS_STATE_OPTIMIZED; pg->state = SCSI_ACCESS_STATE_OPTIMAL;
if (optimize_stpg) if (optimize_stpg)
pg->flags |= ALUA_OPTIMIZE_STPG; pg->flags |= ALUA_OPTIMIZE_STPG;
kref_init(&pg->kref); kref_init(&pg->kref);
...@@ -378,22 +370,22 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h, ...@@ -378,22 +370,22 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h,
return SCSI_DH_OK; return SCSI_DH_OK;
} }
static char print_alua_state(int state) static char print_alua_state(unsigned char state)
{ {
switch (state) { switch (state) {
case TPGS_STATE_OPTIMIZED: case SCSI_ACCESS_STATE_OPTIMAL:
return 'A'; return 'A';
case TPGS_STATE_NONOPTIMIZED: case SCSI_ACCESS_STATE_ACTIVE:
return 'N'; return 'N';
case TPGS_STATE_STANDBY: case SCSI_ACCESS_STATE_STANDBY:
return 'S'; return 'S';
case TPGS_STATE_UNAVAILABLE: case SCSI_ACCESS_STATE_UNAVAILABLE:
return 'U'; return 'U';
case TPGS_STATE_LBA_DEPENDENT: case SCSI_ACCESS_STATE_LBA:
return 'L'; return 'L';
case TPGS_STATE_OFFLINE: case SCSI_ACCESS_STATE_OFFLINE:
return 'O'; return 'O';
case TPGS_STATE_TRANSITIONING: case SCSI_ACCESS_STATE_TRANSITIONING:
return 'T'; return 'T';
default: default:
return 'X'; return 'X';
...@@ -647,7 +639,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) ...@@ -647,7 +639,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a'); valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a');
switch (pg->state) { switch (pg->state) {
case TPGS_STATE_TRANSITIONING: case SCSI_ACCESS_STATE_TRANSITIONING:
if (time_before(jiffies, pg->expiry)) { if (time_before(jiffies, pg->expiry)) {
/* State transition, retry */ /* State transition, retry */
pg->interval = 2; pg->interval = 2;
...@@ -655,11 +647,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) ...@@ -655,11 +647,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
} else { } else {
/* Transitioning time exceeded, set port to standby */ /* Transitioning time exceeded, set port to standby */
err = SCSI_DH_IO; err = SCSI_DH_IO;
pg->state = TPGS_STATE_STANDBY; pg->state = SCSI_ACCESS_STATE_STANDBY;
pg->expiry = 0; pg->expiry = 0;
} }
break; break;
case TPGS_STATE_OFFLINE: case SCSI_ACCESS_STATE_OFFLINE:
/* Path unusable */ /* Path unusable */
err = SCSI_DH_DEV_OFFLINED; err = SCSI_DH_DEV_OFFLINED;
pg->expiry = 0; pg->expiry = 0;
...@@ -693,20 +685,20 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg) ...@@ -693,20 +685,20 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)
return SCSI_DH_RETRY; return SCSI_DH_RETRY;
} }
switch (pg->state) { switch (pg->state) {
case TPGS_STATE_OPTIMIZED: case SCSI_ACCESS_STATE_OPTIMAL:
return SCSI_DH_OK; return SCSI_DH_OK;
case TPGS_STATE_NONOPTIMIZED: case SCSI_ACCESS_STATE_ACTIVE:
if ((pg->flags & ALUA_OPTIMIZE_STPG) && if ((pg->flags & ALUA_OPTIMIZE_STPG) &&
!pg->pref && !pg->pref &&
(pg->tpgs & TPGS_MODE_IMPLICIT)) (pg->tpgs & TPGS_MODE_IMPLICIT))
return SCSI_DH_OK; return SCSI_DH_OK;
break; break;
case TPGS_STATE_STANDBY: case SCSI_ACCESS_STATE_STANDBY:
case TPGS_STATE_UNAVAILABLE: case SCSI_ACCESS_STATE_UNAVAILABLE:
break; break;
case TPGS_STATE_OFFLINE: case SCSI_ACCESS_STATE_OFFLINE:
return SCSI_DH_IO; return SCSI_DH_IO;
case TPGS_STATE_TRANSITIONING: case SCSI_ACCESS_STATE_TRANSITIONING:
break; break;
default: default:
sdev_printk(KERN_INFO, sdev, sdev_printk(KERN_INFO, sdev,
...@@ -760,7 +752,7 @@ static void alua_rtpg_work(struct work_struct *work) ...@@ -760,7 +752,7 @@ static void alua_rtpg_work(struct work_struct *work)
pg->flags &= ~ALUA_PG_RUN_RTPG; pg->flags &= ~ALUA_PG_RUN_RTPG;
spin_unlock_irqrestore(&pg->lock, flags); spin_unlock_irqrestore(&pg->lock, flags);
if (state == TPGS_STATE_TRANSITIONING) { if (state == SCSI_ACCESS_STATE_TRANSITIONING) {
if (alua_tur(sdev) == SCSI_DH_RETRY) { if (alua_tur(sdev) == SCSI_DH_RETRY) {
spin_lock_irqsave(&pg->lock, flags); spin_lock_irqsave(&pg->lock, flags);
pg->flags &= ~ALUA_PG_RUNNING; pg->flags &= ~ALUA_PG_RUNNING;
...@@ -1006,7 +998,7 @@ static int alua_prep_fn(struct scsi_device *sdev, struct request *req) ...@@ -1006,7 +998,7 @@ static int alua_prep_fn(struct scsi_device *sdev, struct request *req)
{ {
struct alua_dh_data *h = sdev->handler_data; struct alua_dh_data *h = sdev->handler_data;
struct alua_port_group __rcu *pg; struct alua_port_group __rcu *pg;
int state = TPGS_STATE_OPTIMIZED; unsigned char state = SCSI_ACCESS_STATE_OPTIMAL;
int ret = BLKPREP_OK; int ret = BLKPREP_OK;
rcu_read_lock(); rcu_read_lock();
...@@ -1014,11 +1006,11 @@ static int alua_prep_fn(struct scsi_device *sdev, struct request *req) ...@@ -1014,11 +1006,11 @@ static int alua_prep_fn(struct scsi_device *sdev, struct request *req)
if (pg) if (pg)
state = pg->state; state = pg->state;
rcu_read_unlock(); rcu_read_unlock();
if (state == TPGS_STATE_TRANSITIONING) if (state == SCSI_ACCESS_STATE_TRANSITIONING)
ret = BLKPREP_DEFER; ret = BLKPREP_DEFER;
else if (state != TPGS_STATE_OPTIMIZED && else if (state != SCSI_ACCESS_STATE_OPTIMAL &&
state != TPGS_STATE_NONOPTIMIZED && state != SCSI_ACCESS_STATE_ACTIVE &&
state != TPGS_STATE_LBA_DEPENDENT) { state != SCSI_ACCESS_STATE_LBA) {
ret = BLKPREP_KILL; ret = BLKPREP_KILL;
req->cmd_flags |= REQ_QUIET; req->cmd_flags |= REQ_QUIET;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment