ext4: clean up GET_BLOCKS_PRE_IO error handling
If the call to ext4_split_convert_extents() fails in the EXT4_GET_BLOCKS_PRE_IO case within ext4_ext_handle_unwritten_extents(), error out through the exit point at function end rather than jumping through an intermediate point. Fix the error handling in the event ext4_split_convert_extents() returns 0, which it shouldn't do when splitting an existing extent. The current code returns the passed in value of allocated (which is likely non-zero) while failing to set m_flags, m_pblk, and m_len. Signed-off-by: Eric Whitney <enwlinux@gmail.com> Link: https://lore.kernel.org/r/20200430185320.23001-4-enwlinux@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
bee6cf00c7
commit
779e26517b
@ -3818,12 +3818,25 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
|
|||||||
trace_ext4_ext_handle_unwritten_extents(inode, map, flags,
|
trace_ext4_ext_handle_unwritten_extents(inode, map, flags,
|
||||||
allocated, newblock);
|
allocated, newblock);
|
||||||
|
|
||||||
/* get_block() before submit the IO, split the extent */
|
/* get_block() before submitting IO, split the extent */
|
||||||
if (flags & EXT4_GET_BLOCKS_PRE_IO) {
|
if (flags & EXT4_GET_BLOCKS_PRE_IO) {
|
||||||
ret = ext4_split_convert_extents(handle, inode, map, ppath,
|
ret = ext4_split_convert_extents(handle, inode, map, ppath,
|
||||||
flags | EXT4_GET_BLOCKS_CONVERT);
|
flags | EXT4_GET_BLOCKS_CONVERT);
|
||||||
if (ret <= 0)
|
if (ret < 0) {
|
||||||
goto out;
|
err = ret;
|
||||||
|
goto out2;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* shouldn't get a 0 return when splitting an extent unless
|
||||||
|
* m_len is 0 (bug) or extent has been corrupted
|
||||||
|
*/
|
||||||
|
if (unlikely(ret == 0)) {
|
||||||
|
EXT4_ERROR_INODE(inode,
|
||||||
|
"unexpected ret == 0, m_len = %u",
|
||||||
|
map->m_len);
|
||||||
|
err = -EFSCORRUPTED;
|
||||||
|
goto out2;
|
||||||
|
}
|
||||||
map->m_flags |= EXT4_MAP_UNWRITTEN;
|
map->m_flags |= EXT4_MAP_UNWRITTEN;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -3863,12 +3876,13 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
|
|||||||
ret = ext4_ext_convert_to_initialized(handle, inode, map, ppath, flags);
|
ret = ext4_ext_convert_to_initialized(handle, inode, map, ppath, flags);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
ext4_update_inode_fsync_trans(handle, inode, 1);
|
ext4_update_inode_fsync_trans(handle, inode, 1);
|
||||||
out:
|
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
err = ret;
|
err = ret;
|
||||||
goto out2;
|
goto out2;
|
||||||
} else
|
}
|
||||||
allocated = ret;
|
out:
|
||||||
|
allocated = ret;
|
||||||
map->m_flags |= EXT4_MAP_NEW;
|
map->m_flags |= EXT4_MAP_NEW;
|
||||||
map_out:
|
map_out:
|
||||||
map->m_flags |= EXT4_MAP_MAPPED;
|
map->m_flags |= EXT4_MAP_MAPPED;
|
||||||
|
Loading…
Reference in New Issue
Block a user