[pve-devel] [PATCH] fix aio O_DIRECT check for cdrom drives
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Jun 2 16:04:26 CEST 2015
Only non-cdrom drives default to cache=none, so the check
for whether to default to aio=native needs to take the same
condition into account.
I combined them close together to make their relation more
visible.
---
PVE/QemuServer.pm | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index f3cd41e..d8d8671 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1163,16 +1163,6 @@ sub print_drive_full {
$opts .= ",$o=" . int($v*1024*1024) if $v;
}
- # aio native works only with O_DIRECT
- if (!$drive->{aio}) {
- if(!$drive->{cache} || $drive->{cache} eq 'none' || $drive->{cache} eq 'directsync') {
- $opts .= ",aio=native";
- } else {
- $opts .= ",aio=threads";
- }
- }
-
-
my $path;
my $volid = $drive->{file};
if (drive_is_cdrom($drive)) {
@@ -1185,7 +1175,23 @@ sub print_drive_full {
}
}
- $opts .= ",cache=none" if !$drive->{cache} && !drive_is_cdrom($drive);
+ my $cache_direct = 0;
+
+ if (my $cache = $drive->{cache}) {
+ $cache_direct = $cache =~ /^(?:off|none|directsync)$/;
+ } elsif (!drive_is_cdrom($drive)) {
+ $opts .= ",cache=none";
+ $cache_direct = 1;
+ }
+
+ # aio native works only with O_DIRECT
+ if (!$drive->{aio}) {
+ if($cache_direct) {
+ $opts .= ",aio=native";
+ } else {
+ $opts .= ",aio=threads";
+ }
+ }
my $detectzeroes = $drive->{discard} ? "unmap" : "on";
$opts .= ",detect-zeroes=$detectzeroes" if !drive_is_cdrom($drive);
--
2.1.4
More information about the pve-devel
mailing list