[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: e2undel for ext3



On Feb 03, 2004  13:56 -0800, Mike Fedyk wrote:
> I'd love it if someone found a way to allow undelete in ext3.  Any ideas?

Yes, the best solution is to do the following:
- before truncating the file, walk all of the direct/indirect/tindirect blocks
  and count all of the bitmaps and group descriptor blocks that will be
  dirtied when the file is unlinked (this isn't a perf hit, since you will
  need to read these at some point anyways during the unlink, and bonus points
  if you read the {d,t,}indirect blocks many at once instead of one at a
  time like it does now)
- see if you can start a single transaction that is big enough to hold all
  of these blocks (likely yes, up to 8GB file size or larger if you create
  a larger journal on the disk)
- if you can start a single large transaction simply free all of the file
  blocks and mark the inode deleted like ext2 does, without zeroing any
  of the direct/indirect blocks or i_blocks or i_size
- now e2undel can get all of the block information back like it could with
  ext2
- this has the added benefit of not writing out any of the indirect blocks
  (1/1024 of the total file size) so you reduce your writes by 95% and
  speed up unlinking dramatically

So, it's a win-win situation.  Much faster truncating, and undeletion.

If you can't start the large transaction you could always fall back to the
old "zero indirect blocks and grow transaction when possible" method that
ext3 uses now.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]