提交 1aadba75 编写于 作者: J Jan Kara 提交者: Yang Yingliang

ext4: do not zeroout extents beyond i_disksize

stable inclusion
from linux-4.19.117
commit c9fc93e7a96c01bafe8345fa95217b80cc40452c

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

commit 801674f3 upstream.

We do not want to create initialized extents beyond end of file because
for e2fsck it is impossible to distinguish them from a case of corrupted
file size / extent tree and so it complains like:

Inode 12, i_size is 147456, should be 163840.  Fix? no

Code in ext4_ext_convert_to_initialized() and
ext4_split_convert_extents() try to make sure it does not create
initialized extents beyond inode size however they check against
inode->i_size which is wrong. They should instead check against
EXT4_I(inode)->i_disksize which is the current inode size on disk.
That's what e2fsck is going to see in case of crash before all dirty
data is written. This bug manifests as generic/456 test failure (with
recent enough fstests where fsx got fixed to properly pass
FALLOC_KEEP_SIZE_FL flags to the kernel) when run with dioread_lock
mount option.

CC: stable@vger.kernel.org
Fixes: 21ca087a ("ext4: Do not zero out uninitialized extents beyond i_size")
Reviewed-by: NLukas Czerner <lczerner@redhat.com>
Signed-off-by: NJan Kara <jack@suse.cz>
Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20200331105016.8674-1-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 13c56b66
...@@ -3462,8 +3462,8 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, ...@@ -3462,8 +3462,8 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
(unsigned long long)map->m_lblk, map_len); (unsigned long long)map->m_lblk, map_len);
sbi = EXT4_SB(inode->i_sb); sbi = EXT4_SB(inode->i_sb);
eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >> eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1)
inode->i_sb->s_blocksize_bits; >> inode->i_sb->s_blocksize_bits;
if (eof_block < map->m_lblk + map_len) if (eof_block < map->m_lblk + map_len)
eof_block = map->m_lblk + map_len; eof_block = map->m_lblk + map_len;
...@@ -3718,8 +3718,8 @@ static int ext4_split_convert_extents(handle_t *handle, ...@@ -3718,8 +3718,8 @@ static int ext4_split_convert_extents(handle_t *handle,
__func__, inode->i_ino, __func__, inode->i_ino,
(unsigned long long)map->m_lblk, map->m_len); (unsigned long long)map->m_lblk, map->m_len);
eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >> eof_block = (EXT4_I(inode)->i_disksize + inode->i_sb->s_blocksize - 1)
inode->i_sb->s_blocksize_bits; >> inode->i_sb->s_blocksize_bits;
if (eof_block < map->m_lblk + map->m_len) if (eof_block < map->m_lblk + map->m_len)
eof_block = map->m_lblk + map->m_len; eof_block = map->m_lblk + map->m_len;
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册