From a85225d5a30011287ead4b73a94623b5adccb896 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 8 Dec 2015 03:58:10 +0000 Subject: [PATCH] Merged revisions 6703-6718,6720-6721 via svnmerge from svn+ssh://vlnb@svn.code.sf.net/p/scst/svn/trunk ........ r6703 | bvassche | 2015-11-19 08:53:18 -0800 (Thu, 19 Nov 2015) | 5 lines scst_sysfs: Introduce scst_parse_add_repl_param() This makes the __scst_process_luns_mgmt_store() source code slightly easier to read. ........ r6704 | bvassche | 2015-11-19 09:30:24 -0800 (Thu, 19 Nov 2015) | 1 line scripts/run-regression-tests: Also test no-DLM build ........ r6705 | bvassche | 2015-11-19 09:31:02 -0800 (Thu, 19 Nov 2015) | 1 line scst: Fix procfs build ........ r6706 | bvassche | 2015-11-19 09:48:18 -0800 (Thu, 19 Nov 2015) | 1 line scst: More procfs build fixes. See also r6694. ........ r6707 | bvassche | 2015-11-20 13:47:57 -0800 (Fri, 20 Nov 2015) | 5 lines scst_local: Linux kernel v4.4 build fix Signed-off-by: Sebastian Herbszt [ bvanassche: Merged the two #if-statements into a single #if-statement ] ........ r6708 | bvassche | 2015-11-20 15:23:48 -0800 (Fri, 20 Nov 2015) | 2 lines /etc/init.d/scst: Suppress rmmod error messages ........ r6709 | bvassche | 2015-11-20 16:19:04 -0800 (Fri, 20 Nov 2015) | 5 lines scstadmin: Improve copy manager support Add support for saving and restoring copy manager attributes. ........ r6710 | bvassche | 2015-11-22 11:49:18 -0800 (Sun, 22 Nov 2015) | 4 lines qla2x00t: Fix a few typos Signed-off-by: Sebastian Herbszt ........ r6711 | bvassche | 2015-11-22 12:03:29 -0800 (Sun, 22 Nov 2015) | 7 lines mpt: Include header file mptbase.h without path Allow include path modification with LSI_INC_DIR. Signed-off-by: Sebastian Herbszt ........ r6712 | bvassche | 2015-11-23 15:04:57 -0800 (Mon, 23 Nov 2015) | 4 lines scstadmin: Improve copy manager support further Also restore pass-through LUNs ........ r6713 | bvassche | 2015-11-23 15:05:24 -0800 (Mon, 23 Nov 2015) | 2 lines scstadmin: Make regression test 6 pass ........ r6714 | bvassche | 2015-11-25 09:28:02 -0800 (Wed, 25 Nov 2015) | 6 lines usr/fileio: Build fix for Ubuntu 15.10 Ubuntu 15.10 includes Linux kernel 4.2 but does not define SERVICE_ACTION_IN_16 in the glibc header. Hence provide a definition in scst_const.h. ........ r6715 | bvassche | 2015-11-27 20:39:57 -0800 (Fri, 27 Nov 2015) | 1 line scst-const.h: Follow-up for r6714 ........ r6716 | bvassche | 2015-12-02 08:57:45 -0800 (Wed, 02 Dec 2015) | 1 line scst: Rename the PR-sync document to avoid filenames with spaces in the SCST tree ........ r6717 | bvassche | 2015-12-02 14:59:33 -0800 (Wed, 02 Dec 2015) | 1 line scstadmin: Ensure that -no_lip takes effect for all SCST configuration commands ........ r6718 | bvassche | 2015-12-03 16:31:40 -0800 (Thu, 03 Dec 2015) | 1 line nightly build: Update kernel versions ........ r6720 | vlnb | 2015-12-07 19:44:51 -0800 (Mon, 07 Dec 2015) | 3 lines docs: fix (extra)clean brocken by r6716 ........ r6721 | vlnb | 2015-12-07 19:51:01 -0800 (Mon, 07 Dec 2015) | 3 lines Cleanup ........ git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.1.x@6722 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- doc/Makefile | 4 +- ...M-as-a-Distributed-In-Memory-Database.pdf} | Bin mpt/mpt_scst.h | 2 +- nightly/conf/nightly.conf | 6 +- qla2x00t/qla_isr.c | 6 +- qla2x00t/qla_os.c | 4 +- scripts/run-regression-tests | 21 +++ scst/include/scst.h | 2 + scst/include/scst_const.h | 4 +- scst/src/dev_handlers/scst_user.c | 15 +- scst/src/scst_priv.h | 21 +++ scst/src/scst_proc.c | 2 +- scst/src/scst_sysfs.c | 142 ++++++++++-------- scst_local/scst_local.c | 3 +- scstadmin/init.d/scst | 5 +- .../scst-0.9.10/lib/SCST/SCST.pm | 11 +- .../scst-0.9.10/t/01-start-scst.t | 2 + .../scst-0.9.10/t/06-cont-on-err.t | 4 +- .../scst-0.9.10/t/after-restore.conf | 10 +- scstadmin/scstadmin.sysfs/scstadmin | 57 +++++-- 20 files changed, 220 insertions(+), 101 deletions(-) rename doc/{Using the DLM as a Distributed In-Memory Database.pdf => Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf} (100%) diff --git a/doc/Makefile b/doc/Makefile index c1b59b8cc..de55e58a8 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -36,9 +36,9 @@ rtf: $(RTFS) $(COMMAND)rtf $(<) clean: - mv "Using the DLM as a Distributed In-Memory Database.pdf" "Using the DLM as a Distributed In-Memory Database.pdf_" + -mv "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf" "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf_" rm -f *.txt *.html *.tex *.dvi *.ps *.pdf *.info *.lyx *.rtf - mv "Using the DLM as a Distributed In-Memory Database.pdf_" "Using the DLM as a Distributed In-Memory Database.pdf" + -mv "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf_" "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf" extraclean: clean rm -f *.orig *.rej diff --git a/doc/Using the DLM as a Distributed In-Memory Database.pdf b/doc/Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf similarity index 100% rename from doc/Using the DLM as a Distributed In-Memory Database.pdf rename to doc/Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf diff --git a/mpt/mpt_scst.h b/mpt/mpt_scst.h index 98d11fcab..51dd1c55f 100644 --- a/mpt/mpt_scst.h +++ b/mpt/mpt_scst.h @@ -37,7 +37,7 @@ #define MPT_STM_64_BIT_DMA 1 #endif -#include "../drivers/message/fusion/mptbase.h" +#include "mptbase.h" #ifndef MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED #define MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED 0x24000002 diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 6b79841c8..67abb86e4 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -8,13 +8,13 @@ ABT_KERNELS=" \ 4.1.13-nc \ 4.0.9-nc \ 3.19.7-nc \ -3.18.19-nc \ +3.18.24-nc \ 3.17.8-nc \ 3.16.7-nc \ 3.15.10-nc \ 3.14.57-nc \ 3.13.11-nc \ -3.12.44-nc \ +3.12.51-nc \ 3.11.10-nc \ 3.10.93-nc \ 3.9.11-nc \ @@ -24,7 +24,7 @@ ABT_KERNELS=" \ 3.5.7-nc \ 3.4.108-nc \ 3.3.8-nc \ -3.2.67-nc \ +3.2.74-nc \ 3.1.10-nc \ 3.0.101-nc \ 2.6.39.4-nc \ diff --git a/qla2x00t/qla_isr.c b/qla2x00t/qla_isr.c index 5f2923dbe..83714a603 100644 --- a/qla2x00t/qla_isr.c +++ b/qla2x00t/qla_isr.c @@ -261,7 +261,7 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) /* Read all mbox registers? */ mboxes = (1 << ha->mbx_count) - 1; if (!ha->mcp) - ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERRROR.\n"); + ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); else mboxes = ha->mcp->in_mb; @@ -1516,7 +1516,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, struct scsi_dif_tuple { __be16 guard; /* Checksum */ - __be16 app_tag; /* APPL identifer */ + __be16 app_tag; /* APPL identifier */ __be32 ref_tag; /* Target LBA or indirect LBA */ }; @@ -2073,7 +2073,7 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) /* Read all mbox registers? */ mboxes = (1 << ha->mbx_count) - 1; if (!ha->mcp) - ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERRROR.\n"); + ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); else mboxes = ha->mcp->in_mb; diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index bbaad3885..eb40c5405 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -1171,7 +1171,7 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, cmd->device->lun, type) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800d, - "wait for peding cmds failed for cmd=%p.\n", cmd); + "wait for pending cmds failed for cmd=%p.\n", cmd); goto eh_reset_failed; } @@ -1274,7 +1274,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) eh_bus_reset_done: ql_log(ql_log_warn, vha, 0x802b, "BUS RESET %s nexus=%ld:%d:%d.\n", - (ret == FAILED) ? "FAILED" : "SUCCEDED", vha->host_no, id, lun); + (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); return ret; } diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index 745e3d19d..031e73117 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -141,6 +141,26 @@ function compile_scst_unpatched { ) } +# Compile the unpatched SCST source code without DLM. +function compile_scst_no_dlm { + local scst="$PWD" + local outputfile="${outputdir}/compilation-output-no-dlm.txt" + local workingdirectory="${outputdir}/scst-no-dlm" + + echo "Testing whether the SCST tree compiles fine without DLM support ..." + ( + if mkdir -p "${workingdirectory}" \ + && cd "${workingdirectory}" \ + && duplicate_scst_source_tree "${scst}" \ + && CONFIG_SCST_NO_DLM=y compile_scst &> "${outputfile}" + then + echo "OK" + else + echo "FAILED" + fi + ) +} + # Test out-of-tree compilation agains the kernel header files in # /lib/modules/$(uname -r)/build. function compile_scst_patched { @@ -558,6 +578,7 @@ fi test_scst_tree_patches || exit $? if [ "${run_local_compilation}" = "true" ]; then compile_scst_unpatched || exit $? + compile_scst_no_dlm || exit $? compile_scst_patched 2release || exit $? compile_scst_patched 2perf || exit $? compile_scst_patched enable_proc || exit $? diff --git a/scst/include/scst.h b/scst/include/scst.h index a88f6cce1..34314dc78 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5675,8 +5675,10 @@ struct scst_ext_copy_seg_descr { int tgt_descr_offs; }; +#ifndef CONFIG_SCST_PROC void scst_ext_copy_remap_done(struct scst_cmd *ec_cmd, struct scst_ext_copy_data_descr *dds, int dds_cnt); int scst_ext_copy_get_cur_seg_data_len(struct scst_cmd *ec_cmd); +#endif #endif /* __SCST_H */ diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index 22e585756..c78d998c6 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -466,10 +466,10 @@ static inline int scst_sense_response_code(const uint8_t *sense) #endif #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +#if !defined(__KERNEL__) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) /* * See also patch "scsi: rename SERVICE_ACTION_IN_16 to SERVICE_ACTION_IN_16" - * (commit eb846d9f147455e4e5e1863bfb5e31974bb69b7c). + * (commit eb846d9f147455e4e5e1863bfb5e31974bb69b7c; kernel 3.19.0). */ #ifndef SERVICE_ACTION_IN_16 #define SERVICE_ACTION_IN_16 0x9e diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index caf33d27c..a319a9382 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -955,6 +955,7 @@ static int dev_user_exec(struct scst_cmd *cmd) return res; } +#ifndef CONFIG_SCST_PROC static void dev_user_ext_copy_remap(struct scst_cmd *cmd, struct scst_ext_copy_seg_descr *seg) { @@ -985,6 +986,7 @@ static void dev_user_ext_copy_remap(struct scst_cmd *cmd, TRACE_EXIT(); return; } +#endif static void dev_user_free_sgv(struct scst_user_cmd *ucmd) { @@ -1485,6 +1487,7 @@ static int dev_user_process_reply_on_cache_free(struct scst_user_cmd *ucmd) return res; } +#ifndef CONFIG_SCST_PROC static int dev_user_process_reply_ext_copy_remap(struct scst_user_cmd *ucmd, struct scst_user_reply_cmd *reply) { @@ -1628,6 +1631,7 @@ out_status: scst_set_cmd_error_status(cmd, rreply->status); goto out_done; } +#endif static int dev_user_process_ws_reply(struct scst_user_cmd *ucmd, struct scst_user_scsi_cmd_reply_exec *ereply) @@ -1950,9 +1954,11 @@ unlock_process: res = dev_user_process_reply_on_cache_free(ucmd); break; +#ifndef CONFIG_SCST_PROC case UCMD_STATE_EXT_COPY_REMAPPING: res = dev_user_process_reply_ext_copy_remap(ucmd, reply); break; +#endif case UCMD_STATE_TM_RECEIVED_EXECING: case UCMD_STATE_TM_DONE_EXECING: @@ -2677,7 +2683,11 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, SCST_CONTEXT_THREAD); else { sBUG_ON(state != UCMD_STATE_EXT_COPY_REMAPPING); +#ifndef CONFIG_SCST_PROC scst_ext_copy_remap_done(ucmd->cmd, NULL, 0); +#else + sBUG(); +#endif } /* !! At this point cmd and ucmd can be already freed !! */ @@ -3217,10 +3227,11 @@ static void dev_user_setup_functions(struct scst_user_dev *dev) dev->devtype.dev_alloc_data_buf = dev_user_alloc_data_buf; dev->devtype.dev_done = NULL; + dev->devtype.ext_copy_remap = NULL; +#ifndef CONFIG_SCST_PROC if (dev->ext_copy_remap_supported) dev->devtype.ext_copy_remap = dev_user_ext_copy_remap; - else - dev->devtype.ext_copy_remap = NULL; +#endif if (dev->parse_type != SCST_USER_PARSE_CALL) { switch (dev->devtype.type) { diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index ae1157d36..f0f87d8e3 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -893,6 +893,27 @@ void scst_cm_exit(void); static inline int scst_cm_on_dev_register(struct scst_device *dev) { return 0; } static inline void scst_cm_on_dev_unregister(struct scst_device *dev) {} +static inline int scst_cm_on_add_acg(struct scst_acg *acg) +{ + return 0; +} + +static inline void scst_cm_on_del_acg(struct scst_acg *acg) +{ +} + +static inline int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun, + unsigned int *flags) +{ + return 0; +} + +static inline bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev, + bool gen_report_luns_changed) +{ + return gen_report_luns_changed; +} + static inline int scst_cm_parse_descriptors(struct scst_cmd *cmd) { scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_opcode)); diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 26b99c3fe..0ade29717 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -2072,7 +2072,7 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, rc = scst_acg_add_lun(acg, NULL, dev, virt_lun, read_only ? SCST_ADD_LUN_READ_ONLY : 0, - false, NULL); + NULL); if (rc) { res = rc; goto out_free_up; diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index cc939175e..11f0f2663 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1253,11 +1253,88 @@ static void scst_tgt_release(struct kobject *kobj) return; } +static int scst_parse_add_repl_param(struct scst_acg *acg, + struct scst_device *dev, char *pp, + unsigned long *virt_lun, + bool *read_only) +{ + int res; + char *e; + + *read_only = false; + e = scst_get_next_lexem(&pp); + res = kstrtoul(e, 0, virt_lun); + if (res != 0) { + PRINT_ERROR("Valid LUN required for dev %s (res %d)", + dev->virt_name, res); + goto out; + } else if (*virt_lun > SCST_MAX_LUN) { + PRINT_ERROR("Too big LUN %ld (max %d)", *virt_lun, SCST_MAX_LUN); + res = -EINVAL; + goto out; + } + + while (1) { + unsigned long val; + char *param = scst_get_next_token_str(&pp); + char *p, *pp; + + if (param == NULL) + break; + + p = scst_get_next_lexem(¶m); + if (*p == '\0') { + PRINT_ERROR("Syntax error at %s (device %s)", param, + dev->virt_name); + res = -EINVAL; + goto out; + } + + pp = scst_get_next_lexem(¶m); + if (*pp == '\0') { + PRINT_ERROR("Parameter %s value missed for device %s", + p, dev->virt_name); + res = -EINVAL; + goto out; + } + + if (scst_get_next_lexem(¶m)[0] != '\0') { + PRINT_ERROR("Too many parameter %s values (device %s)", + p, dev->virt_name); + res = -EINVAL; + goto out; + } + + res = kstrtoul(pp, 0, &val); + if (res != 0) { + PRINT_ERROR("kstrtoul() for %s failed: %d " + "(device %s)", pp, res, dev->virt_name); + goto out; + } + + if (strcasecmp("read_only", p) == 0) { + *read_only = !!val; + TRACE_DBG("READ ONLY %d", *read_only); + } else { + PRINT_ERROR("Unknown parameter %s (device %s)", p, + dev->virt_name); + res = -EINVAL; + goto out; + } + } + + res = 0; + +out: + return res; +} + static int __scst_process_luns_mgmt_store(char *buffer, struct scst_tgt *tgt, struct scst_acg *acg, bool tgt_kobj) { - int res, read_only = 0, action; - char *p, *pp, *e; + int res, action; + bool read_only; + char *p, *pp; unsigned long virt_lun; struct scst_acg_dev *acg_dev = NULL, *acg_dev_tmp; struct scst_device *d, *dev = NULL; @@ -1329,65 +1406,10 @@ static int __scst_process_luns_mgmt_store(char *buffer, bool dev_replaced = false; unsigned int flags = 0; - e = scst_get_next_lexem(&pp); - res = kstrtoul(e, 0, &virt_lun); - if (res != 0) { - PRINT_ERROR("Valid LUN required for dev %s (res %d)", p, res); + res = scst_parse_add_repl_param(acg, dev, pp, &virt_lun, + &read_only); + if (res != 0) goto out_unlock; - } else if (virt_lun > SCST_MAX_LUN) { - PRINT_ERROR("Too big LUN %ld (max %d)", virt_lun, SCST_MAX_LUN); - res = -EINVAL; - goto out_unlock; - } - - while (1) { - unsigned long val; - char *param = scst_get_next_token_str(&pp); - char *pp; - - if (param == NULL) - break; - - p = scst_get_next_lexem(¶m); - if (*p == '\0') { - PRINT_ERROR("Syntax error at %s (device %s)", - param, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - - pp = scst_get_next_lexem(¶m); - if (*pp == '\0') { - PRINT_ERROR("Parameter %s value missed for device %s", - p, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - - if (scst_get_next_lexem(¶m)[0] != '\0') { - PRINT_ERROR("Too many parameter's %s values (device %s)", - p, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - - res = kstrtoul(pp, 0, &val); - if (res != 0) { - PRINT_ERROR("kstrtoul() for %s failed: %d " - "(device %s)", pp, res, dev->virt_name); - goto out_unlock; - } - - if (!strcasecmp("read_only", p)) { - read_only = val; - TRACE_DBG("READ ONLY %d", read_only); - } else { - PRINT_ERROR("Unknown parameter %s (device %s)", - p, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - } acg_dev = NULL; list_for_each_entry(acg_dev_tmp, &acg->acg_dev_list, diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 278c3588e..c5dbf0aa7 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1619,7 +1619,8 @@ static struct scsi_host_template scst_lcl_ini_driver_template = { #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 25)) .eh_target_reset_handler = scst_local_target_reset, #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) .use_blk_tags = true, #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33) || \ diff --git a/scstadmin/init.d/scst b/scstadmin/init.d/scst index ba5ce6f19..5e609c26f 100755 --- a/scstadmin/init.d/scst +++ b/scstadmin/init.d/scst @@ -149,6 +149,7 @@ parse_scst_conf() { case "$d" in iscsi) echo iscsi_scst;; qla2x00t) echo qla2x00tgt;; + copy_manager) ;; *) echo "$d";; esac done | sort -u` \ @@ -171,7 +172,9 @@ unload_kmod() { m="$1" t="$2" i=0 - while [ -e "/sys/module/$m/refcnt" ] && ! rmmod "$m" && [ $i -lt "$t" ]; do + while [ -e "/sys/module/$m/refcnt" ] && ! rmmod "$m" 2>/dev/null && + [ $i -lt "$t" ] + do sleep 1 i=$((i+1)) done 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 4aa497f98..2eb5055e2 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 @@ -5,7 +5,7 @@ package SCST::SCST; # Author: Mark R. Buechler # License: GPLv2 # Copyright (c) 2005-2011 Mark R. Buechler -# Copyright (c) 2011 Bart Van Assche . +# Copyright (c) 2011-2015 Bart Van Assche . use 5.005; use Fcntl ':mode'; @@ -550,8 +550,7 @@ sub drivers { if (opendir($dHandle, $_path)) { foreach my $driver (readdir($dHandle)) { - next if ($driver eq '.' || $driver eq '..' || - $driver eq 'copy_manager'); + next if ($driver eq '.' || $driver eq '..'); if (-d make_path(SCST_TARGETS_DIR(), $driver)) { push @drivers, $driver; @@ -3931,7 +3930,11 @@ sub handlerAttributes { } } - next if ($attribute eq SCST_MGMT_IO); + if ($attribute eq SCST_MGMT_IO) { + $attributes{$attribute}->{'static'} = TRUE; + $attributes{$attribute}->{'value'} = $value; + next; + } if (!(($mode & S_IRUSR) >> 6)) { $attributes{$attribute}->{'static'} = FALSE; diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t index b30abe46a..703756e0f 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t @@ -9,6 +9,8 @@ BEGIN { if ($> == 0) { ok(system("killall iscsi-scstd >/dev/null 2>&1; " . + "modprobe -r scst_cdrom; " . + "modprobe -r scst_disk; " . "modprobe -r scst_local; " . "modprobe -r isert-scst; " . "modprobe -r iscsi-scst; " . diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t index 883f020f3..ada3d17a4 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t @@ -41,13 +41,15 @@ sub testRestoreConfig { "scstadmin-test-06-$$-1"); my $tmpfilename2 = File::Spec->catfile(File::Spec->tmpdir(), "scstadmin-test-06-$$-2"); + my $diff = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-06-$$-diff"); system("$scstadmin -clear_config -force -noprompt -no_lip >/dev/null"); system("$scstadmin -cont_on_err -no_lip -config $to_be_restored" . " >/dev/null"); system("$scstadmin -write_config $tmpfilename1 >/dev/null"); system("awk 'BEGIN {t = 0 } /^# Automatically generated by SCST Configurator v/ { \$0 = \"# Automatically generated by SCST Configurator v...\" } /^TARGET_DRIVER.*{\$/ { if (\$0 != \"TARGET_DRIVER scst_local {\") t = 1 } /^}\$/ { if (t == 1) t = 2 } /^\$/ { if (t == 2) { t = 3 } } /^./ { if (t == 3) { t = 0 } } { if (t == 0) print }' <$tmpfilename1 >$tmpfilename2"); - my $compare_result = system("diff -u $tmpfilename2 $expected"); + my $compare_result = system("diff -u $tmpfilename2 $expected >$diff"); ok($compare_result, 0); if ($compare_result == 0) { unlink($tmpfilename2); 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 f0c5264f2..8f5291be5 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 @@ -14,6 +14,11 @@ TARGET_DRIVER scst_local { LUN 0 disk01 LUN 1 disk01 + GROUP group_without_luns_with_attrs { + + addr_method FLAT + } + GROUP initiator_group { LUN 0 disk01 LUN 1 disk01 { @@ -27,11 +32,6 @@ TARGET_DRIVER scst_local { INITIATOR ini3 } - - GROUP group_without_luns_with_attrs { - - addr_method FLAT - } } } diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 60d609717..4a5b4556c 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -7,7 +7,7 @@ $Version = 'SCST Configurator v3.1.0-pre1'; # Author: Mark R. Buechler # License: GPLv2 # Copyright (c) 2005-2011 Mark R. Buechler -# Copyright (C) 2011 Bart Van Assche +# Copyright (C) 2011-2015 Bart Van Assche sub usage { @@ -1051,7 +1051,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeVirtualTarget($driver, $removeTarget); - $rc = issueLip($driver) if (!$rc); + $rc = issueLip($driver) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1071,7 +1071,7 @@ sub main { defined($addInitiator) && do { print "\n-> Making requested changes.\n"; $rc = addInitiator($driver, $target, $group, $addInitiator); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1079,7 +1079,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeInitiator($driver, $target, $group, $removeInitiator); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1087,7 +1087,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = moveInitiator($driver, $target, $group, $moveInitiator, $to); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1095,14 +1095,14 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearInitiators($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; defined($addLun) && do { print "\n-> Making requested changes.\n"; $rc = addLun($driver, $target, $device, $addLun, $attributes, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1110,7 +1110,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeLun($driver, $target, $removeLun, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1118,7 +1118,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = replaceLun($driver, $target, $group, $replaceLun, $device, $attributes); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1126,7 +1126,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearLuns($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1145,7 +1145,7 @@ sub main { }; defined($issueLip) && do { print "\n-> Making requested changes.\n"; - $rc = issueLip($driver, $issueLip, TRUE); + $rc = issueLip($driver, $issueLip, TRUE) if (!$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1334,6 +1334,25 @@ sub serializeNkAttr { return $result; } +# Return TRUE if and only if $1 is an SCST pass-through device. +sub isPassthroughDev { + my $dev = shift; + my $pt = FALSE; + + foreach my $handler (keys %{$CURRENT{'handler'}}) { + my ($ha, $errorString) = $SCST->handlerAttributes($handler); + next if ($ha->{'mgmt'} !~ 'echo "add_device H:C:I:L"'); + my @devs = @{$CURRENT{'handler'}->{$handler}}; + for my $i (0 .. $#devs) { + if ($dev eq @devs[$i]) { + $pt = TRUE; + last; + } + } + last if $pt; + } +} + # Returns 0 upon success and 1 upon error. sub writeConfiguration { my $nonkey = shift; @@ -1464,6 +1483,12 @@ sub writeConfiguration { foreach my $lun (sort numerically keys %{$luns}) { my $lun_dev = $$luns{$lun}; + # Do not save copy_manager LUN definitions + # for LUNs associated with an SCST device + # handler. + next if ($driver eq 'copy_manager' && + isPassthroughDev($lun_dev)); + $t_lun_buff .= "\t\tLUN $lun $lun_dev"; my ($attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun); @@ -1892,7 +1917,7 @@ sub checkConfiguration { } } - if (!defined($$tgt{'LUN'}->{'0'})) { + if ($driver ne 'copy_manager' && !defined($$tgt{'LUN'}->{'0'})) { print "\t-> WARNING: No LUN 0 defined for driver/target '$driver/$target'. ". "Many initiators require a LUN 0 to be defined.\n\n"; $warnings++; @@ -2104,7 +2129,7 @@ sub applyConfigAssignments { if ($deletions) { removeLun($driver, $target, $lun); $changes++; - } else { + } elsif ($driver ne 'copy_manager') { print "\t-> Device '$device' at LUN '$lun' is not in configuration ". "for driver/target '$driver/$target'. ". "Use -force to remove it.\n"; @@ -4880,6 +4905,12 @@ sub addLun { my $attributes = shift; my $group = shift; + # Do not complain about existing copy manager LUNs. + if ($driver eq 'copy_manager' && + $SCST->lunExists($driver, $target, $lun, $group)) { + return FALSE; + } + if (defined($group)) { print "\t-> Adding device '$device' at LUN $lun to driver/target/group ". "'$driver/$target/$group': ";