diff --git a/iscsi-scst/kernel/isert-scst/iser.h b/iscsi-scst/kernel/isert-scst/iser.h index 082cf9cd4..65ae7e3db 100644 --- a/iscsi-scst/kernel/isert-scst/iser.h +++ b/iscsi-scst/kernel/isert-scst/iser.h @@ -36,10 +36,13 @@ #ifndef __ISER_H__ #define __ISER_H__ -#include #include #include #include +#ifndef INSIDE_KERNEL_TREE +#include +#endif + #if defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 5 static inline u16 vlan_dev_vlan_id(const void *dev) { diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index e24b5ecdb..bfc03f0d9 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -36,9 +36,11 @@ #include #include -#include #include #include +#ifndef INSIDE_KERNEL_TREE +#include +#endif #include "isert_dbg.h" #include "iser.h" diff --git a/iscsi-scst/kernel/isert-scst/isert.h b/iscsi-scst/kernel/isert-scst/isert.h index ee48c33ea..7a4554bce 100644 --- a/iscsi-scst/kernel/isert-scst/isert.h +++ b/iscsi-scst/kernel/isert-scst/isert.h @@ -43,7 +43,6 @@ #include #include #include -#include #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) #include @@ -55,6 +54,7 @@ #include #include #else +#include #include "isert_scst.h" #include "iscsi_scst.h" #endif diff --git a/iscsi-scst/kernel/isert-scst/isert_dbg.h b/iscsi-scst/kernel/isert-scst/isert_dbg.h index 4531b0c09..9bf2aba17 100644 --- a/iscsi-scst/kernel/isert-scst/isert_dbg.h +++ b/iscsi-scst/kernel/isert-scst/isert_dbg.h @@ -16,8 +16,6 @@ #ifndef ISERT_DBG_H #define ISERT_DBG_H -#include - #ifdef LOG_PREFIX #undef LOG_PREFIX #endif @@ -27,6 +25,7 @@ #ifdef INSIDE_KERNEL_TREE #include #else +#include #include #endif diff --git a/iscsi-scst/kernel/isert-scst/isert_login.c b/iscsi-scst/kernel/isert-scst/isert_login.c index f0220e958..a6ffea6af 100644 --- a/iscsi-scst/kernel/isert-scst/isert_login.c +++ b/iscsi-scst/kernel/isert-scst/isert_login.c @@ -39,7 +39,9 @@ #include /* error codes */ #include #include +#ifndef INSIDE_KERNEL_TREE #include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) #include #else diff --git a/iscsi-scst/kernel/session.c b/iscsi-scst/kernel/session.c index 19f9b4f84..6111b73d1 100644 --- a/iscsi-scst/kernel/session.c +++ b/iscsi-scst/kernel/session.c @@ -14,7 +14,9 @@ * GNU General Public License for more details. */ +#ifndef INSIDE_KERNEL_TREE #include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) #include #endif diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index debed3370..6f94728e9 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -22,10 +22,6 @@ #include #include #include -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) -#include -#endif #define LOG_PREFIX DEV_USER_NAME @@ -33,11 +29,16 @@ #include #include #else +#include #include "scst.h" #include "scst_user.h" #endif #include "scst_dev_handler.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif + #ifndef INSIDE_KERNEL_TREE #if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G) #warning HIGHMEM kernel configurations are not supported by this module, \ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index db750af52..40e4b038e 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1091,7 +1091,9 @@ check: if (virt_dev->unmap_opt_gran == virt_dev->unmap_align) virt_dev->unmap_align = 0; virt_dev->unmap_max_lba_cnt = q->limits.max_discard_sectors >> (block_shift - 9); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) virt_dev->discard_zeroes_data = q->limits.discard_zeroes_data; +#endif #else sBUG(); #endif diff --git a/scst/src/scst_debug.c b/scst/src/scst_debug.c index 8d36da1c7..3e5de31b0 100644 --- a/scst/src/scst_debug.c +++ b/scst/src/scst_debug.c @@ -19,8 +19,6 @@ * GNU General Public License for more details. */ -#include - #ifndef INSIDE_KERNEL_TREE #include #endif diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 4ec509bf0..ff2a0074b 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -11,7 +11,9 @@ #include #include #include +#ifndef INSIDE_KERNEL_TREE #include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) #include #endif diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 788a17351..735261405 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -33,7 +33,9 @@ #include #include #include +#ifndef INSIDE_KERNEL_TREE #include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) #include #endif @@ -43,10 +45,6 @@ #include #include -#ifndef INSIDE_KERNEL_TREE -#include -#endif - #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) #include #endif @@ -8366,7 +8364,7 @@ out: static void scsi_end_async(struct request *req, int error) { struct scsi_io_context *sioc = req->end_io_data; - int errors; + int result; TRACE_DBG("sioc %p, cmd %p, error %d / %d", sioc, sioc->data, error, req->errors); @@ -8378,20 +8376,31 @@ static void scsi_end_async(struct request *req, int error) lockdep_assert_held(req->q->queue_lock); #endif - errors = req->errors && !IS_ERR_VALUE((long)req->errors) ? req->errors : - IS_ERR_VALUE((long)req->errors) || error ? +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + result = scsi_req(req)->result; +#else + result = req->errors; +#endif + result = result && !IS_ERR_VALUE((long)result) ? result : + IS_ERR_VALUE((long)result) || error ? SAM_STAT_CHECK_CONDITION : 0; - if (sioc->done) + if (sioc->done) { + int resid_len; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) - sioc->done(sioc->data, sioc->sense, errors, - scsi_req(req)->resid_len); + resid_len = scsi_req(req)->resid_len; #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) - sioc->done(sioc->data, sioc->sense, errors, req->resid_len); -#else - sioc->done(sioc->data, sioc->sense, errors, req->data_len); + resid_len = req->resid_len; #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) + sioc->done(sioc->data, sioc->sense, result, resid_len); +#else + sioc->done(sioc->data, sioc->sense, result, req->data_len); +#endif + } + kmem_cache_free(scsi_io_context_cache, sioc); __blk_put_request(req->q, req); @@ -8479,7 +8488,11 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, req->sense = sioc->sense; req->sense_len = sizeof(sioc->sense); rq->timeout = cmd->timeout; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + req->retries = cmd->retries; +#else rq->retries = cmd->retries; +#endif rq->end_io_data = sioc; #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35) rq->cmd_flags |= REQ_FAILFAST_MASK;