Merge "Configure write cache option of tgtd iscsi driver"
This commit is contained in:
commit
226a9511dc
@ -84,6 +84,7 @@ class TgtAdm(TargetAdmin):
|
|||||||
<target %s>
|
<target %s>
|
||||||
backing-store %s
|
backing-store %s
|
||||||
lld iscsi
|
lld iscsi
|
||||||
|
write-cache %s
|
||||||
</target>
|
</target>
|
||||||
"""
|
"""
|
||||||
VOLUME_CONF_WITH_CHAP_AUTH = """
|
VOLUME_CONF_WITH_CHAP_AUTH = """
|
||||||
@ -91,6 +92,7 @@ class TgtAdm(TargetAdmin):
|
|||||||
backing-store %s
|
backing-store %s
|
||||||
lld iscsi
|
lld iscsi
|
||||||
%s
|
%s
|
||||||
|
write-cache %s
|
||||||
</target>
|
</target>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -166,11 +168,13 @@ class TgtAdm(TargetAdmin):
|
|||||||
fileutils.ensure_tree(self.volumes_dir)
|
fileutils.ensure_tree(self.volumes_dir)
|
||||||
|
|
||||||
vol_id = name.split(':')[1]
|
vol_id = name.split(':')[1]
|
||||||
|
write_cache = kwargs.get('write_cache', 'on')
|
||||||
if chap_auth is None:
|
if chap_auth is None:
|
||||||
volume_conf = self.VOLUME_CONF % (name, path)
|
volume_conf = self.VOLUME_CONF % (name, path, write_cache)
|
||||||
else:
|
else:
|
||||||
volume_conf = self.VOLUME_CONF_WITH_CHAP_AUTH % (name,
|
volume_conf = self.VOLUME_CONF_WITH_CHAP_AUTH % (name,
|
||||||
path, chap_auth)
|
path, chap_auth,
|
||||||
|
write_cache)
|
||||||
|
|
||||||
LOG.info(_('Creating iscsi_target for: %s') % vol_id)
|
LOG.info(_('Creating iscsi_target for: %s') % vol_id)
|
||||||
volumes_dir = self.volumes_dir
|
volumes_dir = self.volumes_dir
|
||||||
@ -601,6 +605,7 @@ class ISERTgtAdm(TgtAdm):
|
|||||||
<target %s>
|
<target %s>
|
||||||
driver iser
|
driver iser
|
||||||
backing-store %s
|
backing-store %s
|
||||||
|
write_cache %s
|
||||||
</target>
|
</target>
|
||||||
"""
|
"""
|
||||||
VOLUME_CONF_WITH_CHAP_AUTH = """
|
VOLUME_CONF_WITH_CHAP_AUTH = """
|
||||||
@ -608,6 +613,7 @@ class ISERTgtAdm(TgtAdm):
|
|||||||
driver iser
|
driver iser
|
||||||
backing-store %s
|
backing-store %s
|
||||||
%s
|
%s
|
||||||
|
write_cache %s
|
||||||
</target>
|
</target>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ class TargetAdminTestCase(object):
|
|||||||
self.path = '/foo'
|
self.path = '/foo'
|
||||||
self.vol_id = 'blaa'
|
self.vol_id = 'blaa'
|
||||||
self.vol_name = 'volume-blaa'
|
self.vol_name = 'volume-blaa'
|
||||||
|
self.write_cache = 'off'
|
||||||
self.db = {}
|
self.db = {}
|
||||||
|
|
||||||
self.script_template = None
|
self.script_template = None
|
||||||
@ -95,7 +96,8 @@ class TargetAdminTestCase(object):
|
|||||||
target_helper = self.driver.get_target_helper(self.db)
|
target_helper = self.driver.get_target_helper(self.db)
|
||||||
target_helper.set_execute(self.fake_execute)
|
target_helper.set_execute(self.fake_execute)
|
||||||
target_helper.create_iscsi_target(self.target_name, self.tid,
|
target_helper.create_iscsi_target(self.target_name, self.tid,
|
||||||
self.lun, self.path)
|
self.lun, self.path,
|
||||||
|
write_cache=self.write_cache)
|
||||||
target_helper.show_target(self.tid, iqn=self.target_name)
|
target_helper.show_target(self.tid, iqn=self.target_name)
|
||||||
target_helper.remove_iscsi_target(self.tid, self.lun, self.vol_id,
|
target_helper.remove_iscsi_target(self.tid, self.lun, self.vol_id,
|
||||||
self.vol_name)
|
self.vol_name)
|
||||||
|
@ -113,6 +113,12 @@ volume_opts = [
|
|||||||
default=0,
|
default=0,
|
||||||
help='The upper limit of bandwidth of volume copy. '
|
help='The upper limit of bandwidth of volume copy. '
|
||||||
'0 => unlimited'),
|
'0 => unlimited'),
|
||||||
|
cfg.StrOpt('iscsi_write_cache',
|
||||||
|
default='on',
|
||||||
|
help='Sets the behavior of the iSCSI target to either '
|
||||||
|
'perform write-back(on) or write-through(off). '
|
||||||
|
'This parameter is valid if iscsi_helper is set '
|
||||||
|
'to tgtadm or iseradm.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# for backward compatibility
|
# for backward compatibility
|
||||||
|
@ -521,7 +521,8 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
|
|||||||
context, volume,
|
context, volume,
|
||||||
iscsi_name,
|
iscsi_name,
|
||||||
volume_path,
|
volume_path,
|
||||||
self.configuration.volume_group)
|
self.configuration.volume_group,
|
||||||
|
self.configuration)
|
||||||
if model_update:
|
if model_update:
|
||||||
self.db.volume_update(context, volume['id'], model_update)
|
self.db.volume_update(context, volume['id'], model_update)
|
||||||
|
|
||||||
|
@ -52,7 +52,9 @@ class _ExportMixin(object):
|
|||||||
iscsi_target,
|
iscsi_target,
|
||||||
0,
|
0,
|
||||||
volume_path,
|
volume_path,
|
||||||
chap_auth)
|
chap_auth,
|
||||||
|
write_cache=
|
||||||
|
conf.iscsi_write_cache)
|
||||||
data = {}
|
data = {}
|
||||||
data['location'] = self._iscsi_location(
|
data['location'] = self._iscsi_location(
|
||||||
conf.iscsi_ip_address, tid, iscsi_name, conf.iscsi_port, lun)
|
conf.iscsi_ip_address, tid, iscsi_name, conf.iscsi_port, lun)
|
||||||
@ -86,7 +88,7 @@ class _ExportMixin(object):
|
|||||||
self.remove_iscsi_target(iscsi_target, 0, volume['id'], volume['name'])
|
self.remove_iscsi_target(iscsi_target, 0, volume['id'], volume['name'])
|
||||||
|
|
||||||
def ensure_export(self, context, volume, iscsi_name, volume_path,
|
def ensure_export(self, context, volume, iscsi_name, volume_path,
|
||||||
vg_name, old_name=None):
|
vg_name, conf, old_name=None):
|
||||||
iscsi_target = self._get_target_for_ensure_export(context,
|
iscsi_target = self._get_target_for_ensure_export(context,
|
||||||
volume['id'])
|
volume['id'])
|
||||||
if iscsi_target is None:
|
if iscsi_target is None:
|
||||||
@ -106,7 +108,8 @@ class _ExportMixin(object):
|
|||||||
old_name = None
|
old_name = None
|
||||||
self.create_iscsi_target(iscsi_name, iscsi_target, 0, volume_path,
|
self.create_iscsi_target(iscsi_name, iscsi_target, 0, volume_path,
|
||||||
chap_auth, check_exit_code=False,
|
chap_auth, check_exit_code=False,
|
||||||
old_name=old_name)
|
old_name=old_name,
|
||||||
|
write_cache=conf.iscsi_write_cache)
|
||||||
|
|
||||||
def _ensure_iscsi_targets(self, context, host, max_targets):
|
def _ensure_iscsi_targets(self, context, host, max_targets):
|
||||||
"""Ensure that target ids have been created in datastore."""
|
"""Ensure that target ids have been created in datastore."""
|
||||||
@ -223,7 +226,7 @@ class FakeIscsiHelper(_ExportMixin, iscsi.FakeIscsiHelper):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def ensure_export(self, context, volume, iscsi_name, volume_path,
|
def ensure_export(self, context, volume, iscsi_name, volume_path,
|
||||||
vg_name, old_name=None):
|
vg_name, conf, old_name=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -241,7 +244,7 @@ class LioAdm(_ExportMixin, iscsi.LioAdm):
|
|||||||
self.remove_iscsi_target(iscsi_target, 0, volume['id'], volume['name'])
|
self.remove_iscsi_target(iscsi_target, 0, volume['id'], volume['name'])
|
||||||
|
|
||||||
def ensure_export(self, context, volume, iscsi_name, volume_path,
|
def ensure_export(self, context, volume, iscsi_name, volume_path,
|
||||||
vg_name, old_name=None):
|
vg_name, conf, old_name=None):
|
||||||
try:
|
try:
|
||||||
volume_info = self.db.volume_get(context, volume['id'])
|
volume_info = self.db.volume_get(context, volume['id'])
|
||||||
(auth_method,
|
(auth_method,
|
||||||
|
@ -1043,6 +1043,12 @@
|
|||||||
# (integer value)
|
# (integer value)
|
||||||
#volume_copy_bps_limit=0
|
#volume_copy_bps_limit=0
|
||||||
|
|
||||||
|
# Sets the behavior of the iSCSI target to either perform
|
||||||
|
# write-back(on) or write-through(off). This parameter is
|
||||||
|
# valid if iscsi_helper is set to tgtadm or iseradm. (string
|
||||||
|
# value)
|
||||||
|
#iscsi_write_cache=on
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Options defined in cinder.volume.drivers.block_device
|
# Options defined in cinder.volume.drivers.block_device
|
||||||
|
Loading…
x
Reference in New Issue
Block a user