Bug 563492

Summary: fallocate() always fails on ext4 with x86_64 arch
Product: Red Hat Enterprise Linux 5 Reporter: Roman <rommer>
Component: kernelAssignee: Eric Sandeen <esandeen>
Status: CLOSED NOTABUG QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: medium Docs Contact:
Priority: low    
Version: 5.4CC: esandeen, rommer
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-02-10 19:06:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test.c none

Description Roman 2010-02-10 12:18:32 UTC
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

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

-Eric

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.

Thanks,
-Eric