mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-21 20:51:27 +00:00
scst: Simplify blk_make_request() and blk_map_kern_sg()
For kernel versions >= 4.11.0, pass REQ_OP_SCSI_* as second argument to blk_get_request() instead of READ or WRITE and setting REQ_OP_SCSI_* later. For kernels < 4.11.0, instead of calling blk_rq_set_block_pc() directly, call it indirectly through scsi_req_init(). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7445 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -7955,7 +7955,14 @@ static struct request *blk_make_request(struct request_queue *q,
|
||||
struct bio *bio,
|
||||
gfp_t gfp_mask)
|
||||
{
|
||||
struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
|
||||
struct request *rq;
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
|
||||
rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
|
||||
#else
|
||||
rq = blk_get_request(q, bio_data_dir(bio) == READ ? REQ_OP_SCSI_IN :
|
||||
REQ_OP_SCSI_OUT, gfp_mask);
|
||||
#endif
|
||||
|
||||
if (IS_ERR(rq))
|
||||
return rq;
|
||||
@@ -7965,12 +7972,6 @@ static struct request *blk_make_request(struct request_queue *q,
|
||||
#else
|
||||
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;
|
||||
#else
|
||||
blk_rq_set_block_pc(rq);
|
||||
#endif
|
||||
|
||||
for_each_bio(bio) {
|
||||
int ret;
|
||||
@@ -8155,9 +8156,6 @@ static struct request *__blk_map_kern_sg(struct request_queue *q,
|
||||
*/
|
||||
rq->cmd_type = REQ_TYPE_BLOCK_PC;
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
rq->cmd_flags = reading ? REQ_OP_SCSI_IN : REQ_OP_SCSI_OUT;
|
||||
#endif
|
||||
|
||||
if (bw != NULL) {
|
||||
atomic_set(&bw->bios_inflight, bios);
|
||||
@@ -8203,7 +8201,12 @@ static struct request *blk_map_kern_sg(struct request_queue *q,
|
||||
struct request *rq;
|
||||
|
||||
if (!sgl) {
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
|
||||
rq = blk_get_request(q, reading ? READ : WRITE, gfp);
|
||||
#else
|
||||
rq = blk_get_request(q, reading ? REQ_OP_SCSI_IN :
|
||||
REQ_OP_SCSI_OUT, gfp);
|
||||
#endif
|
||||
if (unlikely(!rq))
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@@ -8211,9 +8214,6 @@ static struct request *blk_map_kern_sg(struct request_queue *q,
|
||||
scsi_req_init(scsi_req(rq));
|
||||
#else
|
||||
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;
|
||||
#endif
|
||||
goto out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user