From 33af3ccb462519f5aaf8ca66fd9c107400b3b491 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 22 Apr 2017 04:15:21 +0000 Subject: [PATCH 1/3] ql2x00t: howto update git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7151 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/doc/qla2x00t-howto.html | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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.
  • From 037138239497d5d388051956dfe717e103f0e20c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 26 Apr 2017 23:53:11 +0000 Subject: [PATCH 2/3] scst: Introduce scst_scsi_execute() This patch does not change any functionality but makes it easier to port SCST to Linux kernel v4.11. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7152 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 4 ++++ scst/src/dev_handlers/scst_cdrom.c | 10 +++----- scst/src/dev_handlers/scst_disk.c | 10 +++----- scst/src/dev_handlers/scst_modisk.c | 10 +++----- scst/src/scst_lib.c | 36 +++++++++++++++++++---------- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 0933041fd..3b684be55 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5694,6 +5694,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 074f72267..b67b28501 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/scst_lib.c b/scst/src/scst_lib.c index f84df53e1..933ca5a03 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6777,6 +6777,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; @@ -6801,12 +6820,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)) { @@ -13248,12 +13263,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); From 909247cb3df6de987cb253f488fb50a02bc4cd6e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 27 Apr 2017 00:17:22 +0000 Subject: [PATCH 3/3] scst: Port to Linux kernel v4.11 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7153 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser_rdma.c | 4 ++ iscsi-scst/kernel/isert-scst/isert_login.c | 4 ++ scst/src/dev_handlers/scst_user.c | 4 ++ scst/src/dev_handlers/scst_vdisk.c | 3 ++ scst/src/scst_event.c | 4 ++ scst/src/scst_lib.c | 48 +++++++++++++++++----- scst/src/scst_sysfs.c | 8 +++- 7 files changed, 63 insertions(+), 12 deletions(-) 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/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 5be651e7c..882904c1e 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 933ca5a03..1b105209b 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 @@ -7853,7 +7856,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; @@ -8063,7 +8070,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; } @@ -8259,10 +8270,14 @@ static void scsi_end_async(struct request *req, int error) #endif if (sioc->done) -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30) - sioc->done(sioc->data, sioc->sense, req->errors, req->data_len); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + sioc->done(sioc->data, sioc->sense, req->errors, + scsi_req(req)->resid_len); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) + sioc->done(sioc->data, sioc->sense, req->errors, + req->resid_len); #else - sioc->done(sioc->data, sioc->sense, req->errors, req->resid_len); + sioc->done(sioc->data, sioc->sense, req->errors, req->data_len); #endif kmem_cache_free(scsi_io_context_cache, sioc); @@ -8283,6 +8298,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; @@ -8331,15 +8351,21 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, sioc->data = data; sioc->done = done; - rq->cmd_len = cmd_len; - if (rq->cmd_len <= BLK_MAX_CDB) { - memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ - memcpy(rq->cmd, cmd->cdb, cmd->cdb_len); - } else - rq->cmd = cmd->cdb; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + req = scsi_req(rq); +#else + req = rq; +#endif - rq->sense = sioc->sense; - 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; diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index c89e453c5..10a95a447 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1203,7 +1203,13 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category, goto out_free; PRINT_INFO("Waiting for release of sysfs entry for %s %s (%d refs)", - category, name ? : "(?)", atomic_read(&kobj->kref.refcount)); + category, name ? : "(?)", +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) + kref_read(&kobj->kref) +#else + atomic_read(&kobj->kref.refcount) +#endif + ); wait_for_completion(c); PRINT_INFO("Finished waiting for release of %s %s sysfs entry", category, name ? : "(?)");