Skip to content

Commit

Permalink
ext4: refine extent status tree
Browse files Browse the repository at this point in the history
This commit refines the extent status tree code.

1) A prefix 'es_' is added to to the extent status tree structure
members.

2) Refactored es_remove_extent() so that __es_remove_extent() can be
used by es_insert_extent() to remove the old extent entry(-ies) before
inserting a new one.

3) Rename extent_status_end() to ext4_es_end()

4) ext4_es_can_be_merged() is define to check whether two extents can
be merged or not.

5) Update and clarified comments.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Zheng Liu authored and Theodore Ts'o committed Feb 18, 2013
1 parent 0f70b40 commit 06b0c88
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 182 deletions.
21 changes: 11 additions & 10 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -3528,13 +3528,14 @@ static int ext4_find_delalloc_range(struct inode *inode,
{
struct extent_status es;

es.start = lblk_start;
ext4_es_find_extent(inode, &es);
if (es.len == 0)
es.es_lblk = lblk_start;
(void)ext4_es_find_extent(inode, &es);
if (es.es_len == 0)
return 0; /* there is no delay extent in this tree */
else if (es.start <= lblk_start && lblk_start < es.start + es.len)
else if (es.es_lblk <= lblk_start &&
lblk_start < es.es_lblk + es.es_len)
return 1;
else if (lblk_start <= es.start && es.start <= lblk_end)
else if (lblk_start <= es.es_lblk && es.es_lblk <= lblk_end)
return 1;
else
return 0;
Expand Down Expand Up @@ -4569,26 +4570,26 @@ static int ext4_find_delayed_extent(struct inode *inode,
struct extent_status es;
ext4_lblk_t next_del;

es.start = newex->ec_block;
es.es_lblk = newex->ec_block;
next_del = ext4_es_find_extent(inode, &es);

if (newex->ec_start == 0) {
/*
* No extent in extent-tree contains block @newex->ec_start,
* then the block may stay in 1)a hole or 2)delayed-extent.
*/
if (es.len == 0)
if (es.es_len == 0)
/* A hole found. */
return 0;

if (es.start > newex->ec_block) {
if (es.es_lblk > newex->ec_block) {
/* A hole found. */
newex->ec_len = min(es.start - newex->ec_block,
newex->ec_len = min(es.es_lblk - newex->ec_block,
newex->ec_len);
return 0;
}

newex->ec_len = es.start + es.len - newex->ec_block;
newex->ec_len = es.es_lblk + es.es_len - newex->ec_block;
}

return next_del;
Expand Down
Loading

0 comments on commit 06b0c88

Please sign in to comment.