From: Ted Ts'o <tytso@mit.edu>
To: Christoph Hellwig <hch@infradead.org>
Cc: P??draig Brady <P@draigBrady.com>, linux-fsdevel@vger.kernel.org
Subject: Re: fallocate vs ENOSPC
Date: Sat, 26 Nov 2011 22:14:55 -0500 [thread overview]
Message-ID: <20111127031455.GK5167@thunk.org> (raw)
In-Reply-To: <20111125104050.GA26729@infradead.org>
On Fri, Nov 25, 2011 at 05:40:50AM -0500, Christoph Hellwig wrote:
> On Fri, Nov 25, 2011 at 10:26:09AM +0000, P??draig Brady wrote:
> > I was wondering about adding fallocate() to cp,
> > where one of the benefits would be immediate indication of ENOSPC.
> > I'm now wondering though might fallocate() fail to allocate an
> > extent with ENOSPC, but there could be fragmented space available to write()?
>
> fallocate isn't guaranteed to allocate a single or even contiguous
> extents, it just allocate the given amount of space, and if the fs isn't
> too fragmented and the allocator not braindead it will be sufficiently
> contiguous. Also all Linux implementation may actually still fail a write
> later if extreme corner cases when btree splits or other metadata
> operations during unwritten extent conversions go over the space limit.
While this is true, *usually* fallocate will allocate enough space,
but as Cirstoph has said, you still have to check the error returns
for the write(2) and close(2) system call, and deal appropriately with
any errors.
The other reason to use fallocate is if you are copying a huge number
of files, it's possible you'll get better block allocation layout,
depending on the file system, and how insane the writeback code for a
particular kernel version might be. (Some versions of the kernel had
writeback algorithms that would write 4MB of one file, then 4MB for
another file, then 4MB for yet another file, then 4MB of the first
file, etc. --- and some file systems can deal with this kind of write
pattern better than others.) Using fallocate if you know the size of
the file up front won't hurt, and on some systems it might help.
- Ted
next prev parent reply other threads:[~2011-11-27 3:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-25 10:26 fallocate vs ENOSPC Pádraig Brady
2011-11-25 10:40 ` Christoph Hellwig
2011-11-27 3:14 ` Ted Ts'o [this message]
2011-11-27 23:43 ` Dave Chinner
2011-11-28 0:13 ` Pádraig Brady
2011-11-28 3:51 ` Dave Chinner
2011-11-28 0:40 ` Theodore Tso
2011-11-28 5:10 ` Dave Chinner
2011-11-28 8:55 ` Pádraig Brady
2011-11-28 10:41 ` tao.peng
2011-11-28 12:02 ` Pádraig Brady
2011-11-28 14:36 ` Theodore Tso
2011-11-28 14:51 ` Pádraig Brady
2011-11-28 20:29 ` Ted Ts'o
2011-11-28 20:49 ` Jeremy Allison
2011-11-29 22:39 ` Eric Sandeen
2011-11-29 23:04 ` Jeremy Allison
2011-11-29 23:19 ` Eric Sandeen
2011-11-28 18:49 ` Jeremy Allison
2011-11-29 0:26 ` Dave Chinner
2011-11-29 0:45 ` Jeremy Allison
2011-11-29 0:24 ` Dave Chinner
2011-11-29 14:11 ` Pádraig Brady
2011-11-29 23:37 ` Dave Chinner
2011-11-30 9:28 ` Pádraig Brady
2011-11-30 15:32 ` Ted Ts'o
2011-11-30 16:11 ` Pádraig Brady
2011-11-30 17:01 ` Ted Ts'o
2011-11-30 23:39 ` Dave Chinner
2011-12-01 0:11 ` Pádraig Brady
2011-12-07 11:42 ` Pádraig Brady
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111127031455.GK5167@thunk.org \
--to=tytso@mit.edu \
--cc=P@draigBrady.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).