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 <herbszt@gmx.de>
  [ 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 <herbszt@gmx.de>
........
  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 <herbszt@gmx.de>
........
  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 <scsi/scsi.h> 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
This commit is contained in:
Vladislav Bolkhovitin
2015-12-08 03:58:10 +00:00
parent 9174680ae4
commit a85225d5a3
20 changed files with 220 additions and 101 deletions
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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 \
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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;
}
+21
View File
@@ -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 $?
+2
View File
@@ -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 */
+2 -2
View File
@@ -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
+13 -2
View File
@@ -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) {
+21
View File
@@ -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));
+1 -1
View File
@@ -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;
+82 -60
View File
@@ -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(&param);
if (*p == '\0') {
PRINT_ERROR("Syntax error at %s (device %s)", param,
dev->virt_name);
res = -EINVAL;
goto out;
}
pp = scst_get_next_lexem(&param);
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(&param)[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(&param);
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(&param);
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(&param)[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,
+2 -1
View File
@@ -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) || \
+4 -1
View File
@@ -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
@@ -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 <bvanassche@acm.org>.
# Copyright (c) 2011-2015 Bart Van Assche <bvanassche@acm.org>.
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;
@@ -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; " .
@@ -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);
@@ -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
}
}
}
+44 -13
View File
@@ -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 <bvanassche@acm.org>
# Copyright (C) 2011-2015 Bart Van Assche <bvanassche@acm.org>
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': ";