diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index d1969de05..745cad781 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -50,7 +50,7 @@ endif INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra INFINIBAND_ENABLED := $(shell if grep -q '^CONFIG_INFINIBAND=[my]$$' $(KDIR)/.config; then echo true; else echo false; fi) -all: include/iscsi_scst_itf_ver.h progs mods +all: progs mods ISER_SYMVERS:=$(KMOD)/Module.symvers OFED_CFLAGS:= @@ -103,7 +103,7 @@ endif CREATE_CQ_FLAG = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/create_cq PRE_CFLAGS="$(OFED_CFLAGS) -Werror" >/dev/null 2>&1 && echo -DIB_CREATE_CQ_HAS_INIT_ATTR) PRE_CFLAGS=$(OFED_CFLAGS) $(CREATE_CQ_FLAG) -DOFED_FLAVOR=$(OFED_FLAVOR) -mods: Modules.symvers Module.symvers +mods: include/iscsi_scst_itf_ver.h Modules.symvers Module.symvers $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) modules if $(INFINIBAND_ENABLED); then \ echo " Building against $(OFED_FLAVOR) InfiniBand kernel headers."; \ @@ -112,7 +112,7 @@ mods: Modules.symvers Module.symvers KBUILD_EXTRA_SYMBOLS=$(ISER_SYMVERS) modules; \ fi -progs: +progs: include/iscsi_scst_itf_ver.h $(MAKE) -C usr SCST_INC_DIR=$(SCST_INC_DIR) include/iscsi_scst_itf_ver.h: include/iscsi_scst.h diff --git a/scst/include/scst.h b/scst/include/scst.h index 140412c43..3e7288f19 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1453,7 +1453,9 @@ struct scst_dev_type { * be started. Can be used to close open file handlers, which might * prevent the state switch. * - * Called under scst_dg_mutex and no activities on the dev handler level. + * Called under scst_dg_mutex and no activities on the dev handler level + * (for implicit ALUA case supposed to be done by the user space via + * "block" sysfs attribute as described in the README). * * OPTIONAL */ @@ -1465,7 +1467,9 @@ struct scst_dev_type { * be finished. Can be used to (re)open file handlers closed in * on_alua_state_change_start(). * - * Called under scst_dg_mutex and no activities on the dev handler level. + * Called under scst_dg_mutex and no activities on the dev handler level + * (for implicit ALUA case supposed to be done by the user space via + * "block" sysfs attribute as described in the README). * * OPTIONAL */ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index dc2e7e7a3..33a2cc7ed 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -3533,9 +3533,23 @@ out_put: static int dev_user_unregister_dev(struct file *file) { + struct scst_user_dev *dev; + int res; + + dev = file->private_data; + res = dev_user_check_reg(dev); + if (unlikely(res != 0)) + goto out; + PRINT_WARNING("SCST_USER_UNREGISTER_DEVICE is obsolete and NOOP. " "Closing fd should be used instead."); - return 0; + + /* For backward compatibility unblock possibly blocked sync threads */ + dev->blocking = 0; + wake_up_all(&dev->udev_cmd_threads.cmd_list_waitQ); + +out: + return res; } static int dev_user_flush_cache(struct file *file) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 9171b1f9f..72df069ef 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -145,6 +145,13 @@ static struct scst_trace_log vdisk_local_trace_tbl[] = { struct scst_vdisk_dev { uint64_t nblocks; + + /* + * Not protected, because assignments to aligned 64-bit integers are + * atomic. At worst, accesses to it should be covered by ACCESS_ONCE(), + * but not sure if that is really needed, so would prefer to keep it + * away from the fast path. + */ loff_t file_size; /* in bytes */ /* diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index 80ca7e8cb..62fdb781a 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -2535,9 +2535,13 @@ static int scst_cm_dev_register(struct scst_device *dev, uint64_t lun) list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { if (tgt_dev->dev == dev) { - PRINT_ERROR("Copy Manager already registered " + /* + * It's OK, because the copy manager could + * auto register some devices + */ + TRACE_DBG("Copy Manager already registered " "device %s", dev->virt_name); - res = -EEXIST; + res = 0; goto out; } } diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 3fb4e0d29..1db5ed914 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4597,7 +4597,7 @@ out: return res; } -/* Either add or replace a LUN. */ +/* Either add or replace a LUN according to flags argument */ int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, struct scst_device *dev, uint64_t lun, unsigned int flags) diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index b8cc4456c..cb65574eb 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -954,7 +954,8 @@ out_fail: * group @tg->dg. */ static void __scst_tg_set_state(struct scst_target_group *tg, - enum scst_tg_state state) + enum scst_tg_state state, + bool call_on_alua_state_change) { struct scst_dg_dev *dg_dev; struct scst_device *dev; @@ -1018,7 +1019,7 @@ int scst_tg_set_state(struct scst_target_group *tg, enum scst_tg_state state) if (res) goto out; - __scst_tg_set_state(tg, state); + __scst_tg_set_state(tg, state, true); mutex_unlock(&scst_dg_mutex); out: @@ -1325,7 +1326,7 @@ static void __scst_dg_remove(struct scst_dev_group *dg) list_del(&dg->entry); scst_dg_sysfs_del(dg); list_for_each_entry(tg, &dg->tg_list, entry) - __scst_tg_set_state(tg, SCST_TG_STATE_OPTIMIZED); + __scst_tg_set_state(tg, SCST_TG_STATE_OPTIMIZED, false); while (!list_empty(&dg->dev_list)) { dgdev = list_first_entry(&dg->dev_list, struct scst_dg_dev, entry); diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index b6bac0e8d..e65ce3fc8 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1499,6 +1499,7 @@ sub serializeNkAttr { || defined($attr_filter) && defined($$attr_filter{$attribute})) && !defined($$attributes{$attribute}->{'keys'}) + && $attribute ne 'dif_checks_failed' && $attribute ne 'enabled' && $attribute ne 'hw_target') { my $value = $$attributes{$attribute}->{'value'}; diff --git a/usr/fileio/Makefile b/usr/fileio/Makefile index 6705f3496..231d2d81e 100644 --- a/usr/fileio/Makefile +++ b/usr/fileio/Makefile @@ -1,5 +1,5 @@ # -# SCSI target mid-level makefile +# Fileio_tgt user space dev handler make file # # Copyright (C) 2007 - 2016 Vladislav Bolkhovitin # Copyright (C) 2007 - 2016 SanDisk Corporation