Accepting request 1137998 from Base:System
OBS-URL: https://build.opensuse.org/request/show/1137998 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/targetcli-fb?expand=0&rev=26
This commit is contained in:
commit
fdb26c12e3
@ -1,79 +0,0 @@
|
||||
From 7374ba0e53d8e6af4abbb02bd60f35ed541b94f5 Mon Sep 17 00:00:00 2001
|
||||
From: David Disseldorp <ddiss@suse.de>
|
||||
Date: Tue, 10 Apr 2018 16:22:54 +0200
|
||||
Patch-mainline: never (SUSE-specific)
|
||||
Subject: Split out blockdev readonly state detection helper
|
||||
|
||||
So that it can be reused for RBD backstores.
|
||||
|
||||
Note: not accepted upstream, but still needed
|
||||
here for our rbd stuff. (lduncan@suse.com)
|
||||
|
||||
Signed-off-by: David Disseldorp <ddiss@suse.de>
|
||||
---
|
||||
targetcli/ui_backstore.py | 40 ++++++++++++++++++++--------------------
|
||||
1 file changed, 20 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/targetcli/ui_backstore.py
|
||||
+++ b/targetcli/ui_backstore.py
|
||||
@@ -119,6 +119,25 @@ def complete_path(path, stat_fn):
|
||||
return sorted(filtered,
|
||||
key=lambda s: '~'+s if s.endswith('/') else s)
|
||||
|
||||
+def blk_dev_ro_check(dev):
|
||||
+ BLKROGET=0x0000125E
|
||||
+ try:
|
||||
+ f = os.open(dev, os.O_RDONLY)
|
||||
+ except (OSError, IOError):
|
||||
+ raise ExecutionError("Could not open %s" % dev)
|
||||
+ # ioctl returns an int. Provision a buffer for it
|
||||
+ buf = array.array('b', [0] * 4)
|
||||
+ try:
|
||||
+ fcntl.ioctl(f, BLKROGET, buf)
|
||||
+ except (OSError, IOError):
|
||||
+ os.close(f)
|
||||
+ return False
|
||||
+
|
||||
+ os.close(f)
|
||||
+ if struct.unpack('I', buf)[0] == 0:
|
||||
+ return False
|
||||
+ return True
|
||||
+
|
||||
|
||||
class UIALUATargetPortGroup(UIRTSLibNode):
|
||||
'''
|
||||
@@ -536,25 +555,6 @@ class UIBlockBackstore(UIBackstore):
|
||||
self.so_cls = UIBlockStorageObject
|
||||
UIBackstore.__init__(self, 'block', parent)
|
||||
|
||||
- def _ui_block_ro_check(self, dev):
|
||||
- BLKROGET=0x0000125E
|
||||
- try:
|
||||
- f = os.open(dev, os.O_RDONLY)
|
||||
- except (OSError, IOError):
|
||||
- raise ExecutionError("Could not open %s" % dev)
|
||||
- # ioctl returns an int. Provision a buffer for it
|
||||
- buf = array.array('b', [0] * 4)
|
||||
- try:
|
||||
- fcntl.ioctl(f, BLKROGET, buf)
|
||||
- except (OSError, IOError):
|
||||
- os.close(f)
|
||||
- return False
|
||||
-
|
||||
- os.close(f)
|
||||
- if struct.unpack('I', buf)[0] == 0:
|
||||
- return False
|
||||
- return True
|
||||
-
|
||||
def ui_command_create(self, name, dev, readonly=None, wwn=None):
|
||||
'''
|
||||
Creates an Block Storage object. "dev" is the path to the TYPE_DISK
|
||||
@@ -565,7 +565,7 @@ class UIBlockBackstore(UIBackstore):
|
||||
ro_string = self.ui_eval_param(readonly, 'string', None)
|
||||
if ro_string == None:
|
||||
# attempt to detect block device readonly state via ioctl
|
||||
- readonly = self._ui_block_ro_check(dev)
|
||||
+ readonly = blk_dev_ro_check(dev)
|
||||
else:
|
||||
readonly = self.ui_eval_param(readonly, 'bool', False)
|
||||
|
@ -1,103 +0,0 @@
|
||||
From dc250fa879939702bdf69e561cb9041a57f997ea Mon Sep 17 00:00:00 2001
|
||||
From: Mike Christie <mchristi@redhat.com>
|
||||
Date: Tue, 10 Apr 2018 17:31:32 +0200
|
||||
Subject: [PATCH 4/4] rbd support
|
||||
|
||||
targetcli-fb-rbd.patch obtained from:
|
||||
https://marc.info/?l=ceph-devel&m=143816209010058
|
||||
|
||||
[ddiss@suse.de: accept and propagate wwn parameter]
|
||||
Reviewed-by: David Disseldorp <ddiss@suse.de>
|
||||
---
|
||||
targetcli/ui_backstore.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 59 insertions(+)
|
||||
|
||||
--- a/targetcli/ui_backstore.py
|
||||
+++ b/targetcli/ui_backstore.py
|
||||
@@ -29,6 +29,7 @@ import stat
|
||||
from configshell_fb import ExecutionError
|
||||
from rtslib_fb import BlockStorageObject, FileIOStorageObject
|
||||
from rtslib_fb import PSCSIStorageObject, RDMCPStorageObject, UserBackedStorageObject
|
||||
+from rtslib_fb import RBDStorageObject
|
||||
from rtslib_fb import ALUATargetPortGroup
|
||||
from rtslib_fb import RTSLibError
|
||||
from rtslib_fb import RTSRoot
|
||||
@@ -281,6 +282,7 @@ class UIBackstores(UINode):
|
||||
UIRDMCPBackstore(self)
|
||||
UIFileIOBackstore(self)
|
||||
UIBlockBackstore(self)
|
||||
+ UIRBDBackstore(self)
|
||||
|
||||
for name, iface, prop_dict in self._user_backstores():
|
||||
UIUserBackedBackstore(self, name, iface, prop_dict)
|
||||
@@ -589,6 +591,48 @@ class UIBlockBackstore(UIBackstore):
|
||||
completions = [completions[0] + ' ']
|
||||
return completions
|
||||
|
||||
+class UIRBDBackstore(UIBackstore):
|
||||
+ '''
|
||||
+ RBD backstore UI.
|
||||
+ '''
|
||||
+ def __init__(self, parent):
|
||||
+ self.so_cls = UIRBDStorageObject
|
||||
+ UIBackstore.__init__(self, 'rbd', parent)
|
||||
+
|
||||
+ def ui_command_create(self, name, dev, readonly=None, wwn=None):
|
||||
+ '''
|
||||
+ Creates an RBD Storage object. I{dev} is the path to the RBD
|
||||
+ block device to use.
|
||||
+ '''
|
||||
+ self.assert_root()
|
||||
+
|
||||
+ ro_string = self.ui_eval_param(readonly, 'string', None)
|
||||
+ if ro_string == None:
|
||||
+ # attempt to detect block device readonly state via ioctl
|
||||
+ readonly = blk_dev_ro_check(dev)
|
||||
+ else:
|
||||
+ readonly = self.ui_eval_param(readonly, 'bool', False)
|
||||
+
|
||||
+ wwn = self.ui_eval_param(wwn, 'string', None)
|
||||
+
|
||||
+ so = RBDStorageObject(name, dev, readonly=readonly, wwn=wwn)
|
||||
+ ui_so = UIRBDStorageObject(so, self)
|
||||
+ self.setup_model_alias(so)
|
||||
+ self.shell.log.info("Created RBD storage object %s using %s."
|
||||
+ % (name, dev))
|
||||
+ return self.new_node(ui_so)
|
||||
+
|
||||
+ def ui_complete_create(self, parameters, text, current_param):
|
||||
+ '''
|
||||
+ Auto-completes the device name
|
||||
+ '''
|
||||
+ if current_param != 'dev':
|
||||
+ return []
|
||||
+ completions = complete_path(text, stat.S_ISBLK)
|
||||
+ if len(completions) == 1 and not completions[0].endswith('/'):
|
||||
+ completions = [completions[0] + ' ']
|
||||
+ return completions
|
||||
+
|
||||
|
||||
class UIUserBackedBackstore(UIBackstore):
|
||||
'''
|
||||
@@ -791,6 +835,21 @@ class UIBlockStorageObject(UIStorageObje
|
||||
return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size),
|
||||
ro_str, wb_str, so.status), True)
|
||||
|
||||
+class UIRBDStorageObject(UIStorageObject):
|
||||
+ def summary(self):
|
||||
+ so = self.rtsnode
|
||||
+
|
||||
+ if so.write_back:
|
||||
+ wb_str = "write-back"
|
||||
+ else:
|
||||
+ wb_str = "write-thru"
|
||||
+
|
||||
+ ro_str = ""
|
||||
+ if so.readonly:
|
||||
+ ro_str = "ro "
|
||||
+
|
||||
+ return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size),
|
||||
+ ro_str, wb_str, so.status), True)
|
||||
|
||||
class UIUserBackedStorageObject(UIStorageObject):
|
||||
def summary(self):
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 9 11:36:21 UTC 2024 - David Disseldorp <ddiss@suse.com>
|
||||
|
||||
- Drop downstream-only LIO target_core_rbd support (bsc#1218634)
|
||||
* Split-out-blockdev-readonly-state-detection-helper.patch
|
||||
* rbd-support.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 25 21:11:37 UTC 2023 - lduncan@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package targetcli-fb
|
||||
#
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -49,17 +49,8 @@ Provides: targetcli-fb = %{version}-%{release}
|
||||
Obsoletes: targetcli < %{version}-%{release}
|
||||
Obsoletes: targetcli-fb < %{version}-%{release}
|
||||
BuildArch: noarch
|
||||
%if 0%{?sle_version} >= 150000
|
||||
# explicit Provides advertising RBD support
|
||||
Provides: targetcli-rbd = %{version}
|
||||
Obsoletes: targetcli-rbd < %{version}
|
||||
%endif
|
||||
%{?systemd_ordering}
|
||||
|
||||
# SUSE-specific patches
|
||||
Patch1: Split-out-blockdev-readonly-state-detection-helper.patch
|
||||
Patch2: rbd-support.patch
|
||||
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
@ -83,11 +74,6 @@ all python-version-dependant packages, such as python3-*-targetcli-fb.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p1
|
||||
%if 0%{?sle_version} >= 150000
|
||||
# RBD support is dependent on LIO changes present in the SLE/Leap kernel
|
||||
%patch2 -p1
|
||||
%endif
|
||||
|
||||
%build
|
||||
%python_build
|
||||
|
Loading…
Reference in New Issue
Block a user