From 43d851abbabfe6968707cb151157ac9b1dd52faa Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 14 Jul 2022 18:43:34 +0200 Subject: [PATCH] DEMC: Add support for trim/discard This patch adds support for trim/discard to 3 Dell EMC drivers: - PowerStore - PowerMax - PowerFlex Support is added to report this capability to both Nova, via the 'discard' value in connection properties, as well as internally to Cinder, via the 'sparse_copy_volume' driver capability. PowerStore and PowerMax only support thin volumes, so they will always report the trimming capability, but the PowerFlex also supports thick volumes, so it will only be returned for thin volumes, and following vendor's recommendation [1] it will not be returned for volumes that have snapshots. SysAdmins can force all volumes to return discard capabilities for Nova with the ``report_discard_supported`` configuration option. [1]: https://docs.delltechnologies.com/bundle/READY_NODE_AMS_DG/page/GUID-8E6676C1-425A-4D51-8F59-1A92DE4F6638.html Change-Id: Ib119fd689545bdb636a4844c6125aec7c3c24b96 --- .../drivers/dell_emc/powermax/test_powermax_fc.py | 1 + .../dell_emc/powermax/test_powermax_iscsi.py | 2 ++ cinder/volume/drivers/dell_emc/powerflex/driver.py | 14 ++++++++++++-- cinder/volume/drivers/dell_emc/powermax/common.py | 1 + cinder/volume/drivers/dell_emc/powermax/fc.py | 4 +++- cinder/volume/drivers/dell_emc/powermax/iscsi.py | 4 +++- .../volume/drivers/dell_emc/powerstore/adapter.py | 5 ++++- .../volume/drivers/dell_emc/powerstore/driver.py | 3 ++- releasenotes/notes/demc-trim-bb2165f74a5703a6.yaml | 13 +++++++++++++ 9 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/demc-trim-bb2165f74a5703a6.yaml diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py index dd679034aca..84ff9225788 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_fc.py @@ -108,6 +108,7 @@ class PowerMaxFCTest(test.TestCase): 'data': {'target_lun': self.data.fc_device_info['hostlunid'], 'target_discovered': True, 'target_wwn': [], + 'discard': True, 'initiator_target_map': {}}} data = self.driver.populate_data(self.data.fc_device_info, self.data.test_volume, diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py index 663a75100d5..5025e7610b7 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_iscsi.py @@ -155,6 +155,7 @@ class PowerMaxISCSITest(test.TestCase): 'target_iqn': ip_and_iqn[0]['iqn'].split(',')[0], 'target_portal': ip_and_iqn[0]['ip'] + ':3260', 'target_lun': host_lun_id, + 'discard': True, 'volume_id': self.data.test_volume.id} iscsi_properties = self.driver.vmax_get_iscsi_properties( self.data.array, vol, ip_and_iqn, True, host_lun_id, [], None) @@ -271,6 +272,7 @@ class PowerMaxISCSITest(test.TestCase): 'target_iqn': ip_and_iqn[0]['iqn'].split(',')[0], 'target_portal': ip_and_iqn[0]['ip'] + ':3260', 'target_lun': host_lun_id, + 'discard': True, 'volume_id': self.data.test_volume.id} iscsi_properties = self.driver.vmax_get_iscsi_properties( self.data.array, self.data.test_volume, ip_and_iqn, True, diff --git a/cinder/volume/drivers/dell_emc/powerflex/driver.py b/cinder/volume/drivers/dell_emc/powerflex/driver.py index 0ac24fd50f5..206752f625b 100644 --- a/cinder/volume/drivers/dell_emc/powerflex/driver.py +++ b/cinder/volume/drivers/dell_emc/powerflex/driver.py @@ -95,9 +95,10 @@ class PowerFlexDriver(driver.VolumeDriver): 3.5.5 - Rebrand VxFlex OS to PowerFlex. 3.5.6 - Fix for Bug #1897598 when volume can be migrated without conversion of its type. + 3.5.7 - Report trim/discard support. """ - VERSION = "3.5.6" + VERSION = "3.5.7" # ThirdPartySystems wiki CI_WIKI_NAME = "DellEMC_PowerFlex_CI" @@ -840,7 +841,14 @@ class PowerFlexDriver(driver.VolumeDriver): self._get_client().remove_volume(snapshot.provider_id) def initialize_connection(self, volume, connector, **kwargs): - return self._initialize_connection(volume, connector, volume.size) + res = self._initialize_connection(volume, connector, volume.size) + + # TODO: Should probably be enabled for SSDs as well + # It is recommended not to trim volumes that contain snapshots as the + # logical capacity may not shrink. + if self.provisioning_type == 'thin' and not len(volume.snapshots): + res['data']['discard'] = True + return res def _initialize_connection(self, vol_or_snap, connector, vol_size): """Initialize connection and return connection info. @@ -1027,6 +1035,8 @@ class PowerFlexDriver(driver.VolumeDriver): "prov": backend_provisioned_capacity, }) stats["pools"] = pools + # TODO: Should probably be enabled for SSDs as well + stats['sparse_copy_volume'] = self.provisioning_type == 'thin' self._stats = stats def _query_pool_stats(self, domain_name, pool_name): diff --git a/cinder/volume/drivers/dell_emc/powermax/common.py b/cinder/volume/drivers/dell_emc/powermax/common.py index 67476c7848a..80e28099c6d 100644 --- a/cinder/volume/drivers/dell_emc/powermax/common.py +++ b/cinder/volume/drivers/dell_emc/powermax/common.py @@ -1424,6 +1424,7 @@ class PowerMaxCommon(object): 'reserved_percentage': 0, 'replication_enabled': self.replication_enabled, 'replication_targets': self.replication_targets, + 'sparse_copy_volume': True, 'pools': pools} return data diff --git a/cinder/volume/drivers/dell_emc/powermax/fc.py b/cinder/volume/drivers/dell_emc/powermax/fc.py index 2a2824a365b..2a659acdac2 100644 --- a/cinder/volume/drivers/dell_emc/powermax/fc.py +++ b/cinder/volume/drivers/dell_emc/powermax/fc.py @@ -131,9 +131,10 @@ class PowerMaxFCDriver(san.SanDriver, driver.FibreChannelDriver): - Use of snap id instead of generation (bp powermax-snapset-ids) - Support for Failover Abilities (bp/powermax-failover-abilities) 4.4.0 - Early check for status of port + 4.4.1 - Report trim/discard support """ - VERSION = "4.4.0" + VERSION = "4.4.1" # ThirdPartySystems wiki CI_WIKI_NAME = "DellEMC_PowerMAX_CI" @@ -311,6 +312,7 @@ class PowerMaxFCDriver(san.SanDriver, driver.FibreChannelDriver): 'data': {'target_lun': device_number, 'target_discovered': True, 'target_wwn': target_wwns, + 'discard': True, 'initiator_target_map': init_targ_map}} LOG.debug("Return FC data for zone addition: %(data)s.", diff --git a/cinder/volume/drivers/dell_emc/powermax/iscsi.py b/cinder/volume/drivers/dell_emc/powermax/iscsi.py index c87f05d19cd..90cc944e5db 100644 --- a/cinder/volume/drivers/dell_emc/powermax/iscsi.py +++ b/cinder/volume/drivers/dell_emc/powermax/iscsi.py @@ -137,9 +137,10 @@ class PowerMaxISCSIDriver(san.SanISCSIDriver): - Use of snap id instead of generation (bp powermax-snapset-ids) - Support for Failover Abilities (bp/powermax-failover-abilities) 4.4.0 - Early check for status of port + 4.4.1 - Report trim/discard support """ - VERSION = "4.4.0" + VERSION = "4.4.1" # ThirdPartySystems wiki CI_WIKI_NAME = "DellEMC_PowerMAX_CI" @@ -422,6 +423,7 @@ class PowerMaxISCSIDriver(san.SanISCSIDriver): properties['target_discovered'] = True properties['target_lun'] = host_lun_id properties['volume_id'] = volume.id + properties['discard'] = True if self.configuration.safe_get('use_chap_auth'): LOG.info("Chap authentication enabled.") diff --git a/cinder/volume/drivers/dell_emc/powerstore/adapter.py b/cinder/volume/drivers/dell_emc/powerstore/adapter.py index 08f8329d5c5..df3e35669f9 100644 --- a/cinder/volume/drivers/dell_emc/powerstore/adapter.py +++ b/cinder/volume/drivers/dell_emc/powerstore/adapter.py @@ -293,6 +293,7 @@ class CommonAdapter(object): "compression_support": True, "multiattach": True, "consistent_group_snapshot_enabled": True, + "sparse_copy_volume": True, } backend_stats = self.client.get_metrics() backend_total_capacity = utils.bytes_to_gib( @@ -1061,6 +1062,7 @@ class FibreChannelAdapter(CommonAdapter): "target_discovered": False, "target_lun": volume_identifier, "target_wwn": target_wwns, + "discard": True, } } @@ -1180,6 +1182,7 @@ class NVMEoFAdapter(CommonAdapter): "nqn": nqn, "target_port": 4420, "transport_type": "tcp", - "volume_nguid": volume_identifier + "volume_nguid": volume_identifier, + "discard": True, }, } diff --git a/cinder/volume/drivers/dell_emc/powerstore/driver.py b/cinder/volume/drivers/dell_emc/powerstore/driver.py index f0bd8f8f9cb..3b7e27f01ac 100644 --- a/cinder/volume/drivers/dell_emc/powerstore/driver.py +++ b/cinder/volume/drivers/dell_emc/powerstore/driver.py @@ -52,9 +52,10 @@ class PowerStoreDriver(driver.VolumeDriver): targets are used for multiple purposes (iSCSI target, Replication target, etc.) 1.2.0 - Add NVMe-OF support + 1.2.1 - Report trim/discard support """ - VERSION = "1.2.0" + VERSION = "1.2.1" VENDOR = "Dell EMC" # ThirdPartySystems wiki page diff --git a/releasenotes/notes/demc-trim-bb2165f74a5703a6.yaml b/releasenotes/notes/demc-trim-bb2165f74a5703a6.yaml new file mode 100644 index 00000000000..9f6807859a9 --- /dev/null +++ b/releasenotes/notes/demc-trim-bb2165f74a5703a6.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + Dell EMC PowerStore driver: Report trimming/discard support to Nova and + Cinder. + - | + Dell EMC PowerMax driver: Report trimming/discard support to Nova and + Cinder. + - | + Dell EMC PowerFlex driver: Report trimming/discard support to Nova and + Cinder on thin volumes that don't have snapshots. Not doing trim on + volumes with snapshots is the vendor's recommendation, but can be overriden + with the ``report_discard_supported`` configuration option.