From 43a252aef2a52eeada9b928b399da1fa862bd648 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 Mar 2019 02:54:31 +0000 Subject: [PATCH] scst, ib_srpt: Add support for kernel version v5.1 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8064 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 13 ++++++++++--- scst/src/scst_lib.c | 6 ++++++ scst_local/scst_local.c | 5 +++-- srpt/src/ib_srpt.c | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index f4f6ce8fa..4ecbe034c 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -902,6 +902,11 @@ static inline struct ib_pd *ib_alloc_pd_backport(struct ib_device *device) }) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) +#define ib_sg_dma_len(dev, sg) sg_dma_len(sg) +#define ib_sg_dma_address(dev, sg) sg_dma_address(sg) +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && \ @@ -1245,10 +1250,12 @@ static inline void *vzalloc(unsigned long size) /* */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) || \ + LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) /* - * See also patch "[SCSI] bidirectional command support" - * (commit ID 6f9a35e2dafa). + * See also patch "[SCSI] bidirectional command support" (commit ID + * 6f9a35e2dafa). See also commit ae3d56d81507 ("scsi: remove bidirectional + * command support") # v5.1. */ static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd) { diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 9c86e5be4..63ae3c320 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -8606,6 +8606,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, } if (cmd->data_direction == SCST_DATA_BIDI) { +#ifdef QUEUE_FLAG_BIDI struct request *next_rq; if (!test_bit(QUEUE_FLAG_BIDI, &q->queue_flags)) { @@ -8628,6 +8629,9 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, goto out_free_unmap; } rq->next_rq = next_rq; +#else + return -EOPNOTSUPP; +#endif } else { rq = blk_map_kern_sg(q, cmd->sg, cmd->sg_cnt, gfp, reading); if (IS_ERR(rq)) { @@ -8668,6 +8672,7 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, out: return res; +#ifdef QUEUE_FLAG_BIDI out_free_unmap: { struct bio *bio = rq->bio, *b; @@ -8690,6 +8695,7 @@ out_free_unmap: rq->bio = NULL; blk_put_request(rq); +#endif out_free_sioc: kmem_cache_free(scsi_io_context_cache, sioc); diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index d37afe927..9fa1e4209 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1010,7 +1010,8 @@ static int scst_local_queuecommand_lck(struct scsi_cmnd *scmd, #endif if (scsi_bidi_cmnd(scmd)) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 24) +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 24) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) /* Some of these symbols are only defined after 2.6.24 */ dir = SCST_DATA_BIDI; scst_cmd_set_expected(scst_cmd, dir, scsi_bufflen(scmd)); @@ -1177,7 +1178,7 @@ static int scst_local_slave_alloc(struct scsi_device *sdev) #if !defined(RHEL_MAJOR) || RHEL_MAJOR -0 >= 6 queue_flag_set_unlocked(QUEUE_FLAG_BIDI, sdev->request_queue); #endif -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) blk_queue_flag_set(QUEUE_FLAG_BIDI, sdev->request_queue); #endif diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 03c8f3a4c..2f127e40a 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3231,7 +3231,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, struct scst_cmd *cmd) { - struct ib_device *dev; + struct ib_device *dev __maybe_unused; struct scatterlist *sg, *cur_sg; int sg_cnt; scst_data_direction dir;