提交 0d0cd58a 编写于 作者: Y Ye Bin 提交者: Zheng Zengkai

ext4: avoid remove directory when directory is corrupted

stable inclusion
from stable-v5.10.138
commit 285447b81925ff785533c677d552c97818081181
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60QFD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=285447b81925ff785533c677d552c97818081181

--------------------------------

[ Upstream commit b24e77ef ]

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: NYe Bin <yebin10@huawei.com>
Reviewed-by: NJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220622090223.682234-1-yebin10@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 7831d4d5
...@@ -2986,11 +2986,8 @@ bool ext4_empty_dir(struct inode *inode) ...@@ -2986,11 +2986,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;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册