From 2b477bd7193aaa29f3423429417b39ae6fce650a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 13 Jan 2019 21:27:19 +0000 Subject: [PATCH] scst: Port to Linux kernel v5.0 (merge r7849 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@7888 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_iocb.c | 2 +- qla2x00t/qla_os.c | 5 ++++- scst/include/backport.h | 14 ++++++++++++++ scst/src/scst_lib.c | 12 +++++++++++- scst_local/scst_local.c | 5 +++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/qla2x00t/qla_iocb.c b/qla2x00t/qla_iocb.c index 37e0bdbd9..fe327ea4f 100644 --- a/qla2x00t/qla_iocb.c +++ b/qla2x00t/qla_iocb.c @@ -1875,7 +1875,7 @@ static void qla25xx_set_que(srb_t *sp, struct rsp_que **rsp) { struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct qla_hw_data *ha = sp->fcport->vha->hw; - int affinity = cmd->request->cpu; + int affinity = scst_blk_rq_cpu(cmd->request); if (ha->flags.cpu_affinity_enabled && affinity >= 0 && affinity < ha->max_rsp_queues - 1) diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index a565b8719..f9ebba662 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -304,7 +304,9 @@ struct scsi_host_template qla2xxx_driver_template = { #endif .this_id = -1, .cmd_per_lun = 3, +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) .use_clustering = ENABLE_CLUSTERING, +#endif .sg_tablesize = SG_ALL, .max_sectors = 0xFFFF, @@ -1160,7 +1162,8 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, goto eh_reset_failed; } err = 2; - if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) + if (do_reset(fcport, cmd->device->lun, + scst_blk_rq_cpu(cmd->request) + 1) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800c, "do_reset failed for cmd=%p.\n", cmd); diff --git a/scst/include/backport.h b/scst/include/backport.h index b5b9d033b..f2db11483 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -22,6 +22,9 @@ #include #include /* struct request_queue */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0) +#include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) #include /* struct bsg_job */ #endif @@ -116,6 +119,17 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) } #endif +/* */ + +static inline unsigned int scst_blk_rq_cpu(struct request *rq) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) + return rq->cpu; +#else + return blk_mq_rq_cpu(rq); +#endif +} + /* */ /* diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 3e55e290b..85351c44f 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5281,7 +5281,12 @@ static int scst_alloc_add_tgt_dev(struct scst_session *sess, ini_sg = shost->sg_tablesize; ini_unchecked_isa_dma = shost->unchecked_isa_dma; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) ini_use_clustering = shost->use_clustering == ENABLE_CLUSTERING; +#else + ini_use_clustering = !(shost->dma_boundary == PAGE_SIZE - 1 && + shost->max_segment_size == PAGE_SIZE); +#endif } else { ini_sg = (1 << 15) /* infinite */; ini_unchecked_isa_dma = 0; @@ -8398,7 +8403,7 @@ static void scsi_end_async(struct request *req, blk_status_t error) #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) lockdep_assert_held(req->q->queue_lock); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) if (!req->q->mq_ops) lockdep_assert_held(req->q->queue_lock); #endif @@ -8429,7 +8434,12 @@ static void scsi_end_async(struct request *req, blk_status_t error) kmem_cache_free(scsi_io_context_cache, sioc); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) + /* See also commit 92bc5a24844a ("block: remove __blk_put_request()") */ __blk_put_request(req->q, req); +#else + blk_put_request(req); +#endif return; } diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 2d0e5aab2..1be668940 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1663,7 +1663,12 @@ static struct scsi_host_template scst_lcl_ini_driver_template = { .sg_tablesize = 0xFFFF, .max_sectors = 0xffff, /* Possible pass-through backend device may not support clustering */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 21, 0) .use_clustering = DISABLE_CLUSTERING, +#else + .dma_boundary = PAGE_SIZE - 1, + .max_segment_size = PAGE_SIZE, +#endif .skip_settle_delay = 1, .module = THIS_MODULE, };