Skip to content

Commit

Permalink
ext4: fix the wrong number of the allocated blocks in ext4_split_exte…
Browse files Browse the repository at this point in the history
…nt()

This commit fixes a wrong return value of the number of the allocated
blocks in ext4_split_extent.  When the length of blocks we want to
allocate is greater than the length of the current extent, we return a
wrong number.  Let's see what happens in the following case when we
call ext4_split_extent().

  map: [48, 72]
  ex:  [32, 64, u]

'ex' will be split into two parts:
  ex1: [32, 47, u]
  ex2: [48, 64, w]

'map->m_len' is returned from this function, and the value is 24.  But
the real length is 16.  So it should be fixed.

Meanwhile in this commit we use right length of the allocated blocks
when get_reserved_cluster_alloc in ext4_ext_handle_uninitialized_extents
is called.

Signed-off-by: Zheng Liu <[email protected]>
Signed-off-by: "Theodore Ts'o" <[email protected]>
Cc: Dmitry Monakhov <[email protected]>
Cc: [email protected]
  • Loading branch information
gnehzuil authored and tytso committed Mar 11, 2013
1 parent adb2355 commit 3a22567
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -3067,6 +3067,7 @@ static int ext4_split_extent(handle_t *handle,
int err = 0;
int uninitialized;
int split_flag1, flags1;
int allocated = map->m_len;

depth = ext_depth(inode);
ex = path[depth].p_ext;
Expand All @@ -3086,6 +3087,8 @@ static int ext4_split_extent(handle_t *handle,
map->m_lblk + map->m_len, split_flag1, flags1);
if (err)
goto out;
} else {
allocated = ee_len - (map->m_lblk - ee_block);
}
/*
* Update path is required because previous ext4_split_extent_at() may
Expand Down Expand Up @@ -3115,7 +3118,7 @@ static int ext4_split_extent(handle_t *handle,

ext4_ext_show_leaf(inode, path);
out:
return err ? err : map->m_len;
return err ? err : allocated;
}

/*
Expand Down Expand Up @@ -3730,6 +3733,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
allocated - map->m_len);
allocated = map->m_len;
}
map->m_len = allocated;

/*
* If we have done fallocate with the offset that is already
Expand Down

0 comments on commit 3a22567

Please sign in to comment.