Hello community, here is the log from the commit of package lio-utils for openSUSE:Factory checked in at 2016-08-12 15:43:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lio-utils (Old) and /work/SRC/openSUSE:Factory/.lio-utils.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lio-utils" Changes: -------- --- /work/SRC/openSUSE:Factory/lio-utils/lio-utils.changes 2016-08-05 18:17:36.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.lio-utils.new/lio-utils.changes 2016-08-12 15:43:26.000000000 +0200 @@ -1,0 +2,29 @@ +Fri Aug 5 14:12:23 UTC 2016 - [email protected] + +- Updated to latest from SLE 12, adding: + * Wait for sysconfig to mount when loading iscsi_target_mod module + (bsc#910721) + (original author: [email protected]) + * Convert user-input of an empty string to the explicit 4-letter + string "NULL", when writing sysfs string attributes, such as + userid and password (bsc#919474), adding: + * lio-utils-fix-empty-attribute-string-writes.patch + (original author: [email protected]) + * Added retrying 5 times if first attempt to enable a new target + fails, which can happen on a fast multiprocessor system + (bsc#940636), adding: + * lio-utils-retry-enabling-fileio-target.patch + (original author: [email protected]) + * when dumping lio state, do not consider it an error if there is no + target directory, since that can mean there are no targets + (bsc#934521), adding: + * lio-utils-dump-skeleton-file-when-no-targets.patch + (original author: [email protected]) + * Restore configuration from saved file, at startup (bsc#950990), + adding patch: + * lio-utils-init-script-restore-config.patch + (original author: [email protected]) + * Converted /usr/sbin to %_sbin in spec file + (original author: [email protected]) + +------------------------------------------------------------------- New: ---- lio-utils-dump-skeleton-file-when-no-targets.patch lio-utils-fix-empty-attribute-string-writes.patch lio-utils-init-script-restore-config.patch lio-utils-retry-enabling-fileio-target.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lio-utils.spec ++++++ --- /var/tmp/diff_new_pack.NtJyUO/_old 2016-08-12 15:43:27.000000000 +0200 +++ /var/tmp/diff_new_pack.NtJyUO/_new 2016-08-12 15:43:27.000000000 +0200 @@ -89,6 +89,10 @@ Patch36: lio-utils-update-HOWTO-for-systemd.patch Patch37: lio-utils-dont-use-U64-from-net-snmp.patch Patch38: tcm_fabric-Ignore-dbroot-file.patch +Patch39: lio-utils-fix-empty-attribute-string-writes.patch +Patch40: lio-utils-retry-enabling-fileio-target.patch +Patch41: lio-utils-dump-skeleton-file-when-no-targets.patch +Patch42: lio-utils-init-script-restore-config.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -196,6 +200,10 @@ %patch36 -p1 %patch37 -p1 %patch38 -p1 +%patch39 -p1 +%patch40 -p1 +%patch41 -p1 +%patch42 -p1 %build make %{?_smp_mflags} OPTFLAGS="$RPM_OPT_FLAGS" @@ -218,6 +226,7 @@ chmod 755 $RPM_BUILD_ROOT/etc/target/tcm_start.sh echo "#!/bin/bash" > $RPM_BUILD_ROOT/etc/target/lio_start.sh echo "modprobe iscsi_target_mod" >> $RPM_BUILD_ROOT/etc/target/lio_start.sh +echo "udevadm settle -t 3 -E /sys/kernel/config/target" >> $RPM_BUILD_ROOT/etc/target/lio_start.sh chmod 755 $RPM_BUILD_ROOT/etc/target/lio_start.sh (cd tcm-py; python setup.py install --prefix=%{_prefix} --root=%{buildroot}) (cd lio-py; python setup.py install --prefix=%{_prefix} --root=%{buildroot}) @@ -281,11 +290,11 @@ %dir %{_vardir}/alua %dir %{_vardir}/fabric %dir %{_vardir}/policy -/usr/sbin/iscsi-name -/usr/sbin/tcm_* -/usr/sbin/lio_node -/usr/sbin/lio_dump -/usr/sbin/rctarget +%{_sbindir}/iscsi-name +%{_sbindir}/tcm_* +%{_sbindir}/lio_node +%{_sbindir}/lio_dump +%{_sbindir}/rctarget %{python_sitelib}/* %doc lio-utils.HOWTO /usr/sbin/target_status ++++++ lio-utils-dump-skeleton-file-when-no-targets.patch ++++++ From: Lee Duncan <[email protected]> Date: Fri Nov 20 15:24:01 PST 2015 Subject: dump skeleton file when no targets Reference: bsc#934521 When there is not target directory go ahead and dump an empty skeleton target, since this happens if there are no targets configured. signed-off-by: Lee Duncan <[email protected]> --- --- lio-py/lio_dump.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/lio-py/lio_dump.py +++ b/lio-py/lio_dump.py @@ -10,18 +10,18 @@ lio_root = "/sys/kernel/config/target/is def lio_target_configfs_dump(option, opt_str, value, parser): - if not os.path.isdir(lio_root): - print "Unable to access lio_root: " + lio_root - sys.exit(1) - - iqn_root = os.listdir(lio_root) - # Add proper shell header print "#!/bin/bash" # This will load up iscsi_target_mod.ko print "mkdir " + lio_root print "[ $? -eq 0 ] || exit 1" + + # skip the rest if no lio_root + if not os.path.isdir(lio_root): + print >>sys.stderr, "No targets? Unable to access lio_root: " + lio_root + sys.exit(0) + print "#### iSCSI Discovery authentication information" auth_dir = lio_root + "/discovery_auth" if os.path.isdir(auth_dir) == True: ++++++ lio-utils-fix-empty-attribute-string-writes.patch ++++++ From: Lee Duncan <[email protected]> Date: Wed Mar 4 10:42:09 PST 2015 Subject: [lio-utils] fix empty attribute string writes Writing an empty string to a sysfs attribute does not work, as 'echo -n "" >/sys/some/path/to/attribute" fails, as it gets optimized to a NOOP. This patch converts user input of an empty string to the 4-leter string "NULL", which is how sysfs actually detects empty string values for targets. --- diff -aurp lio-utils-4.1.orig/lio-py/lio_node.py lio-utils-4.1/lio-py/lio_node.py --- lio-utils-4.1.orig/lio-py/lio_node.py 2015-02-26 15:23:33.472000000 -0800 +++ lio-utils-4.1/lio-py/lio_node.py 2015-03-04 10:39:22.024000000 -0800 @@ -652,14 +652,10 @@ def lio_target_set_chap_auth(option, opt if not os.path.isdir(auth_dir): lio_err("iSCSI Initiator ACL " + initiator_iqn + " does not exist for iSCSI Target Portal Group: " + iqn + " " + tpgt) - setuser_op = "echo -n " + user + " > " + auth_dir + "/userid" - ret = os.system(setuser_op) - if ret: + if not write_to_file(auth_dir + "/userid", user): lio_err("Unable to set CHAP username for iSCSI Initaitor ACL " + initiator_iqn + " for iSCSI Target Portal Group: " + iqn + " " + tpgt) - setpassword_op = "echo -n " + password + " > " + auth_dir + "/password" - ret = os.system(setpassword_op) - if ret: + if not write_to_file(auth_dir + "/password", password): lio_err("Unable to set CHAP password for iSCSI Initaitor ACL " + initiator_iqn + " for iSCSI Target Portal Group: " + iqn + " " + tpgt) else: lio_dbg("Successfully set CHAP authentication for iSCSI Initaitor ACL " + initiator_iqn + " for iSCSI Target Portal Group: " + iqn + " " + tpgt) @@ -680,14 +676,10 @@ def lio_target_set_chap_mutual_auth(opti if not os.path.isdir(auth_dir): lio_err("iSCSI Initiator ACL " + initiator_iqn + " does not exist for iSCSI Target Portal Group: " + iqn + " " + tpgt) - setuser_op = "echo -n " + user_mutual + " > " + auth_dir + "/userid_mutual" - ret = os.system(setuser_op) - if ret: + if not write_to_file(auth_dir + "/userid_mutual", user_mutual): lio_err("Unable to set mutual CHAP username for iSCSI Initaitor ACL " + initiator_iqn + " for iSCSI Target Portal Group: " + iqn + " " + tpgt) - setpassword_op = "echo -n " + password_mutual + " > " + auth_dir + "/password_mutual" - ret = os.system(setpassword_op) - if ret: + if not write_to_file(auth_dir + "/password_mutual", password_mutual): lio_err("Unable to set mutual CHAP password for iSCSI Initaitor ACL " + initiator_iqn + " for iSCSI Target Portal Group: " + iqn + " " + tpgt) else: lio_dbg("Successfully set mutual CHAP authentication for iSCSI Initaitor ACL " + initiator_iqn + " for iSCSI Target Portal Group: " + iqn + " " + tpgt) @@ -698,7 +690,7 @@ def write_to_file(fname, vstr): if not os.path.isfile(fname): return False if not vstr: - vstr = "\0" + vstr = "NULL" with open(fname, 'w', 0) as sysfile: res = os.write(sysfile.fileno(), vstr) return (res > 0) ++++++ lio-utils-init-script-restore-config.patch ++++++ --- scripts/rc.target.suse | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/scripts/rc.target.suse +++ b/scripts/rc.target.suse @@ -45,6 +45,8 @@ SEMA_TARGET="/var/crash/target.fault" CONFIGFS_SCRIPT_DIR="/etc/target" TCM_CONFIGFS_SCRIPT="/etc/target/tcm_start.sh" LIO_CONFIGFS_SCRIPT="/etc/target/lio_start.sh" +TARGETCLI="/usr/bin/targetcli" +SAVECONFIG="/etc/target/saveconfig.json" ######################################################################### # Allows saving command & arguments into a file for subsequent debugging @@ -161,6 +163,16 @@ function run_tcm_cfs_ops() { run_lio_target_cfs_ops run_fabric_cfs_ops + # restore config from savefile + if [ -x $TARGETCLI -a -r $SAVECONFIG ]; then + echo -n $"Restoring configuration from $SAVECONFIG: " + ${TARGETCLI} restoreconfig clear_existing=true savefile=${SAVECONFIG} > /dev/null 2>&1 + RET=$? + if [ $RET != 0 ]; then + rc_failed 1 + fi + rc_status -v + fi } function check_configfs_mount() { ++++++ lio-utils-retry-enabling-fileio-target.patch ++++++ From: Lee Duncan Date: Thu Nov 19 14:15:22 PST 2015 Subject: retrying enabling FILEIO target Reference: bsc#940636 When trying to enable a newly create target in sysfs, if we are too fast, the target might not yet be fully set, since the time between creating the target (with a mkdir in sysfs) and the time when the target is fully set up is indetermanent. This patch enables 3 retries, at one second each, when trying to enable a target. --- tcm-py/tcm_fileio.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) --- a/tcm-py/tcm_fileio.py +++ b/tcm-py/tcm_fileio.py @@ -3,10 +3,37 @@ import os import subprocess as sub import string, re +import time from optparse import OptionParser tcm_root = "/sys/kernel/config/target/core" +def write_with_retries(attr_value, attr_path, newline=True, retries=5): + """ + Write an attribute value to an attribute path, followed by an + optional newline, with retries if needed. Return boolean + success or failure. + """ + success = False + while 1: + try: + with open(attr_path, 'w') as attr_file: + if newline: + print >>attr_file, attr_value + else: + print >>attr_file, attr_value, + success=True + break + except Exception, e: +# print "DEBUG: write failed", e + retries = retries - 1 + if not retries: + break + time.sleep(1) +# print "DEBUG: write '%s' to '%s': success=%s, retries left=%d" % \ +# (attr_value, attr_path, success, retries) + return success + def createvirtdev(path, params): # print "Calling fileio createvirtdev: path " + path @@ -40,13 +67,12 @@ def createvirtdev(path, params): print "FILEIO: createvirtdev failed for control_opt with " + params[0] return -1 - enable_opt = "echo 1 > " + cfs_path + "enable" -# print "Calling enable_opt " + enable_opt - ret = os.system(enable_opt) - if ret: + if not write_with_retries("1", cfs_path + "enable"): print "FILEIO: createvirtdev failed for enable_opt with " + params[0] return -1 + return 0 + def fd_freevirtdev(): pass
