diff --git a/SOURCES/0001-Turn-off-unsupported-fabrics.patch b/SOURCES/0001-Turn-off-unsupported-fabrics.patch index 40ed1af..dedea71 100644 --- a/SOURCES/0001-Turn-off-unsupported-fabrics.patch +++ b/SOURCES/0001-Turn-off-unsupported-fabrics.patch @@ -12,13 +12,11 @@ diff --git a/rtslib/fabric.py b/rtslib/fabric.py index 2887783..a44aa7e 100644 --- a/rtslib/fabric.py +++ b/rtslib/fabric.py -@@ -464,13 +464,13 @@ fabric_modules = { - "srpt": SRPTFabricModule, +@@ -465,12 +465,12 @@ fabric_modules = { "iscsi": ISCSIFabricModule, "loopback": LoopbackFabricModule, -- "qla2xxx": Qla2xxxFabricModule, + "qla2xxx": Qla2xxxFabricModule, - "sbp": SBPFabricModule, -+# "qla2xxx": Qla2xxxFabricModule, +# "sbp": SBPFabricModule, "tcm_fc": FCoEFabricModule, # "usb_gadget": USBGadgetFabricModule, # very rare, don't show diff --git a/SOURCES/0004-Support-Reconfiguration-of-device-path.patch b/SOURCES/0004-Support-Reconfiguration-of-device-path.patch new file mode 100644 index 0000000..4793d88 --- /dev/null +++ b/SOURCES/0004-Support-Reconfiguration-of-device-path.patch @@ -0,0 +1,55 @@ +From 2a816d67e95ac0edc6d56076595b29eddfeb433b Mon Sep 17 00:00:00 2001 +From: "Bryant G. Ly" +Date: Thu, 1 Jun 2017 13:11:37 -0500 +Subject: [PATCH] Support Reconfiguration of device path + +This patch allows users to pass in a string into the +attributes. Prior it would throw: + +Traceback (most recent call last): +File "/usr/bin/targetcli", line 121, in + main() +File "/usr/bin/targetcli", line 117, in main + root_node.ui_command_saveconfig() +File "/usr/lib/python3/dist-packages/targetcli/ui_root.py", line 98, in ui_command_saveconfig + self.rtsroot.save_to_file(savefile) +File "/usr/lib/python3/dist-packages/rtslib_fb/root.py", line 270, in save_to_file + f.write(json.dumps(self.dump(), sort_keys=True, indent=2)) +File "/usr/lib/python3/dist-packages/rtslib_fb/root.py", line 160, in dump + d['storage_objects'] = [so.dump() for so in self.storage_objects] +File "/usr/lib/python3/dist-packages/rtslib_fb/root.py", line 160, in + d['storage_objects'] = [so.dump() for so in self.storage_objects] +File "/usr/lib/python3/dist-packages/rtslib_fb/tcm.py", line 850, in dump + d = super(UserBackedStorageObject, self).dump() +File "/usr/lib/python3/dist-packages/rtslib_fb/tcm.py", line 294, in dump + d = super(StorageObject, self).dump() +File "/usr/lib/python3/dist-packages/rtslib_fb/node.py", line 217, in dump + attrs[item] = int(self.get_attribute(item)) +ValueError: invalid literal for int() with base 10: 'file//home/neo/test.raw' + +This error is due to set attribute dev_path being a non integer. + +Signed-off-by: Bryant G. Ly +--- + rtslib/node.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/rtslib/node.py b/rtslib/node.py +index c319a5b..c0092fc 100644 +--- a/rtslib/node.py ++++ b/rtslib/node.py +@@ -214,7 +214,10 @@ class CFSNode(object): + attrs = {} + params = {} + for item in self.list_attributes(writable=True): +- attrs[item] = int(self.get_attribute(item)) ++ try: ++ attrs[item] = int(self.get_attribute(item)) ++ except ValueError: ++ attrs[item] = self.get_attribute(item) + if attrs: + d['attributes'] = attrs + for item in self.list_parameters(writable=True): +-- +1.8.3.1 + diff --git a/SOURCES/0005-Remove-hba-only-directories-in-clear_existing.patch b/SOURCES/0005-Remove-hba-only-directories-in-clear_existing.patch new file mode 100644 index 0000000..4ba85d8 --- /dev/null +++ b/SOURCES/0005-Remove-hba-only-directories-in-clear_existing.patch @@ -0,0 +1,43 @@ +From 12e626b649ef4a928aa95e60d8b8c58b20bd3372 Mon Sep 17 00:00:00 2001 +From: Andy Grover +Date: Thu, 21 Sep 2017 16:45:30 -0700 +Subject: [PATCH] Remove hba-only directories in clear_existing() + +rtslib never creates hba directories without a storage object within it, +but if under some circumstance these existed then clear_existing() wouldn't +remove them, since StorageObject::all()'s glob ignores them. + +Add code to ensure these are also removed. + +Signed-off-by: Andy Grover +--- + rtslib/root.py | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/rtslib/root.py b/rtslib/root.py +index 0c3c231..72c0299 100644 +--- a/rtslib/root.py ++++ b/rtslib/root.py +@@ -21,6 +21,7 @@ under the License. + import os + import stat + import json ++import glob + + from .node import CFSNode + from .target import Target +@@ -206,6 +207,11 @@ class RTSRoot(CFSNode): + for so in self.storage_objects: + so.delete() + ++ # If somehow some hbas still exist (no storage object within?) clean ++ # them up too. ++ for hba_dir in glob.glob("%s/core/*_*" % self.configfs_dir): ++ os.rmdir(hba_dir) ++ + def restore(self, config, clear_existing=False, abort_on_error=False): + ''' + Takes a dict generated by dump() and reconfigures the target to match. +-- +1.8.3.1 + diff --git a/SOURCES/0006-create-remove-stale-hba-only-dir.patch b/SOURCES/0006-create-remove-stale-hba-only-dir.patch new file mode 100644 index 0000000..0e5caf8 --- /dev/null +++ b/SOURCES/0006-create-remove-stale-hba-only-dir.patch @@ -0,0 +1,54 @@ +From f06103354394ffa86817696a37edb7ddd351bc10 Mon Sep 17 00:00:00 2001 +From: Prasanna Kumar Kalever +Date: Fri, 9 Feb 2018 17:20:26 +0530 +Subject: [PATCH] create: remove stale hba-only dir + +curretly if there exist any stale hba-only directories, + +$ ls /sys/kernel/config/target/core/user_0/ +hba_info hba_mode + +Then backend creation fails, + +$ targetcli /backstores/fileio create block file 1M +This _Backstore already exists in configFS + +We will have to restart target.service or restore the configuration +again to clear the stale hba-only dirs. + +This patch checks for hba directory before creating one, +if it is already existing and found to be stale then removes it. + +Thanks to "Maurizio Lombardi " for debugging along + +Signed-off-by: Prasanna Kumar Kalever +--- + rtslib/node.py | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/rtslib/node.py b/rtslib/node.py +index c0092fc..1d77cd1 100644 +--- a/rtslib/node.py ++++ b/rtslib/node.py +@@ -52,9 +52,16 @@ class CFSNode(object): + ''' + if mode not in ['any', 'lookup', 'create']: + raise RTSLibError("Invalid mode: %s" % mode) ++ + if self.exists and mode == 'create': +- raise RTSLibError("This %s already exists in configFS" +- % self.__class__.__name__) ++ # ensure that self.path is not stale hba-only dir ++ if os.path.samefile(os.path.dirname(self.path), self.configfs_dir+'/core') \ ++ and not next(os.walk(self.path))[1]: ++ os.rmdir(self.path) ++ else: ++ raise RTSLibError("This %s already exists in configFS" ++ % self.__class__.__name__) ++ + elif not self.exists and mode == 'lookup': + raise RTSLibNotInCFS("No such %s in configfs: %s" + % (self.__class__.__name__, self.path)) +-- +1.8.3.1 + diff --git a/SPECS/python-rtslib.spec b/SPECS/python-rtslib.spec index aef9700..e025c20 100644 --- a/SPECS/python-rtslib.spec +++ b/SPECS/python-rtslib.spec @@ -9,13 +9,16 @@ License: ASL 2.0 Group: System Environment/Libraries Summary: API for Linux kernel LIO SCSI target Version: 2.1.fb63 -Release: 2%{?dist} +Release: 5%{?dist} URL: https://fedorahosted.org/targetcli-fb/ Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz Source1: target.service Patch0: 0001-Turn-off-unsupported-fabrics.patch Patch1: 0002-Fix-comparisons-to-None.patch Patch2: 0003-Fix-exception-in-convert_scsi_hctl_to_path.patch +Patch3: 0004-Support-Reconfiguration-of-device-path.patch +Patch4: 0005-Remove-hba-only-directories-in-clear_existing.patch +Patch5: 0006-create-remove-stale-hba-only-dir.patch BuildArch: noarch BuildRequires: python-devel epydoc python-setuptools systemd-units python-six python-pyudev Requires: python-kmod python-six python-pyudev @@ -55,6 +58,9 @@ API for generic Linux SCSI kernel target. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 %if 0%{?with_python3} rm -rf %{py3dir} @@ -128,6 +134,16 @@ popd %doc doc/html %changelog +* Mon Feb 26 2018 Maurizio Lombardi - 2.1.fb63-5 +- rtslib never creates hba directories without a storage object within it, + but if under some circumstance these existed then we should remove them. + +* Wed Feb 21 2018 Maurizio Lombardi - 2.1.fb63-4 +- Allow users to pass in a string into the attributes. + +* Wed Nov 02 2017 Maurizio Lombardi - 2.1.fb63-3 +- Enabled qla2xxx target support to fix #1327710 + * Wed May 17 2017 Andy Grover - 2.1.fb63-2 - Add patch 0003 to fix #1440172