Whamcloud - gitweb
LU-7381 e2fsck: fix e2fsck -fD directory truncation
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 13 Nov 2015 05:35:17 +0000 (22:35 -0700)
committerAndreas Dilger <andreas.dilger@intel.com>
Tue, 10 May 2016 05:12:34 +0000 (23:12 -0600)
commit7bdcf88d5b805d6e81fbe6ba83ed5e556519339a
tree1de4c4148e6f5387a0d8a7772d71eda349617c56
parenteb022796b7e9e4f59d3daa102024e0337892cfc7
LU-7381 e2fsck: fix e2fsck -fD directory truncation

When an extent-mapped directory is compacted by "e2fsck -fD" and
frees enough leaf blocks that it loses an extent tree index block,
the old e2fsck_rehash_dir->ext2fs_block_iterate3->write_dir_block()
code would not free the extent block, which would result in the
extent tree becoming corrupted when it is written out.

    Pass 1: Checking inodes, blocks, and sizes
    Inode 17825800, end of extent exceeds allowed value
            (logical block 710, physical block 570459684, len 1019)

This results in loss of a whole index block of directory leaf blocks
and thousands or millions of files in lost+found.

Fix e2fsck_rehash_dir() to call ext2fs_punch() to free the blocks
at the end of the directory instead of trying to handle this itself
while writing out the directory.  That properly handles all of the
cases of updating the extent tree as well as accounting for blocks
that are released (both leaf blocks and index blocks).

Add a test case for compacting the directory to be smaller than the
index block that originally caused the corruption.

e2fsprogs-commit: 19961cd0003564c63c33ec14e69dfec6d81a2238
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change-Id: I2e075849423693ebf4468fd7b0f41d6b2f500c1e
Reviewed-on: http://review.whamcloud.com/17153
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
e2fsck/rehash.c
tests/f_extent_htree/expect.1 [new file with mode: 0644]
tests/f_extent_htree/expect.2 [new file with mode: 0644]
tests/f_extent_htree/image.gz [new file with mode: 0644]
tests/f_extent_htree/name [new file with mode: 0644]
tests/f_extent_htree/script [new file with mode: 0644]
tests/f_h_badnode/expect.1
tests/f_h_badnode/expect.2