summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-06 19:40:41 +0000
committerGerrit Code Review <review@openstack.org>2012-09-06 19:40:41 +0000
commitc29f6d27a8de2e475b06ba3123f65b658eff72e5 (patch)
tree223a17a18973c4006348335d7c870f866ce0c460
parentf14bf21152fb996897acf5e46a5dbdff832318c2 (diff)
parent64f1916d5871344bdd5177993bca709950e0b819 (diff)
downloadnova-c29f6d27a8de2e475b06ba3123f65b658eff72e5.tar.gz
nova-c29f6d27a8de2e475b06ba3123f65b658eff72e5.tar.xz
nova-c29f6d27a8de2e475b06ba3123f65b658eff72e5.zip
Merge "avoid the buffer cache when copying volumes"
-rw-r--r--nova/volume/driver.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/nova/volume/driver.py b/nova/volume/driver.py
index dee0df953..d03ad7cdc 100644
--- a/nova/volume/driver.py
+++ b/nova/volume/driver.py
@@ -112,9 +112,20 @@ class VolumeDriver(object):
volume_name, FLAGS.volume_group, run_as_root=True)
def _copy_volume(self, srcstr, deststr, size_in_g):
+ # Use O_DIRECT to avoid thrashing the system buffer cache
+ direct_flags = ('iflag=direct', 'oflag=direct')
+
+ # Check whether O_DIRECT is supported
+ try:
+ self._execute('dd', 'count=0', 'if=%s' % srcstr, 'of=%s' % deststr,
+ *direct_flags, run_as_root=True)
+ except exception.ProcessExecutionError:
+ direct_flags = ()
+
+ # Perform the copy
self._execute('dd', 'if=%s' % srcstr, 'of=%s' % deststr,
'count=%d' % (size_in_g * 1024), 'bs=1M',
- run_as_root=True)
+ *direct_flags, run_as_root=True)
def _volume_not_present(self, volume_name):
path_name = '%s/%s' % (FLAGS.volume_group, volume_name)