Skip to content

Commit 3bac20a

Browse files
author
Jaegeuk Kim
committed
f2fs: move internal functions into extent_cache.c
No functional change. Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 12607c1 commit 3bac20a

File tree

2 files changed

+81
-76
lines changed

2 files changed

+81
-76
lines changed

fs/f2fs/extent_cache.c

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,77 @@
1515
#include "node.h"
1616
#include <trace/events/f2fs.h>
1717

18+
static void __set_extent_info(struct extent_info *ei,
19+
unsigned int fofs, unsigned int len,
20+
block_t blk, bool keep_clen)
21+
{
22+
ei->fofs = fofs;
23+
ei->blk = blk;
24+
ei->len = len;
25+
26+
if (keep_clen)
27+
return;
28+
29+
#ifdef CONFIG_F2FS_FS_COMPRESSION
30+
ei->c_len = 0;
31+
#endif
32+
}
33+
34+
static bool f2fs_may_extent_tree(struct inode *inode)
35+
{
36+
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
37+
38+
/*
39+
* for recovered files during mount do not create extents
40+
* if shrinker is not registered.
41+
*/
42+
if (list_empty(&sbi->s_list))
43+
return false;
44+
45+
if (!test_opt(sbi, READ_EXTENT_CACHE) ||
46+
is_inode_flag_set(inode, FI_NO_EXTENT) ||
47+
(is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
48+
!f2fs_sb_has_readonly(sbi)))
49+
return false;
50+
51+
return S_ISREG(inode->i_mode);
52+
}
53+
54+
static void __try_update_largest_extent(struct extent_tree *et,
55+
struct extent_node *en)
56+
{
57+
if (en->ei.len <= et->largest.len)
58+
return;
59+
60+
et->largest = en->ei;
61+
et->largest_updated = true;
62+
}
63+
64+
static bool __is_extent_mergeable(struct extent_info *back,
65+
struct extent_info *front)
66+
{
67+
#ifdef CONFIG_F2FS_FS_COMPRESSION
68+
if (back->c_len && back->len != back->c_len)
69+
return false;
70+
if (front->c_len && front->len != front->c_len)
71+
return false;
72+
#endif
73+
return (back->fofs + back->len == front->fofs &&
74+
back->blk + back->len == front->blk);
75+
}
76+
77+
static bool __is_back_mergeable(struct extent_info *cur,
78+
struct extent_info *back)
79+
{
80+
return __is_extent_mergeable(back, cur);
81+
}
82+
83+
static bool __is_front_mergeable(struct extent_info *cur,
84+
struct extent_info *front)
85+
{
86+
return __is_extent_mergeable(cur, front);
87+
}
88+
1889
static struct rb_entry *__lookup_rb_tree_fast(struct rb_entry *cached_re,
1990
unsigned int ofs)
2091
{
@@ -591,16 +662,16 @@ static void f2fs_update_extent_tree_range(struct inode *inode,
591662

592663
if (end < org_end && org_end - end >= F2FS_MIN_EXTENT_LEN) {
593664
if (parts) {
594-
set_extent_info(&ei, end,
595-
end - dei.fofs + dei.blk,
596-
org_end - end);
665+
__set_extent_info(&ei,
666+
end, org_end - end,
667+
end - dei.fofs + dei.blk, false);
597668
en1 = __insert_extent_tree(sbi, et, &ei,
598669
NULL, NULL, true);
599670
next_en = en1;
600671
} else {
601-
en->ei.fofs = end;
602-
en->ei.blk += end - dei.fofs;
603-
en->ei.len -= end - dei.fofs;
672+
__set_extent_info(&en->ei,
673+
end, en->ei.len - (end - dei.fofs),
674+
en->ei.blk + (end - dei.fofs), true);
604675
next_en = en;
605676
}
606677
parts++;
@@ -632,8 +703,7 @@ static void f2fs_update_extent_tree_range(struct inode *inode,
632703

633704
/* 3. update extent in extent cache */
634705
if (blkaddr) {
635-
636-
set_extent_info(&ei, fofs, blkaddr, len);
706+
__set_extent_info(&ei, fofs, len, blkaddr, false);
637707
if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en))
638708
__insert_extent_tree(sbi, et, &ei,
639709
insert_p, insert_parent, leftmost);
@@ -692,7 +762,7 @@ void f2fs_update_extent_tree_range_compressed(struct inode *inode,
692762
if (en)
693763
goto unlock_out;
694764

695-
set_extent_info(&ei, fofs, blkaddr, llen);
765+
__set_extent_info(&ei, fofs, llen, blkaddr, true);
696766
ei.c_len = c_len;
697767

698768
if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en))

fs/f2fs/f2fs.h

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ struct rb_entry {
621621
struct extent_info {
622622
unsigned int fofs; /* start offset in a file */
623623
unsigned int len; /* length of the extent */
624-
u32 blk; /* start block address of the extent */
624+
block_t blk; /* start block address of the extent */
625625
#ifdef CONFIG_F2FS_FS_COMPRESSION
626626
unsigned int c_len; /* physical extent length of compressed blocks */
627627
#endif
@@ -846,17 +846,6 @@ static inline void set_raw_read_extent(struct extent_info *ext,
846846
i_ext->len = cpu_to_le32(ext->len);
847847
}
848848

849-
static inline void set_extent_info(struct extent_info *ei, unsigned int fofs,
850-
u32 blk, unsigned int len)
851-
{
852-
ei->fofs = fofs;
853-
ei->blk = blk;
854-
ei->len = len;
855-
#ifdef CONFIG_F2FS_FS_COMPRESSION
856-
ei->c_len = 0;
857-
#endif
858-
}
859-
860849
static inline bool __is_discard_mergeable(struct discard_info *back,
861850
struct discard_info *front, unsigned int max_len)
862851
{
@@ -876,41 +865,6 @@ static inline bool __is_discard_front_mergeable(struct discard_info *cur,
876865
return __is_discard_mergeable(cur, front, max_len);
877866
}
878867

879-
static inline bool __is_extent_mergeable(struct extent_info *back,
880-
struct extent_info *front)
881-
{
882-
#ifdef CONFIG_F2FS_FS_COMPRESSION
883-
if (back->c_len && back->len != back->c_len)
884-
return false;
885-
if (front->c_len && front->len != front->c_len)
886-
return false;
887-
#endif
888-
return (back->fofs + back->len == front->fofs &&
889-
back->blk + back->len == front->blk);
890-
}
891-
892-
static inline bool __is_back_mergeable(struct extent_info *cur,
893-
struct extent_info *back)
894-
{
895-
return __is_extent_mergeable(back, cur);
896-
}
897-
898-
static inline bool __is_front_mergeable(struct extent_info *cur,
899-
struct extent_info *front)
900-
{
901-
return __is_extent_mergeable(cur, front);
902-
}
903-
904-
extern void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync);
905-
static inline void __try_update_largest_extent(struct extent_tree *et,
906-
struct extent_node *en)
907-
{
908-
if (en->ei.len > et->largest.len) {
909-
et->largest = en->ei;
910-
et->largest_updated = true;
911-
}
912-
}
913-
914868
/*
915869
* For free nid management
916870
*/
@@ -2581,6 +2535,7 @@ static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)
25812535
return le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum);
25822536
}
25832537

2538+
extern void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync);
25842539
static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,
25852540
struct inode *inode, bool is_inode)
25862541
{
@@ -4403,26 +4358,6 @@ F2FS_FEATURE_FUNCS(casefold, CASEFOLD);
44034358
F2FS_FEATURE_FUNCS(compression, COMPRESSION);
44044359
F2FS_FEATURE_FUNCS(readonly, RO);
44054360

4406-
static inline bool f2fs_may_extent_tree(struct inode *inode)
4407-
{
4408-
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
4409-
4410-
if (!test_opt(sbi, READ_EXTENT_CACHE) ||
4411-
is_inode_flag_set(inode, FI_NO_EXTENT) ||
4412-
(is_inode_flag_set(inode, FI_COMPRESSED_FILE) &&
4413-
!f2fs_sb_has_readonly(sbi)))
4414-
return false;
4415-
4416-
/*
4417-
* for recovered files during mount do not create extents
4418-
* if shrinker is not registered.
4419-
*/
4420-
if (list_empty(&sbi->s_list))
4421-
return false;
4422-
4423-
return S_ISREG(inode->i_mode);
4424-
}
4425-
44264361
#ifdef CONFIG_BLK_DEV_ZONED
44274362
static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
44284363
block_t blkaddr)

0 commit comments

Comments
 (0)