From e554a61844800b61ceb4ddb4fc86ffb3d7f2ed37 Mon Sep 17 00:00:00 2001 From: katarimanojkumar Date: Mon, 10 Aug 2020 19:07:27 +0000 Subject: [PATCH] [storwize]:Fixed select_io_group issues Fixed issues in select_io_group that impacts the performance during Create_volume, Group Snapshot/Clone operations for bulk non-hyperswap volumes. select_io_grp can avoid get_pool_attrs if the topology is not hyperswap. closes bug: #1890588 Change-Id: Ibee878cfe86c82ad4c79247f2a3bd37f08be80b8 --- .../volume/drivers/ibm/test_storwize_svc.py | 62 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 14 +++-- ...-select_io_group-fix-7200f2e00140ab34.yaml | 7 +++ 3 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/bug-1890588-storwize-select_io_group-fix-7200f2e00140ab34.yaml diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index 31e9c3d4053..3bc07161e9a 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -7181,6 +7181,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): pool = 'openstack2' opts['iogrp'] = '0,1' + opts['volume_topology'] = 'hyperswap' state['available_iogrps'] = [0, 1, 2, 3] iog = self.driver._helpers.select_io_group(state, opts, pool) self.assertEqual(0, iog) @@ -8275,6 +8276,66 @@ class StorwizeHelpersTestCase(test.TestCase): # system io groups state = {} + lsmdiskgrp.return_value = {} + fake_iog_vdc1 = {0: 10, 1: 50, 2: 50, 3: 300} + fake_iog_vdc2 = {0: 2, 1: 1, 2: 200} + fake_iog_vdc3 = {0: 2, 2: 200} + fake_iog_vdc4 = {0: 100, 1: 100, 2: 100, 3: 100} + fake_iog_vdc5 = {0: 10, 1: 1, 2: 200, 3: 300} + + get_vdisk_count_by_io_group.side_effect = [fake_iog_vdc1, + fake_iog_vdc2, + fake_iog_vdc3, + fake_iog_vdc4, + fake_iog_vdc5] + pool = _get_test_pool(False) + opts['volume_topology'] = None + opts['iogrp'] = '0,2' + state['available_iogrps'] = [0, 1, 2, 3] + + iog = self.storwize_svc_common.select_io_group(state, opts, pool) + self.assertTrue(iog in state['available_iogrps']) + self.assertEqual(0, iog) + + opts['iogrp'] = '0' + state['available_iogrps'] = [0, 1, 2] + + iog = self.storwize_svc_common.select_io_group(state, opts, pool) + self.assertTrue(iog in state['available_iogrps']) + self.assertEqual(0, iog) + + opts['iogrp'] = '1,2' + state['available_iogrps'] = [0, 2] + + iog = self.storwize_svc_common.select_io_group(state, opts, pool) + self.assertTrue(iog in state['available_iogrps']) + self.assertEqual(2, iog) + + opts['iogrp'] = ' 0, 1, 2 ' + state['available_iogrps'] = [0, 1, 2, 3] + + iog = self.storwize_svc_common.select_io_group(state, opts, pool) + self.assertTrue(iog in state['available_iogrps']) + # since vdisk count in all iogroups is same, it will pick the first + self.assertEqual(0, iog) + + opts['iogrp'] = '0,1,2, 3' + state['available_iogrps'] = [0, 1, 2, 3] + + iog = self.storwize_svc_common.select_io_group(state, opts, pool) + self.assertTrue(iog in state['available_iogrps']) + self.assertEqual(1, iog) + + @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsmdiskgrp') + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_vdisk_count_by_io_group') + def test_select_io_group_hyperswap(self, get_vdisk_count_by_io_group, + lsmdiskgrp): + # given io groups + opts = {} + # system io groups + state = {} + lsmdiskgrp.return_value = {} fake_iog_vdc1 = {0: 100, 1: 50, 2: 50, 3: 300} fake_iog_vdc2 = {0: 2, 1: 1, 2: 200} @@ -8289,6 +8350,7 @@ class StorwizeHelpersTestCase(test.TestCase): fake_iog_vdc5] pool = _get_test_pool(False) opts['iogrp'] = '0,2' + opts['volume_topology'] = 'hyperswap' state['available_iogrps'] = [0, 1, 2, 3] iog = self.storwize_svc_common.select_io_group(state, opts, pool) diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index 26c3e9eaaa3..cbf4b7fd232 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -871,12 +871,14 @@ class StorwizeHelpers(object): 'avail': state['available_iogrps']}) site_iogrp = [] - pool_data = self.get_pool_attrs(pool) - if pool_data is None: - msg = (_('Failed getting details for pool %s.') % pool) - LOG.error(msg) - raise exception.InvalidConfigurationValue(message=msg) - if 'site_id' in pool_data and pool_data['site_id']: + hyperswap = opts['volume_topology'] == 'hyperswap' + if hyperswap: + pool_data = self.get_pool_attrs(pool) + if pool_data is None: + msg = (_('Failed getting details for pool %s.') % pool) + LOG.error(msg) + raise exception.InvalidConfigurationValue(message=msg) + if hyperswap and pool_data.get('site_id'): for node in state['storage_nodes'].values(): if pool_data['site_id'] == node['site_id']: site_iogrp.append(node['IO_group']) diff --git a/releasenotes/notes/bug-1890588-storwize-select_io_group-fix-7200f2e00140ab34.yaml b/releasenotes/notes/bug-1890588-storwize-select_io_group-fix-7200f2e00140ab34.yaml new file mode 100644 index 00000000000..1e7c20a7b7c --- /dev/null +++ b/releasenotes/notes/bug-1890588-storwize-select_io_group-fix-7200f2e00140ab34.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `Bug #1890588 `_: + IBM Storwize: Fixed issues in select_io_group that impacts the + performance during Create_volume, Group Snapshot/Clone operations + for bulk non-hyperswap volumes.