Skip to content

Commit

Permalink
ext4: don't verify checksums of dx non-leaf nodes during fallback scan
Browse files Browse the repository at this point in the history
During a directory entry lookup of a hashed directory, if the
hash-based lookup functions fail and we fall back to a linear scan,
don't try to verify the dirent checksum on the internal nodes of the
hash tree because they don't store a checksum in a hidden dirent like
the leaf nodes do.

Reported-by: George Spelvin <linux@horizon.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
djwong authored and tytso committed Nov 13, 2012
1 parent dffe9d8 commit c6af880
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fs/ext4/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,21 @@ static inline int search_dirblock(struct buffer_head *bh,
return 0;
}

static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block,
struct ext4_dir_entry *de)
{
struct super_block *sb = dir->i_sb;

if (!is_dx(dir))
return 0;
if (block == 0)
return 1;
if (de->inode == 0 &&
ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize) ==
sb->s_blocksize)
return 1;
return 0;
}

/*
* ext4_find_entry()
Expand Down Expand Up @@ -1246,6 +1261,8 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
goto next;
}
if (!buffer_verified(bh) &&
!is_dx_internal_node(dir, block,
(struct ext4_dir_entry *)bh->b_data) &&
!ext4_dirent_csum_verify(dir,
(struct ext4_dir_entry *)bh->b_data)) {
EXT4_ERROR_INODE(dir, "checksumming directory "
Expand Down

0 comments on commit c6af880

Please sign in to comment.