ext4: avoid remove directory when directory is corrupted
[ Upstream commit b24e77ef1c6d4dbf42749ad4903c97539cc9755a ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f5d46f1b47
commit
5bebfd6077
@ -2929,11 +2929,8 @@ bool ext4_empty_dir(struct inode *inode)
|
|||||||
de = (struct ext4_dir_entry_2 *) (bh->b_data +
|
de = (struct ext4_dir_entry_2 *) (bh->b_data +
|
||||||
(offset & (sb->s_blocksize - 1)));
|
(offset & (sb->s_blocksize - 1)));
|
||||||
if (ext4_check_dir_entry(inode, NULL, de, bh,
|
if (ext4_check_dir_entry(inode, NULL, de, bh,
|
||||||
bh->b_data, bh->b_size, offset)) {
|
bh->b_data, bh->b_size, offset) ||
|
||||||
offset = (offset | (sb->s_blocksize - 1)) + 1;
|
le32_to_cpu(de->inode)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (le32_to_cpu(de->inode)) {
|
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user