Skip to content

Commit 63ea923

Browse files
Armen BaloyanJames Bottomley
Armen Baloyan
authored and
James Bottomley
committed
[SCSI] qla2xxx: Properly set result field of bsg_job reply structure for success and failure.
FC transport on receiving bsg_job submission failure, calls bsg_job->job_done() and sets the bsg_job->reply->result the returned value. In contrast, when the success code (0) is returned fc transport doesn't call bsg_job->job_done() and doesn't populate bsg_job->reply->result. Signed-off-by: Steve Hodgson <[email protected]> Signed-off-by: Armen Baloyan <[email protected]> Signed-off-by: Saurav Kashyap <[email protected]> Cc: <[email protected]> #3.7 Signed-off-by: James Bottomley <[email protected]>
1 parent 691e3d3 commit 63ea923

File tree

1 file changed

+24
-41
lines changed

1 file changed

+24
-41
lines changed

drivers/scsi/qla2xxx/qla_bsg.c

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job)
219219
break;
220220
}
221221
exit_fcp_prio_cfg:
222-
bsg_job->job_done(bsg_job);
222+
if (!ret)
223+
bsg_job->job_done(bsg_job);
223224
return ret;
224225
}
225226

@@ -741,7 +742,6 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
741742
if (qla81xx_get_port_config(vha, config)) {
742743
ql_log(ql_log_warn, vha, 0x701f,
743744
"Get port config failed.\n");
744-
bsg_job->reply->result = (DID_ERROR << 16);
745745
rval = -EPERM;
746746
goto done_free_dma_req;
747747
}
@@ -761,7 +761,6 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
761761
new_config, elreq.options);
762762

763763
if (rval) {
764-
bsg_job->reply->result = (DID_ERROR << 16);
765764
rval = -EPERM;
766765
goto done_free_dma_req;
767766
}
@@ -795,7 +794,6 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
795794
"MPI reset failed.\n");
796795
}
797796

798-
bsg_job->reply->result = (DID_ERROR << 16);
799797
rval = -EIO;
800798
goto done_free_dma_req;
801799
}
@@ -812,33 +810,25 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
812810
ql_log(ql_log_warn, vha, 0x702c,
813811
"Vendor request %s failed.\n", type);
814812

815-
fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
816-
sizeof(struct fc_bsg_reply);
817-
818-
memcpy(fw_sts_ptr, response, sizeof(response));
819-
fw_sts_ptr += sizeof(response);
820-
*fw_sts_ptr = command_sent;
821813
rval = 0;
822814
bsg_job->reply->result = (DID_ERROR << 16);
815+
bsg_job->reply->reply_payload_rcv_len = 0;
823816
} else {
824817
ql_dbg(ql_dbg_user, vha, 0x702d,
825818
"Vendor request %s completed.\n", type);
826-
827-
bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
828-
sizeof(response) + sizeof(uint8_t);
829-
bsg_job->reply->reply_payload_rcv_len =
830-
bsg_job->reply_payload.payload_len;
831-
fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
832-
sizeof(struct fc_bsg_reply);
833-
memcpy(fw_sts_ptr, response, sizeof(response));
834-
fw_sts_ptr += sizeof(response);
835-
*fw_sts_ptr = command_sent;
836-
bsg_job->reply->result = DID_OK;
819+
bsg_job->reply->result = (DID_OK << 16);
837820
sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
838821
bsg_job->reply_payload.sg_cnt, rsp_data,
839822
rsp_data_len);
840823
}
841-
bsg_job->job_done(bsg_job);
824+
825+
bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
826+
sizeof(response) + sizeof(uint8_t);
827+
fw_sts_ptr = ((uint8_t *)bsg_job->req->sense) +
828+
sizeof(struct fc_bsg_reply);
829+
memcpy(fw_sts_ptr, response, sizeof(response));
830+
fw_sts_ptr += sizeof(response);
831+
*fw_sts_ptr = command_sent;
842832

843833
dma_free_coherent(&ha->pdev->dev, rsp_data_len,
844834
rsp_data, rsp_data_dma);
@@ -853,6 +843,8 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
853843
dma_unmap_sg(&ha->pdev->dev,
854844
bsg_job->request_payload.sg_list,
855845
bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
846+
if (!rval)
847+
bsg_job->job_done(bsg_job);
856848
return rval;
857849
}
858850

