From: Lukas Czerner Subject: Re: [PATCH 2/2] Add batched discard support for ext4 - using rbtree Date: Mon, 26 Apr 2010 20:42:58 +0200 (CEST) Message-ID: References: <1271674527-2977-2-git-send-email-lczerner@redhat.com> <1271674527-2977-3-git-send-email-lczerner@redhat.com> <4BCE6243.5010209@teksavvy.com> <4BCE66C5.3060906@redhat.com> <4BCF4C53.3010608@redhat.com> <20100426165527.GB21179@atrey.karlin.mff.cuni.cz> <4BD5D2EA.1070008@redhat.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Jeff Moyer , Ric Wheeler , Jan Kara , Greg Freemyer , Eric Sandeen , Mark Lord , linux-ext4@vger.kernel.org, Edward Shishkin , Eric Sandeen , Christoph Hellwig To: Lukas Czerner Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48283 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280Ab0DZSnC (ORCPT ); Mon, 26 Apr 2010 14:43:02 -0400 In-Reply-To: Sender: linux-ext4-owner@vger.kernel.org List-ID: On Mon, 26 Apr 2010, Lukas Czerner wrote: > Create an ioctl which walks through all the free extents in each > allocating group and discard those extents. As an addition to improve > its performance one can specify minimum free extent length, so ioctl > will not bother with shorter extents. > > This of course means, that with each invocation the ioctl must walk > through whole file system, checking and discarding free extents, which > is not very efficient. The best way to avoid this is to keep track of > deleted (freed) blocks. Then the ioctl have to trim just those free > extents which were recently freed. > > In order to implement this I have created new structure > ext4_deleted_data which represents deleted extent in per-group rbtree. > When blocks are freed, extents are stored in the tree (possibly merged > with other extents). The ioctl then can walk through the tree, take out > extents from the tree, compare them with the free extents and possibly > trim them. > > Note that there is support for setting minimum extent length in ioctl > call, so it will not bother with shorter extents. Also, when the > previously deleted range is taken from the tree and it is not entirely > free, the free fragments are discarded and extents shorter than minlen > are NOT returned back to the tree to avoid fragmentation of the tree > which could lead to the big memory consumption. > > But you may notice, that there is one problem. bb_bitmap_deleted does > not survive umount. To bypass the problem the first ioctl call have to > walk through whole file system trimming all free extents. > > Signed-off-by: Lukas Czerner For now it just ignores the small extents to avoid fragmentation. As I said before, I agree that they should not be ignored, I just need to figure out the way to do this efficiently. Also it was not properly tested yet. -Lukas.