From d3a4f1d79f830c0b39a9ade1889d62b7ad4cae5a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 5 Oct 2017 16:57:27 +0000 Subject: [PATCH] scst: Port to openSUSE Leap 42.x git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7242 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 8 +++++-- scst/src/dev_handlers/scst_user.c | 4 +++- scst/src/dev_handlers/scst_vdisk.c | 38 ++++++++++++++++++++++-------- scst/src/scst_lib.c | 11 ++++++--- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index c7fd7909f..3aeb67771 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -238,7 +238,9 @@ static inline struct inode *file_inode(const struct file *f) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) static inline ssize_t vfs_readv_backport(struct file *file, const struct iovec __user *vec, unsigned long vlen, loff_t *pos, @@ -430,7 +432,9 @@ static inline bool list_entry_in_list(const struct list_head *entry) /* */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) static inline long get_user_pages_backport(unsigned long start, unsigned long nr_pages, int write, int force, diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 5decbc2da..c2dd44aec 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -1272,7 +1272,9 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff, (ucmd->cmd != NULL) ? ucmd->cmd->bufflen : -1); down_read(&tsk->mm->mmap_sem); -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) rc = get_user_pages(ubuff, ucmd->num_data_pages, 1/*writable*/, 0/*don't force*/, ucmd->data_pages, NULL); #else diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 67646e93b..3e5efddfc 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -6601,7 +6601,9 @@ static void blockio_endio(struct bio *bio) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) if (bio->bi_rw & (1 << BIO_RW)) { -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#elif (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) if (bio->bi_rw & REQ_WRITE) { #else if (op_is_write(bio_op(bio))) { @@ -6641,7 +6643,9 @@ 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); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#elif (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) bio->bi_rw |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; @@ -6654,7 +6658,8 @@ static void vdisk_bio_set_failfast(struct bio *bio) static void vdisk_bio_set_hoq(struct bio *bio) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || \ +defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) bio->bi_opf |= REQ_SYNC; #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || \ (defined(RHEL_MAJOR) && \ @@ -6665,7 +6670,8 @@ static void vdisk_bio_set_hoq(struct bio *bio) #else bio->bi_rw |= 1 << BIO_RW_SYNC; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || \ +defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) bio->bi_opf |= REQ_META; #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || \ (defined(RHEL_MAJOR) && \ @@ -6921,7 +6927,9 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) 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) +#elif (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) bio->bi_rw |= REQ_WRITE; #else bio_set_op_attrs(bio, REQ_OP_WRITE, 0); @@ -6936,7 +6944,9 @@ 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) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) bio->bi_rw |= REQ_FUA; #else bio->bi_opf |= REQ_FUA; @@ -6993,7 +7003,9 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) hbio = hbio->bi_next; bio->bi_next = NULL; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) submit_bio(bio->bi_rw, bio); #else submit_bio(bio); @@ -7092,7 +7104,9 @@ 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) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) submit_bio(WRITE_FLUSH, bio); #else bio_set_op_attrs(bio, REQ_OP_FLUSH, 0); @@ -7241,7 +7255,9 @@ 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) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) bio->bi_rw = READ_SYNC; #else bio_set_op_attrs(bio, REQ_OP_READ, REQ_SYNC); @@ -7272,7 +7288,9 @@ static ssize_t blockio_read_sync(struct scst_vdisk_dev *virt_dev, void *buf, } } } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) submit_bio(bio->bi_rw, bio); #else submit_bio(bio); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 0c9e3e7fd..8bf237ef1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -7851,7 +7851,8 @@ static void bio_kmalloc_destructor(struct bio *bio) } #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || \ +(defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) static struct request *blk_make_request(struct request_queue *q, struct bio *bio, gfp_t gfp_mask) @@ -7976,7 +7977,9 @@ 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; -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#elif (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) bio->bi_rw |= REQ_WRITE; #else bio_set_op_attrs(bio, REQ_OP_WRITE, 0); @@ -8042,7 +8045,9 @@ static struct request *__blk_map_kern_sg(struct request_queue *q, if (bw != NULL) { atomic_set(&bw->bios_inflight, bios); -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) +#if (!defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) /* * See also patch "block: split out request-only flags into a * new namespace" (commit e806402130c9).