diff --git a/iscsi-scst/usr/target.c b/iscsi-scst/usr/target.c index 25558e629..9c6898d98 100644 --- a/iscsi-scst/usr/target.c +++ b/iscsi-scst/usr/target.c @@ -357,6 +357,13 @@ int target_del(u32 tid, u32 cookie) /* We might need to handle session(s) removal event(s) from the kernel */ while (handle_iscsi_events(nl_fd, false) == 0); + /* Someone else may have already freed the target object by now. */ + target = target_find_by_id(tid); + if (!target) { + log_info("%s: the target with tid = %u was already freed", __func__, tid); + return 0; + } + if (list_empty(&target->sessions_list)) break; diff --git a/qla2x00t/qla2x00-target/Makefile_in-tree-4.5 b/qla2x00t/qla2x00-target/Makefile_in-tree-4.5 new file mode 100644 index 000000000..9657aee84 --- /dev/null +++ b/qla2x00t/qla2x00-target/Makefile_in-tree-4.5 @@ -0,0 +1,5 @@ +ccflags-y += -Idrivers/scsi/qla2xxx + +qla2x00tgt-y := qla2x00t.o + +obj-$(CONFIG_SCST_QLA_TGT_ADDON) += qla2x00tgt.o diff --git a/qla2x00t/qla2x00-target/Makefile_in-tree-4.6 b/qla2x00t/qla2x00-target/Makefile_in-tree-4.6 new file mode 100644 index 000000000..9657aee84 --- /dev/null +++ b/qla2x00t/qla2x00-target/Makefile_in-tree-4.6 @@ -0,0 +1,5 @@ +ccflags-y += -Idrivers/scsi/qla2xxx + +qla2x00tgt-y := qla2x00t.o + +obj-$(CONFIG_SCST_QLA_TGT_ADDON) += qla2x00tgt.o diff --git a/scst/README.dlm b/scst/README.dlm index 435e6d8bb..0d052b4f1 100644 --- a/scst/README.dlm +++ b/scst/README.dlm @@ -13,6 +13,7 @@ with a DLM lock object is called the Lock Value Block or LVB. The code in scst_dlm.c uses the DLM to keep PR data synchronized across all nodes in a cluster. + Software Components ------------------- @@ -29,6 +30,11 @@ The following software components are needed by the code in scst_dlm.c: On most Linux distributions the software packages that contain this software have the names kernel, dlm, corosync and pacemaker. +NOTE! You might need to apply a DLM bugfix patch, see scst-devel mailing list +thread https://sourceforge.net/p/scst/mailman/scst-devel/thread/CADHfD59FK6seaammL8b9LM3U3tw5HvYp3kPTk_r1OYkPR7bPhg@mail.gmail.com/#msg34761854 +for more details. + + DLM Configuration ----------------- @@ -74,6 +80,7 @@ configure and start the DLM control daemon: 12. Check the Pacemaker status: pcs status + Startup and Shutdown -------------------- @@ -127,6 +134,7 @@ The proper shutdown order is as follows: * Unload the SCST kernel modules * Unload the DLM kernel driver + Lockspace names --------------- @@ -134,12 +142,14 @@ The names of the DLM lockspaces used by SCST follow the following pattern: scst- where t10_dev_id is the T10 device ID of the SCST device associated with this lockspace. + Notes ----- Since the lockspace name depends on the t10_dev_id it is not allowed to change the t10_dev_id if cluster mode has been enabled. + Testing ------- @@ -148,11 +158,15 @@ Two examples of test suites for the cluster PR support code are: * The Windows Cluster Validation Tests (https://technet.microsoft.com/en-us/library/Cc726064.aspx). + To do ----- -Ensure that PREEMPT AND ABORT affects all cluster nodes instead of only the -cluster node that received this command. + * Ensure that PREEMPT AND ABORT affects all cluster nodes instead of + only the cluster node that received this command. + + * On APTL bit set, put the PR info on storage on the passive node. + See also -------- diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index ee2e18ee4..d07230199 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -157,6 +157,8 @@ do { \ } \ } while (0) +#define TRACE_PR(format, args...) TRACE(TRACE_PRES, format, ## args) + #ifdef CONFIG_SCST_DEBUG #define PRINT_BUFFER(message, buff, len) \ @@ -215,6 +217,13 @@ do { \ #define PRINT_BUFF_FLAG(flag, message, buff, len) \ ((void)(flag), (void)(message), (void)(buff), (void)(len)) +/* + * no_printk still calls its arguments, so we can not use it in perf build + * for TRACE_PR or debug_transport_id_to_initiator_name() is not going to + * be found. + */ +#define TRACE_PR(format, args...) do { } while (0) + #ifdef LOG_PREFIX #define PRINT_INFO(format, args...) \ @@ -280,8 +289,6 @@ do { \ TRACE_DBG_FLAG(TRACE_MGMT_DEBUG, format, ## args) #define TRACE_MGMT_DBG_SPECIAL(args...) \ TRACE_DBG_FLAG(TRACE_MGMT_DEBUG|TRACE_SPECIAL, format, ## args) -#define TRACE_PR(format, args...) \ - TRACE_DBG_FLAG(TRACE_PRES, format, ## args) #define TRACE_BLOCK(format, args...) \ TRACE_DBG_FLAG(TRACE_BLOCKING, format, ## args) @@ -369,7 +376,6 @@ do { \ #define TRACE_DBG_SPECIAL(format, args...) no_printk(format, ##args) #define TRACE_MGMT_DBG(format, args...) no_printk(format, ##args) #define TRACE_MGMT_DBG_SPECIAL(format, args...) no_printk(format, ##args) -#define TRACE_PR(format, args...) do {} while (0) #define TRACE_BLOCK(format, args...) no_printk(format, ##args) #define TRACE_BUFFER(message, buff, len) \ ((void)(message), (void)(buff), (void)(len)) diff --git a/scst/kernel/in-tree/Kconfig.drivers.Linux-4.5.patch b/scst/kernel/in-tree/Kconfig.drivers.Linux-4.5.patch new file mode 100644 index 000000000..39d30a55e --- /dev/null +++ b/scst/kernel/in-tree/Kconfig.drivers.Linux-4.5.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/Kconfig b/drivers/Kconfig +index c70d6e4..0a4ed1b 100644 +--- a/drivers/Kconfig ++++ b/drivers/Kconfig +@@ -26,6 +26,8 @@ source "drivers/ide/Kconfig" + + source "drivers/scsi/Kconfig" + ++source "drivers/scst/Kconfig" ++ + source "drivers/ata/Kconfig" + + source "drivers/md/Kconfig" diff --git a/scst/kernel/in-tree/Kconfig.drivers.Linux-4.6.patch b/scst/kernel/in-tree/Kconfig.drivers.Linux-4.6.patch new file mode 100644 index 000000000..39d30a55e --- /dev/null +++ b/scst/kernel/in-tree/Kconfig.drivers.Linux-4.6.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/Kconfig b/drivers/Kconfig +index c70d6e4..0a4ed1b 100644 +--- a/drivers/Kconfig ++++ b/drivers/Kconfig +@@ -26,6 +26,8 @@ source "drivers/ide/Kconfig" + + source "drivers/scsi/Kconfig" + ++source "drivers/scst/Kconfig" ++ + source "drivers/ata/Kconfig" + + source "drivers/md/Kconfig" diff --git a/scst/kernel/in-tree/Makefile.dev_handlers-4.5 b/scst/kernel/in-tree/Makefile.dev_handlers-4.5 new file mode 100644 index 000000000..f933b36f7 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.dev_handlers-4.5 @@ -0,0 +1,14 @@ +ccflags-y += -Wno-unused-parameter + +obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ + scst_vdisk.o scst_raid.o scst_processor.o scst_user.o + +obj-$(CONFIG_SCST_DISK) += scst_disk.o +obj-$(CONFIG_SCST_TAPE) += scst_tape.o +obj-$(CONFIG_SCST_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCST_MODISK) += scst_modisk.o +obj-$(CONFIG_SCST_CHANGER) += scst_changer.o +obj-$(CONFIG_SCST_RAID) += scst_raid.o +obj-$(CONFIG_SCST_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o +obj-$(CONFIG_SCST_USER) += scst_user.o diff --git a/scst/kernel/in-tree/Makefile.dev_handlers-4.6 b/scst/kernel/in-tree/Makefile.dev_handlers-4.6 new file mode 100644 index 000000000..f933b36f7 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.dev_handlers-4.6 @@ -0,0 +1,14 @@ +ccflags-y += -Wno-unused-parameter + +obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ + scst_vdisk.o scst_raid.o scst_processor.o scst_user.o + +obj-$(CONFIG_SCST_DISK) += scst_disk.o +obj-$(CONFIG_SCST_TAPE) += scst_tape.o +obj-$(CONFIG_SCST_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCST_MODISK) += scst_modisk.o +obj-$(CONFIG_SCST_CHANGER) += scst_changer.o +obj-$(CONFIG_SCST_RAID) += scst_raid.o +obj-$(CONFIG_SCST_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o +obj-$(CONFIG_SCST_USER) += scst_user.o diff --git a/scst/kernel/in-tree/Makefile.drivers.Linux-4.5.patch b/scst/kernel/in-tree/Makefile.drivers.Linux-4.5.patch new file mode 100644 index 000000000..6bbacd12f --- /dev/null +++ b/scst/kernel/in-tree/Makefile.drivers.Linux-4.5.patch @@ -0,0 +1,12 @@ +diff --git a/drivers/Makefile b/drivers/Makefile +index 527a6da..db2c24f 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -137,6 +137,7 @@ obj-$(CONFIG_SSB) += ssb/ + obj-$(CONFIG_BCMA) += bcma/ + obj-$(CONFIG_VHOST_RING) += vhost/ + obj-$(CONFIG_VLYNQ) += vlynq/ ++obj-$(CONFIG_SCST) += scst/ + obj-$(CONFIG_STAGING) += staging/ + obj-y += platform/ + #common clk code diff --git a/scst/kernel/in-tree/Makefile.drivers.Linux-4.6.patch b/scst/kernel/in-tree/Makefile.drivers.Linux-4.6.patch new file mode 100644 index 000000000..6bbacd12f --- /dev/null +++ b/scst/kernel/in-tree/Makefile.drivers.Linux-4.6.patch @@ -0,0 +1,12 @@ +diff --git a/drivers/Makefile b/drivers/Makefile +index 527a6da..db2c24f 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -137,6 +137,7 @@ obj-$(CONFIG_SSB) += ssb/ + obj-$(CONFIG_BCMA) += bcma/ + obj-$(CONFIG_VHOST_RING) += vhost/ + obj-$(CONFIG_VLYNQ) += vlynq/ ++obj-$(CONFIG_SCST) += scst/ + obj-$(CONFIG_STAGING) += staging/ + obj-y += platform/ + #common clk code diff --git a/scst/kernel/in-tree/Makefile.scst-4.5 b/scst/kernel/in-tree/Makefile.scst-4.5 new file mode 100644 index 000000000..f4e0cc985 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.scst-4.5 @@ -0,0 +1,17 @@ +ccflags-y += -Wno-unused-parameter + +scst-y += scst_copy_mgr.o +scst-y += scst_debug.o +scst-y += scst_dlm.o +scst-y += scst_event.o +scst-y += scst_lib.o +scst-y += scst_main.o +scst-y += scst_mem.o +scst-y += scst_no_dlm.o +scst-y += scst_pres.o +scst-y += scst_sysfs.o +scst-y += scst_targ.o +scst-y += scst_tg.o + +obj-$(CONFIG_SCST) += scst.o dev_handlers/ fcst/ iscsi-scst/ qla2xxx-target/ \ + srpt/ scst_local/ diff --git a/scst/kernel/in-tree/Makefile.scst-4.6 b/scst/kernel/in-tree/Makefile.scst-4.6 new file mode 100644 index 000000000..f4e0cc985 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.scst-4.6 @@ -0,0 +1,17 @@ +ccflags-y += -Wno-unused-parameter + +scst-y += scst_copy_mgr.o +scst-y += scst_debug.o +scst-y += scst_dlm.o +scst-y += scst_event.o +scst-y += scst_lib.o +scst-y += scst_main.o +scst-y += scst_mem.o +scst-y += scst_no_dlm.o +scst-y += scst_pres.o +scst-y += scst_sysfs.o +scst-y += scst_targ.o +scst-y += scst_tg.o + +obj-$(CONFIG_SCST) += scst.o dev_handlers/ fcst/ iscsi-scst/ qla2xxx-target/ \ + srpt/ scst_local/ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 04b98d035..5b5147013 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -7363,13 +7363,19 @@ static void blockio_on_alua_state_change_finish(struct scst_device *dev, if (((new_state == SCST_TG_STATE_OPTIMIZED) || (new_state == SCST_TG_STATE_NONOPTIMIZED)) && (virt_dev->fd == NULL)) { /* Try non-optimized as well, it might be new redirection device */ - int rc; + int rc = 0; TRACE_MGMT_DBG("ALUA state change from %s to %s finished (dev %s), " "reopenning FD", scst_alua_state_name(old_state), scst_alua_state_name(new_state), dev->virt_name); - rc = vdisk_open_fd(virt_dev, dev->dev_rd_only); + /* + * only reopen fd if tgt_dev_cnt is not zero, otherwise we will + * leak reference. + */ + if (virt_dev->tgt_dev_cnt) + rc = vdisk_open_fd(virt_dev, dev->dev_rd_only); + if (rc == 0) { if (virt_dev->reexam_pending) { rc = vdisk_reexamine(virt_dev); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 7725036a5..fa6c33313 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -162,6 +162,7 @@ static ssize_t scst_trace_level_show(const struct scst_trace_log *local_tbl, " echo \"all|none|default\" >trace_level\n" " echo \"value DEC|0xHEX|0OCT\" >trace_level\n" " echo \"add|del TOKEN\" >trace_level\n" +#ifdef CONFIG_SCST_DEBUG "\nwhere TOKEN is one of [debug, function, line, pid,\n" #ifndef GENERATING_UPSTREAM_PATCH " entryexit, buff, mem, sg, out_of_mem,\n" @@ -170,8 +171,14 @@ static ssize_t scst_trace_level_show(const struct scst_trace_log *local_tbl, #endif " special, scsi, mgmt, minor,\n" " mgmt_dbg, scsi_serializing,\n" - " retry, recv_bot, send_bot, recv_top, pr,\n" - " block, send_top%s]\n", help != NULL ? help : ""); + " retry, pr, block%s]\n", +#else /* CONFIG_SCST_DEBUG */ + "\nwhere TOKEN is one of [function, line, pid," + "out_of_mem, special, scsi, mgmt, minor," + "scsi_serializing, retry, pr%s]\n", + +#endif /* CONFIG_SCST_DEBUG */ + help != NULL ? help : ""); return pos; } diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index ba1e7ebfc..20ea82945 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -3454,10 +3454,6 @@ static int scst_do_real_exec(struct scst_cmd *cmd) scsi_dev = dev->scsi_dev; - TRACE_DBG("Sending cmd %p to SCSI mid-level dev %d:%d:%d:%lld", cmd, - scsi_dev->host->host_no, scsi_dev->channel, scsi_dev->id, - (u64)scsi_dev->lun); - if (unlikely(scsi_dev == NULL)) { PRINT_ERROR("Command for virtual device must be " "processed by device handler (LUN %lld)!", @@ -3465,6 +3461,10 @@ static int scst_do_real_exec(struct scst_cmd *cmd) goto out_error; } + TRACE_DBG("Sending cmd %p to SCSI mid-level dev %d:%d:%d:%lld", cmd, + scsi_dev->host->host_no, scsi_dev->channel, scsi_dev->id, + (u64)scsi_dev->lun); + scst_set_exec_start(cmd); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) diff --git a/scst_local/in-tree/Makefile-4.5 b/scst_local/in-tree/Makefile-4.5 new file mode 100644 index 000000000..8cbbbff63 --- /dev/null +++ b/scst_local/in-tree/Makefile-4.5 @@ -0,0 +1,2 @@ +obj-$(CONFIG_SCST_LOCAL) += scst_local.o + diff --git a/scst_local/in-tree/Makefile-4.6 b/scst_local/in-tree/Makefile-4.6 new file mode 100644 index 000000000..8cbbbff63 --- /dev/null +++ b/scst_local/in-tree/Makefile-4.6 @@ -0,0 +1,2 @@ +obj-$(CONFIG_SCST_LOCAL) += scst_local.o + diff --git a/scstadmin/init.d/scst b/scstadmin/init.d/scst index 5e609c26f..c906f32c2 100755 --- a/scstadmin/init.d/scst +++ b/scstadmin/init.d/scst @@ -298,6 +298,15 @@ scst_status() { return 3 fi done + + for d in $SCST_DAEMONS; do + daemon_name=`basename ${d}` + pgrep ${daemon_name} > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "${daemon_name}: not running" + return 3 + fi + done return 0 }