[SVf]:Fix multiple lsvdisk calls for GMCV create volume operation

[Spectrum Virtualize family] During creation of GMCV type volume
there are multiple lsvdisk calls made for checking the existence
of source change volume, aux volume and change aux volume.
Along with these calls there is a lssystem call which can be
optimized.

This patch optimizes these lsvdisk and lssystem calls which in
turn reduces the computational time for creating GMCV volumes.

Closes-Bug: #1961548

Change-Id: Id00cda88132184e66fbf6c03965f1de30cf02dcf
This commit is contained in:
haailani 2022-04-21 10:51:57 +00:00
parent d5b21ab1ec
commit 76de76646d
4 changed files with 111 additions and 73 deletions

View File

@ -2226,7 +2226,8 @@ port_speed!N/A
if 'obj' in kwargs: if 'obj' in kwargs:
name = kwargs['obj'] name = kwargs['obj']
for k, v in self._rcrelationship_list.items(): for k, v in self._rcrelationship_list.items():
if six.text_type(v['name']) == name: if ((str(v['name']) == name) or
(str(v['id']) == name)):
self._rc_state_transition('wait', v) self._rc_state_transition('wait', v)
if self._next_cmd_error['lsrcrelationship'] == 'speed_up': if self._next_cmd_error['lsrcrelationship'] == 'speed_up':
@ -10626,7 +10627,7 @@ class StorwizeHelpersTestCase(test.TestCase):
get_vdisk_attributes.assert_called_with(opts['name']) get_vdisk_attributes.assert_called_with(opts['name'])
if not opts['RC_name']: if not opts['RC_name']:
stoprcrelationship.assert_not_called() stoprcrelationship.assert_not_called()
startrcrelationship.assert_not_called() startrcrelationship.assert_called()
else: else:
stoprcrelationship.assert_called_once_with(opts['RC_name'], stoprcrelationship.assert_called_once_with(opts['RC_name'],
access=access) access=access)
@ -12436,7 +12437,6 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
self.driver.configuration.set_override('replication_device', self.driver.configuration.set_override('replication_device',
[self.rep_target]) [self.rep_target])
self.driver.do_setup(self.ctxt) self.driver.do_setup(self.ctxt)
# Create replication volume. # Create replication volume.
backend_volume, model_update = self._create_test_volume(self.mm_type) backend_volume, model_update = self._create_test_volume(self.mm_type)
volume, model_update = self._create_test_volume(self.mm_type) volume, model_update = self._create_test_volume(self.mm_type)
@ -12933,11 +12933,13 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
start_relationship): start_relationship):
replica_obj = self.driver._get_replica_obj(storwize_const.METRO) replica_obj = self.driver._get_replica_obj(storwize_const.METRO)
mm_vol, model_update = self._create_test_volume(self.mm_type) mm_vol, model_update = self._create_test_volume(self.mm_type)
mm_vol_attrs = self.driver._helpers.get_vdisk_attributes(mm_vol.name)
target_vol = storwize_const.REPLICA_AUX_VOL_PREFIX + mm_vol.name target_vol = storwize_const.REPLICA_AUX_VOL_PREFIX + mm_vol.name
context = mock.Mock context = mock.Mock
replica_obj.failover_volume_host(context, mm_vol) replica_obj.failover_volume_host(context, mm_vol)
stop_relationship.assert_called_once_with(target_vol, access=True) stop_relationship.assert_called_once_with(target_vol, access=True)
calls = [mock.call(mm_vol.name), mock.call(target_vol, 'aux')] calls = [mock.call(mm_vol.name, rcrel=mm_vol_attrs['RC_name']),
mock.call(target_vol, 'aux')]
start_relationship.assert_has_calls(calls, any_order=True) start_relationship.assert_has_calls(calls, any_order=True)
self.assertEqual(2, start_relationship.call_count) self.assertEqual(2, start_relationship.call_count)

View File

