Skip to content

Commit

Permalink
Allow creating more than 256 LUNs per target
Browse files Browse the repository at this point in the history
Currently there's an unnecessary limitation of 256 LUNs per target, which is
not enforced in the kernel driver. We keep a limit of 256 Mapped LUNs per
initiator as required by the iSCSI protocol.
  • Loading branch information
pzakha committed Feb 19, 2018
1 parent 618be87 commit 20a50d9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions rtslib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class LUN(CFSNode):
A LUN is identified by its parent TPG and LUN index.
'''

MAX_LUN = 255
MAX_TARGET_LUN = 65535

# LUN private stuff

Expand All @@ -487,7 +487,7 @@ def __init__(self, parent_tpg, lun=None, storage_object=None, alias=None):
@param parent_tpg: The parent TPG object.
@type parent_tpg: TPG
@param lun: The LUN index.
@type lun: 0-255
@type lun: 0-65535
@param storage_object: The storage object to be exported as a LUN.
@type storage_object: StorageObject subclass
@param alias: An optional parameter to manually specify the LUN alias.
Expand All @@ -504,16 +504,16 @@ def __init__(self, parent_tpg, lun=None, storage_object=None, alias=None):

if lun is None:
luns = [l.lun for l in self.parent_tpg.luns]
for index in range(self.MAX_LUN+1):
for index in range(self.MAX_TARGET_LUN+1):
if index not in luns:
lun = index
break
if lun is None:
raise RTSLibError("All LUNs 0-%d in use" % self.MAX_LUN)
raise RTSLibError("All LUNs 0-%d in use" % self.MAX_TARGET_LUN)
else:
lun = int(lun)
if lun < 0 or lun > self.MAX_LUN:
raise RTSLibError("LUN must be 0 to %d" % self.MAX_LUN)
if lun < 0 or lun > self.MAX_TARGET_LUN:
raise RTSLibError("LUN must be 0 to %d" % self.MAX_TARGET_LUN)

self._lun = lun

Expand Down Expand Up @@ -1060,6 +1060,8 @@ class MappedLUN(CFSNode):
the initiator node as the MappedLUN.
'''

MAX_LUN = 255

# MappedLUN private stuff

def __repr__(self):
Expand Down Expand Up @@ -1107,6 +1109,9 @@ def __init__(self, parent_nodeacl, mapped_lun,
raise RTSLibError("The mapped_lun parameter must be an " \
+ "integer value")

if self._mapped_lun < 0 or self._mapped_lun > self.MAX_LUN:
raise RTSLibError("Mapped LUN must be 0 to %d" % self.MAX_LUN)

self._path = "%s/lun_%d" % (self.parent_nodeacl.path, self.mapped_lun)

if tpg_lun is None and write_protect is not None:
Expand Down

0 comments on commit 20a50d9

Please sign in to comment.