diff options
author | Chao Yu <chao2.yu@samsung.com> | 2015-03-19 19:27:51 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-04-10 15:08:51 -0700 |
commit | 0bdee482509fe8c3cf0e66231ed37b8e70954093 (patch) | |
tree | 2477ba4cbcefcbf2fce8e860e1d7e70c6aafa524 /fs/f2fs/data.c | |
parent | 028a41e89383e1208dff1afe3e260b8cb6d3431c (diff) | |
download | op-kernel-dev-0bdee482509fe8c3cf0e66231ed37b8e70954093.zip op-kernel-dev-0bdee482509fe8c3cf0e66231ed37b8e70954093.tar.gz |
f2fs: preserve extent info for extent cache
This patch tries to preserve last extent info in extent tree cache into on-disk
inode, so this can help us to reuse the last extent info next time for
performance.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index e3be4be..8a940e5 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -719,6 +719,55 @@ update_extent: atomic_dec(&et->refcount); } +void f2fs_preserve_extent_tree(struct inode *inode) +{ + struct extent_tree *et; + struct extent_info *ext = &F2FS_I(inode)->ext; + bool sync = false; + + if (!test_opt(F2FS_I_SB(inode), EXTENT_CACHE)) + return; + + et = __find_extent_tree(F2FS_I_SB(inode), inode->i_ino); + if (!et) { + if (ext->len) { + ext->len = 0; + update_inode_page(inode); + } + return; + } + + read_lock(&et->lock); + if (et->count) { + struct extent_node *en; + + if (et->cached_en) { + en = et->cached_en; + } else { + struct rb_node *node = rb_first(&et->root); + + if (!node) + node = rb_last(&et->root); + en = rb_entry(node, struct extent_node, rb_node); + } + + if (__is_extent_same(ext, &en->ei)) + goto out; + + *ext = en->ei; + sync = true; + } else if (ext->len) { + ext->len = 0; + sync = true; + } +out: + read_unlock(&et->lock); + atomic_dec(&et->refcount); + + if (sync) + update_inode_page(inode); +} + void f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink) { struct extent_tree *treevec[EXT_TREE_VEC_SIZE]; |