@@ -82,7 +82,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
8282{
8383 unsigned char cmd [6 ] = { TEST_UNIT_READY };
8484 struct scsi_sense_hdr sshdr ;
85- int ret = SCSI_DH_OK , res ;
85+ int ret , res ;
8686 blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
8787 REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER ;
8888 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)
9292retry :
9393 res = scsi_execute_cmd (sdev , cmd , opf , NULL , 0 , HP_SW_TIMEOUT ,
9494 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 ) {
10598 h -> path_state = HP_SW_PATH_ACTIVE ;
10699 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 ;
107105 }
106+
108107 if (ret == SCSI_DH_IMM_RETRY )
109108 goto retry ;
110109
@@ -122,7 +121,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
122121 unsigned char cmd [6 ] = { START_STOP , 0 , 0 , 0 , 1 , 0 };
123122 struct scsi_sense_hdr sshdr ;
124123 struct scsi_device * sdev = h -> sdev ;
125- int res , rc = SCSI_DH_OK ;
124+ int res , rc ;
126125 int retry_cnt = HP_SW_RETRIES ;
127126 blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV |
128127 REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER ;
@@ -133,35 +132,37 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
133132retry :
134133 res = scsi_execute_cmd (sdev , cmd , opf , NULL , 0 , HP_SW_TIMEOUT ,
135134 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 ;
163156 }
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 ;
164164 }
165+
165166 return rc ;
166167}
167168
0 commit comments