Bug 563492 - fallocate() always fails on ext4 with x86_64 arch
Summary: fallocate() always fails on ext4 with x86_64 arch
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel
Version: 5.4
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Eric Sandeen
QA Contact: Red Hat Kernel QE team
Depends On:
TreeView+ depends on / blocked
Reported: 2010-02-10 12:18 UTC by Roman
Modified: 2010-02-10 19:06 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-02-10 19:06:04 UTC
Target Upstream Version:

Attachments (Terms of Use)
test.c (477 bytes, text/x-csrc)
2010-02-10 12:18 UTC, Roman
no flags Details

Description Roman 2010-02-10 12:18:32 UTC
Created attachment 389979 [details]

Description of problem:

fallocate() syscall always fails with EOPNOTSUPP on ext4 with x86_64 arch

Version-Release number of selected component (if applicable):

How reproducible:

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) {
                return 1;
        if (fallocate(fd, 0, 0, 1048576)) {
        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

Comment 1 Eric Sandeen 2010-02-10 17:13:45 UTC
I'll take a look, I thought this was working fine but will double check.

Comment 2 Eric Sandeen 2010-02-10 17:27:30 UTC
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


Comment 3 Roman 2010-02-10 19:01:44 UTC
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.

Comment 4 Eric Sandeen 2010-02-10 19:06:04 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.