[libvirt] Fix slow storage file allocation with O_DSYNC

Jiri Denemark jdenemar at redhat.com
Tue Mar 2 15:26:17 UTC 2010


Hi.

By opening storage file with O_DSYNC before allocating disk blocks for it we
made the whole operation terribly slow when the allocation is done using
posix_fallocate() on a filesystem which does not support fallocate(), i.e.
anything but ext4.

And by terribly slow I mean 45 minutes (RHEL5) to 10+ hours (Fedora Rawhide)
for a 12GB storage.

To fix this issue, we have two options. Either avoid using fallocate()
emulation inside posix_fallocate() or stop using O_DSYNC. I prepared a patch
for each of these options and they will follow as replies to this
introduction.

Some numbers for the same 12GB file:

- libvirt's internal fallocate emulation using
    - mmap  ~3.5 minutes (will be used whenever mmap() is present)
    - write ~5 minutes
- fsync() instead of O_DSYNC
    - ~3.5 minutes

So basically the two options are equivalent wrt to time consumption. The
second one seems to be less hacky at the expense of non-lienar behavior which
makes progress reporting less useful.

Jirka




More information about the libvir-list mailing list