diff --git a/scst/include/backport.h b/scst/include/backport.h index 4b2712bcb..51d5ffeac 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -26,6 +26,7 @@ #include /* struct bsg_job */ #endif #include +#include #include /* struct scatterlist */ #include /* kmalloc() */ #include /* sizeof_field() */ @@ -405,6 +406,39 @@ static inline ssize_t call_write_iter(struct file *file, struct kiocb *kio, } #endif +/* */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) || \ + LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0) + +static inline struct io_context * +scst_get_task_io_context(struct task_struct *task, + gfp_t gfp_flags, int node) +{ + return NULL; +} + +static inline void scst_put_io_context(struct io_context *ioc) +{ +} + +static inline void scst_ioc_task_link(struct io_context *ioc) +{ +} + +#define get_task_io_context scst_get_task_io_context +#define put_io_context scst_put_io_context +#define ioc_task_link scst_ioc_task_link + +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) +static inline struct io_context *get_task_io_context(struct task_struct *task, + gfp_t gfp_flags, int node) +{ + WARN_ON_ONCE(task != current); + return get_io_context(gfp_flags, node); +} +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index a88edb1c6..969d3c1c4 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5012,13 +5012,7 @@ static int scst_ioc_keeper_thread(void *arg) sBUG_ON(aic_keeper->aic != NULL); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) aic_keeper->aic = get_task_io_context(current, GFP_KERNEL, NUMA_NO_NODE); -#else - aic_keeper->aic = get_io_context(GFP_KERNEL, -1); -#endif -#endif TRACE_DBG("Alloced new async IO context %p (aic %p)", aic_keeper->aic, aic_keeper); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 79c02cbbf..d617ed949 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -241,7 +241,7 @@ struct scst_cmd_thread_t { }; static inline bool scst_set_io_context(struct scst_cmd *cmd, - struct io_context **old) + struct io_context **old) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) return false; @@ -253,7 +253,8 @@ static inline bool scst_set_io_context(struct scst_cmd *cmd, EXTRACHECKS_BUG_ON(old == NULL); - if (cmd->cmd_threads == &scst_main_cmd_threads) { + if (cmd->cmd_threads == &scst_main_cmd_threads && + cmd->tgt_dev->async_io_context) { EXTRACHECKS_BUG_ON(in_interrupt()); /* * No need for any ref counting action, because io_context @@ -265,8 +266,9 @@ static inline bool scst_set_io_context(struct scst_cmd *cmd, TRACE_DBG("io_context %p (tgt_dev %p)", current->io_context, cmd->tgt_dev); EXTRACHECKS_BUG_ON(current->io_context == NULL); - } else + } else { res = false; + } return res; #endif diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 6379d9e56..6d48f1163 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -5344,12 +5344,8 @@ static void scst_ioctx_get(struct scst_cmd_threads *p_cmd_threads) * io_context 0. */ if (p_cmd_threads->io_context == NULL) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) p_cmd_threads->io_context = get_task_io_context(current, GFP_KERNEL, NUMA_NO_NODE); -#else - p_cmd_threads->io_context = get_io_context(GFP_KERNEL, -1); -#endif TRACE_DBG("Alloced new IO context %p " "(p_cmd_threads %p)", p_cmd_threads->io_context, p_cmd_threads);