Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alua: enable alua for pscsi/tcmu if kernel reports support #99

Merged
merged 1 commit into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions rtslib/alua.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def __init__(self, storage_object, name, tag=None):
@param tag: target port group id. If not passed in, try to look
up existing ALUA TPG with the same name
"""
# kernel partially sets up default_tg_pt_gp and will let you partially
# setup ALUA groups for pscsi and user, but writing to some of the
# files will crash the kernel. Just fail to even create groups until
# the kernel is fixed.
if storage_object.alua_supported is False:
raise RTSLibALUANotSupported("Backend does not support ALUA setup")

Expand Down
23 changes: 18 additions & 5 deletions rtslib/tcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
from .utils import is_dev_in_use, get_blockdev_type
from .utils import get_size_for_blk_dev, get_size_for_disk_name

def storage_object_get_alua_support_attr(so):
'''
Helper function that can be called by passthrough type of backends.
'''
try:
if int(so.get_attribute("alua_support")) == 1:
return True
except RTSLibError:
pass
# Default to false because older kernels will crash when
# reading/writing to some ALUA files when ALUA was not
# fully supported by pscsi and tcmu.
return False

class StorageObject(CFSNode):
'''
Expand Down Expand Up @@ -228,7 +241,7 @@ def _list_alua_tpgs(self):

def _get_alua_supported(self):
'''
Children should override and return false if ALUA setup is not supported.
Children should override if the backend did not always support ALUA
'''
self._check_self()
return True
Expand Down Expand Up @@ -421,7 +434,7 @@ def _get_host_id(self):

def _get_alua_supported(self):
self._check_self()
return False
return storage_object_get_alua_support_attr(self)

# PSCSIStorageObject public stuff

Expand All @@ -443,7 +456,7 @@ def _get_alua_supported(self):
lun = property(_get_lun,
doc="Get the SCSI device LUN")
alua_supported = property(_get_alua_supported,
doc="ALUA cannot be setup with rtslib, so False is returned.");
doc="Returns true if ALUA can be setup. False if not supported.")

def dump(self):
d = super(PSCSIStorageObject, self).dump()
Expand Down Expand Up @@ -836,7 +849,7 @@ def _get_config(self):

def _get_alua_supported(self):
self._check_self()
return False
return storage_object_get_alua_support_attr(self)

hw_max_sectors = property(_get_hw_max_sectors,
doc="Get the max sectors per command.")
Expand All @@ -845,7 +858,7 @@ def _get_alua_supported(self):
config = property(_get_config,
doc="Get the TCMU config.")
alua_supported = property(_get_alua_supported,
doc="ALUA cannot be setup with rtslib, so False is returned.");
doc="Returns true if ALUA can be setup. False if not supported.")

def dump(self):
d = super(UserBackedStorageObject, self).dump()
Expand Down