Created attachment 389979 [details] test.c Description of problem: fallocate() syscall always fails with EOPNOTSUPP on ext4 with x86_64 arch Version-Release number of selected component (if applicable): kernel-2.6.18-164.11.1.el5.x86_64 kernel-2.6.18-186.el5.x86_64 How reproducible: Always. Steps to Reproduce: 1. vi test.c: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/syscall.h> #include <fcntl.h> #include <unistd.h> #include <asm/unistd.h> int fallocate(int fd, int mode, loff_t offset, loff_t len) { return syscall(__NR_fallocate, fd, mode, offset, len); } int main() { int fd = open("test.dat", O_RDWR | O_CREAT, 0666); if (fd == -1) { perror("open"); return 1; } if (fallocate(fd, 0, 0, 1048576)) { perror("fallocate"); } close(fd); return 0; } 2. gcc -Wall -o test test.c 3. ./test Actual results: fallocate: Operation not supported Expected results: test.dat file 1MB length Additional info: tried the same kernels but i686 arch: work as expected
I'll take a look, I thought this was working fine but will double check.
Are you certain you're testing on ext4? # ./bz-fallocate # ls -lh test.dat -rw-r--r-- 1 root root 1.0M Feb 10 11:19 test.dat # du -hc test.dat 1.0M test.dat 1.0M total # unmae -a Linux $HOST #1 SMP Wed Jan 27 18:11:22 EST 2010 x86_64 x86_64 x86_64 GNU/Linux -Eric
Sorry, this is my fault. I've created filesystem with the command # mke4fs -j <block-device> recreating filesystem with the command # mkfs.ext4 <block-device> resolved this issue.
Ok, that mke4fs business is a little confusing, sorry about that. It's just a newer, parallel-installable version of mke2fs, and behaves just as mke2fs does - so yes, you got an ext3 filesystem that way, and fallocate is not supported by ext3 - so everything is working as expected. Thanks, -Eric