btrfs fallocate woes

Paul Komkoff
2010-01-14T11:28:39Z

Oh hai

Sorry if it's already fixed, but at least in fedora's
2.6.32.3-10.fc12.i686.PAE btrfs has a regression which can be
illustrated by running the following dumb test:

=== cut here ===
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main() {
int fd = open("testfile", O_CLOEXEC | O_CREAT | O_NOATIME | O_WRONLY, 0666);

fallocate(fd, 0, 0, 100);

write(fd, "test", 4);

close(fd);
}
=== cut here ===

if you run it on ext4, it will create a 4-byte file with "test" in it.
On btrfs, however, the file size would be 4096, and the remaining
space will be filled with zeroes.

I will try more recent kernels with that though.