Fix slow storage volume allocation (bz 582356)

This commit is contained in:
Cole Robinson 2010-04-20 19:39:41 +00:00
parent a8bac7d647
commit 09a86187e8
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From e3c36a2575bc88a16d776693dc39ea01c780b406 Mon Sep 17 00:00:00 2001
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 16 Mar 2010 16:03:59 +0100
Subject: [PATCH] Use fsync() at the end of file allocation instead of O_DSYNC
Instead of opening storage file with O_DSYNC, make sure data are written
to a disk only before we claim allocation has finished.
---
src/storage/storage_backend.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index ec9fc43..7294a00 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -331,6 +331,13 @@ static int createRawFileOpHook(int fd, void *data) {
goto cleanup;
}
}
+
+ if (fsync(fd) < 0) {
+ ret = errno;
+ virReportSystemError(errno, _("cannot sync data to file '%s'"),
+ hdata->vol->target.path);
+ goto cleanup;
+ }
}
cleanup:
@@ -359,7 +366,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
gid_t gid = (vol->target.perms.gid == -1) ? getgid() : vol->target.perms.gid;
if ((createstat = virFileOperation(vol->target.path,
- O_RDWR | O_CREAT | O_EXCL | O_DSYNC,
+ O_RDWR | O_CREAT | O_EXCL,
vol->target.perms.mode, uid, gid,
createRawFileOpHook, &hdata,
VIR_FILE_OP_FORCE_PERMS |
--
1.6.6.1

View File

@ -169,7 +169,7 @@
Summary: Library providing a simple API virtualization
Name: libvirt
Version: 0.7.7
Release: 2%{?dist}%{?extra_release}
Release: 3%{?dist}%{?extra_release}
License: LGPLv2+
Group: Development/Libraries
Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz
@ -177,6 +177,8 @@ Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz
Patch1: %{name}-%{version}-fix-usb-product.patch
# Set kernel/initrd in security driver, fixes some URL installs (bz 566425)
Patch2: %{name}-%{version}-set-kernel-perms.patch
# Fix slow storage volume allocation (bz 582356)
Patch3: %{name}-%{version}-fix-slow-dsync.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/
BuildRequires: python-devel
@ -400,6 +402,7 @@ of recent versions of Linux (and other OSes).
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
%if ! %{with_xen}
@ -821,6 +824,9 @@ fi
%endif
%changelog
* Tue Apr 20 2010 Cole Robinson <crobinso@redhat.com> - 0.7.7-3.fc13
- Fix slow storage volume allocation (bz 582356)
* Mon Mar 22 2010 Cole Robinson <crobinso@redhat.com> - 0.7.7-2.fc13
- Fix USB devices by product with security enabled (bz 574136)
- Set kernel/initrd in security driver, fixes some URL installs (bz 566425)