@@ -877,16 +869,15 @@ qla84xx_reset(struct fc_bsg_job *bsg_job)
877869
if (rval) {
878870
ql_log(ql_log_warn, vha, 0x7030,
879871
"Vendor request 84xx reset failed.\n");
880-
rval = 0;
881-
bsg_job->reply->result = (DID_ERROR << 16);
872+
rval = (DID_ERROR << 16);
882873

883874
} else {
884875
ql_dbg(ql_dbg_user, vha, 0x7031,
885876
"Vendor request 84xx reset completed.\n");
886877
bsg_job->reply->result = DID_OK;
878+
bsg_job->job_done(bsg_job);
887879
}
888880

889-
bsg_job->job_done(bsg_job);
890881
return rval;
891882
}
892883

@@ -976,8 +967,7 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
976967
ql_log(ql_log_warn, vha, 0x7037,
977968
"Vendor request 84xx updatefw failed.\n");
978969

979-
rval = 0;
980-
bsg_job->reply->result = (DID_ERROR << 16);
970+
rval = (DID_ERROR << 16);
981971
} else {
982972
ql_dbg(ql_dbg_user, vha, 0x7038,
983973
"Vendor request 84xx updatefw completed.\n");
@@ -986,7 +976,6 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
986976
bsg_job->reply->result = DID_OK;
987977
}
988978

989-
bsg_job->job_done(bsg_job);
990979
dma_pool_free(ha->s_dma_pool, mn, mn_dma);
991980

992981
done_free_fw_buf:
@@ -996,6 +985,8 @@ qla84xx_updatefw(struct fc_bsg_job *bsg_job)
996985
dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
997986
bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
998987

988+
if (!rval)
989+
bsg_job->job_done(bsg_job);
999990
return rval;
1000991
}
1001992

@@ -1163,8 +1154,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
11631154
ql_log(ql_log_warn, vha, 0x7043,
11641155
"Vendor request 84xx mgmt failed.\n");
11651156

1166-
rval = 0;
1167-
bsg_job->reply->result = (DID_ERROR << 16);
1157+
rval = (DID_ERROR << 16);
11681158

11691159
} else {
11701160
ql_dbg(ql_dbg_user, vha, 0x7044,
@@ -1184,8 +1174,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
11841174
}
11851175
}
11861176

1187-
bsg_job->job_done(bsg_job);
1188-
11891177
done_unmap_sg:
11901178
if (mgmt_b)
11911179
dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
@@ -1200,6 +1188,8 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
12001188
exit_mgmt:
12011189
dma_pool_free(ha->s_dma_pool, mn, mn_dma);
12021190

1191+
if (!rval)
1192+
bsg_job->job_done(bsg_job);
12031193
return rval;
12041194
}
12051195

@@ -1276,9 +1266,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
12761266
fcport->port_name[3], fcport->port_name[4],
12771267
fcport->port_name[5], fcport->port_name[6],
12781268
fcport->port_name[7], rval, fcport->fp_speed, mb[0], mb[1]);
1279-
rval = 0;
1280-
bsg_job->reply->result = (DID_ERROR << 16);
1281-
1269+
rval = (DID_ERROR << 16);
12821270
} else {
12831271
if (!port_param->mode) {
12841272
bsg_job->reply_len = sizeof(struct fc_bsg_reply) +
@@ -1292,9 +1280,9 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
12921280
}
12931281

12941282
bsg_job->reply->result = DID_OK;
1283+
bsg_job->job_done(bsg_job);
12951284
}
12961285

1297-
bsg_job->job_done(bsg_job);
12981286
return rval;
12991287
}
13001288

@@ -1887,8 +1875,6 @@ qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job)
18871875
return qla24xx_process_bidir_cmd(bsg_job);
18881876

18891877
default:
1890-
bsg_job->reply->result = (DID_ERROR << 16);
1891-
bsg_job->job_done(bsg_job);
18921878
return -ENOSYS;
18931879
}
18941880
}
@@ -1919,8 +1905,6 @@ qla24xx_bsg_request(struct fc_bsg_job *bsg_job)
19191905
ql_dbg(ql_dbg_user, vha, 0x709f,
19201906
"BSG: ISP abort active/needed -- cmd=%d.\n",
19211907
bsg_job->request->msgcode);
1922-
bsg_job->reply->result = (DID_ERROR << 16);
1923-
bsg_job->job_done(bsg_job);
19241908
return -EBUSY;
19251909
}
19261910

@@ -1943,7 +1927,6 @@ qla24xx_bsg_request(struct fc_bsg_job *bsg_job)
19431927
case FC_BSG_RPT_CT:
19441928
default:
19451929
ql_log(ql_log_warn, vha, 0x705a, "Unsupported BSG request.\n");
1946-
bsg_job->reply->result = ret;
19471930
break;
19481931
}
19491932
return ret;

0 commit comments

Comments
 (0)