an interface for filesystem preallocation that doesn't suck?

Eric Sandeen sandeen at redhat.com
Sat Apr 25 16:25:26 UTC 2009


James Ralston wrote:
> Now that ext4 is the default filesystem, it would be nice to see more
> programs taking advantage of its preallocation features.

Just FWIW, I ran a scan of an x86_64 rawhide install to see which
executables & libraries are using these interfaces now; it's not a very
long list:

[root at host /mnt/test/F11]# ../summarize_falloc.pl usr/bin usr/sbin bin
sbin usr/lib usr/lib64
usr/bin/transmission-daemon uses fallocate
usr/bin/transmissioncli uses fallocate
usr/bin/transmission-remote uses fallocate
usr/bin/aria2c uses posix_fallocate
usr/bin/transmission uses fallocate
usr/sbin/nscd uses posix_fallocate
usr/lib64/libvirt.so.0 uses posix_fallocate
usr/lib64/libvirt.so.0.6.2 uses posix_fallocate
usr/lib64/libMonoPosixHelper.so uses posix_fallocate
usr/lib64/libvirt.so uses posix_fallocate

 249105 85.5% are scripts (shell, perl, whatever)
  42149 14.5% don't use any fallocate() family calls at all
      6  0.0% use posix_fallocate() interfaces only
      4  0.0% use fallocate() interfaces only


It might be nice to document how these apps actually use the interfaces
though, so people can take advantage of them.  For example, it's a
fairly obscure config option for transmission, IIRC.

...

> Additionally, the semantics that result from using fallocate() with
> FALLOC_FL_KEEP_SIZE (which posix_fallocate() does NOT do) are arguably
> more intuitive, because FALLOC_FL_KEEP_SIZE (essentially) creates a
> sparse file:
> 
> $ fallocate-test foo $[1024*1024*512] && ls -lsa foo
> fallocate-test: allocating 536870912 bytes for new file foo
> 524292 -rw-r--r-- 1 root root 0 2009-04-02 13:59 foo

Just a nitpick; this isn't really a sparse file (depending on what your
test does) - the blocks really and truly are allocated to it, there are
no holes.  The blocks just happen to be allocated past EOF.  :)

-Eric




More information about the devel mailing list