[libvirt] [PATCH] Create raw storage files with O_DSYNC

Daniel P. Berrange berrange at redhat.com
Tue Feb 9 15:34:44 UTC 2010


On Mon, Feb 08, 2010 at 04:59:31PM +0100, Jiri Denemark wrote:
> When creating preallocated large raw files opening them with O_DSYNC
> prevents long delays in reading because cache pages can be immediately
> reused without writing them on a disk first.
> 
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/storage/storage_backend.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index e79294a..8aab9ab 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -301,7 +301,7 @@ virStorageBackendCreateRaw(virConnectPtr conn,
>          goto cleanup;
>      }
>  
> -    if ((fd = open(vol->target.path, O_RDWR | O_EXCL)) < 0) {
> +    if ((fd = open(vol->target.path, O_RDWR | O_EXCL | O_DSYNC)) < 0) {
>          virReportSystemError(conn, errno,
>                               _("cannot open new path '%s'"),
>                               vol->target.path);
> -- 

ACK,  O_DSYNC isn't ideal, but since there are soo many ways in which the
file ends up being written, it is the simplest option to get what we need


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list