@@ -47,20 +47,23 @@ static bool __may_read_extent_tree(struct inode *inode)
47
47
return S_ISREG (inode -> i_mode );
48
48
}
49
49
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 )
51
51
{
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
+ }
53
56
57
+ static bool __may_extent_tree (struct inode * inode , enum extent_type type )
58
+ {
54
59
/*
55
60
* for recovered files during mount do not create extents
56
61
* if shrinker is not registered.
57
62
*/
58
- if (list_empty (& sbi -> s_list ))
63
+ if (list_empty (& F2FS_I_SB ( inode ) -> s_list ))
59
64
return false;
60
65
61
- if (type == EX_READ )
62
- return __may_read_extent_tree (inode );
63
- return false;
66
+ return __init_may_extent_tree (inode , type );
64
67
}
65
68
66
69
static void __try_update_largest_extent (struct extent_tree * et ,
@@ -439,34 +442,30 @@ static void __drop_largest_extent(struct extent_tree *et,
439
442
}
440
443
}
441
444
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 )
445
446
{
446
447
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 ;
449
450
struct extent_tree * et ;
450
451
struct extent_node * en ;
451
452
struct extent_info ei ;
452
453
453
- if (!__may_extent_tree (inode , type )) {
454
+ if (!__may_extent_tree (inode , EX_READ )) {
454
455
/* drop largest read extent */
455
- if (type == EX_READ && i_ext && i_ext -> len ) {
456
+ if (i_ext && i_ext -> len ) {
456
457
f2fs_wait_on_page_writeback (ipage , NODE , true, true);
457
458
i_ext -> len = 0 ;
458
459
set_page_dirty (ipage );
459
460
}
460
461
goto out ;
461
462
}
462
463
463
- et = __grab_extent_tree (inode , type );
464
+ et = __grab_extent_tree (inode , EX_READ );
464
465
465
466
if (!i_ext || !i_ext -> len )
466
467
goto out ;
467
468
468
- BUG_ON (type != EX_READ );
469
-
470
469
get_read_extent_info (& ei , i_ext );
471
470
472
471
write_lock (& et -> lock );
@@ -486,14 +485,15 @@ static void __f2fs_init_extent_tree(struct inode *inode, struct page *ipage,
486
485
unlock_out :
487
486
write_unlock (& et -> lock );
488
487
out :
489
- if (type == EX_READ && !F2FS_I (inode )-> extent_tree [EX_READ ])
488
+ if (!F2FS_I (inode )-> extent_tree [EX_READ ])
490
489
set_inode_flag (inode , FI_NO_EXTENT );
491
490
}
492
491
493
- void f2fs_init_extent_tree (struct inode * inode , struct page * ipage )
492
+ void f2fs_init_extent_tree (struct inode * inode )
494
493
{
495
494
/* 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 );
497
497
}
498
498
499
499
static bool __lookup_extent_tree (struct inode * inode , pgoff_t pgofs ,
0 commit comments