Mingming Cao has attempted to fix this problem with a set of "block reservation" patches for ext3; those patches are currently part of the -mm tree. The core idea behind these patches is that the filesystem should think ahead of time about where it might place blocks for growing files and reserve that space. That way, when the file does grow, there will be blocks available in a useful part of the disk.
To that end, the ext3 block allocator has been replaced by a reservation-oriented version. The first time a block is needed for a file, the filesystem creates a "reservation window" which sets aside a range of blocks (eight of them, initially); the actual block allocations are then taken from the window. When the window is exhausted, a new, possibly expanded window is allocated, as near as possible to the old window, to replace it. Reservations only last until the process writing the file closes it; thereafter, the blocks become free once again.
Interestingly, nothing in the filesystem itself tracks block reservations; they are all handled by a single, in-core linked list (per filesystem). A block reservation will not actually prevent blocks inside the window from being allocated to some other file. Since the filesystem allocates out of reservation windows whenever possible, however, and those windows do not overlap, the reservations are almost always honored. In some situations (such as when all remaining free blocks are reserved) the filesystem will forget about reservations and allocate blocks from anywhere.
Some benchmark results show significant performance improvements, especially when large numbers of processes are running. To some extent, this improvement comes about because block reservations narrow down the area of the disk that must be searched for free blocks and increase the chances that a block will be found quickly. The real benefit, however, is that the on-disk layout of the files is much improved. Unless problems turn up, this patch may find its way into the mainline fairly quickly.
ext3 defragmentation
Posted Apr 22, 2004 11:23 UTC (Thu) by jbh (subscriber, #494) [Link]
There has been some progress to avoid fragmentation. But it doesn't help much for older filesystems that are already heavily fragmented. Does anyone know of an ext3 defragmenter? Online or offline.I've seen one for ext2 but I don't trust it, especially after seeing this:
"Tried it on a spare ext3 partition that I backed up first. Did a diff after, the defrag corrupted data."
http://lists.debian.org/debian-user/2003/debian-user-200308/msg03259.html
ext3 defragmentation
Posted Apr 22, 2004 16:42 UTC (Thu) by Duncan (guest, #6647) [Link]
There's not enough info in that limited quote to tell for sure, but if an
ext3 defragmentation
Posted Apr 23, 2004 1:43 UTC (Fri) by prat (guest, #20866) [Link]
I've actually looked at this before, and found a few solutions, but quickly concluded that the programs in question (which had to be run offline) seemed a little too unmaintained and unreliable to test out on my partition. The best answer I've gotten from anyone so far is that yes, there is a program that can do this, and that program is tar. =) Of course, you'd need someplace to back everything up to. Then you can just untar everything onto a clean partition, possibly with these new patches in place in the kernel you use during the restore, but since tar is probably doing this linearly anyway, I doubt it would make much difference.Long story short, most people I've talked to have never had any problems with fragmented ext[23] filesystems. Sorry.
ext3 defragmentation
Posted Apr 23, 2004 18:35 UTC (Fri) by southey (subscriber, #9466) [Link]
In my (poor) opinion defragmentation is a myth. At least on Windows it doesn't change a thing except the time waiting for it to finish. There is more benefit is having files used together in the same sequence - at least this is one of the tricks MS uses to get Windows to 'boot' faster. Linux's ability to put that 'unused' memory to 'good use' also probably helps minimize fragmentation delays with file access. Harddrive technology probably also makes this a less of an issue.
ext3 defragmentation
Posted Apr 25, 2004 11:15 UTC (Sun) by tialaramex (subscriber, #21167) [Link]
ext3 filesystems that are cleanly unmounted are also valid ext2 filesystems and can therefore be defrag'd by any working ext2 defrag application. I last used such a thing in 1998 and it seemed to work fine at that time. I believe there have since been one or perhaps at most two incompatible changes to the ext2 structures that might (not sure) affect defrag programs. You should check that any defrag application you consider is aware of ext2/3's compatibility flags, which would prevent it from modifying a filesystem with features that it doesn't understand.
Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds