Commit 41a099de authored by Fan Li's avatar Fan Li Committed by Jaegeuk Kim

f2fs: drop largest extent by range

now we update extent by range, fofs may not be on the largest
extent if the new extent overlaps with it. so add a new function
to drop largest extent properly.
Signed-off-by: default avatarFan li <fanofcode.li@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent a7230d16
...@@ -155,11 +155,12 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi, ...@@ -155,11 +155,12 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi,
return count - et->count; return count - et->count;
} }
static void __drop_largest_extent(struct inode *inode, pgoff_t fofs) static void __drop_largest_extent(struct inode *inode,
pgoff_t fofs, unsigned int len)
{ {
struct extent_info *largest = &F2FS_I(inode)->extent_tree->largest; struct extent_info *largest = &F2FS_I(inode)->extent_tree->largest;
if (largest->fofs <= fofs && largest->fofs + largest->len > fofs) if (fofs < largest->fofs + largest->len && fofs + len > largest->fofs)
largest->len = 0; largest->len = 0;
} }
...@@ -168,7 +169,7 @@ void f2fs_drop_largest_extent(struct inode *inode, pgoff_t fofs) ...@@ -168,7 +169,7 @@ void f2fs_drop_largest_extent(struct inode *inode, pgoff_t fofs)
if (!f2fs_may_extent_tree(inode)) if (!f2fs_may_extent_tree(inode))
return; return;
__drop_largest_extent(inode, fofs); __drop_largest_extent(inode, fofs, 1);
} }
void f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext) void f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext)
...@@ -422,7 +423,7 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode, ...@@ -422,7 +423,7 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
dei.len = 0; dei.len = 0;
/* we do not guarantee that the largest extent is cached all the time */ /* we do not guarantee that the largest extent is cached all the time */
__drop_largest_extent(inode, fofs); __drop_largest_extent(inode, fofs, len);
/* 1. lookup first extent node in range [fofs, fofs + len - 1] */ /* 1. lookup first extent node in range [fofs, fofs + len - 1] */
en = __lookup_extent_tree_ret(et, fofs, &prev_en, &next_en, en = __lookup_extent_tree_ret(et, fofs, &prev_en, &next_en,
......
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