From f8954fe5f75102e7b9b22c8cb447dbefb6c6b9bf Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 29 Sep 2015 00:08:51 +0000 Subject: [PATCH] scst: Port to Linux kernel v4.3 Signed-off-by: Sebastian Herbszt git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6522 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 40 +++++++++++++++++++++++++----- scst/src/scst_lib.c | 11 ++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 939cc3afc..547eff2fc 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -6186,10 +6186,15 @@ static void blockio_bio_destructor(struct bio *bio) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) static int blockio_endio(struct bio *bio, unsigned int bytes_done, int error) -#else -static void blockio_endio(struct bio *bio, int error) -#endif { +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +static void blockio_endio(struct bio *bio, int error) +{ +#else +static void blockio_endio(struct bio *bio) +{ + int error = bio->bi_error; +#endif struct scst_blockio_work *blockio_work = bio->bi_private; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) @@ -6197,6 +6202,7 @@ static void blockio_endio(struct bio *bio, int error) return 1; #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) if (unlikely(!bio_flagged(bio, BIO_UPTODATE))) { if (error == 0) { PRINT_ERROR("Not up to date bio with error 0 for " @@ -6204,6 +6210,7 @@ static void blockio_endio(struct bio *bio, int error) error = -EIO; } } +#endif if (unlikely(error != 0)) { unsigned long flags; @@ -6454,7 +6461,11 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) #endif if (q) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) + max_nr_vecs = BIO_MAX_PAGES; +#else max_nr_vecs = min(bio_get_nr_vecs(bdev), BIO_MAX_PAGES); +#endif else max_nr_vecs = 1; @@ -6618,8 +6629,14 @@ finish_cmd: } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) static void vdev_flush_end_io(struct bio *bio, int error) { +#else +static void vdev_flush_end_io(struct bio *bio) +{ + int error = bio->bi_error; +#endif struct scst_cmd *cmd = bio->bi_private; TRACE_ENTRY(); @@ -6720,10 +6737,15 @@ static void blockio_bio_destructor_sync(struct bio *bio) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) static int blockio_end_sync_io(struct bio *bio, unsigned int bytes_done, int error) -#else -static void blockio_end_sync_io(struct bio *bio, int error) -#endif { +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +static void blockio_end_sync_io(struct bio *bio, int error) +{ +#else +static void blockio_end_sync_io(struct bio *bio) +{ + int error = bio->bi_error; +#endif struct bio_priv_sync *s = bio->bi_private; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) @@ -6731,10 +6753,12 @@ static void blockio_end_sync_io(struct bio *bio, int error) return 1; #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) if (!bio_flagged(bio, BIO_UPTODATE) && error == 0) { PRINT_ERROR("Not up to date bio with error 0; returning -EIO"); error = -EIO; } +#endif s->error = error; complete(&s->c); @@ -6779,7 +6803,11 @@ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, bool submitted = false; #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) + max_nr_vecs = BIO_MAX_PAGES; +#else max_nr_vecs = min(bio_get_nr_vecs(bdev), BIO_MAX_PAGES); +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) bio = bio_alloc_bioset(GFP_KERNEL, max_nr_vecs, virt_dev->vdisk_bioset); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 53f2b71ca..a3b689a81 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6858,8 +6858,14 @@ static void blk_free_kern_sg_work(struct blk_kern_sg_work *bw) return; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) static void blk_bio_map_kern_endio(struct bio *bio, int err) { +#else +static void blk_bio_map_kern_endio(struct bio *bio) +{ + int err = bio->bi_error; +#endif struct blk_kern_sg_work *bw = bio->bi_private; if (bw != NULL) { @@ -7467,7 +7473,12 @@ out_free_unmap: while (bio) { b = bio; bio = bio->bi_next; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) b->bi_end_io(b, res); +#else + b->bi_error = res; + b->bi_end_io(b); +#endif } } rq->bio = NULL;