Skip to content

Commit caf5faf

Browse files
committed
Move file system freeze after end of mirroring
The file system before the start of mirroring generates kernel task blocked for more than 120 seconds. The file system freeze after the start of mirroring and just before stopping the mirror between the original disk and copy of disk reduce the time of the freeze. Related-Bug: #1939116 Change-Id: I067382ec676b65f8698772a262c5e4cea7a1216d
1 parent 2ffd973 commit caf5faf

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

nova/tests/unit/virt/libvirt/test_driver.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19715,9 +19715,10 @@ def _test_live_snapshot(
1971519715
mock.patch('nova.virt.libvirt.utils.get_disk_backing_file'),
1971619716
mock.patch('nova.virt.libvirt.utils.create_cow_image'),
1971719717
mock.patch('nova.virt.libvirt.utils.extract_snapshot'),
19718-
mock.patch.object(drvr, '_set_quiesced')
19718+
mock.patch.object(drvr, '_set_quiesced'),
19719+
mock.patch.object(drvr, '_can_quiesce')
1971919720
) as (mock_define, mock_size, mock_backing, mock_create_cow,
19720-
mock_snapshot, mock_quiesce):
19721+
mock_snapshot, mock_quiesce, mock_can_quiesce):
1972119722

1972219723
xmldoc = "<domain/>"
1972319724
srcfile = "/first/path"
@@ -19732,7 +19733,7 @@ def _test_live_snapshot(
1973219733
guest = libvirt_guest.Guest(mock_dom)
1973319734

1973419735
if not can_quiesce:
19735-
mock_quiesce.side_effect = (
19736+
mock_can_quiesce.side_effect = (
1973619737
exception.InstanceQuiesceNotSupported(
1973719738
instance_id=self.test_instance['id'], reason='test'))
1973819739

@@ -19763,6 +19764,7 @@ def _test_live_snapshot(
1976319764
mock_define.assert_called_once_with(xmldoc)
1976419765
mock_quiesce.assert_any_call(mock.ANY, self.test_instance,
1976519766
mock.ANY, True)
19767+
1976619768
if can_quiesce:
1976719769
mock_quiesce.assert_any_call(mock.ANY, self.test_instance,
1976819770
mock.ANY, False)

nova/virt/libvirt/driver.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,14 +3164,15 @@ def _live_snapshot(self, context, instance, guest, disk_path, out_path,
31643164
libvirt_utils.create_cow_image(src_back_path, disk_delta,
31653165
src_disk_size)
31663166

3167-
quiesced = False
31683167
try:
3169-
self._set_quiesced(context, instance, image_meta, True)
3170-
quiesced = True
3168+
self._can_quiesce(instance, image_meta)
31713169
except exception.NovaException as err:
3172-
if self._requires_quiesce(image_meta):
3170+
if image_meta.properties.get('os_require_quiesce', False):
3171+
LOG.error('Quiescing instance failed but image property '
3172+
'"os_require_quiesce" is set: %(reason)s.',
3173+
{'reason': err}, instance=instance)
31733174
raise
3174-
LOG.info('Skipping quiescing instance: %(reason)s.',
3175+
LOG.info('Quiescing instance not available: %(reason)s.',
31753176
{'reason': err}, instance=instance)
31763177

31773178
try:
@@ -3192,12 +3193,24 @@ def _live_snapshot(self, context, instance, guest, disk_path, out_path,
31923193
while not dev.is_job_complete():
31933194
time.sleep(0.5)
31943195

3196+
finally:
3197+
quiesced = False
3198+
try:
3199+
# NOTE: The freeze FS is applied after the end of
3200+
# the mirroring of the disk to minimize the time of
3201+
# the freeze. The mirror between both disks is finished,
3202+
# sync continuously, and stopped after abort_job().
3203+
self.quiesce(context, instance, image_meta)
3204+
quiesced = True
3205+
except exception.NovaException as err:
3206+
LOG.info('Skipping quiescing instance: %(reason)s.',
3207+
{'reason': err}, instance=instance)
3208+
31953209
dev.abort_job()
31963210
nova.privsep.path.chown(disk_delta, uid=os.getuid())
3197-
finally:
31983211
self._host.write_instance_config(xml)
31993212
if quiesced:
3200-
self._set_quiesced(context, instance, image_meta, False)
3213+
self.unquiesce(context, instance, image_meta)
32013214

32023215
# Convert the delta (CoW) image with a backing file to a flat
32033216
# image with no backing file.

0 commit comments

Comments
 (0)