Skip to content

Commit b24e77e

Browse files
Ye Bintytso
authored andcommitted
ext4: avoid remove directory when directory is corrupted
Now if check directoy entry is corrupted, ext4_empty_dir may return true then directory will be removed when file system mounted with "errors=continue". In order not to make things worse just return false when directory is corrupted. Signed-off-by: Ye Bin <yebin10@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20220622090223.682234-1-yebin10@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent c64a929 commit b24e77e

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

fs/ext4/namei.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,11 +3067,8 @@ bool ext4_empty_dir(struct inode *inode)
30673067
de = (struct ext4_dir_entry_2 *) (bh->b_data +
30683068
(offset & (sb->s_blocksize - 1)));
30693069
if (ext4_check_dir_entry(inode, NULL, de, bh,
3070-
bh->b_data, bh->b_size, offset)) {
3071-
offset = (offset | (sb->s_blocksize - 1)) + 1;
3072-
continue;
3073-
}
3074-
if (le32_to_cpu(de->inode)) {
3070+
bh->b_data, bh->b_size, offset) ||
3071+
le32_to_cpu(de->inode)) {
30753072
brelse(bh);
30763073
return false;
30773074
}

0 commit comments

Comments
 (0)