@ -167,10 +167,7 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
new_type['id'], volume_type=new_type) new_type['id'], volume_type=new_type)
src_attr = self.driver._helpers.get_vdisk_attributes( src_attr = self.driver._helpers.get_vdisk_attributes(
vref['name']) vref['name'])
# Create source change volume if it doesn't exist # Source change volume creation
src_change_attr = self.driver._helpers.get_vdisk_attributes(
source_change_vol_name)
if not src_change_attr:
src_change_opts = self.driver._get_vdisk_params( src_change_opts = self.driver._get_vdisk_params(
vref['volume_type_id']) vref['volume_type_id'])
src_change_opts['iogrp'] = src_attr['IO_group_id'] src_change_opts['iogrp'] = src_attr['IO_group_id']
@ -185,29 +182,36 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
src_change_opts['storwize_svc_src_child_pool']) src_change_opts['storwize_svc_src_child_pool'])
if src_child_pool: if src_child_pool:
src_change_pool = src_child_pool src_change_pool = src_child_pool
try:
self.driver._helpers.create_vdisk(source_change_vol_name, self.driver._helpers.create_vdisk(source_change_vol_name,
six.text_type(vref['size']), six.text_type(vref['size']),
'gb', 'gb',
src_change_pool, src_change_pool,
src_change_opts) src_change_opts)
# Create target volume if it doesn't exist except exception.VolumeBackendAPIException as excp:
target_attr = self.target_helpers.get_vdisk_attributes( if "CMMVC6035E" in excp.msg:
target_vol_name) msg = ('Source change volume: %s already exists'
if not target_attr: % source_change_vol_name)
LOG.info(msg)
# Target volume creation
target_opts = self.driver._get_vdisk_params( target_opts = self.driver._get_vdisk_params(
vref['volume_type_id']) vref['volume_type_id'])
target_pool = self.target.get('pool_name') target_pool = self.target.get('pool_name')
target_opts['iogrp'] = src_attr['IO_group_id'] target_opts['iogrp'] = src_attr['IO_group_id']
try:
self.target_helpers.create_vdisk(target_vol_name, self.target_helpers.create_vdisk(target_vol_name,
six.text_type(vref['size']), six.text_type(vref['size']),
'gb', 'gb',
target_pool, target_pool,
target_opts) target_opts)
except exception.VolumeBackendAPIException as excp:
if "CMMVC6035E" in excp.msg:
msg = ('Target Volume: %s already exists'
% target_vol_name)
LOG.info(msg)
# Create target change volume if it doesn't exist # Target change volume creation
target_change_attr = self.target_helpers.get_vdisk_attributes(
target_change_vol_name)
if not target_change_attr:
target_change_opts = self.driver._get_vdisk_params( target_change_opts = self.driver._get_vdisk_params(
vref['volume_type_id']) vref['volume_type_id'])
target_change_pool = self.target.get('pool_name') target_change_pool = self.target.get('pool_name')
@ -222,26 +226,34 @@ class StorwizeSVCReplicationGMCV(StorwizeSVCReplicationGlobalMirror):
target_change_opts['iogrp'] = src_attr['IO_group_id'] target_change_opts['iogrp'] = src_attr['IO_group_id']
# Change Volumes would usually be thin-provisioned # Change Volumes would usually be thin-provisioned
target_change_opts['autoexpand'] = True target_change_opts['autoexpand'] = True
try:
self.target_helpers.create_vdisk(target_change_vol_name, self.target_helpers.create_vdisk(target_change_vol_name,
six.text_type(vref['size']), six.text_type(vref['size']),
'gb', 'gb',
target_change_pool, target_change_pool,
target_change_opts) target_change_opts)
except exception.VolumeBackendAPIException as excp:
if "CMMVC6035E" in excp.msg:
msg = ('Target Change Volume: %s already exists'
% target_change_vol_name)
LOG.info(msg)
system_info = self.target_helpers.get_system_info() target_system_id = self.driver._aux_state['system_id']
# Get cycle_period_seconds # Get cycle_period_seconds
src_change_opts = self.driver._get_vdisk_params( src_change_opts = self.driver._get_vdisk_params(
vref['volume_type_id']) vref['volume_type_id'])
cycle_period_seconds = src_change_opts.get('cycle_period_seconds') cycle_period_seconds = src_change_opts.get('cycle_period_seconds')
self.driver._helpers.create_relationship( rc_name = self.driver._helpers.create_relationship(
vref['name'], target_vol_name, system_info.get('system_id'), vref['name'], target_vol_name, target_system_id,
self.asyncmirror, True, source_change_vol_name, self.asyncmirror, True, source_change_vol_name,
cycle_period_seconds) cycle_period_seconds)
# Set target change volume # Set target change volume
self.target_helpers.change_relationship_changevolume( self.target_helpers.change_relationship_changevolume(
target_vol_name, target_change_vol_name, False) target_vol_name, target_change_vol_name, False,
rc_name)
# Start gmcv relationship # Start gmcv relationship
self.driver._helpers.start_relationship(vref['name']) self.driver._helpers.start_relationship(vref['name'],
rcrel=rc_name)
except Exception as e: except Exception as e:
msg = (_("Unable to set up gmcv mode replication for %(vol)s. " msg = (_("Unable to set up gmcv mode replication for %(vol)s. "
"Exception: %(err)s.") % {'vol': vref['id'], "Exception: %(err)s.") % {'vol': vref['id'],

View File

@ -2558,10 +2558,12 @@ class StorwizeHelpers(object):
timer.stop() timer.stop()
return ret return ret
def start_relationship(self, volume_name, primary=None): def start_relationship(self, volume_name, primary=None,
rcrel=None):
if rcrel is None:
vol_attrs = self.get_vdisk_attributes(volume_name) vol_attrs = self.get_vdisk_attributes(volume_name)
if vol_attrs['RC_name']: rcrel = vol_attrs['RC_name']
self.ssh.startrcrelationship(vol_attrs['RC_name'], primary) self.ssh.startrcrelationship(rcrel, primary)
def stop_relationship(self, volume_name, access=False): def stop_relationship(self, volume_name, access=False):
vol_attrs = self.get_vdisk_attributes(volume_name) vol_attrs = self.get_vdisk_attributes(volume_name)
@ -2588,34 +2590,49 @@ class StorwizeHelpers(object):
# We need setup master and aux change volumes for gmcv # We need setup master and aux change volumes for gmcv
# before we can start remote relationship # before we can start remote relationship
# aux change volume must be set on target site # aux change volume must be set on target site
rel_info = self.ssh.lsrcrelationship(rc_id)
rc_name = rel_info[0]['name']
if cycle_period_seconds: if cycle_period_seconds:
self.change_relationship_cycleperiod(master, self.change_relationship_cycleperiod(master,
cycle_period_seconds) cycle_period_seconds,
rc_name)
if masterchange: if masterchange:
self.change_relationship_changevolume(master, self.change_relationship_changevolume(master,
masterchange, True) masterchange, True,
rc_name)
else: else:
self.start_relationship(master) self.start_relationship(master, rcrel=rc_name)
return rc_name
def change_relationship_changevolume(self, volume_name, def change_relationship_changevolume(self, volume_name,
change_volume, master): change_volume, master,
rcrel=None):
if rcrel is None:
vol_attrs = self.get_vdisk_attributes(volume_name) vol_attrs = self.get_vdisk_attributes(volume_name)
if vol_attrs['RC_name'] and change_volume: rcrel = vol_attrs['RC_name']
self.ssh.ch_rcrelationship_changevolume(vol_attrs['RC_name'], if rcrel and change_volume:
change_volume, master) self.ssh.ch_rcrelationship_changevolume(rcrel,
change_volume,
master)
def change_relationship_cycleperiod(self, volume_name, def change_relationship_cycleperiod(self, volume_name,
cycle_period_seconds): cycle_period_seconds,
rcrel=None):
if rcrel is None:
vol_attrs = self.get_vdisk_attributes(volume_name) vol_attrs = self.get_vdisk_attributes(volume_name)
if vol_attrs['RC_name'] and cycle_period_seconds: rcrel = vol_attrs['RC_name']
self.ssh.ch_rcrelationship_cycleperiod(vol_attrs['RC_name'], if rcrel and cycle_period_seconds:
self.ssh.ch_rcrelationship_cycleperiod(rcrel,
cycle_period_seconds) cycle_period_seconds)
def change_relationship_cyclingmode(self, volume_name, def change_relationship_cyclingmode(self, volume_name,
cyclingmode='none'): cyclingmode='none',
rcrel=None):
if rcrel is None:
vol_attrs = self.get_vdisk_attributes(volume_name) vol_attrs = self.get_vdisk_attributes(volume_name)
if vol_attrs['RC_name'] and cyclingmode: rcrel = vol_attrs['RC_name']
self.ssh.ch_rcrelationship_cyclingmode(vol_attrs['RC_name'], if rcrel and cyclingmode:
self.ssh.ch_rcrelationship_cyclingmode(rcrel,
cyclingmode) cyclingmode)
def change_consistgrp_cyclingmode(self, rccg_name, def change_consistgrp_cyclingmode(self, rccg_name,

View File

@ -0,0 +1,7 @@
---
fixes:
- |
IBM Spectrum Virtualize Family driver: `Bug #1961548
<https://bugs.launchpad.net/cinder/+bug/1961548>`_:
Optimize lsvdisk and lssystem calls to reduce the
computational time for creating GMCV volumes.