Commit f064a9d6 authored by Eric Whitney's avatar Eric Whitney Committed by Theodore Ts'o

ext4: clean up error return for convert_initialized_extent()

Although convert_initialized_extent() can potentially return an error
code with a negative value, its returned value is assigned to an
unsigned variable containing a block count in ext4_ext_map_blocks() and
then returned to that function's caller. The code currently works,
though the way this happens is obscure.  The code would be more
readable if it followed the error handling convention used elsewhere
in ext4_ext_map_blocks().

This patch does not address any known test failure or bug report - it's
simply a cleanup.  It also addresses a nearby coding standard issue.
Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
Link: https://lore.kernel.org/r/20200218202656.21561-1-enwlinux@gmail.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 780f66e5
...@@ -3871,7 +3871,7 @@ static int ...@@ -3871,7 +3871,7 @@ static int
convert_initialized_extent(handle_t *handle, struct inode *inode, convert_initialized_extent(handle_t *handle, struct inode *inode,
struct ext4_map_blocks *map, struct ext4_map_blocks *map,
struct ext4_ext_path **ppath, struct ext4_ext_path **ppath,
unsigned int allocated) unsigned int *allocated)
{ {
struct ext4_ext_path *path = *ppath; struct ext4_ext_path *path = *ppath;
struct ext4_extent *ex; struct ext4_extent *ex;
...@@ -3933,10 +3933,10 @@ convert_initialized_extent(handle_t *handle, struct inode *inode, ...@@ -3933,10 +3933,10 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
ext4_update_inode_fsync_trans(handle, inode, 1); ext4_update_inode_fsync_trans(handle, inode, 1);
map->m_flags |= EXT4_MAP_UNWRITTEN; map->m_flags |= EXT4_MAP_UNWRITTEN;
if (allocated > map->m_len) if (*allocated > map->m_len)
allocated = map->m_len; *allocated = map->m_len;
map->m_len = allocated; map->m_len = *allocated;
return allocated; return 0;
} }
static int static int
...@@ -4240,12 +4240,12 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ...@@ -4240,12 +4240,12 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
*/ */
if ((!ext4_ext_is_unwritten(ex)) && if ((!ext4_ext_is_unwritten(ex)) &&
(flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) { (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {
allocated = convert_initialized_extent( err = convert_initialized_extent(handle,
handle, inode, map, &path, inode, map, &path, &allocated);
allocated);
goto out2; goto out2;
} else if (!ext4_ext_is_unwritten(ex)) } else if (!ext4_ext_is_unwritten(ex)) {
goto out; goto out;
}
ret = ext4_ext_handle_unwritten_extents( ret = ext4_ext_handle_unwritten_extents(
handle, inode, map, &path, flags, handle, inode, map, &path, flags,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment