diff --git a/qla2x00t/qla_bsg.c b/qla2x00t/qla_bsg.c index cfa98919d..4e3070f66 100644 --- a/qla2x00t/qla_bsg.c +++ b/qla2x00t/qla_bsg.c @@ -25,11 +25,16 @@ static inline void set_bsg_result(struct bsg_job *job, int result) { job->req->errors = result; } -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) static inline void set_bsg_result(struct bsg_job *job, int result) { scsi_req(job->req)->result = result; } +#else +static inline void set_bsg_result(struct bsg_job *job, int result) +{ + scsi_req(blk_mq_rq_from_pdu(job))->result = result; +} #endif #ifndef NEW_LIBFC_API @@ -893,7 +898,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job) ql_log(ql_log_warn, vha, 0x702c, "Vendor request %s failed.\n", type); - fw_sts_ptr = ((uint8_t *)scsi_req(bsg_job->req)->sense) + + fw_sts_ptr = bsg_job_sense(bsg_job) + sizeof(struct fc_bsg_reply); memcpy(fw_sts_ptr, response, sizeof(response)); @@ -909,7 +914,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job) sizeof(response) + sizeof(uint8_t); bsg_reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; - fw_sts_ptr = ((uint8_t *)scsi_req(bsg_job->req)->sense) + + fw_sts_ptr = bsg_job_sense(bsg_job) + sizeof(struct fc_bsg_reply); memcpy(fw_sts_ptr, response, sizeof(response)); fw_sts_ptr += sizeof(response); diff --git a/qla2x00t/qla_isr.c b/qla2x00t/qla_isr.c index e93ea31b4..e79ae7a96 100644 --- a/qla2x00t/qla_isr.c +++ b/qla2x00t/qla_isr.c @@ -1228,7 +1228,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, type, sp->handle, comp_status, fw_status[1], fw_status[2], le16_to_cpu(((struct els_sts_entry_24xx *) pkt)->total_byte_count)); - fw_sts_ptr = ((uint8_t*)scsi_req(bsg_job->req)->sense) + + fw_sts_ptr = bsg_job_sense(bsg_job) + sizeof(struct fc_bsg_reply); memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); } @@ -1246,7 +1246,7 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req, #else bsg_reply->reply_payload_rcv_len = 0; #endif - fw_sts_ptr = ((uint8_t*)scsi_req(bsg_job->req)->sense) + + fw_sts_ptr = bsg_job_sense(bsg_job) + sizeof(struct fc_bsg_reply); memcpy( fw_sts_ptr, fw_status, sizeof(fw_status)); } diff --git a/scst/include/backport.h b/scst/include/backport.h index 2fd1fe847..21344c67e 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -22,6 +22,9 @@ #include #include /* struct request_queue */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) +#include /* struct bsg_job */ +#endif #include /* struct scatterlist */ #include /* kmalloc() */ #include @@ -29,6 +32,7 @@ #include /* sync_page_range() */ #include #include /* struct scsi_cmnd */ +#include /* struct fc_bsg_job */ /* */ @@ -90,6 +94,34 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) } #endif +/* */ + +/* + * Note: the function bsg_job_sense() exists only in SCST but not in any + * upstream kernel. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) && \ + ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) && \ + !defined(CONFIG_SUSE_KERNEL)) || \ + (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) && \ + defined(CONFIG_SUSE_KERNEL))) +static inline void *bsg_job_sense(struct fc_bsg_job *job) +{ + return job->req->sense; +} +#else +static inline void *bsg_job_sense(struct bsg_job *job) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + return job->req->sense; +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) + return scsi_req(job->req)->sense; +#else + return scsi_req(blk_mq_rq_from_pdu(job))->sense; +#endif +} +#endif + /* */ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20)