From bf7cb97bc7304b0b478a86184ee3692e3706bfea Mon Sep 17 00:00:00 2001 From: Yan Burman Date: Mon, 29 Sep 2014 08:25:48 +0000 Subject: [PATCH] Merged revisions 5799-5800,5803,5807,5809,5812-5813,5815 via svnmerge from svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/branches/3.0.x ................ r5799 | bvassche | 2014-09-12 14:17:49 +0300 (Fri, 12 Sep 2014) | 1 line fcst/Makefile: Add release-archive target (merge r5798 from trunk) ................ r5800 | bvassche | 2014-09-12 14:19:21 +0300 (Fri, 12 Sep 2014) | 1 line fcst: Change version number from 0.3 into 3.0.0 ................ r5803 | vlnb | 2014-09-13 04:15:12 +0300 (Sat, 13 Sep 2014) | 9 lines Merged revisions 5802 via svnmerge from svn+ssh://vlnb@svn.code.sf.net/p/scst/svn/trunk ........ r5802 | vlnb | 2014-09-12 18:13:29 -0700 (Fri, 12 Sep 2014) | 3 lines Fix autofinding SCST headers in fileio_tgt ........ ................ r5807 | bvassche | 2014-09-15 15:32:02 +0300 (Mon, 15 Sep 2014) | 1 line ib_srpt: Make "make -j install" work for n >= 2 if "make all" has not been run first (merge r5806 from trunk) ................ r5809 | bvassche | 2014-09-16 14:26:10 +0300 (Tue, 16 Sep 2014) | 1 line scst/src/Makefile: Make "make install" without prior "make" work (merge r5808 from trunk) ................ r5812 | bvassche | 2014-09-17 14:14:38 +0300 (Wed, 17 Sep 2014) | 1 line scst_vdisk: Insert a blank line (merge r5810 from trunk) ................ r5813 | bvassche | 2014-09-17 14:18:17 +0300 (Wed, 17 Sep 2014) | 2 lines vdisk_blockio: Make large COMPARE AND WRITE requests work for stacked block devices (merge r5811 from trunk) ................ r5815 | vlnb | 2014-09-20 08:52:06 +0300 (Sat, 20 Sep 2014) | 3 lines Version updated ................ git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x-iser@5818 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/Makefile | 7 +- fcst/fcst.h | 2 +- iscsi-scst/README | 4 +- iscsi-scst/include/iscsi_scst_ver.h | 2 +- qla2x00t/qla2x00-target/README | 4 +- qla2x00t/qla2x00-target/qla2x00t.h | 2 +- scst/README | 4 +- scst/include/scst_const.h | 2 +- scst/src/Makefile | 17 +-- scst/src/dev_handlers/scst_vdisk.c | 105 +++++++++++++++--- .../scst-0.9.10/t/after-restore.conf | 2 +- .../scst-0.9.10/t/to-be-restored.conf | 2 +- scstadmin/scstadmin.sysfs/scstadmin | 2 +- srpt/Makefile | 2 +- usr/fileio/Makefile | 5 +- usr/fileio/README | 4 +- usr/fileio/fileio.c | 2 +- 17 files changed, 119 insertions(+), 49 deletions(-) diff --git a/fcst/Makefile b/fcst/Makefile index 1200bcb77..d70f7626c 100644 --- a/fcst/Makefile +++ b/fcst/Makefile @@ -3,6 +3,7 @@ # Based on ../mvsas_tgt/Makefile # # Copyright (C) 2006 - 2008 Jacky Feng +# Copyright (C) 2011 - 2014 Bart Van Assche # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -137,4 +138,8 @@ extraclean: clean -$(MAKE) clean $(call set_var,build_mode,BUILDMODE,PERF) -.PHONY: all tgt install uninstall clean extraclean +release-archive: + ../scripts/generate-release-archive fcst "$$(sed -n 's/^#define[[:blank:]]FT_VERSION[[:blank:]]*\"\([^\"]*\)\".*/\1/p' fcst.h)" + +.PHONY: all tgt install uninstall clean extraclean 2debug 2release 2perf \ + release-archive diff --git a/fcst/fcst.h b/fcst/fcst.h index 50f25b4a5..8c1ef155f 100644 --- a/fcst/fcst.h +++ b/fcst/fcst.h @@ -26,7 +26,7 @@ #include "scst.h" #endif -#define FT_VERSION "0.3" +#define FT_VERSION "3.0.0" #define FT_MODULE "fcst" #define FT_MAX_HW_PENDING_TIME 20 /* max I/O time in seconds */ diff --git a/iscsi-scst/README b/iscsi-scst/README index f265be6c3..ca8559766 100644 --- a/iscsi-scst/README +++ b/iscsi-scst/README @@ -1,8 +1,8 @@ iSCSI SCST target driver ======================== -Version 3.0.0, XX XXXXX 2014 ----------------------------- +Version 3.0.0, 19 September 2014 +-------------------------------- ISCSI-SCST is a deeply reworked fork of iSCSI Enterprise Target (IET) (http://iscsitarget.sourceforge.net). Reasons of the fork were: diff --git a/iscsi-scst/include/iscsi_scst_ver.h b/iscsi-scst/include/iscsi_scst_ver.h index cbb4c9750..ba24f5ccc 100644 --- a/iscsi-scst/include/iscsi_scst_ver.h +++ b/iscsi-scst/include/iscsi_scst_ver.h @@ -21,4 +21,4 @@ #define ISCSI_VERSION_STRING_SUFFIX #endif -#define ISCSI_VERSION_STRING "3.0.0-rc1" ISCSI_VERSION_STRING_SUFFIX +#define ISCSI_VERSION_STRING "3.0.0" ISCSI_VERSION_STRING_SUFFIX diff --git a/qla2x00t/qla2x00-target/README b/qla2x00t/qla2x00-target/README index 0834aa94b..4af82ad4c 100644 --- a/qla2x00t/qla2x00-target/README +++ b/qla2x00t/qla2x00-target/README @@ -1,8 +1,8 @@ Target driver for QLogic 22xx/23xx/24xx/25xx Fibre Channel cards ================================================================ -Version 3.0.0, XX XXXXX 2014 ----------------------------- +Version 3.0.0, 19 September 2014 +-------------------------------- This driver consists from two parts: the target mode driver itself and the changed initiator driver from Linux kernel, which is, particularly, diff --git a/qla2x00t/qla2x00-target/qla2x00t.h b/qla2x00t/qla2x00-target/qla2x00t.h index 52ec37749..7c98dc7f8 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.h +++ b/qla2x00t/qla2x00-target/qla2x00t.h @@ -31,7 +31,7 @@ /* Version numbers, the same as for the kernel */ #define Q2T_VERSION(a, b, c, d) (((a) << 030) + ((b) << 020) + (c) << 010 + (d)) #define Q2T_VERSION_CODE Q2T_VERSION(3, 0, 0, 0) -#define Q2T_VERSION_STRING "3.0.0-rc1" +#define Q2T_VERSION_STRING "3.0.0" #define Q2T_PROC_VERSION_NAME "version" #define Q2T_MAX_CDB_LEN 16 diff --git a/scst/README b/scst/README index 1f42e569e..92d5c8301 100644 --- a/scst/README +++ b/scst/README @@ -1,8 +1,8 @@ Generic SCSI target mid-level for Linux (SCST) ============================================== -Version 3.0.0, XX XXXXX 2014 ----------------------------- +Version 3.0.0, 19 September 2014 +-------------------------------- SCST is designed to provide unified, consistent interface between SCSI target drivers and Linux kernel and simplify target drivers development diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index e635a446b..c18f874fa 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -48,7 +48,7 @@ #else #define SCST_VERSION_STRING_SUFFIX #endif -#define SCST_VERSION_NAME "3.0.0-rc1" +#define SCST_VERSION_NAME "3.0.0" #define SCST_VERSION_STRING SCST_VERSION_NAME SCST_VERSION_STRING_SUFFIX #define SCST_CONST_VERSION "$Revision$" diff --git a/scst/src/Makefile b/scst/src/Makefile index 09c0317e0..6fa3ed67c 100644 --- a/scst/src/Makefile +++ b/scst/src/Makefile @@ -79,9 +79,10 @@ all: scst: $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_DEV=n -MODS_VERS := $(shell ls Modules.symvers 2>/dev/null) -# It's renamed in 2.6.18 -MOD_VERS := $(shell ls Module.symvers 2>/dev/null) +# The file Modules.symvers has been renamed in the 2.6.18 kernel to +# Module.symvers. Find out which name to use by looking in $(KDIR). +MODULE_SYMVERS:=$(shell if [ -e $(KDIR)/Module.symvers ]; then \ + echo Module.symvers; else echo Modules.symvers; fi) install: all @if [ -z "$(DESTDIR)" ] && \ @@ -99,14 +100,8 @@ install: all install -m 644 ../include/scst_debug.h $(INSTALL_DIR_H) install -m 644 ../include/scst_user.h $(INSTALL_DIR_H) install -m 644 ../include/scst_const.h $(INSTALL_DIR_H) -ifneq ($(MODS_VERS),) - rm -f $(INSTALL_DIR_H)/Module.symvers - install -m 644 Modules.symvers $(INSTALL_DIR_H) -endif -ifneq ($(MOD_VERS),) - rm -f $(INSTALL_DIR_H)/Modules.symvers - install -m 644 Module.symvers $(INSTALL_DIR_H) -endif + rm -f $(INSTALL_DIR_H)/$(MODULE_SYMVERS) + install -m 644 $(MODULE_SYMVERS) $(INSTALL_DIR_H) -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) mkdir -p $(DESTDIR)/var/lib/scst/pr mkdir -p $(DESTDIR)/var/lib/scst/vdev_mode_pages diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 64b674fd4..a5d7726c5 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -118,6 +118,9 @@ static struct scst_trace_log vdisk_local_trace_tbl[] = { #define DEF_TST SCST_TST_1_SEP_TASK_SETS #define DEF_TMF_ONLY 0 +#define NO_CAW_LEN_LIM 0xff +#define DEF_CAW_LEN_LIM 0xfe + /* * Since we can't control backstorage device's reordering, we have to always * report unrestricted reordering. @@ -200,6 +203,10 @@ struct scst_vdisk_dev { uint8_t inq_vend_specific[MAX_INQ_VEND_SPECIFIC_LEN]; int inq_vend_specific_len; + /* Block limits INQUIRY parameters */ + uint8_t caw_len_lim; + struct mutex caw_mutex; + struct scst_device *dev; struct list_head vdev_list_entry; @@ -3391,7 +3398,7 @@ static enum compl_status_e vdisk_exec_inquiry(struct vdisk_cmd_params *p) buf[1] = 0xB0; buf[3] = 0x3C; buf[4] = 1; /* WSNZ set */ - buf[5] = 0xFF; /* No MAXIMUM COMPARE AND WRITE LENGTH limit */ + buf[5] = virt_dev->caw_len_lim; /* Optimal transfer granuality is PAGE_SIZE */ put_unaligned_be16(max_t(int, PAGE_SIZE/dev->block_size, 1), &buf[6]); @@ -5423,6 +5430,17 @@ static void blockio_end_sync_io(struct bio *bio, int error) #endif } +/** + * blockio_rw_sync() - read or write up to @len bytes from a block I/O device + * + * Returns: + * - A negative value if an error occurred. + * - Zero if len == 0. + * - A positive value <= len if I/O succeeded. + * + * Note: + * Increments *@loff with the number of bytes transferred upon success. + */ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, size_t len, loff_t *loff, unsigned rw) { @@ -5461,12 +5479,23 @@ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, bytes = min_t(size_t, PAGE_SIZE - off, buf + len - p); q = is_vmalloc ? vmalloc_to_page(p) : virt_to_page(p); rc = bio_add_page(bio, q, bytes, off); - if (WARN_ON_ONCE(rc < bytes)) - goto free; + if (rc < bytes) { + if (rc <= 0 && p == buf) { + goto free; + } else { + if (rc > 0) + p += rc; + break; + } + } } submit_bio(rw, bio); wait_for_completion(&c); - ret = (unsigned long)bio->bi_private ? : len; + ret = (unsigned long)bio->bi_private; + if (likely(ret == 0)) { + ret = p - buf; + *loff += ret; + } free: bio_put(bio); @@ -5475,6 +5504,7 @@ out: return ret; } +/* Note: Updates *@loff if reading succeeded. */ static ssize_t fileio_read_sync(struct file *fd, void *buf, size_t len, loff_t *loff) { @@ -5499,6 +5529,7 @@ out: return ret; } +/* Note: Updates *@loff if writing succeeded. */ static ssize_t fileio_write_sync(struct file *fd, void *buf, size_t len, loff_t *loff) { @@ -5522,26 +5553,47 @@ out: return ret; } + +/* Note: Updates *@loff if reading succeeded except for NULLIO devices. */ static ssize_t vdev_read_sync(struct scst_vdisk_dev *virt_dev, void *buf, size_t len, loff_t *loff) { - if (virt_dev->nullio) + ssize_t read, res; + + if (virt_dev->nullio) { return len; - else if (virt_dev->blockio) - return blockio_rw_sync(virt_dev, buf, len, loff, READ_SYNC); - else + } else if (virt_dev->blockio) { + for (read = 0; read < len; read += res) { + res = blockio_rw_sync(virt_dev, buf + read, len - read, + loff, READ_SYNC); + if (res < 0) + return res; + } + return read; + } else { return fileio_read_sync(virt_dev->fd, buf, len, loff); + } } +/* Note: Updates *@loff if reading succeeded except for NULLIO devices. */ static ssize_t vdev_write_sync(struct scst_vdisk_dev *virt_dev, void *buf, size_t len, loff_t *loff) { - if (virt_dev->nullio) + ssize_t written, res; + + if (virt_dev->nullio) { return len; - else if (virt_dev->blockio) - return blockio_rw_sync(virt_dev, buf, len, loff, WRITE_SYNC); - else + } else if (virt_dev->blockio) { + for (written = 0; written < len; written += res) { + res = blockio_rw_sync(virt_dev, buf + written, + len - written, loff, WRITE_SYNC); + if (res < 0) + return res; + } + return written; + } else { return fileio_write_sync(virt_dev->fd, buf, len, loff); + } } static enum compl_status_e vdev_exec_verify(struct vdisk_cmd_params *p) @@ -5666,6 +5718,16 @@ static enum compl_status_e vdisk_exec_caw(struct vdisk_cmd_params *p) if (data_len == 0) goto out; + if (virt_dev->caw_len_lim != NO_CAW_LEN_LIM && + (data_len > virt_dev->caw_len_lim << dev->block_shift)) { + PRINT_ERROR("COMPARE AND WRITE: data length %u exceeds" + " limit %u << %u = %u", data_len, + virt_dev->caw_len_lim, dev->block_shift, + virt_dev->caw_len_lim << dev->block_shift); + scst_set_invalid_field_in_cdb(cmd, 13, 0); + goto out; + } + length = scst_get_buf_full(cmd, &caw_buf); read_buf = vmalloc(data_len); if (length < 0 || !read_buf) { @@ -5683,6 +5745,8 @@ static enum compl_status_e vdisk_exec_caw(struct vdisk_cmd_params *p) goto out; } + mutex_lock(&virt_dev->caw_mutex); + loff = p->loff; read = vdev_read_sync(virt_dev, read_buf, data_len, &loff); if (read < data_len) { @@ -5693,7 +5757,7 @@ static enum compl_status_e vdisk_exec_caw(struct vdisk_cmd_params *p) else scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_read_error)); - goto out; + goto unlock; } if (memcmp(caw_buf, read_buf, data_len) != 0) { @@ -5710,9 +5774,8 @@ static enum compl_status_e vdisk_exec_caw(struct vdisk_cmd_params *p) * INFORMATION field. */ scst_set_cmd_error_and_inf(cmd, - SCST_LOAD_SENSE(scst_sense_miscompare_error), - p->loff + i); - goto out; + SCST_LOAD_SENSE(scst_sense_miscompare_error), i); + goto unlock; } loff = p->loff; @@ -5726,12 +5789,15 @@ static enum compl_status_e vdisk_exec_caw(struct vdisk_cmd_params *p) else scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_write_error)); - goto out; + goto unlock; } if (p->fua) - vdisk_fsync(loff, scst_cmd_get_data_len(cmd), cmd->dev, + vdisk_fsync(p->loff, scst_cmd_get_data_len(cmd), cmd->dev, cmd->cmd_gfp_mask, cmd, false); +unlock: + mutex_unlock(&virt_dev->caw_mutex); + out: if (read_buf) vfree(read_buf); @@ -5937,6 +6003,8 @@ static int vdev_create(struct scst_dev_type *devt, } spin_lock_init(&virt_dev->flags_lock); + mutex_init(&virt_dev->caw_mutex); + virt_dev->vdev_devt = devt; virt_dev->rd_only = DEF_RD_ONLY; @@ -5945,6 +6013,7 @@ static int vdev_create(struct scst_dev_type *devt, virt_dev->rotational = DEF_ROTATIONAL; virt_dev->thin_provisioned = DEF_THIN_PROVISIONED; virt_dev->tst = DEF_TST; + virt_dev->caw_len_lim = DEF_CAW_LEN_LIM; virt_dev->blk_shift = DEF_DISK_BLOCK_SHIFT; diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf index 77c6f5389..a6ee39010 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf @@ -1,4 +1,4 @@ -# Automatically generated by SCST Configurator v3.0.0-pre2. +# Automatically generated by SCST Configurator v3.0.0. HANDLER vdisk_fileio { diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf index b4988b721..7d9229b6c 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf @@ -1,4 +1,4 @@ -# Automatically generated by SCST Configurator v3.0.0-pre2. +# Automatically generated by SCST Configurator v3.0.0. HANDLER vdisk_fileio { diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 8ee27556c..14b2b849f 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1,6 +1,6 @@ #!/usr/bin/perl -$Version = 'SCST Configurator v3.0.0-pre2'; +$Version = 'SCST Configurator v3.0.0'; # Configures SCST # diff --git a/srpt/Makefile b/srpt/Makefile index 20e5709ea..555525018 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -87,7 +87,7 @@ all: src/$(MODULE_SYMVERS) PRE_CFLAGS="$(OFED_CFLAGS) $(AUTOCONF_FLAGS)" \ KCFLAGS="$(AUTOCONF_FLAGS)" SCST_INC_DIR=$(SCST_INC_DIR) modules -install: all src/ib_srpt.ko +install: all @[ -z "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && \ find /lib/modules/$(KVER) -name ib_srpt.ko -exec rm {} \; ; \ true diff --git a/usr/fileio/Makefile b/usr/fileio/Makefile index 6b193e219..6c8f68991 100644 --- a/usr/fileio/Makefile +++ b/usr/fileio/Makefile @@ -26,8 +26,9 @@ OBJS_F = $(SRCS_F:.c=.o) #SRCS_C = #OBJS_C = $(SRCS_C:.c=.o) -SCST_INC_DIR := ../../scst/include -#SCST_INC_DIR := $(PREFIX)/include/scst +SCST_INC_DIR := $(shell if [ -e "$$PWD/../../scst" ]; \ + then echo "$$PWD/../../scst/include"; \ + else echo "$(DESTDIR)$(PREFIX)/include/scst"; fi) INSTALL_DIR := $(DESTDIR)$(PREFIX)/bin/scst CFLAGS += -O2 -Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes \ diff --git a/usr/fileio/README b/usr/fileio/README index 79e43ccc8..6e7258fe8 100644 --- a/usr/fileio/README +++ b/usr/fileio/README @@ -1,8 +1,8 @@ User space FILEIO handler ========================= -Version 3.0.0, XX XXXXX 2014 ----------------------------- +Version 3.0.0, 19 September 2014 +-------------------------------- User space program fileio_tgt uses interface of SCST's scst_user dev handler and allows to see how it works in various modes. Fileio_tgt diff --git a/usr/fileio/fileio.c b/usr/fileio/fileio.c index 9d583c4e5..ebc2960ce 100644 --- a/usr/fileio/fileio.c +++ b/usr/fileio/fileio.c @@ -66,7 +66,7 @@ unsigned long trace_flag = DEFAULT_LOG_FLAGS; #endif /* defined(DEBUG) || defined(TRACING) */ #define DEF_BLOCK_SHIFT 9 -#define VERSION_STR "3.0.0-pre2" +#define VERSION_STR "3.0.0" #define THREADS 7 #define MAX_VDEVS 10