From: Eric Sandeen <sandeen@redhat.com>
To: Bron Gondwana <brong@fastmail.fm>
Cc: linux-ext4@vger.kernel.org, Rob Mueller <robm@fastmail.fm>
Subject: Re: fallocate creating fragmented files
Date: Wed, 30 Jan 2013 00:05:39 -0600 [thread overview]
Message-ID: <5108B833.6010004@redhat.com> (raw)
In-Reply-To: <1359524809.5789.140661184325217.261ED7C8@webmail.messagingengine.com>
On 1/29/13 11:46 PM, Bron Gondwana wrote:
> Hi All,
>
> I'm trying to understand why my ext4 filesystem is creating highly fragmented files even though it's only just over 50% full.
It's at least possible that freespace is very fragmented; you could try the "e2freefrag" command to see.
<backgroun>
> Now we've got some background, let's create two files using the fallocate command line tool, and see where the blocks wound up. This mirrors exactly the behaviour we have seen with both using posix_fallocate to pre-allocate space, or just using seek and writev to write individual records out to the file. Except with the slower writes of a real application, we get closer to 9000 extents for a file this size.
>
> [brong@imap14 conf]$ fallocate -l 20m testfile
> [brong@imap14 conf]$ fallocate -l 20m testfile2
> [brong@imap14 conf]$ filefrag testfile
> testfile: 421 extents found
> [brong@imap14 conf]$ filefrag testfile2
> testfile2: 306 extents found
>
> Now looking at the verbose output, we can see that there are many extents of just 3 or 4 blocks:
>
> [brong@imap14 conf]$ filefrag -v testfile | awk '{print $5}' | sort -n | uniq -c | head
> 2
> 1 is
> 1 length
> 1 unwritten
> 6 3
> 10 4
> 6 5
> 5 6
> 3 7
> 1 8
But longer extents too, right:
$ filefrag -v testfile | awk '{print $5}' | sort -n | uniq -c | tail
1 162
1 164
1 179
1 188
1 215
1 231
1 233
1 255
1 322
1 357
> Yet looking at the next file,
>
> [brong@imap14 conf]$ filefrag -v testfile2 | awk '{print $5}' | sort -n | uniq -c | tail
> 1 173
> 1 175
> 1 178
> 1 184
> 1 187
> 1 189
> 1 194
> 1 289
> 1 321
> 1 330
>
and presumably shorter extents at the beginning?
So it sounds like both files are a mix of long & short extents.
> There are multiple extents of hundreds of blocks in length. Why weren't they used in allocating the first file?
I'm not sure, offhand. But just to be clear, while contiguous allocations are usually a nice side-effect of fallocate, nothing at all guarantees it. It only guarantees that you'll have that space available for future writes.
Still, it'd be interesting to figure out why the allocator is behaving this way.
It'd be interesting to see the freefrag info, the allocator might really be in scavenger mode.
-Eric
> This filesystem is quite busy all the time. There are hundreds of imapd processes all locking and writing to it, including a lot of fdatasync and fsync calls. During the time it took to run this command, there would have been multiple fsyncs. I can't see why that would affect the allocator in this way for a single fallocate call though.
>
> Regards,
>
> Bron.
next prev parent reply other threads:[~2013-01-30 6:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-30 5:46 fallocate creating fragmented files Bron Gondwana
2013-01-30 6:05 ` Eric Sandeen [this message]
2013-01-30 6:35 ` Bron Gondwana
2013-01-30 15:56 ` Eric Sandeen
2013-01-30 20:14 ` Theodore Ts'o
2013-01-30 21:21 ` Robert Mueller
2013-01-30 21:43 ` Theodore Ts'o
2013-01-30 22:40 ` Bron Gondwana
2013-01-30 22:49 ` Robert Mueller
2013-01-30 22:51 ` Robert Mueller
2013-02-01 11:33 ` Bron Gondwana
2013-02-01 13:55 ` Theodore Ts'o
2013-02-02 10:50 ` Bron Gondwana
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=5108B833.6010004@redhat.com \
--to=sandeen@redhat.com \
--cc=brong@fastmail.fm \
--cc=linux-ext4@vger.kernel.org \
--cc=robm@fastmail.fm \
/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).