diff --git a/os_brick/initiator/connectors/fibre_channel.py b/os_brick/initiator/connectors/fibre_channel.py index 570dd1240..96d2a5054 100644 --- a/os_brick/initiator/connectors/fibre_channel.py +++ b/os_brick/initiator/connectors/fibre_channel.py @@ -176,7 +176,8 @@ class FibreChannelConnector(base.BaseLinuxConnector): volume_paths = self.get_volume_paths(connection_properties) if volume_paths: - return self._linuxscsi.extend_volume(volume_paths) + return self._linuxscsi.extend_volume( + volume_paths, use_multipath=self.use_multipath) else: LOG.warning("Couldn't find any volume paths on the host to " "extend volume for %(props)s", diff --git a/os_brick/initiator/connectors/iscsi.py b/os_brick/initiator/connectors/iscsi.py index 82cdca839..eb1377974 100644 --- a/os_brick/initiator/connectors/iscsi.py +++ b/os_brick/initiator/connectors/iscsi.py @@ -474,7 +474,8 @@ class ISCSIConnector(base.BaseLinuxConnector, base_iscsi.BaseISCSIConnector): volume_paths = self.get_volume_paths(connection_properties) LOG.info("Found paths for volume %s", volume_paths) if volume_paths: - return self._linuxscsi.extend_volume(volume_paths) + return self._linuxscsi.extend_volume( + volume_paths, use_multipath=self.use_multipath) else: LOG.warning("Couldn't find any volume paths on the host to " "extend volume for %(props)s", diff --git a/os_brick/initiator/connectors/nvme.py b/os_brick/initiator/connectors/nvme.py index d60246875..f5a64bddd 100644 --- a/os_brick/initiator/connectors/nvme.py +++ b/os_brick/initiator/connectors/nvme.py @@ -34,7 +34,7 @@ class NVMeConnector(base.BaseLinuxConnector): """Connector class to attach/detach NVMe over fabric volumes.""" - def __init__(self, root_helper, driver=None, + def __init__(self, root_helper, driver=None, use_multipath=False, device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, *args, **kwargs): super(NVMeConnector, self).__init__( @@ -42,6 +42,7 @@ class NVMeConnector(base.BaseLinuxConnector): driver=driver, device_scan_attempts=device_scan_attempts, *args, **kwargs) + self.use_multipath = use_multipath def _get_system_uuid(self): # RSD requires system_uuid to let Cinder RSD Driver identify @@ -226,7 +227,8 @@ class NVMeConnector(base.BaseLinuxConnector): """ volume_paths = self.get_volume_paths(connection_properties) if volume_paths: - return self._linuxscsi.extend_volume(volume_paths) + return self._linuxscsi.extend_volume( + volume_paths, use_multipath=self.use_multipath) else: LOG.warning("Couldn't find any volume paths on the host to " "extend volume for %(props)s", diff --git a/os_brick/initiator/linuxscsi.py b/os_brick/initiator/linuxscsi.py index 717878c84..74eec5002 100644 --- a/os_brick/initiator/linuxscsi.py +++ b/os_brick/initiator/linuxscsi.py @@ -531,7 +531,7 @@ class LinuxSCSI(executor.Executor): root_helper=self._root_helper) return out - def extend_volume(self, volume_paths): + def extend_volume(self, volume_paths, use_multipath=False): """Signal the SCSI subsystem to test for volume resize. This function tries to signal the local system's kernel @@ -561,24 +561,26 @@ class LinuxSCSI(executor.Executor): LOG.debug("volume size after scsi device rescan %s", new_size) scsi_wwn = self.get_scsi_wwn(volume_paths[0]) - mpath_device = self.find_multipath_device_path(scsi_wwn) - if mpath_device: - # Force a reconfigure so that resize works - self.multipath_reconfigure() + if use_multipath: + mpath_device = self.find_multipath_device_path(scsi_wwn) + if mpath_device: + # Force a reconfigure so that resize works + self.multipath_reconfigure() - size = self.get_device_size(mpath_device) - LOG.info("mpath(%(device)s) current size %(size)s", - {'device': mpath_device, 'size': size}) - result = self.multipath_resize_map(scsi_wwn) - if 'fail' in result: - LOG.error("Multipathd failed to update the size mapping of " - "multipath device %(scsi_wwn)s volume %(volume)s", - {'scsi_wwn': scsi_wwn, 'volume': volume_paths}) - return None + size = self.get_device_size(mpath_device) + LOG.info("mpath(%(device)s) current size %(size)s", + {'device': mpath_device, 'size': size}) + result = self.multipath_resize_map(scsi_wwn) + if 'fail' in result: + LOG.error("Multipathd failed to update the size mapping " + "of multipath device %(scsi_wwn)s volume " + "%(volume)s", + {'scsi_wwn': scsi_wwn, 'volume': volume_paths}) + return None - new_size = self.get_device_size(mpath_device) - LOG.info("mpath(%(device)s) new size %(size)s", - {'device': mpath_device, 'size': new_size}) + new_size = self.get_device_size(mpath_device) + LOG.info("mpath(%(device)s) new size %(size)s", + {'device': mpath_device, 'size': new_size}) return new_size diff --git a/os_brick/tests/initiator/connectors/test_nvme.py b/os_brick/tests/initiator/connectors/test_nvme.py index 7589c3fe8..f741d0374 100644 --- a/os_brick/tests/initiator/connectors/test_nvme.py +++ b/os_brick/tests/initiator/connectors/test_nvme.py @@ -38,7 +38,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase): def setUp(self): super(NVMeConnectorTestCase, self).setUp() self.connector = nvme.NVMeConnector(None, - execute=self.fake_execute) + execute=self.fake_execute, + use_multipath=False) @mock.patch.object(nvme.NVMeConnector, '_execute') def test_get_sysuuid_without_newline(self, mock_execute): @@ -284,9 +285,11 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase): self.connector.extend_volume, connection_properties) + @mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device_path') @mock.patch.object(linuxscsi.LinuxSCSI, 'extend_volume') @mock.patch.object(nvme.NVMeConnector, 'get_volume_paths') - def test_extend_volume(self, mock_volume_paths, mock_scsi_extend): + def test_extend_volume(self, mock_volume_paths, mock_scsi_extend, + mock_scsi_find_mpath): fake_new_size = 1024 mock_volume_paths.return_value = ['/dev/vdx'] mock_scsi_extend.return_value = fake_new_size @@ -297,3 +300,4 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase): 'transport_type': 'rdma'} new_size = self.connector.extend_volume(connection_properties) self.assertEqual(fake_new_size, new_size) + mock_scsi_find_mpath.assert_not_called() diff --git a/os_brick/tests/initiator/test_linuxscsi.py b/os_brick/tests/initiator/test_linuxscsi.py index 7493ecf35..9d7c99b52 100644 --- a/os_brick/tests/initiator/test_linuxscsi.py +++ b/os_brick/tests/initiator/test_linuxscsi.py @@ -761,7 +761,8 @@ loop0 0""" mock_find_mpath_path.return_value = ('/dev/mapper/dm-uuid-mpath-%s' % wwn) - ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2']) + ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'], + use_multipath=True) self.assertEqual(2048, ret_size) # because we don't mock out the echo_scsi_command @@ -795,7 +796,8 @@ loop0 0""" mock_mpath_resize_map.return_value = 'fail' - ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2']) + ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'], + use_multipath=True) self.assertIsNone(ret_size) # because we don't mock out the echo_scsi_command