searching for ext3 defrag/file move program
Joseph D. Wagner
theman at josephdwagner.info
Fri Mar 4 10:05:24 UTC 2005
I approached the problem from several different angles.
Approach #1 - Partition Must Be Unmounted to Defrag
Advantages:
* Minimize chance of file system corruption because
no other processes could be modifying files.
* Can manipulate the file system in ways that would
otherwise be unsafe if the file system were mounted.
Disadvantages:
* Must directly manipulate the journal (i.e. a lot of
tedious programming) so that the file system can
remain consistent in the event of a power failure
* The partition would be completely unavailable during
the entire defrag process resulting in significant
down time.
Ultimately rejected because of the last disadvantage.
Approach #2 - On-the-fly Defragmentation using the
EXT2FS library for Block Allocation
Advantages:
* No down time.
* Utilizes existing EXT3 journal programming by
performing the defragmentation using normal
read-write operations.
Disadvantages:
* Without mandatory locking, there would be no way
to ensure that another process has not modified the
file.
* Because of the way the kernel buffers I/O data,
another process could be attempting to utilize the
same blocks as the defrag program.
Attempted, but ultimately rejected because of the last disadvantage.
Approach #3 - On-the-fly Defragmentation without a
Block Allocation Policy
Advantages:
* This is a close as we can get to a "safe" on-the-fly
defragmentation program.
* No down time.
* Utilizes existing EXT3 journal programming by
performing the defragmentation using normal
read-write operations.
Disadvantages:
* Without a block allocation policy, defrag would be
nothing more than a sophisticated copy program.
* While it is likely that the copy would be less
fragmented than the original, without a block
allocation policy there would be no guarantee. The
copy would have to be checked against the original
before overwriting it.
* Without mandatory locking, there would be no way
to ensure that another process has not modified the
file.
Attempted, but ultimately rejected because of the last disadvantage.
In order to make a defrag for EXT3 safe, you would need to do one of
two things:
1) Develop a Defrag API or some sort of File System Maintenance API
which included Defrag support and successfully integrate it into
the kernel.
- OR -
2) Extend Mandatory Locking to every file the system opens and closes
and integrate such a patch into the kernel.
Either task is uphill sledding.
Joseph D. Wagner
More information about the Ext3-users
mailing list