Skip to content

Commit 72840cc

Browse files
author
Jaegeuk Kim
committed
f2fs: allocate the extent_cache by default
Let's allocate it to remove the runtime complexity. Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent e7547da commit 72840cc

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

fs/f2fs/extent_cache.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,23 @@ static bool __may_read_extent_tree(struct inode *inode)
4747
return S_ISREG(inode->i_mode);
4848
}
4949

50-
static bool __may_extent_tree(struct inode *inode, enum extent_type type)
50+
static bool __init_may_extent_tree(struct inode *inode, enum extent_type type)
5151
{
52-
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
52+
if (type == EX_READ)
53+
return __may_read_extent_tree(inode);
54+
return false;
55+
}
5356

57+
static bool __may_extent_tree(struct inode *inode, enum extent_type type)
58+
{
5459
/*
5560
* for recovered files during mount do not create extents
5661
* if shrinker is not registered.
5762
*/
58-
if (list_empty(&sbi->s_list))
63+
if (list_empty(&F2FS_I_SB(inode)->s_list))
5964
return false;
6065

61-
if (type == EX_READ)
62-
return __may_read_extent_tree(inode);
63-
return false;
66+
return __init_may_extent_tree(inode, type);
6467
}
6568

6669
static void __try_update_largest_extent(struct extent_tree *et,
@@ -439,34 +442,30 @@ static void __drop_largest_extent(struct extent_tree *et,
439442
}
440443
}
441444

442-
/* return true, if inode page is changed */
443-
static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage,
444-
enum extent_type type)
445+
void f2fs_init_read_extent_tree(struct inode *inode, struct page *ipage)
445446
{
446447
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
447-
struct extent_tree_info *eti = &sbi->extent_tree[type];
448-
struct f2fs_extent *i_ext = ipage ? &F2FS_INODE(ipage)->i_ext : NULL;
448+
struct extent_tree_info *eti = &sbi->extent_tree[EX_READ];
449+
struct f2fs_extent *i_ext = &F2FS_INODE(ipage)->i_ext;
449450
struct extent_tree *et;
450451
struct extent_node *en;
451452
struct extent_info ei;
452453

453-
if (!__may_extent_tree(inode, type)) {
454+
if (!__may_extent_tree(inode, EX_READ)) {
454455
/* drop largest read extent */
455-
if (type == EX_READ && i_ext && i_ext->len) {
456+
if (i_ext && i_ext->len) {
456457
f2fs_wait_on_page_writeback(ipage, NODE, true, true);
457458
i_ext->len = 0;
458459
set_page_dirty(ipage);
459460
}
460461
goto out;
461462
}
462463

463-
et = __grab_extent_tree(inode, type);
464+
et = __grab_extent_tree(inode, EX_READ);
464465

465466
if (!i_ext || !i_ext->len)
466467
goto out;
467468

468-
BUG_ON(type != EX_READ);
469-
470469
get_read_extent_info(&ei, i_ext);
471470

472471
write_lock(&et->lock);
@@ -486,14 +485,15 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage,
486485
unlock_out:
487486
write_unlock(&et->lock);
488487
out:
489-
if (type == EX_READ && !F2FS_I(inode)->extent_tree[EX_READ])
488+
if (!F2FS_I(inode)->extent_tree[EX_READ])
490489
set_inode_flag(inode, FI_NO_EXTENT);
491490
}
492491

493-
void f2fs_init_extent_tree(struct inode *inode, struct page *ipage)
492+
void f2fs_init_extent_tree(struct inode *inode)
494493
{
495494
/* initialize read cache */
496-
__f2fs_init_extent_tree(inode, ipage, EX_READ);
495+
if (__init_may_extent_tree(inode, EX_READ))
496+
__grab_extent_tree(inode, EX_READ);
497497
}
498498

499499
static bool __lookup_extent_tree(struct inode *inode, pgoff_t pgofs,

fs/f2fs/f2fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4150,7 +4150,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root,
41504150
bool force, bool *leftmost);
41514151
bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
41524152
struct rb_root_cached *root, bool check_key);
4153-
void f2fs_init_extent_tree(struct inode *inode, struct page *ipage);
4153+
void f2fs_init_extent_tree(struct inode *inode);
41544154
void f2fs_drop_extent_tree(struct inode *inode);
41554155
void f2fs_destroy_extent_node(struct inode *inode);
41564156
void f2fs_destroy_extent_tree(struct inode *inode);
@@ -4159,6 +4159,7 @@ int __init f2fs_create_extent_cache(void);
41594159
void f2fs_destroy_extent_cache(void);
41604160

41614161
/* read extent cache ops */
4162+
void f2fs_init_read_extent_tree(struct inode *inode, struct page *ipage);
41624163
bool f2fs_lookup_read_extent_cache(struct inode *inode, pgoff_t pgofs,
41634164
struct extent_info *ei);
41644165
void f2fs_update_read_extent_cache(struct dnode_of_data *dn);

fs/f2fs/inode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ static int do_read_inode(struct inode *inode)
392392
fi->i_pino = le32_to_cpu(ri->i_pino);
393393
fi->i_dir_level = ri->i_dir_level;
394394

395-
f2fs_init_extent_tree(inode, node_page);
396-
397395
get_inline_info(inode, ri);
398396

399397
fi->i_extra_isize = f2fs_has_extra_attr(inode) ?
@@ -479,6 +477,10 @@ static int do_read_inode(struct inode *inode)
479477
}
480478

481479
init_idisk_time(inode);
480+
481+
/* Need all the flag bits */
482+
f2fs_init_read_extent_tree(inode, node_page);
483+
482484
f2fs_put_page(node_page, 1);
483485

484486
stat_inc_inline_xattr(inode);

fs/f2fs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
284284
}
285285
F2FS_I(inode)->i_inline_xattr_size = xattr_size;
286286

287-
f2fs_init_extent_tree(inode, NULL);
288-
289287
F2FS_I(inode)->i_flags =
290288
f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED);
291289

@@ -311,6 +309,8 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
311309

312310
f2fs_set_inode_flags(inode);
313311

312+
f2fs_init_extent_tree(inode);
313+
314314
trace_f2fs_new_inode(inode, 0);
315315
return inode;
316316

0 commit comments

Comments
 (0)