[libvirt] [PATCH 1/2] Introduce posix_fallocate() to allocate disk space

Daniel Veillard veillard at redhat.com
Thu Mar 19 12:20:28 UTC 2009


On Thu, Mar 19, 2009 at 05:02:48PM +0530, Amit Shah wrote:
> On (Thu) Mar 19 2009 [10:39:05], Daniel P. Berrange wrote:
> >    char * buf = mmap(NULL, len, MAP_SHARED, MAP_ANONYMOUS, fd, offset)
> >    memset(buf, 0, len);
> >    munmap(buf, len);
> > 
> > Or, do your calloc() of a 1 MB chunk, and then call safewrite in a
> > loop, just to avoid too large a memory allocation.
> 
> Yeah; I forgot the free().
> 
> My approach was to never allocate more than 500MiB. However we can call
> safezero() itself with less than 500M; is 200M OK?

  No IMHO that's definitely too big. Even 1MB is too much if you
can avoid it, please try to use mmap, if that dowsn't work then
use 1MB chunk,

  thanks,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list