diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 2f6752379..e24b5ecdb 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -1400,7 +1400,11 @@ static void isert_kref_free(struct kref *kref) void isert_conn_free(struct isert_connection *isert_conn) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + sBUG_ON(kref_read(&isert_conn->kref) == 0); +#else sBUG_ON(atomic_read(&isert_conn->kref.refcount) == 0); +#endif kref_put(&isert_conn->kref, isert_kref_free); } diff --git a/iscsi-scst/kernel/isert-scst/isert_login.c b/iscsi-scst/kernel/isert-scst/isert_login.c index 3a0028595..f0220e958 100644 --- a/iscsi-scst/kernel/isert-scst/isert_login.c +++ b/iscsi-scst/kernel/isert-scst/isert_login.c @@ -111,7 +111,11 @@ static void isert_kref_release_dev(struct kref *kref) static void isert_dev_release(struct isert_conn_dev *dev) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + sBUG_ON(kref_read(&dev->kref) == 0); +#else sBUG_ON(atomic_read(&dev->kref.refcount) == 0); +#endif mutex_lock(&isert_listen_dev.conn_lock); kref_put(&dev->kref, isert_kref_release_dev); mutex_unlock(&isert_listen_dev.conn_lock); diff --git a/qla2x00t/doc/qla2x00t-howto.html b/qla2x00t/doc/qla2x00t-howto.html index 2f3195e53..925de8968 100644 --- a/qla2x00t/doc/qla2x00t-howto.html +++ b/qla2x00t/doc/qla2x00t-howto.html @@ -89,11 +89,6 @@ And on SUSE systems these packages can be installed by running the following com
[root@proj ]# zypper install gcc ncurses-devel kernel-devel lsscsi patch subversion
-
  • - Download the latest QLogic SCST target driver: -
    [root@proj ]# git clone git://git.qlogic.com/scst-qla2xxx.git
    -
  • -
  • Download the SCST source code. That source code can be downloaded either from the SCST @@ -113,14 +108,15 @@ And on SUSE systems these packages can be installed by running the following com
  • - In the SCST directory, create a soft link to the QLogic driver: -
    [root@proj ]# cd scst
    +  If you want to use the latest QLogic SCST target driver from the QLogic git, download it by:
    +  
    [root@proj ]# git clone git://git.qlogic.com/scst-qla2xxx.git
    +[root@proj ]# cd scst
     [root@proj scst]# ln -s ../scst-qla2xxx/drivers/scsi/qla2xxx qla2x00t_git
    + Note, this driver is not stable at the moment, therefore use of the driver from the SCST tree is recommended.
  • -Find out whether you will need SCSI pass-through and/or the iSCSI -zero-copy optimization. If not, skip the kernel download, patch, rebuild +Find out whether you will need iSCSI zero-copy optimization. Since it is valuable only with scst_user user space dev handlers, most likely, you don't need this feature. If you don't, skip the kernel download, patch, rebuild and reboot steps and continue with the SCST build step.
  • diff --git a/scst/include/backport.h b/scst/include/backport.h index 11fb4b9d2..ac1e6430f 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -738,27 +738,4 @@ static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd) } #endif -/* */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) -static inline struct request *scsi_req(struct request *rq) -{ - return rq; -} - -static inline void scsi_req_init(struct request *rq) -{ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) - rq->cmd_type = REQ_TYPE_BLOCK_PC; - rq->__data_len = 0; - rq->__sector = (sector_t) -1; - rq->bio = rq->biotail = NULL; - memset(rq->__cmd, 0, sizeof(rq->__cmd)); - rq->cmd = rq->__cmd; -#else - return blk_rq_set_block_pc(rq); -#endif -} -#endif - #endif /* _SCST_BACKPORT_H_ */ diff --git a/scst/include/scst.h b/scst/include/scst.h index 6e1ae4cc0..4b412a564 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5690,6 +5690,10 @@ struct scst_data_descriptor { }; void scst_write_same(struct scst_cmd *cmd, struct scst_data_descriptor *where); +int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries, + u64 flags); __be64 scst_pack_lun(const uint64_t lun, enum scst_lun_addr_method addr_method); uint64_t scst_unpack_lun(const uint8_t *lun, int len); diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index 163c174ab..030834a2d 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -96,13 +96,9 @@ static int cdrom_attach(struct scst_device *dev) data_dir = SCST_DATA_READ; TRACE_DBG("%s", "Doing READ_CAPACITY"); - rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, - buffer_size, sense_buffer, - SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, + buffer_size, sense_buffer, + SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", rc); diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 8de5f3bb4..d296da5e7 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -193,13 +193,9 @@ static int disk_attach(struct scst_device *dev) data_dir = SCST_DATA_READ; TRACE_DBG("%s", "Doing READ_CAPACITY"); - rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, - buffer_size, sense_buffer, - SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, + buffer_size, sense_buffer, + SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", rc); diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index 0111955cc..66e4b7b38 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -197,13 +197,9 @@ static int modisk_attach(struct scst_device *dev) data_dir = SCST_DATA_READ; TRACE_DBG("%s", "Doing READ_CAPACITY"); - rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, - buffer_size, sense_buffer, - SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, + buffer_size, sense_buffer, + SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0); TRACE_DBG("READ_CAPACITY done: %x", rc); diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index eb6aa6b26..debed3370 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -22,6 +22,10 @@ #include #include #include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif #define LOG_PREFIX DEV_USER_NAME diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 378b9720d..db750af52 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -55,6 +55,9 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) #include #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif #define LOG_PREFIX "dev_vdisk" diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 70ca038a9..4ec509bf0 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -11,6 +11,10 @@ #include #include #include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif #ifdef INSIDE_KERNEL_TREE #include diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 10d931db4..788a17351 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -37,6 +37,9 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) #include #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif #include #include @@ -6883,6 +6886,25 @@ out: return res; } +int scst_scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries, u64 flags) +{ + return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + NULL, /* sshdr */ +#endif + timeout, retries, flags +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + , 0 /* rq_flags */ +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) + , NULL /* resid */ +#endif + ); +} +EXPORT_SYMBOL(scst_scsi_execute); + static void scst_send_release(struct scst_device *dev) { struct scsi_device *scsi_dev; @@ -6907,12 +6929,8 @@ static void scst_send_release(struct scst_device *dev) TRACE(TRACE_DEBUG | TRACE_SCSI, "%s", "Sending RELEASE req to " "SCSI mid-level"); - rc = scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, - sense, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, + sense, 15, 0, 0); TRACE_DBG("RELEASE done: %x", rc); if (scsi_status_is_good(rc)) { @@ -7945,7 +7963,11 @@ static struct request *blk_make_request(struct request_queue *q, if (IS_ERR(rq)) return rq; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) scsi_req_init(rq); +#else + blk_rq_set_block_pc(rq); +#endif for_each_bio(bio) { struct bio *bounce_bio = bio; @@ -8155,7 +8177,11 @@ static struct request *blk_map_kern_sg(struct request_queue *q, if (unlikely(!rq)) return ERR_PTR(-ENOMEM); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) scsi_req_init(rq); +#else + rq->cmd_type = REQ_TYPE_BLOCK_PC; +#endif goto out; } @@ -8357,11 +8383,13 @@ static void scsi_end_async(struct request *req, int error) SAM_STAT_CHECK_CONDITION : 0; if (sioc->done) -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30) - sioc->done(sioc->data, sioc->sense, errors, req->data_len); -#else +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) sioc->done(sioc->data, sioc->sense, errors, 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); #endif kmem_cache_free(scsi_io_context_cache, sioc); @@ -8382,6 +8410,11 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, int res = 0; struct request_queue *q = cmd->dev->scsi_dev->request_queue; struct request *rq; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + struct scsi_request *req; +#else + struct request *req; +#endif struct scsi_io_context *sioc; bool reading = !(cmd->data_direction & SCST_DATA_WRITE); gfp_t gfp = cmd->cmd_gfp_mask; @@ -8430,15 +8463,21 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, sioc->data = data; sioc->done = done; - scsi_req(rq)->cmd_len = cmd_len; - if (scsi_req(rq)->cmd_len <= BLK_MAX_CDB) { - memset(scsi_req(rq)->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ - memcpy(scsi_req(rq)->cmd, cmd->cdb, cmd->cdb_len); - } else - scsi_req(rq)->cmd = cmd->cdb; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + req = scsi_req(rq); +#else + req = rq; +#endif - scsi_req(rq)->sense = sioc->sense; - scsi_req(rq)->sense_len = sizeof(sioc->sense); + req->cmd_len = cmd_len; + if (req->cmd_len <= BLK_MAX_CDB) { + memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ + memcpy(req->cmd, cmd->cdb, cmd->cdb_len); + } else + req->cmd = cmd->cdb; + + req->sense = sioc->sense; + req->sense_len = sizeof(sioc->sense); rq->timeout = cmd->timeout; rq->retries = cmd->retries; rq->end_io_data = sioc; @@ -13359,12 +13398,9 @@ int scst_obtain_device_parameters(struct scst_device *dev, memset(sense_buffer, 0, sizeof(sense_buffer)); TRACE(TRACE_SCSI, "%s", "Doing internal MODE_SENSE"); - rc = scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, buffer, - sizeof(buffer), sense_buffer, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - , NULL -#endif - ); + rc = scst_scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, + buffer, sizeof(buffer), sense_buffer, + 15, 0, 0); TRACE_DBG("MODE_SENSE done: %x", rc); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 7ba6dc203..440f718fb 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1204,10 +1204,10 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category, PRINT_INFO("Waiting for release of sysfs entry for %s %s (%d refs)", category, name ? : "(?)", -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) - atomic_read(&kobj->kref.refcount) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + kref_read(&kobj->kref) #else - atomic_read(&kobj->kref.refcount.refs) + atomic_read(&kobj->kref.refcount) #endif ); wait_for_completion(c);