From 7d89890704ef2ed9265a5dec9cbe47cb1ffc5aaa Mon Sep 17 00:00:00 2001 From: GirishChilukuri Date: Fri, 25 Sep 2020 20:31:25 +0000 Subject: [PATCH] [SVF]:Reduce slowness by caching pool information [Spectrum Virtualize Family] Data_reduction is a pool specific property, this property should be saved for a specific pool during initialisation. With this, calls to get_pool_attrs can be reduced everytime create_vdisk is called, in order to check if pool is a data_reduction_pool. closes bug: #1890591 Change-Id: I00f1bd46bc8715591016f59c32651fc2c9cddf35 --- .../volume/drivers/ibm/test_storwize_svc.py | 32 ++++++++++++++++++- .../ibm/storwize_svc/storwize_svc_common.py | 31 ++++++++++++++++++ ...s-not-saved-in-stats-22f302d941cd9fe2.yaml | 7 ++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-1890591-Pool-information-is-not-saved-in-stats-22f302d941cd9fe2.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 3354e6290a0..e0fde784a39 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -5537,7 +5537,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): self._set_flag('reserved_percentage', 25) self._set_flag('storwize_svc_multihostmap_enabled', True) self._set_flag('storwize_svc_vol_rsize', rsize) - stats = self.driver.get_volume_stats() + stats = self.driver.get_volume_stats(True) for each_pool in stats['pools']: self.assertIn(each_pool['pool_name'], self._def_flags['storwize_svc_volpool_name']) @@ -8269,6 +8269,7 @@ port_speed!8Gb list(resp.select('port_id', 'port_status'))) +@ddt.ddt class StorwizeHelpersTestCase(test.TestCase): def setUp(self): super(StorwizeHelpersTestCase, self).setUp() @@ -8522,6 +8523,35 @@ class StorwizeHelpersTestCase(test.TestCase): self.storwize_svc_common.check_flashcopy_rate, flashcopy_rate) + @ddt.data(({'mirror_pool': 'openstack2', + 'volume_topology': None, + 'peer_pool': None}, True, 1), + ({'mirror_pool': 'openstack2', + 'volume_topology': None, + 'peer_pool': None}, False, 2), + ({'mirror_pool': None, + 'volume_topology': 'hyperswap', + 'peer_pool': 'openstack1'}, True, 1), + ({'mirror_pool': None, + 'volume_topology': 'hyperswap', + 'peer_pool': 'openstack1'}, False, 2)) + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'is_data_reduction_pool') + @ddt.unpack + def test_is_volume_type_dr_pools_dr_pool(self, opts, is_drp, call_count, + is_data_reduction_pool): + is_data_reduction_pool.return_value = is_drp + pool = 'openstack' + rep_type = None + rep_target_pool = None + + isdrpool = (self.storwize_svc_common. + is_volume_type_dr_pools(pool, opts, rep_type, + rep_target_pool)) + self.assertEqual(is_drp, isdrpool) + is_data_reduction_pool.assert_called() + self.assertEqual(call_count, is_data_reduction_pool.call_count) + @ddt.ddt class StorwizeSSHTestCase(test.TestCase): 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 a30681529a8..d0bb7d31a1e 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -756,6 +756,7 @@ class StorwizeHelpers(object): self.ssh = StorwizeSSH(run_ssh) self.check_fcmapping_interval = 3 self.code_level = None + self.stats = {} @staticmethod def handle_keyerror(cmd, out): @@ -825,6 +826,12 @@ class StorwizeHelpers(object): def is_data_reduction_pool(self, pool_name): """Check if pool is data reduction pool.""" + # Check pool is data reduction pool or not from pool information + # saved in stats. + for pool in self.stats.get('pools', []): + if pool['pool_name'] == pool_name: + return pool['data_reduction'] + pool_data = self.get_pool_attrs(pool_name) if (pool_data and 'data_reduction' in pool_data and pool_data['data_reduction'] == 'yes'): @@ -2778,6 +2785,9 @@ class StorwizeSVCCommonDriver(san.SanDriver, # This is used to save the available pools in failed-over status self._secondary_pools = None + # This dictionary is used to save pools information. + self._stats = {} + # Storwize has the limitation that can not burst more than 3 new ssh # connections within 1 second. So slow down the initialization. time.sleep(1) @@ -2795,6 +2805,12 @@ class StorwizeSVCCommonDriver(san.SanDriver, # Get list of all volumes self._get_all_volumes() + # Update the pool stats + self._update_volume_stats() + + # Save the pool stats information in helpers class. + self._master_backend_helpers.stats = self._stats + # Build the list of in-progress vdisk copy operations if ctxt is None: admin_context = context.get_admin_context() @@ -3583,6 +3599,8 @@ class StorwizeSVCCommonDriver(san.SanDriver, self._state = self._master_state self._update_volume_stats() + self._master_backend_helpers.stats = self._stats + return storwize_const.FAILBACK_VALUE, volumes_update, groups_update def _failback_replica_volumes(self, ctxt, rep_volumes): @@ -3832,6 +3850,8 @@ class StorwizeSVCCommonDriver(san.SanDriver, self._state = self._aux_state self._update_volume_stats() + self._aux_backend_helpers.stats = self._stats + return self._active_backend_id, volumes_update, groups_update def _failover_replica_volumes(self, ctxt, rep_volumes): @@ -5632,6 +5652,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, """Build pool status""" QoS_support = True pool_stats = {} + is_dr_pool = False pool_data = self._helpers.get_pool_attrs(pool) if pool_data: easy_tier = pool_data['easy_tier'] in ['on', 'auto'] @@ -5655,6 +5676,14 @@ class StorwizeSVCCommonDriver(san.SanDriver, storwize_svc_multihostmap_enabled) backend_state = ('up' if pool_data['status'] == 'online' else 'down') + + # Get the data_reduction information for pool and set + # is_dr_pool flag. + if pool_data.get('data_reduction') == 'Yes': + is_dr_pool = True + elif pool_data.get('data_reduction') == 'No': + is_dr_pool = False + pool_stats = { 'pool_name': pool_data['name'], 'total_capacity_gb': total_capacity_gb, @@ -5674,6 +5703,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, 'max_over_subscription_ratio': over_sub_ratio, 'consistent_group_snapshot_enabled': True, 'backend_state': backend_state, + 'data_reduction': is_dr_pool, } if self._replica_enabled: pool_stats.update({ @@ -5695,6 +5725,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, 'thick_provisioning_support': False, 'max_over_subscription_ratio': 0, 'reserved_percentage': 0, + 'data_reduction': is_dr_pool, 'backend_state': 'down'} return pool_stats diff --git a/releasenotes/notes/bug-1890591-Pool-information-is-not-saved-in-stats-22f302d941cd9fe2.yaml b/releasenotes/notes/bug-1890591-Pool-information-is-not-saved-in-stats-22f302d941cd9fe2.yaml new file mode 100644 index 00000000000..5503b8da2c6 --- /dev/null +++ b/releasenotes/notes/bug-1890591-Pool-information-is-not-saved-in-stats-22f302d941cd9fe2.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `Bug #1890591 `_: + IBM Spectrum Virtualize Family: Fixed issue in do_setup of + StorwizeSVCCommonDriver to save pool information in stats + during initialisation.