|
|
dbfba8 |
From 86fed9fdab8803fd8d321c8242097e7b4f952ada Mon Sep 17 00:00:00 2001
|
|
|
dbfba8 |
From: Maurizio Lombardi <mlombard@redhat.com>
|
|
|
dbfba8 |
Date: Tue, 27 Mar 2018 14:50:09 +0200
|
|
|
dbfba8 |
Subject: [PATCH] alua: enable alua for pscsi/tcmu if kernel reports support
|
|
|
dbfba8 |
|
|
|
dbfba8 |
4.14 (it is currently the 4.13 feature window and I think we will
|
|
|
dbfba8 |
miss it) will add this patch
|
|
|
dbfba8 |
|
|
|
dbfba8 |
https://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git/commit/?h=for-next&id=c17d5d5f51f72f24e0e17a4450ae5010bf6962d9
|
|
|
dbfba8 |
|
|
|
dbfba8 |
commit c17d5d5f51f72f24e0e17a4450ae5010bf6962d9
|
|
|
dbfba8 |
Author: Mike Christie <mchristi@redhat.com>
|
|
|
dbfba8 |
Date: Mon Jul 10 14:53:31 2017 -0500
|
|
|
dbfba8 |
|
|
|
dbfba8 |
target: export lio pgr/alua support as device attr
|
|
|
dbfba8 |
|
|
|
dbfba8 |
which has the lio device report if it supports lio based ALUA.
|
|
|
dbfba8 |
We can then check this configfs file and know if we are using
|
|
|
dbfba8 |
a modern kernel with support and not worry about possibly crashing
|
|
|
dbfba8 |
the system.
|
|
|
dbfba8 |
|
|
|
dbfba8 |
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
|
|
dbfba8 |
---
|
|
|
dbfba8 |
rtslib/alua.py | 4 ----
|
|
|
dbfba8 |
rtslib/tcm.py | 23 ++++++++++++++++++-----
|
|
|
dbfba8 |
2 files changed, 18 insertions(+), 9 deletions(-)
|
|
|
dbfba8 |
|
|
|
dbfba8 |
diff --git a/rtslib/alua.py b/rtslib/alua.py
|
|
|
dbfba8 |
index 390e74a..fadc225 100644
|
|
|
dbfba8 |
--- a/rtslib/alua.py
|
|
|
dbfba8 |
+++ b/rtslib/alua.py
|
|
|
dbfba8 |
@@ -46,10 +46,6 @@ class ALUATargetPortGroup(CFSNode):
|
|
|
dbfba8 |
@param tag: target port group id. If not passed in, try to look
|
|
|
dbfba8 |
up existing ALUA TPG with the same name
|
|
|
dbfba8 |
"""
|
|
|
dbfba8 |
- # kernel partially sets up default_tg_pt_gp and will let you partially
|
|
|
dbfba8 |
- # setup ALUA groups for pscsi and user, but writing to some of the
|
|
|
dbfba8 |
- # files will crash the kernel. Just fail to even create groups until
|
|
|
dbfba8 |
- # the kernel is fixed.
|
|
|
dbfba8 |
if storage_object.alua_supported is False:
|
|
|
dbfba8 |
raise RTSLibALUANotSupported("Backend does not support ALUA setup")
|
|
|
dbfba8 |
|
|
|
dbfba8 |
diff --git a/rtslib/tcm.py b/rtslib/tcm.py
|
|
|
dbfba8 |
index aa3530a..bf681fe 100644
|
|
|
dbfba8 |
--- a/rtslib/tcm.py
|
|
|
dbfba8 |
+++ b/rtslib/tcm.py
|
|
|
dbfba8 |
@@ -32,6 +32,19 @@ from .utils import convert_scsi_path_to_hctl, convert_scsi_hctl_to_path
|
|
|
dbfba8 |
from .utils import is_dev_in_use, get_blockdev_type
|
|
|
dbfba8 |
from .utils import get_size_for_blk_dev, get_size_for_disk_name
|
|
|
dbfba8 |
|
|
|
dbfba8 |
+def storage_object_get_alua_support_attr(so):
|
|
|
dbfba8 |
+ '''
|
|
|
dbfba8 |
+ Helper function that can be called by passthrough type of backends.
|
|
|
dbfba8 |
+ '''
|
|
|
dbfba8 |
+ try:
|
|
|
dbfba8 |
+ if int(so.get_attribute("alua_support")) == 1:
|
|
|
dbfba8 |
+ return True
|
|
|
dbfba8 |
+ except RTSLibError:
|
|
|
dbfba8 |
+ pass
|
|
|
dbfba8 |
+ # Default to false because older kernels will crash when
|
|
|
dbfba8 |
+ # reading/writing to some ALUA files when ALUA was not
|
|
|
dbfba8 |
+ # fully supported by pscsi and tcmu.
|
|
|
dbfba8 |
+ return False
|
|
|
dbfba8 |
|
|
|
dbfba8 |
class StorageObject(CFSNode):
|
|
|
dbfba8 |
'''
|
|
|
dbfba8 |
@@ -227,7 +240,7 @@ class StorageObject(CFSNode):
|
|
|
dbfba8 |
|
|
|
dbfba8 |
def _get_alua_supported(self):
|
|
|
dbfba8 |
'''
|
|
|
dbfba8 |
- Children should override and return false if ALUA setup is not supported.
|
|
|
dbfba8 |
+ Children should override if the backend did not always support ALUA
|
|
|
dbfba8 |
'''
|
|
|
dbfba8 |
self._check_self()
|
|
|
dbfba8 |
return True
|
|
|
dbfba8 |
@@ -420,7 +433,7 @@ class PSCSIStorageObject(StorageObject):
|
|
|
dbfba8 |
|
|
|
dbfba8 |
def _get_alua_supported(self):
|
|
|
dbfba8 |
self._check_self()
|
|
|
dbfba8 |
- return False
|
|
|
dbfba8 |
+ return storage_object_get_alua_support_attr(self)
|
|
|
dbfba8 |
|
|
|
dbfba8 |
# PSCSIStorageObject public stuff
|
|
|
dbfba8 |
|
|
|
dbfba8 |
@@ -442,7 +455,7 @@ class PSCSIStorageObject(StorageObject):
|
|
|
dbfba8 |
lun = property(_get_lun,
|
|
|
dbfba8 |
doc="Get the SCSI device LUN")
|
|
|
dbfba8 |
alua_supported = property(_get_alua_supported,
|
|
|
dbfba8 |
- doc="ALUA cannot be setup with rtslib, so False is returned.");
|
|
|
dbfba8 |
+ doc="Returns true if ALUA can be setup. False if not supported.")
|
|
|
dbfba8 |
|
|
|
dbfba8 |
def dump(self):
|
|
|
dbfba8 |
d = super(PSCSIStorageObject, self).dump()
|
|
|
dbfba8 |
@@ -826,14 +839,14 @@ class UserBackedStorageObject(StorageObject):
|
|
|
dbfba8 |
|
|
|
dbfba8 |
def _get_alua_supported(self):
|
|
|
dbfba8 |
self._check_self()
|
|
|
dbfba8 |
- return False
|
|
|
dbfba8 |
+ return storage_object_get_alua_support_attr(self)
|
|
|
dbfba8 |
|
|
|
dbfba8 |
size = property(_get_size,
|
|
|
dbfba8 |
doc="Get the size in bytes.")
|
|
|
dbfba8 |
config = property(_get_config,
|
|
|
dbfba8 |
doc="Get the TCMU config.")
|
|
|
dbfba8 |
alua_supported = property(_get_alua_supported,
|
|
|
dbfba8 |
- doc="ALUA cannot be setup with rtslib, so False is returned.");
|
|
|
dbfba8 |
+ doc="Returns true if ALUA can be setup. False if not supported.")
|
|
|
dbfba8 |
|
|
|
dbfba8 |
def dump(self):
|
|
|
dbfba8 |
d = super(UserBackedStorageObject, self).dump()
|
|
|
dbfba8 |
--
|
|
|
dbfba8 |
1.8.3.1
|
|
|
dbfba8 |
|