From 7a043f261875a0a67ae1b3111a13aa2faec6d374 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 14 Nov 2015 02:32:38 +0000 Subject: [PATCH] Merged revisions 6682-6691 via svnmerge from svn://svn.code.sf.net/p/scst/svn/trunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ........ r6682 | bvassche | 2015-11-12 09:43:26 -0800 (Thu, 12 Nov 2015) | 1 line scst_copy_mgr: Fix indentation ........ r6683 | bvassche | 2015-11-12 10:26:26 -0800 (Thu, 12 Nov 2015) | 8 lines qla2x00t: Suppress a Coverity complaint about a potential buffer overflow Coverity reported the following: Copy into fixed size buffer (STRING_OVERFLOW) fixed_size_dest: You might overrun the 17 byte fixed-size string ha->model_number by copying def without checking the length. ........ r6684 | bvassche | 2015-11-12 10:30:15 -0800 (Thu, 12 Nov 2015) | 1 line qla2x00t: Do not compare an array pointer with NULL ........ r6685 | bvassche | 2015-11-12 10:30:42 -0800 (Thu, 12 Nov 2015) | 1 line qla2x00t: Use strlcpy() instead of strcpy() ........ r6686 | bvassche | 2015-11-12 14:17:59 -0800 (Thu, 12 Nov 2015) | 4 lines scst_lib: Avoid using 64-bit divisions Reported-by: Sebastian Herbszt ........ r6687 | vlnb | 2015-11-12 15:33:45 -0800 (Thu, 12 Nov 2015) | 3 lines Update the root README regarding QLogic target driver ........ r6688 | bvassche | 2015-11-13 08:26:09 -0800 (Fri, 13 Nov 2015) | 8 lines scst: Fix kernel 2.6.36 build Avoid that compilation fails with the following error message: include/linux/slub_def.h:246: error: conflicting types for ‘kmalloc’ include/scst/backport.h:458: error: implicit declaration of function ‘kmalloc’ ........ r6689 | bvassche | 2015-11-13 11:07:10 -0800 (Fri, 13 Nov 2015) | 7 lines scstadmin: Do not try to clear copy manager assignments This patch avoids that the following error message is displayed on the console while "/etc/init.d/scst start" is executed: scst: scst_cm_mgmt:3556:***ERROR***: Device copy_manager_tgt not found ........ r6690 | bvassche | 2015-11-13 13:07:50 -0800 (Fri, 13 Nov 2015) | 1 line scstadmin: Leave out the copy manager from the driver list ........ r6691 | bvassche | 2015-11-13 17:07:27 -0800 (Fri, 13 Nov 2015) | 4 lines scstadmin: Pass $PREFIX to Makefile.PL Signed-off-by: Alexey Mochkin ........ git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.1.x@6692 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- README | 32 +++++++++++-------- qla2x00t/qla_attr.c | 3 +- qla2x00t/qla_gs.c | 3 +- qla2x00t/qla_init.c | 3 +- scst/include/backport.h | 3 +- scst/src/scst_copy_mgr.c | 4 +-- scst/src/scst_lib.c | 9 ++++-- scstadmin/scstadmin.sysfs/Makefile | 2 +- .../scst-0.9.10/lib/SCST/SCST.pm | 3 +- scstadmin/scstadmin.sysfs/scstadmin | 2 -- 10 files changed, 36 insertions(+), 28 deletions(-) diff --git a/README b/README index aa14955cd..31b01bd6d 100644 --- a/README +++ b/README @@ -31,12 +31,15 @@ For more information about each subproject see their README files. QLogic target driver ==================== -QLogic target driver in qla2x00t/ is the old one, forked from qla2xxx -from kernel 2.6.26. It is not maintained anymore and not built by -default by the common Makefile targets, like "all". +QLogic target driver qla2x00t is the old driver, forked from qla2xxx +several years ago. It is very stable, well tested and actively used in +many production setups. The ultimate goal is to have the mainstream +(git) QLogic target driver to be the main and the only QLogic target +driver, but, unfortunately, this driver not yet reached level of quality +and maturity of qla2x00t. We with QLogic are working toward it. -You can find the latest version of this driver in git://git.qlogic.com/scst-qla2xxx.git. -It is now maintained by QLogic, hence located in the QLogic's git. +You can find the latest version of the git driver in git://git.qlogic.com/scst-qla2xxx.git. +It is maintained by QLogic, hence located in the QLogic's git. To integrate it into the SCST build tree you need: @@ -45,19 +48,20 @@ To integrate it into the SCST build tree you need: 2. Create in the SCST root, i.e. this directory, a subdirectory with name qla2x00t_git -3. Symlink drivers/scsi/qla2xxx subdirectory in the cloned git tree to the -qla2x00t_git subdirectory +3. Optional for the in-tree build: symlink drivers/scsi/qla2xxx +subdirectory in the cloned git tree to the qla2x00t_git subdirectory -Thats all. Now run either "make all" to build the SCST core and all -target drivers with in-tree QLogic drivers, or the following command +Thats all. Now common and QLA specific root Makefile targets "magically" +start working with the new driver. + +For detail instructions how to setup QLA target build environment see +its README or HOWTO. Run either "make all" to build the SCST core and +all target drivers with in-tree QLogic drivers, or the following command with standalone QLogic drivers: BUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y make all -and other common and QLA specific root Makefile targets "magically" start -working. For detail instructions how to setup QLA target build environment see -its README or HOWTO. - -You can still build the old driver using qla_old* root Makefile targets. +In presence of qla2x00t_git subdirectory you can still build the +qla2x00t using qla_old* root Makefile targets. Vladislav Bolkhovitin , http://scst.sourceforge.net diff --git a/qla2x00t/qla_attr.c b/qla2x00t/qla_attr.c index a4f7cd6d0..60afa6024 100644 --- a/qla2x00t/qla_attr.c +++ b/qla2x00t/qla_attr.c @@ -1505,8 +1505,7 @@ qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr, char *buf) { scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); - return scnprintf(buf, PAGE_SIZE, "%s\n", - vha->hw->model_desc ? vha->hw->model_desc : ""); + return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_desc); } static ssize_t diff --git a/qla2x00t/qla_gs.c b/qla2x00t/qla_gs.c index ee93bc8a4..b169d5581 100644 --- a/qla2x00t/qla_gs.c +++ b/qla2x00t/qla_gs.c @@ -1378,7 +1378,8 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Hardware version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); - strcpy(eiter->a.hw_version, ha->adapter_id); + strlcpy(eiter->a.hw_version, ha->adapter_id, + sizeof(eiter->a.hw_version)); alen = strlen(eiter->a.hw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); diff --git a/qla2x00t/qla_init.c b/qla2x00t/qla_init.c index 995aecf14..76c946f7b 100644 --- a/qla2x00t/qla_init.c +++ b/qla2x00t/qla_init.c @@ -2190,7 +2190,8 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, qla2x00_model_name[index * 2 + 1], sizeof(ha->model_desc) - 1); } else { - strcpy(ha->model_number, def); + strlcpy(ha->model_number, def, + sizeof(ha->model_number)); } } if (IS_FWI2_CAPABLE(ha)) diff --git a/scst/include/backport.h b/scst/include/backport.h index 8bb4f4bfb..480b13e3c 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -20,7 +20,8 @@ * GNU General Public License for more details. */ -#include /* sync_page_range() */ +#include /* kmalloc() */ +#include /* sync_page_range() */ /* */ diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index 2b873f088..c59233ba8 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -3548,8 +3548,8 @@ static int scst_cm_mgmt(struct scst_sysfs_work_item *work) d->scsi_dev->channel == channel && d->scsi_dev->id == id && d->scsi_dev->lun == lun) { - dev = d; - break; + dev = d; + break; } } if (dev == NULL) { diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index c026d02e0..8cd269cc7 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6131,11 +6131,12 @@ static int scst_ws_sg_init(struct scatterlist **ws_sg, int ws_sg_cnt, static int scst_ws_sg_tails_get(struct scst_data_descriptor *where, struct scst_write_same_priv *wsp) { int i; + uint64_t n; TRACE_ENTRY(); for (i = 0; where[i].sdd_blocks != 0; i++) { - if (where[i].sdd_blocks / wsp->ws_max_each != 0) { + if (where[i].sdd_blocks >= wsp->ws_max_each) { wsp->ws_sg_full_cnt = wsp->ws_max_each; break; } @@ -6150,8 +6151,10 @@ static int scst_ws_sg_tails_get(struct scst_data_descriptor *where, struct scst_ sizeof(*wsp->ws_sg_tails)*i); return -ENOMEM; } - for (i = 0; where[i].sdd_blocks != 0; i++) - wsp->ws_sg_tails[i].sg_cnt = where[i].sdd_blocks % wsp->ws_max_each; + for (i = 0; where[i].sdd_blocks != 0; i++) { + n = where[i].sdd_blocks; + wsp->ws_sg_tails[i].sg_cnt = do_div(n, wsp->ws_max_each); + } TRACE_EXIT(); return 0; diff --git a/scstadmin/scstadmin.sysfs/Makefile b/scstadmin/scstadmin.sysfs/Makefile index d6e9ee34c..3a41eeb89 100644 --- a/scstadmin/scstadmin.sysfs/Makefile +++ b/scstadmin/scstadmin.sysfs/Makefile @@ -20,7 +20,7 @@ uninstall: perl-module: @cd ./scst-$(MODULE_VERSION); \ - perl Makefile.PL; + perl Makefile.PL PREFIX=$(PREFIX); $(MAKE) -C scst-$(MODULE_VERSION) test: diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm index 9b9e5db2f..4aa497f98 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm @@ -550,7 +550,8 @@ sub drivers { if (opendir($dHandle, $_path)) { foreach my $driver (readdir($dHandle)) { - next if (($driver eq '.') || ($driver eq '..')); + next if ($driver eq '.' || $driver eq '..' || + $driver eq 'copy_manager'); if (-d make_path(SCST_TARGETS_DIR(), $driver)) { push @drivers, $driver; diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 7c7a7939e..60d609717 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1423,8 +1423,6 @@ sub writeConfiguration { } foreach my $driver (sort keys %{$CURRENT{'assign'}}) { - next if $driver eq 'copy_manager'; - my $driver_buff; my ($drv_attrs, $errorString) = $SCST->driverAttributes($driver);