From df749aea97cd8578952cc21b5289ae9c32f73c98 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Wed, 16 Jan 2013 16:50:57 +0000 Subject: ensure zeros are written out when clearing volumes Note O_DIRECT is _not_ used at the end of devices to avoid issues with odd sized blocks etc. so instead we arrange to have dd issue an fdatasync() to ensure the data is persisted, lest it be discarded from the write cache when the device is unprovisioned. * nova/virt/libvirt/utils.py (clear_logical_volume): Add 'conv=fdatasync' to the dd option list if O_DIRECT isn't used when clearing. Fixes bug: 1100363 Change-Id: I76789557754ebaeb6d52bb34548a2ef17808fbf6 --- nova/virt/libvirt/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nova') diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index 4b3517da7..a6df70af3 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -227,6 +227,7 @@ def clear_logical_volume(path): vol_size = logical_volume_size(path) bs = 1024 * 1024 direct_flags = ('oflag=direct',) + sync_flags = () remaining_bytes = vol_size # The loop caters for versions of dd that @@ -238,11 +239,14 @@ def clear_logical_volume(path): 'if=/dev/zero', 'of=%s' % path, 'seek=%s' % seek_blocks, 'count=%s' % zero_blocks) zero_cmd += direct_flags + zero_cmd += sync_flags if zero_blocks: utils.execute(*zero_cmd, run_as_root=True) remaining_bytes %= bs bs /= 1024 # Limit to 3 iterations - direct_flags = () # Only use O_DIRECT with initial block size + # Use O_DIRECT with initial block size and fdatasync otherwise + direct_flags = () + sync_flags = ('conv=fdatasync',) def remove_logical_volumes(*paths): -- cgit