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 <lczerner@xxxxxxxxxx> 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. -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html