All of lore.kernel.org
 help / color / mirror / Atom feed
* fallocate() not "atomic" if insufficient disk space?
@ 2011-12-28 16:09 markk
  2011-12-30 23:13 ` Eric Sandeen
  0 siblings, 1 reply; 4+ messages in thread
From: markk @ 2011-12-28 16:09 UTC (permalink / raw)
  To: linux-ext4

Hi,

I've been experimenting with using fallocate() to pre-allocate space for a
file on an ext4 partition. I'm testing with Ubuntu kernel
3.0.0-14-generic. Does fallocate() behave in the same way on more
recent/vanilla kernels?

What I expected to happen is that if fallocate() fails due to lack of disk
space, no space is allocated, i.e. either nothing happens or the
allocation succeeds.

What actually seems to happen is that all remaining space in the partition
gets allocated to the file. (Thus risking that other programs will fail
due to lack of disk space until the file is deleted.)

If it's relevant, the partition in question has no journal and is mounted
with barrier=0.

Example on a partition with ~100MB free:

$ fallocate -o 0 -l 999999999 blah
fallocate: blah: fallocate failed: No space left on device
$ df /
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb1              3849136   3653604         0 100% /
$ du blah
107860	blah
$ ls -l blah
-rw-r--r-- 1 mark mark 110444544 2011-12-28 15:51 blah
$ rm blah

Same issue when specifying -n to call fallocate() with FALLOC_FL_KEEP_SIZE:

$ fallocate -n -o 0 -l 999999999 blah
fallocate: blah: fallocate failed: No space left on device
$ df /
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb1              3849136   3653604         0 100% /
$ du blah
107860	blah
$ ls -l blah
-rw-r--r-- 1 mark mark 0 2011-12-28 15:52 blah


-- Mark



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-05  0:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-28 16:09 fallocate() not "atomic" if insufficient disk space? markk
2011-12-30 23:13 ` Eric Sandeen
2012-01-04 22:40   ` markk
2012-01-05  0:19     ` Sunil Mushran

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.