mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-17 10:41:26 +00:00
scst: Port to Linux kernel v4.8
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6991 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -6519,8 +6519,10 @@ static void blockio_endio(struct bio *bio)
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
|
||||
if (bio->bi_rw & (1 << BIO_RW))
|
||||
#else
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
if (bio->bi_rw & REQ_WRITE)
|
||||
#else
|
||||
if (bio_op(bio) == REQ_OP_WRITE)
|
||||
#endif
|
||||
scst_set_cmd_error(blockio_work->cmd,
|
||||
SCST_LOAD_SENSE(scst_sense_write_error));
|
||||
@@ -6551,16 +6553,22 @@ static void vdisk_bio_set_failfast(struct bio *bio)
|
||||
bio->bi_rw |= (1 << BIO_RW_FAILFAST_DEV) |
|
||||
(1 << BIO_RW_FAILFAST_TRANSPORT) |
|
||||
(1 << BIO_RW_FAILFAST_DRIVER);
|
||||
#else
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_rw |= REQ_FAILFAST_DEV |
|
||||
REQ_FAILFAST_TRANSPORT |
|
||||
REQ_FAILFAST_DRIVER;
|
||||
#else
|
||||
bio->bi_opf |= REQ_FAILFAST_DEV |
|
||||
REQ_FAILFAST_TRANSPORT |
|
||||
REQ_FAILFAST_DRIVER;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vdisk_bio_set_hoq(struct bio *bio)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || \
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_opf |= REQ_SYNC;
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || \
|
||||
(defined(RHEL_MAJOR) && \
|
||||
(RHEL_MAJOR -0 > 6 || RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 > 0))
|
||||
bio->bi_rw |= REQ_SYNC;
|
||||
@@ -6569,7 +6577,9 @@ static void vdisk_bio_set_hoq(struct bio *bio)
|
||||
#else
|
||||
bio->bi_rw |= 1 << BIO_RW_SYNC;
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || \
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_opf |= REQ_META;
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || \
|
||||
(defined(RHEL_MAJOR) && \
|
||||
(RHEL_MAJOR -0 > 6 || RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 > 0))
|
||||
bio->bi_rw |= REQ_META;
|
||||
@@ -6819,6 +6829,14 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua)
|
||||
bio->bi_private = blockio_work;
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 6, 0))
|
||||
bio->bi_destructor = blockio_bio_destructor;
|
||||
#endif
|
||||
if (write)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
|
||||
bio->bi_rw |= (1 << BIO_RW);
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_rw |= REQ_WRITE;
|
||||
#else
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
#endif
|
||||
/*
|
||||
* Better to fail fast w/o any local recovery
|
||||
@@ -6830,7 +6848,11 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua)
|
||||
bio->bi_rw |= REQ_SYNC;
|
||||
#endif
|
||||
if (fua)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_rw |= REQ_FUA;
|
||||
#else
|
||||
bio->bi_opf |= REQ_FUA;
|
||||
#endif
|
||||
|
||||
if (cmd->queue_type == SCST_CMD_QUEUE_HEAD_OF_QUEUE)
|
||||
vdisk_bio_set_hoq(bio);
|
||||
@@ -6883,7 +6905,11 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua)
|
||||
hbio = hbio->bi_next;
|
||||
bio->bi_next = NULL;
|
||||
|
||||
submit_bio((write != 0), bio);
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
submit_bio(bio->bi_rw, bio);
|
||||
#else
|
||||
submit_bio(bio);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
|
||||
@@ -6974,7 +7000,12 @@ static int vdisk_blockio_flush(struct block_device *bdev, gfp_t gfp_mask,
|
||||
bio->bi_end_io = vdev_flush_end_io;
|
||||
bio->bi_private = cmd;
|
||||
bio->bi_bdev = bdev;
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
submit_bio(WRITE_FLUSH, bio);
|
||||
#else
|
||||
bio_set_op_attrs(bio, REQ_OP_FLUSH, 0);
|
||||
submit_bio(bio);
|
||||
#endif
|
||||
goto out;
|
||||
} else {
|
||||
#else
|
||||
@@ -7114,7 +7145,11 @@ static ssize_t blockio_read_sync(struct scst_vdisk_dev *virt_dev, void *buf,
|
||||
if (!bio)
|
||||
goto out;
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_rw = READ_SYNC;
|
||||
#else
|
||||
bio_set_op_attrs(bio, REQ_OP_READ, REQ_SYNC);
|
||||
#endif
|
||||
bio->bi_bdev = bdev;
|
||||
bio->bi_end_io = blockio_end_sync_io;
|
||||
bio->bi_private = &s;
|
||||
@@ -7141,7 +7176,11 @@ static ssize_t blockio_read_sync(struct scst_vdisk_dev *virt_dev, void *buf,
|
||||
}
|
||||
}
|
||||
}
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
submit_bio(bio->bi_rw, bio);
|
||||
#else
|
||||
submit_bio(bio);
|
||||
#endif
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 6, 0))
|
||||
submitted = true;
|
||||
#endif
|
||||
|
||||
@@ -7803,6 +7803,34 @@ static void bio_kmalloc_destructor(struct bio *bio)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
|
||||
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);
|
||||
|
||||
if (IS_ERR(rq))
|
||||
return rq;
|
||||
|
||||
blk_rq_set_block_pc(rq);
|
||||
|
||||
for_each_bio(bio) {
|
||||
struct bio *bounce_bio = bio;
|
||||
int ret;
|
||||
|
||||
blk_queue_bounce(q, &bounce_bio);
|
||||
ret = blk_rq_append_bio(rq, bounce_bio);
|
||||
if (unlikely(ret)) {
|
||||
blk_put_request(rq);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return rq;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* __blk_map_kern_sg - map kernel data to a request for REQ_TYPE_BLOCK_PC */
|
||||
static struct request *__blk_map_kern_sg(struct request_queue *q,
|
||||
struct scatterlist *sgl, int nents, struct blk_kern_sg_work *bw,
|
||||
@@ -7885,8 +7913,10 @@ static struct request *__blk_map_kern_sg(struct request_queue *q,
|
||||
if (!reading)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
|
||||
bio->bi_rw |= 1 << BIO_RW;
|
||||
#else
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
bio->bi_rw |= REQ_WRITE;
|
||||
#else
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
#endif
|
||||
bios++;
|
||||
bio->bi_private = bw;
|
||||
|
||||
Reference in New Issue
Block a user