@@ -82,7 +82,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
82
82
{
83
83
unsigned char cmd [6 ] = { TEST_UNIT_READY };
84
84
struct scsi_sense_hdr sshdr ;
85
- int ret = SCSI_DH_OK , res ;
85
+ int ret , res ;
86
86
blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
87
87
REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER ;
88
88
const struct scsi_exec_args exec_args = {
@@ -92,19 +92,18 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
92
92
retry :
93
93
res = scsi_execute_cmd (sdev , cmd , opf , NULL , 0 , HP_SW_TIMEOUT ,
94
94
HP_SW_RETRIES , & exec_args );
95
- if (res ) {
96
- if (scsi_sense_valid (& sshdr ))
97
- ret = tur_done (sdev , h , & sshdr );
98
- else {
99
- sdev_printk (KERN_WARNING , sdev ,
100
- "%s: sending tur failed with %x\n" ,
101
- HP_SW_NAME , res );
102
- ret = SCSI_DH_IO ;
103
- }
104
- } else {
95
+ if (res > 0 && scsi_sense_valid (& sshdr )) {
96
+ ret = tur_done (sdev , h , & sshdr );
97
+ } else if (res == 0 ) {
105
98
h -> path_state = HP_SW_PATH_ACTIVE ;
106
99
ret = SCSI_DH_OK ;
100
+ } else {
101
+ sdev_printk (KERN_WARNING , sdev ,
102
+ "%s: sending tur failed with %x\n" ,
103
+ HP_SW_NAME , res );
104
+ ret = SCSI_DH_IO ;
107
105
}
106
+
108
107
if (ret == SCSI_DH_IMM_RETRY )
109
108
goto retry ;
110
109
@@ -122,7 +121,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
122
121
unsigned char cmd [6 ] = { START_STOP , 0 , 0 , 0 , 1 , 0 };
123
122
struct scsi_sense_hdr sshdr ;
124
123
struct scsi_device * sdev = h -> sdev ;
125
- int res , rc = SCSI_DH_OK ;
124
+ int res , rc ;
126
125
int retry_cnt = HP_SW_RETRIES ;
127
126
blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
128
127
REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER ;
@@ -133,35 +132,37 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
133
132
retry :
134
133
res = scsi_execute_cmd (sdev , cmd , opf , NULL , 0 , HP_SW_TIMEOUT ,
135
134
HP_SW_RETRIES , & exec_args );
136
- if (res ) {
137
- if (!scsi_sense_valid (& sshdr )) {
138
- sdev_printk (KERN_WARNING , sdev ,
139
- "%s: sending start_stop_unit failed, "
140
- "no sense available\n" , HP_SW_NAME );
141
- return SCSI_DH_IO ;
142
- }
143
- switch (sshdr .sense_key ) {
144
- case NOT_READY :
145
- if (sshdr .asc == 0x04 && sshdr .ascq == 3 ) {
146
- /*
147
- * LUN not ready - manual intervention required
148
- *
149
- * Switch-over in progress, retry.
150
- */
151
- if (-- retry_cnt )
152
- goto retry ;
153
- rc = SCSI_DH_RETRY ;
154
- break ;
155
- }
156
- fallthrough ;
157
- default :
158
- sdev_printk (KERN_WARNING , sdev ,
159
- "%s: sending start_stop_unit failed, "
160
- "sense %x/%x/%x\n" , HP_SW_NAME ,
161
- sshdr .sense_key , sshdr .asc , sshdr .ascq );
162
- rc = SCSI_DH_IO ;
135
+ if (!res ) {
136
+ return SCSI_DH_OK ;
137
+ } else if (res < 0 || !scsi_sense_valid (& sshdr )) {
138
+ sdev_printk (KERN_WARNING , sdev ,
139
+ "%s: sending start_stop_unit failed, "
140
+ "no sense available\n" , HP_SW_NAME );
141
+ return SCSI_DH_IO ;
142
+ }
143
+
144
+ switch (sshdr .sense_key ) {
145
+ case NOT_READY :
146
+ if (sshdr .asc == 0x04 && sshdr .ascq == 3 ) {
147
+ /*
148
+ * LUN not ready - manual intervention required
149
+ *
150
+ * Switch-over in progress, retry.
151
+ */
152
+ if (-- retry_cnt )
153
+ goto retry ;
154
+ rc = SCSI_DH_RETRY ;
155
+ break ;
163
156
}
157
+ fallthrough ;
158
+ default :
159
+ sdev_printk (KERN_WARNING , sdev ,
160
+ "%s: sending start_stop_unit failed, "
161
+ "sense %x/%x/%x\n" , HP_SW_NAME ,
162
+ sshdr .sense_key , sshdr .asc , sshdr .ascq );
163
+ rc = SCSI_DH_IO ;
164
164
}
165
+
165
166
return rc ;
166
167
}
167
168
0 commit comments