Skip to content

Commit

Permalink
ext4: remove unreachable code after ext4_can_extents_be_merged()
Browse files Browse the repository at this point in the history
Commit ec22ba8 ("ext4: disable merging of uninitialized extents")
ensured that if either extent under consideration is uninit, we
decline to merge, and ext4_can_extents_be_merged() returns false.

So there is no need for the caller to then test whether the
extent under consideration is unitialized; if it were, we
wouldn't have gotten that far.

The comments were also inaccurate; ext4_can_extents_be_merged()
no longer XORs the states, it fails if *either* is uninit.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
  • Loading branch information
Eric Sandeen authored and Theodore Ts'o committed Nov 8, 2013
1 parent da0169b commit f275411
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,6 @@ static int ext4_ext_try_to_merge_right(struct inode *inode,
struct ext4_extent_header *eh;
unsigned int depth, len;
int merge_done = 0;
int uninitialized = 0;

depth = ext_depth(inode);
BUG_ON(path[depth].p_hdr == NULL);
Expand All @@ -1725,12 +1724,8 @@ static int ext4_ext_try_to_merge_right(struct inode *inode,
if (!ext4_can_extents_be_merged(inode, ex, ex + 1))
break;
/* merge with next extent! */
if (ext4_ext_is_uninitialized(ex))
uninitialized = 1;
ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex)
+ ext4_ext_get_actual_len(ex + 1));
if (uninitialized)
ext4_ext_mark_uninitialized(ex);

if (ex + 1 < EXT_LAST_EXTENT(eh)) {
len = (EXT_LAST_EXTENT(eh) - ex - 1)
Expand Down Expand Up @@ -1885,7 +1880,6 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
struct ext4_ext_path *npath = NULL;
int depth, len, err;
ext4_lblk_t next;
unsigned uninitialized = 0;
int mb_flags = 0;

if (unlikely(ext4_ext_get_actual_len(newext) == 0)) {
Expand Down Expand Up @@ -1937,18 +1931,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
if (err)
return err;

/*
* ext4_can_extents_be_merged should have checked
* that either both extents are uninitialized, or
* both aren't. Thus we need to check only one of
* them here.
*/
if (ext4_ext_is_uninitialized(ex))
uninitialized = 1;
ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex)
+ ext4_ext_get_actual_len(newext));
if (uninitialized)
ext4_ext_mark_uninitialized(ex);
eh = path[depth].p_hdr;
nearex = ex;
goto merge;
Expand All @@ -1971,20 +1955,10 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
if (err)
return err;

/*
* ext4_can_extents_be_merged should have checked
* that either both extents are uninitialized, or
* both aren't. Thus we need to check only one of
* them here.
*/
if (ext4_ext_is_uninitialized(ex))
uninitialized = 1;
ex->ee_block = newext->ee_block;
ext4_ext_store_pblock(ex, ext4_ext_pblock(newext));
ex->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex)
+ ext4_ext_get_actual_len(newext));
if (uninitialized)
ext4_ext_mark_uninitialized(ex);
eh = path[depth].p_hdr;
nearex = ex;
goto merge;
Expand Down

0 comments on commit f275411

Please sign in to comment.