scst: Port to kernel v4.13

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7240 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2017-10-03 23:08:29 +00:00
parent 8d3f00f0ec
commit c0419026e3
4 changed files with 70 additions and 4 deletions
+14
View File
@@ -20,6 +20,7 @@
* GNU General Public License for more details.
*/
#include <linux/bio.h>
#include <linux/blkdev.h> /* struct request_queue */
#include <linux/scatterlist.h> /* struct scatterlist */
#include <linux/slab.h> /* kmalloc() */
@@ -45,6 +46,19 @@
#endif
#endif
/* <linux/bio.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
static inline struct bio_set *bioset_create_backport(unsigned int pool_size,
unsigned int front_pad,
int flags)
{
WARN_ON_ONCE(flags != 0);
return bioset_create(pool_size, front_pad);
}
#define bioset_create bioset_create_backport
#endif
/* <linux/blkdev.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
+15
View File
@@ -5499,6 +5499,7 @@ void scst_dev_inquiry_data_changed(struct scst_device *dev);
* allows exclusive wake ups of threads in LIFO order. We need it to let (yet)
* unneeded threads sleep and not pollute CPU cache by their stacks.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
static inline void prepare_to_wait_exclusive_head(wait_queue_head_t *q,
wait_queue_t *wait, int state)
{
@@ -5511,6 +5512,20 @@ static inline void prepare_to_wait_exclusive_head(wait_queue_head_t *q,
set_current_state(state);
spin_unlock_irqrestore(&q->lock, flags);
}
#else
static inline void prepare_to_wait_exclusive_head(struct wait_queue_head *wq_head,
struct wait_queue_entry *wq_entry, int state)
{
unsigned long flags;
wq_entry->flags |= WQ_FLAG_EXCLUSIVE;
spin_lock_irqsave(&wq_head->lock, flags);
if (list_empty(&wq_entry->entry))
__add_wait_queue(wq_head, wq_entry);
set_current_state(state);
spin_unlock_irqrestore(&wq_head->lock, flags);
}
#endif
/**
* wait_event_locked() - Wait until a condition becomes true.
+13 -1
View File
@@ -6563,7 +6563,11 @@ static void blockio_endio(struct bio *bio, int error)
#else
static void blockio_endio(struct bio *bio)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
int error = bio->bi_error;
#else
int error = blk_status_to_errno(bio->bi_status);
#endif
#endif
struct scst_blockio_work *blockio_work = bio->bi_private;
@@ -7039,7 +7043,11 @@ static void vdev_flush_end_io(struct bio *bio, int error)
#else
static void vdev_flush_end_io(struct bio *bio)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
int error = bio->bi_error;
#else
int error = blk_status_to_errno(bio->bi_status);
#endif
#endif
struct scst_cmd *cmd = bio->bi_private;
@@ -7155,7 +7163,11 @@ static void blockio_end_sync_io(struct bio *bio, int error)
#else
static void blockio_end_sync_io(struct bio *bio)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
int error = bio->bi_error;
#else
int error = blk_status_to_errno(bio->bi_status);
#endif
#endif
struct bio_priv_sync *s = bio->bi_private;
@@ -7788,7 +7800,7 @@ static int vdisk_create_bioset(struct scst_vdisk_dev *virt_dev)
EXTRACHECKS_BUG_ON(virt_dev->vdisk_bioset || !virt_dev->blockio);
/* Pool size doesn't really matter */
virt_dev->vdisk_bioset = bioset_create(2, 0);
virt_dev->vdisk_bioset = bioset_create(2, 0, 0);
if (virt_dev->vdisk_bioset == NULL) {
PRINT_ERROR("Failed to create bioset (dev %s)", virt_dev->name);
res = -ENOMEM;
+28 -3
View File
@@ -7705,7 +7705,11 @@ static void blk_bio_map_kern_endio(struct bio *bio, int err)
#else
static void blk_bio_map_kern_endio(struct bio *bio)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
int err = bio->bi_error;
#else
int err = blk_status_to_errno(bio->bi_status);
#endif
#endif
struct blk_kern_sg_work *bw = bio->bi_private;
@@ -7857,22 +7861,33 @@ static struct request *blk_make_request(struct request_queue *q,
if (IS_ERR(rq))
return rq;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#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);
#else
blk_rq_set_block_pc(rq);
#endif
for_each_bio(bio) {
struct bio *bounce_bio = bio;
int ret;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
struct bio *bounce_bio = bio;
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);
}
#else
ret = blk_rq_append_bio(rq, bio);
if (unlikely(ret)) {
blk_put_request(rq);
return ERR_PTR(ret);
}
#endif
}
return rq;
@@ -8071,7 +8086,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, 11, 0)
#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);
#else
rq->cmd_type = REQ_TYPE_BLOCK_PC;
@@ -8257,7 +8274,11 @@ out:
#endif /* !defined(SCSI_EXEC_REQ_FIFO_DEFINED) */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
static void scsi_end_async(struct request *req, int error)
#else
static void scsi_end_async(struct request *req, blk_status_t error)
#endif
{
struct scsi_io_context *sioc = req->end_io_data;
@@ -8406,7 +8427,11 @@ out_free_unmap:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
b->bi_end_io(b, res);
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
b->bi_error = res;
#else
b->bi_status = errno_to_blk_status(res);
#endif
b->bi_end_io(b);
#endif
}