scst: Fix build for kernels 3.15 and older

blk_rq_set_block_pc() was introduced in kernel 3.16.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7262 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2017-11-13 16:18:00 +00:00
parent 1190cf1ea1
commit f8fab6fcab
2 changed files with 23 additions and 15 deletions

View File

@@ -746,4 +746,27 @@ static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd)
}
#endif
/* <scsi/scsi_request.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
static inline struct request *scsi_req(struct request *rq)
{
return rq;
}
static inline void scsi_req_init(struct request *rq)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
rq->cmd_type = REQ_TYPE_BLOCK_PC;
rq->__data_len = 0;
rq->__sector = (sector_t) -1;
rq->bio = rq->biotail = NULL;
memset(rq->__cmd, 0, sizeof(rq->__cmd));
rq->cmd = rq->__cmd;
#else
return blk_rq_set_block_pc(rq);
#endif
}
#endif
#endif /* _SCST_BACKPORT_H_ */

View File

@@ -7957,11 +7957,7 @@ static struct request *blk_make_request(struct request_queue *q,
if (IS_ERR(rq))
return rq;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
scsi_req_init(scsi_req(rq));
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
scsi_req_init(rq);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
rq->cmd_flags = bio_data_dir(bio) == READ ? REQ_OP_SCSI_IN :
REQ_OP_SCSI_OUT;
@@ -8193,15 +8189,9 @@ static struct request *blk_map_kern_sg(struct request_queue *q,
if (unlikely(!rq))
return ERR_PTR(-ENOMEM);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
scsi_req_init(scsi_req(rq));
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
scsi_req_init(rq);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
rq->cmd_flags = reading ? REQ_OP_SCSI_IN : REQ_OP_SCSI_OUT;
#else
blk_rq_set_block_pc(rq);
#endif
goto out;
}
@@ -8496,12 +8486,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data,
sioc->data = data;
sioc->done = done;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
req = scsi_req(rq);
#else
req = rq;
#endif
req->cmd_len = cmd_len;
if (req->cmd_len <= BLK_MAX_CDB) {
memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */