From: Andreas Dilger Subject: Re: Minimizing fragmentation in ext4, fallocate not enough? Date: Fri, 24 Sep 2010 19:07:03 -0600 Message-ID: <7A56949B-99B6-439F-A015-1C0398A8B525@dilger.ca> References: <4C9D3CD6.9080000@mozilla.com> Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Cc: linux-ext4@vger.kernel.org To: Taras Glek Return-path: Received: from idcmail-mo2no.shaw.ca ([64.59.134.9]:14802 "EHLO idcmail-mo2no.shaw.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752993Ab0IYBHN convert rfc822-to-8bit (ORCPT ); Fri, 24 Sep 2010 21:07:13 -0400 In-Reply-To: <4C9D3CD6.9080000@mozilla.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: On 2010-09-24, at 18:05, Taras Glek wrote: > I noticed that several random IO-heavy Firefox files got fragmented easily. Our cache suffers most. > The cache works by creating a flat file and storing fixed-size entries in it. I though if I fallocate() the file first, then all of the writes within the allocated area would not cause additional fragmentation. > > This doesn't seem to completely cure fragmentation with ext4 in 2.6.33. If I allocate a 4mb file, it gets more and more fragmented over time. fallocate() does reduce fragmentation, but not as much as I expected. Have you checked filefrag immediately after fallocating the file? Is it OK? It may be that the issue is that an fallocate()'d file is using "unwritten extents" and converting these extents to "normal" extents may cause apparent fragmentation. However, depending on which version of e2fsprogs/filefrag you are using, it may well be that these extents only appear to be fragmented due to the different extent types. > ps2. Does running filefrag on a directory mean anything in ext4? With newer e2fsprogs using FIEMAP and kernels it should be possible to get useful filefrag data from a directory. Older kernels/e2fsprogs using FIBMAP will just fail outright.