Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1129205 - fallocate to create swap file creates a file with holes
fallocate to create swap file creates a file with holes
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: util-linux (Show other bugs)
20
x86_64 Linux
unspecified Severity high
: ---
: ---
Assigned To: Karel Zak
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-12 06:00 EDT by George R. Goffe
Modified: 2014-12-17 08:02 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-12-17 08:02:13 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description George R. Goffe 2014-08-12 06:00:18 EDT
Description of problem:

"fallocate -l 8g swapfile" creates a file that "swapon -fv swapfile" gives error messages:
Aug 12 02:52:42 fedora-20-x86_64 kernel: [ 1392.638622] swapon: swapfile has holes
Aug 12 02:52:42 fedora-20-x86_64 kernel: swapon: swapfile has holes


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

util-linux-2.24.2-1.fc20.x86_64

How reproducible:

Always

Steps to Reproduce:
1.fallocate -l 8g swapfile
2.swapon -fv swapfile -- generates error msgs...
3.

Actual results:

see above

Expected results:

valid swap file without holes

Additional info:
Comment 1 Karel Zak 2014-08-12 08:50:19 EDT
Well, which FS type are you using? Does it work when you create the file by another way? What about if you create loop device from the file and then use the device for swapon?

See NOTES in swapon man page -- for example btrfs does not implement bmap() in kernel, so swapfiles on btrfs are impossible.
Comment 2 George R. Goffe 2014-08-12 12:43:16 EDT
Karel,

The fs is xfs.

How else does one create a swapfile?

Regards,

George...
Comment 3 Karel Zak 2014-10-30 09:11:27 EDT
Sorry for delay,

> How else does one create a swapfile?

dd if=/dev/zero of=swapfile count=8000 bs=1MiB

the problem with fallocate(1) or truncate(1) is that it uses filesystem ioctls to make the allocation fast and effective, the disadvantage is that it does not physically allocate the space -- but swapon(2) syscall requires a real space.

It seems we need a note about it to fallocate(1) man page.

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