Commit 72840ccc authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: allocate the extent_cache by default

Let's allocate it to remove the runtime complexity.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent e7547dac
...@@ -47,20 +47,23 @@ static bool __may_read_extent_tree(struct inode *inode) ...@@ -47,20 +47,23 @@ static bool __may_read_extent_tree(struct inode *inode)
return S_ISREG(inode->i_mode); return S_ISREG(inode->i_mode);
} }
static bool __may_extent_tree(struct inode *inode, enum extent_type type) static bool __init_may_extent_tree(struct inode *inode, enum extent_type type)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); if (type == EX_READ)
return __may_read_extent_tree(inode);
return false;
}
static bool __may_extent_tree(struct inode *inode, enum extent_type type)
{
/* /*
* for recovered files during mount do not create extents * for recovered files during mount do not create extents
* if shrinker is not registered. * if shrinker is not registered.
*/ */
if (list_empty(&sbi->s_list)) if (list_empty(&F2FS_I_SB(inode)->s_list))
return false; return false;
if (type == EX_READ) return __init_may_extent_tree(inode, type);
return __may_read_extent_tree(inode);
return false;
} }
static void __try_update_largest_extent(struct extent_tree *et, static void __try_update_largest_extent(struct extent_tree *et,
...@@ -439,20 +442,18 @@ static void __drop_largest_extent(struct extent_tree *et, ...@@ -439,20 +442,18 @@ static void __drop_largest_extent(struct extent_tree *et,
} }
} }
/* return true, if inode page is changed */ void f2fs_init_read_extent_tree(struct inode *inode, struct page *ipage)
static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage,
enum extent_type type)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct extent_tree_info *eti = &sbi->extent_tree[type]; struct extent_tree_info *eti = &sbi->extent_tree[EX_READ];
struct f2fs_extent *i_ext = ipage ? &F2FS_INODE(ipage)->i_ext : NULL; struct f2fs_extent *i_ext = &F2FS_INODE(ipage)->i_ext;
struct extent_tree *et; struct extent_tree *et;
struct extent_node *en; struct extent_node *en;
struct extent_info ei; struct extent_info ei;
if (!__may_extent_tree(inode, type)) { if (!__may_extent_tree(inode, EX_READ)) {
/* drop largest read extent */ /* drop largest read extent */
if (type == EX_READ && i_ext && i_ext->len) { if (i_ext && i_ext->len) {
f2fs_wait_on_page_writeback(ipage, NODE, true, true); f2fs_wait_on_page_writeback(ipage, NODE, true, true);
i_ext->len = 0; i_ext->len = 0;
set_page_dirty(ipage); set_page_dirty(ipage);
...@@ -460,13 +461,11 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage, ...@@ -460,13 +461,11 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage,
goto out; goto out;
} }
et = __grab_extent_tree(inode, type); et = __grab_extent_tree(inode, EX_READ);
if (!i_ext || !i_ext->len) if (!i_ext || !i_ext->len)
goto out; goto out;
BUG_ON(type != EX_READ);
get_read_extent_info(&ei, i_ext); get_read_extent_info(&ei, i_ext);
write_lock(&et->lock); write_lock(&et->lock);
...@@ -486,14 +485,15 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage, ...@@ -486,14 +485,15 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage,
unlock_out: unlock_out:
write_unlock(&et->lock); write_unlock(&et->lock);
out: out:
if (type == EX_READ && !F2FS_I(inode)->extent_tree[EX_READ]) if (!F2FS_I(inode)->extent_tree[EX_READ])
set_inode_flag(inode, FI_NO_EXTENT); set_inode_flag(inode, FI_NO_EXTENT);
} }
void f2fs_init_extent_tree(struct inode *inode, struct page *ipage) void f2fs_init_extent_tree(struct inode *inode)
{ {
/* initialize read cache */ /* initialize read cache */
__f2fs_init_extent_tree(inode, ipage, EX_READ); if (__init_may_extent_tree(inode, EX_READ))
__grab_extent_tree(inode, EX_READ);
} }
static bool __lookup_extent_tree(struct inode *inode, pgoff_t pgofs, static bool __lookup_extent_tree(struct inode *inode, pgoff_t pgofs,
......
...@@ -4150,7 +4150,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, ...@@ -4150,7 +4150,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root,
bool force, bool *leftmost); bool force, bool *leftmost);
bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi, bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
struct rb_root_cached *root, bool check_key); struct rb_root_cached *root, bool check_key);
void f2fs_init_extent_tree(struct inode *inode, struct page *ipage); void f2fs_init_extent_tree(struct inode *inode);
void f2fs_drop_extent_tree(struct inode *inode); void f2fs_drop_extent_tree(struct inode *inode);
void f2fs_destroy_extent_node(struct inode *inode); void f2fs_destroy_extent_node(struct inode *inode);
void f2fs_destroy_extent_tree(struct inode *inode); void f2fs_destroy_extent_tree(struct inode *inode);
...@@ -4159,6 +4159,7 @@ int __init f2fs_create_extent_cache(void); ...@@ -4159,6 +4159,7 @@ int __init f2fs_create_extent_cache(void);
void f2fs_destroy_extent_cache(void); void f2fs_destroy_extent_cache(void);
/* read extent cache ops */ /* read extent cache ops */
void f2fs_init_read_extent_tree(struct inode *inode, struct page *ipage);
bool f2fs_lookup_read_extent_cache(struct inode *inode, pgoff_t pgofs, bool f2fs_lookup_read_extent_cache(struct inode *inode, pgoff_t pgofs,
struct extent_info *ei); struct extent_info *ei);
void f2fs_update_read_extent_cache(struct dnode_of_data *dn); void f2fs_update_read_extent_cache(struct dnode_of_data *dn);
......
...@@ -392,8 +392,6 @@ static int do_read_inode(struct inode *inode) ...@@ -392,8 +392,6 @@ static int do_read_inode(struct inode *inode)
fi->i_pino = le32_to_cpu(ri->i_pino); fi->i_pino = le32_to_cpu(ri->i_pino);
fi->i_dir_level = ri->i_dir_level; fi->i_dir_level = ri->i_dir_level;
f2fs_init_extent_tree(inode, node_page);
get_inline_info(inode, ri); get_inline_info(inode, ri);
fi->i_extra_isize = f2fs_has_extra_attr(inode) ? fi->i_extra_isize = f2fs_has_extra_attr(inode) ?
...@@ -479,6 +477,10 @@ static int do_read_inode(struct inode *inode) ...@@ -479,6 +477,10 @@ static int do_read_inode(struct inode *inode)
} }
init_idisk_time(inode); init_idisk_time(inode);
/* Need all the flag bits */
f2fs_init_read_extent_tree(inode, node_page);
f2fs_put_page(node_page, 1); f2fs_put_page(node_page, 1);
stat_inc_inline_xattr(inode); stat_inc_inline_xattr(inode);
......
...@@ -284,8 +284,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns, ...@@ -284,8 +284,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
} }
F2FS_I(inode)->i_inline_xattr_size = xattr_size; F2FS_I(inode)->i_inline_xattr_size = xattr_size;
f2fs_init_extent_tree(inode, NULL);
F2FS_I(inode)->i_flags = F2FS_I(inode)->i_flags =
f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED); f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED);
...@@ -311,6 +309,8 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns, ...@@ -311,6 +309,8 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
f2fs_set_inode_flags(inode); f2fs_set_inode_flags(inode);
f2fs_init_extent_tree(inode);
trace_f2fs_new_inode(inode, 0); trace_f2fs_new_inode(inode, 0);
return inode; return inode;
......
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