remove shared memory structures
Subsystems (2)
Jaegeuk Kim
maintainercover remove shared memory structures
This series removes the use of rb_entry based on memory alignment which doesn't look like a right design when considering various architectures/compilers.
v2 from v1:
- adjusted Eric's review
- refactored gc.c further to clean up
Jaegeuk Kim (3):
f2fs: factor out victim_entry usage from general rb_tree use
f2fs: factor out discard_cmd usage from general rb_tree use
f2fs: remove entire rb_entry sharing
fs/f2fs/extent_cache.c | 241 ++++++++++++--------------------------- fs/f2fs/f2fs.h | 38 +------ fs/f2fs/gc.c | 139 ++++++++++++++--------- fs/f2fs/gc.h | 14 +-- fs/f2fs/segment.c | 252 +++++++++++++++++++++++++++-------------- 5 files changed, 324 insertions(+), 360 deletions(-)
Signature · 8 lines
2.40.0.rc1.284.g88254d51c5-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerPATCH 2/3 f2fs: factor out discard_cmd usage from general rb_tree use
This is a second part to remove the mixed use of rb_tree in discard_cmd from extent_cache.
This should also fix arm32 memory alignment issue caused by shared rb_entry.
[struct discard_cmd] [struct rb_entry]
[0] struct rb_node rb_node; [0] struct rb_node rb_node;
union { union {
struct { struct {
[16] block_t lstart; [12] unsigned int ofs;
block_t len; unsigned int len;
};
unsigned long long key;
} __packed;--- fs/f2fs/extent_cache.c | 36 +----- fs/f2fs/f2fs.h | 23 +--- fs/f2fs/segment.c | 252 +++++++++++++++++++++++++++-------------- 3 files changed, 169 insertions(+), 142 deletions(-)
fs/f2fs/extent_cache.c +3 -33
@@ -192,7 +192,7 @@ static struct rb_entry *__lookup_rb_tree_slow(struct rb_root_cached *root,return NULL ; } -struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root, +static struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root,struct rb_entry *cached_re,unsigned int ofs) {struct rb_entry *re;
@@ -204,7 +204,7 @@ struct rb_entry *f2fs_lookup_rb_tree(struct rb_root_cached *root,return re; } -struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi, +static struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi,struct rb_root_cached *root,struct rb_node **parent,unsigned int ofs,bool *leftmost)
@@ -238,7 +238,7 @@ struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,* in order to simplify the insertion after. * tree must stay unchanged between lookup and insertion. */ -struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, +static struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, struct rb_entry *cached_re, unsigned int ofs, struct rb_entry **prev_entry,
@@ -311,36 +311,6 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root,return re; } -bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root) -{ -#ifdef CONFIG_F2FS_CHECK_FS -struct rb_node *cur =rb_first_cached (root), *next; -struct rb_entry *cur_re, *next_re; - -if (!cur) -return true; - -while (cur) { - next =rb_next (cur); -if (!next) -return true; - - cur_re = rb_entry(cur, struct rb_entry, rb_node); - next_re = rb_entry(next, struct rb_entry, rb_node); - -if (cur_re->ofs + cur_re->len > next_re->ofs) { -f2fs_info (sbi,"inconsistent rbtree, cur(%u, %u) next(%u, %u)" , - cur_re->ofs, cur_re->len, - next_re->ofs, next_re->len); -return false; - } - cur = next; - } -#endif -return true; -} -static struct kmem_cache *extent_tree_slab;static struct kmem_cache *extent_node_slab;
fs/f2fs/f2fs.h +1 -22
@@ -353,15 +353,7 @@ struct discard_info {struct discard_cmd {struct rb_node rb_node;/* rb node located in rb-tree */ -union { -struct { -block_t lstart;/* logical start address */ -block_t len;/* length */ -block_t start;/* actual start address in dev */ - }; -struct discard_info di;/* discard info */ - - }; +struct discard_info di;/* discard info */ struct list_head list;/* command list */ struct completion wait;/* compleation */ struct block_device *bdev;/* bdev */
@@ -4132,19 +4124,6 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);* extent_cache.c */ bool sanity_check_extent_cache (struct inode *inode); -struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root, -struct rb_entry *cached_re,unsigned int ofs); -struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi, -struct rb_root_cached *root, -struct rb_node **parent, -unsigned int ofs,bool *leftmost); -struct rb_entry *f2fs_lookup_rb_tree_ret (struct rb_root_cached *root, -struct rb_entry *cached_re,unsigned int ofs, -struct rb_entry **prev_entry,struct rb_entry **next_entry, -struct rb_node ***insert_p,struct rb_node **insert_parent, -bool force,bool *leftmost); -bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root);void f2fs_init_extent_tree (struct inode *inode);void f2fs_drop_extent_tree (struct inode *inode);void f2fs_destroy_extent_node (struct inode *inode);
fs/f2fs/segment.c +165 -87
447 lines not on this page · raw message
Signature · 8 lines
2.40.0.rc1.284.g88254d51c5-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerPATCH 3/3 f2fs: remove entire rb_entry sharing
In reply to Jaegeuk KimThis is a last part to remove the memory sharing for rb_tree in extent_cache.
This should also fix arm32 memory alignment issue.
[struct extent_node] [struct rb_entry]
[0] struct rb_node rb_node; [0] struct rb_node rb_node;
union { union {
struct { struct {
[16] unsigned int fofs; [12] unsigned int ofs;
unsigned int len; unsigned int len;
};
unsigned long long key;
} __packed;--- fs/f2fs/extent_cache.c | 177 +++++++++++++++++------------------------ fs/f2fs/f2fs.h | 6 -- 2 files changed, 71 insertions(+), 112 deletions(-)
fs/f2fs/extent_cache.c +71 -106
@@ -161,95 +161,52 @@ static bool __is_front_mergeable(struct extent_info *cur,return __is_extent_mergeable (cur, front, type); } -static struct rb_entry *__lookup_rb_tree_fast (struct rb_entry *cached_re, -unsigned int ofs) -{ -if (cached_re) { -if (cached_re->ofs <= ofs && - cached_re->ofs + cached_re->len > ofs) { -return cached_re; - } - } -return NULL ; -} - -static struct rb_entry *__lookup_rb_tree_slow (struct rb_root_cached *root, -unsigned int ofs) +static struct extent_node *__lookup_extent_node (struct rb_root_cached *root, +struct extent_node *cached_en,unsigned int fofs) {struct rb_node *node = root->rb_root.rb_node; -struct rb_entry *re; +struct extent_node *en; + +/* check a cached entry */ +if (cached_en && cached_en->ei.fofs <= fofs && + cached_en->ei.fofs + cached_en->ei.len > fofs) +return cached_en; +/* check rb_tree */ while (node) { - re = rb_entry(node, struct rb_entry, rb_node); + en = rb_entry(node, struct extent_node, rb_node); -if (ofs < re->ofs) +if (fofs < en->ei.fofs) node = node->rb_left; -else if (ofs >= re->ofs + re->len) +else if (fofs >= en->ei.fofs + en->ei.len) node = node->rb_right;else -return re; +return en; }return NULL ; } -static struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root, -struct rb_entry *cached_re,unsigned int ofs) -{ -struct rb_entry *re; - - re =__lookup_rb_tree_fast (cached_re, ofs); -if (!re) -return __lookup_rb_tree_slow (root, ofs); - -return re; -} - -static struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi, -struct rb_root_cached *root, -struct rb_node **parent, -unsigned int ofs,bool *leftmost) -{ -struct rb_node **p = &root->rb_root.rb_node; -struct rb_entry *re; - -while (*p) { - *parent = *p; - re = rb_entry(*parent, struct rb_entry, rb_node); - -if (ofs < re->ofs) { - p = &(*p)->rb_left; - }else if (ofs >= re->ofs + re->len) { - p = &(*p)->rb_right; - *leftmost = false; - }else { -f2fs_bug_on (sbi,1 ); - } - } - -return p; -} -/* -* lookup rb entry in position of @ofs in rb-tree, +* lookup rb entry in position of @fofs in rb-tree, * if hit, return the entry, otherwise, return NULL -* @prev_ex: extent before ofs -* @next_ex: extent after ofs -* @insert_p: insert point for new extent at ofs +* @prev_ex: extent before fofs +* @next_ex: extent after fofs +* @insert_p: insert point for new extent at fofs * in order to simplify the insertion after. * tree must stay unchanged between lookup and insertion. */ -static struct rb_entry *f2fs_lookup_rb_tree_ret (struct rb_root_cached *root, -struct rb_entry *cached_re, -unsigned int ofs, -struct rb_entry **prev_entry, -struct rb_entry **next_entry, +static struct extent_node *__lookup_extent_node_ret (struct rb_root_cached *root, +struct extent_node *cached_en, +unsigned int fofs, +struct extent_node **prev_entry, +struct extent_node **next_entry,struct rb_node ***insert_p,struct rb_node **insert_parent, -bool force,bool *leftmost) +bool *leftmost) {struct rb_node **pnode = &root->rb_root.rb_node;struct rb_node *parent =NULL , *tmp_node; -struct rb_entry *re = cached_re; +struct extent_node *en = cached_en; *insert_p =NULL ; *insert_parent =NULL ;
@@ -259,24 +216,20 @@ static struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root,if (RB_EMPTY_ROOT (&root->rb_root))return NULL ; -if (re) { -if (re->ofs <= ofs && re->ofs + re->len > ofs) - goto lookup_neighbors; - } +if (en && en->ei.fofs <= fofs && en->ei.fofs + en->ei.len > fofs) + goto lookup_neighbors; -if (leftmost) - *leftmost = true; + *leftmost = true;while (*pnode) { parent = *pnode; - re = rb_entry(*pnode, struct rb_entry, rb_node); + en = rb_entry(*pnode, struct extent_node, rb_node); -if (ofs < re->ofs) { +if (fofs < en->ei.fofs) { pnode = &(*pnode)->rb_left; - }else if (ofs >= re->ofs + re->len) { + }else if (fofs >= en->ei.fofs + en->ei.len) { pnode = &(*pnode)->rb_right; -if (leftmost) - *leftmost = false; + *leftmost = false; }else { goto lookup_neighbors; }
@@ -285,30 +238,32 @@ static struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, *insert_p = pnode; *insert_parent = parent; - re = rb_entry(parent, struct rb_entry, rb_node); + en = rb_entry(parent, struct extent_node, rb_node); tmp_node = parent; -if (parent && ofs > re->ofs) +if (parent && fofs > en->ei.fofs) tmp_node =rb_next (parent); - *next_entry = rb_entry_safe(tmp_node, struct rb_entry, rb_node); + *next_entry = rb_entry_safe(tmp_node, struct extent_node, rb_node); tmp_node = parent; -if (parent && ofs < re->ofs) +if (parent && fofs < en->ei.fofs) tmp_node =rb_prev (parent); - *prev_entry = rb_entry_safe(tmp_node, struct rb_entry, rb_node); + *prev_entry = rb_entry_safe(tmp_node, struct extent_node, rb_node);return NULL ; lookup_neighbors: -if (ofs == re->ofs || force) { +if (fofs == en->ei.fofs) {/* lookup prev node for merging backward later */ - tmp_node =rb_prev (&re->rb_node); - *prev_entry = rb_entry_safe(tmp_node, struct rb_entry, rb_node); + tmp_node =rb_prev (&en->rb_node); + *prev_entry =rb_entry_safe (tmp_node, + struct extent_node, rb_node); } -if (ofs == re->ofs + re->len -1 || force) { +if (fofs == en->ei.fofs + en->ei.len -1 ) {/* lookup next node for merging frontward later */ - tmp_node =rb_next (&re->rb_node); - *next_entry = rb_entry_safe(tmp_node, struct rb_entry, rb_node); + tmp_node =rb_next (&en->rb_node); + *next_entry =rb_entry_safe (tmp_node, + struct extent_node, rb_node); } -return re; +return en; }static struct kmem_cache *extent_tree_slab;
@@ -523,8 +478,7 @@ static bool __lookup_extent_tree(struct inode *inode, pgoff_t pgofs, goto out; } - en = (struct extent_node *)f2fs_lookup_rb_tree (&et->root, - (struct rb_entry *)et->cached_en, pgofs); + en =__lookup_extent_node (&et->root, et->cached_en, pgofs);if (!en) goto out;
@@ -598,7 +552,7 @@ static struct extent_node *__insert_extent_tree(struct f2fs_sb_info *sbi, bool leftmost) {struct extent_tree_info *eti = &sbi->extent_tree[et->type]; -struct rb_node **p; +struct rb_node **p = &et->root.rb_root.rb_node;struct rb_node *parent =NULL ;struct extent_node *en =NULL ;
@@ -610,8 +564,21 @@ static struct extent_node *__insert_extent_tree(struct f2fs_sb_info *sbi, leftmost = true; - p =f2fs_lookup_rb_tree_for_insert (sbi, &et->root, &parent, - ei->fofs, &leftmost); +/* look up extent_node in the rb tree */ +while (*p) { + parent = *p; + en = rb_entry(parent, struct extent_node, rb_node); + +if (ei->fofs < en->ei.fofs) { + p = &(*p)->rb_left; + }else if (ei->fofs >= en->ei.fofs + en->ei.len) { + p = &(*p)->rb_right; + leftmost = false; + }else { +f2fs_bug_on (sbi,1 ); + } + } + do_insert: en =__attach_extent_node (sbi, et, ei, parent, p, leftmost);if (!en)
@@ -670,11 +637,10 @@ static void __update_extent_tree_range(struct inode *inode, }/* 1. lookup first extent node in range [fofs, fofs + len - 1] */ - en = (struct extent_node *)f2fs_lookup_rb_tree_ret (&et->root, - (struct rb_entry *)et->cached_en, fofs, - (struct rb_entry **)&prev_en, - (struct rb_entry **)&next_en, - &insert_p, &insert_parent, false, + en =__lookup_extent_node_ret (&et->root, + et->cached_en, fofs, + &prev_en, &next_en, + &insert_p, &insert_parent, &leftmost);if (!en) en = next_en;
@@ -812,12 +778,11 @@ void f2fs_update_read_extent_tree_range_compressed(struct inode *inode,write_lock (&et->lock); - en = (struct extent_node *)f2fs_lookup_rb_tree_ret (&et->root, - (struct rb_entry *)et->cached_en, fofs, - (struct rb_entry **)&prev_en, - (struct rb_entry **)&next_en, - &insert_p, &insert_parent, false, - &leftmost); + en =__lookup_extent_node_ret (&et->root, + et->cached_en, fofs, + &prev_en, &next_en, + &insert_p, &insert_parent, + &leftmost);if (en) goto unlock_out;
fs/f2fs/f2fs.h +0 -6
@@ -620,12 +620,6 @@ enum extent_type { NR_EXTENT_CACHES, }; -struct rb_entry { -struct rb_node rb_node;/* rb node located in rb-tree */ -unsigned int ofs;/* start offset of the entry */ -unsigned int len;/* length of the entry */ -}; -struct extent_info {unsigned int fofs;/* start offset in a file */ unsigned int len;/* length of the extent */
Signature · 8 lines
2.40.0.rc1.284.g88254d51c5-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerPATCH 1/3 f2fs: factor out victim_entry usage from general rb_tree use
In reply to Jaegeuk KimLet's reduce the complexity of mixed use of rb_tree in victim_entry from extent_cache and discard_cmd.
This should fix arm32 memory alignment issue caused by shared rb_entry.
[struct victim_entry] [struct rb_entry]
[0] struct rb_node rb_node; [0] struct rb_node rb_node;
union {
struct {
unsigned int ofs;
unsigned int len;
};
[16] unsigned long long mtime; [12] unsigned long long key;
} __packed;--- fs/f2fs/extent_cache.c | 36 +---------- fs/f2fs/f2fs.h | 15 +---- fs/f2fs/gc.c | 139 +++++++++++++++++++++++++---------------- fs/f2fs/gc.h | 14 +---- fs/f2fs/segment.c | 4 +- 5 files changed, 93 insertions(+), 115 deletions(-)
fs/f2fs/extent_cache.c +1 -35
@@ -204,29 +204,6 @@ struct rb_entry *f2fs_lookup_rb_tree(struct rb_root_cached *root,return re; } -struct rb_node **f2fs_lookup_rb_tree_ext (struct f2fs_sb_info *sbi, -struct rb_root_cached *root, -struct rb_node **parent, -unsigned long long key,bool *leftmost) -{ -struct rb_node **p = &root->rb_root.rb_node; -struct rb_entry *re; - -while (*p) { - *parent = *p; - re = rb_entry(*parent, struct rb_entry, rb_node); - -if (key < re->key) { - p = &(*p)->rb_left; - }else { - p = &(*p)->rb_right; - *leftmost = false; - } - } - -return p; -} - struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi, struct rb_root_cached *root, struct rb_node **parent,
@@ -335,7 +312,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, }bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root,bool check_key) +struct rb_root_cached *root) {#ifdef CONFIG_F2FS_CHECK_FS struct rb_node *cur =rb_first_cached (root), *next;
@@ -352,23 +329,12 @@ bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi, cur_re = rb_entry(cur, struct rb_entry, rb_node); next_re = rb_entry(next, struct rb_entry, rb_node); -if (check_key) { -if (cur_re->key > next_re->key) { -f2fs_info (sbi,"inconsistent rbtree, " -"cur(%llu) next(%llu)" , - cur_re->key, next_re->key); -return false; - } - goto next; - } -if (cur_re->ofs + cur_re->len > next_re->ofs) {f2fs_info (sbi,"inconsistent rbtree, cur(%u, %u) next(%u, %u)" , cur_re->ofs, cur_re->len, next_re->ofs, next_re->len);return false; } -next: cur = next; }#endif
fs/f2fs/f2fs.h +3 -12
@@ -630,13 +630,8 @@ enum extent_type {struct rb_entry {struct rb_node rb_node;/* rb node located in rb-tree */ -union { -struct { -unsigned int ofs;/* start offset of the entry */ -unsigned int len;/* length of the entry */ - }; -unsigned long long key;/* 64-bits key */ - } __packed; +unsigned int ofs;/* start offset of the entry */ +unsigned int len;/* length of the entry */ };struct extent_info {
@@ -4139,10 +4134,6 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);bool sanity_check_extent_cache (struct inode *inode);struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root,struct rb_entry *cached_re,unsigned int ofs); -struct rb_node **f2fs_lookup_rb_tree_ext (struct f2fs_sb_info *sbi, -struct rb_root_cached *root, -struct rb_node **parent, -unsigned long long key,bool *left_most); struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi, struct rb_root_cached *root, struct rb_node **parent,
@@ -4153,7 +4144,7 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, struct rb_node ***insert_p, struct rb_node **insert_parent, bool force, bool *leftmost);bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root,bool check_key); +struct rb_root_cached *root);void f2fs_init_extent_tree (struct inode *inode);void f2fs_drop_extent_tree (struct inode *inode);void f2fs_destroy_extent_node (struct inode *inode);
fs/f2fs/gc.c +85 -54
220 lines not on this page · raw message
fs/f2fs/gc.h +2 -12
@@ -55,20 +55,10 @@ struct gc_inode_list {struct radix_tree_root iroot; }; -struct victim_info { -unsigned long long mtime;/* mtime of section */ -unsigned int segno;/* section No. */ -}; -struct victim_entry {struct rb_node rb_node;/* rb node located in rb-tree */ -union { -struct { -unsigned long long mtime;/* mtime of section */ -unsigned int segno;/* segment No. */ - }; -struct victim_info vi;/* victim info */ - }; +unsigned long long mtime;/* mtime of section */ +unsigned int segno;/* segment No. */ struct list_head list; };
fs/f2fs/segment.c +2 -2
@@ -1478,7 +1478,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, goto next;if (unlikely (dcc->rbtree_check))f2fs_bug_on (sbi, !f2fs_check_rb_tree_consistence (sbi, - &dcc->root, false)); + &dcc->root));blk_start_plug (&plug);list_for_each_entry_safe (dc, tmp, pend_list, list) {f2fs_bug_on (sbi, dc->state !=D_PREP );
@@ -2965,7 +2965,7 @@ static unsigned int __issue_discard_cmd_range(struct f2fs_sb_info *sbi,mutex_lock (&dcc->cmd_lock);if (unlikely (dcc->rbtree_check))f2fs_bug_on (sbi, !f2fs_check_rb_tree_consistence (sbi, - &dcc->root, false)); + &dcc->root)); dc = (struct discard_cmd *)f2fs_lookup_rb_tree_ret(&dcc->root, NULL, start,
Signature · 8 lines
2.40.0.rc1.284.g88254d51c5-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 8 lines · On Mon, 13 Mar 2023 13:12:13 -0700 you wrote:
This series removes the use of
rb_entrybased on memory alignment which doesn't look like a right design when considering various architectures/compilers.v2 from v1:
- adjusted Eric's review
- refactoredgc.cfurther to clean up[...]
Here is the summary with links:
- [f2fs-dev,1/3] f2fs: factor out victim_entry usage from general rb_tree use
https://git.kernel.org/jaegeuk/f2fs/c/e433c7887585 - [f2fs-dev,2/3] f2fs: factor out discard_cmd usage from general rb_tree use https://git.kernel.org/jaegeuk/f2fs/c/7e9775a516ff - [f2fs-dev,3/3] f2fs: remove entire rb_entry sharing https://git.kernel.org/jaegeuk/f2fs/c/6b40bc364c10
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [f2fs-dev] [PATCH 1/3] f2fs: factor out victim_entry usage from general rb_tree use
In reply to Jaegeuk KimQuoted 15 lines · Jaegeuk Kim
Let's reduce the complexity of mixed use of
rb_treeinvictim_entryfromextent_cacheanddiscard_cmd.This should fix arm32 memory alignment issue caused by shared
rb_entry.[struct
victim_entry] [structrb_entry][0] struct rb_node rb_node; [0] struct rb_node rb_node; union { struct { unsigned int ofs; unsigned int len; }; [16] unsigned long long mtime; [12] unsigned long long key; } __packed;
Quoted 3 lines
Cc <[email protected]>Fixes 093749e296e2 ("f2fs: support age threshold based garbage collection")Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
Re: [f2fs-dev] [PATCH 2/3] f2fs: factor out discard_cmd usage from general rb_tree use
In reply to Jaegeuk KimQuoted 15 lines · Jaegeuk Kim
This is a second part to remove the mixed use of
rb_treeindiscard_cmdfromextent_cache.This should also fix arm32 memory alignment issue caused by shared
rb_entry.[struct
discard_cmd] [structrb_entry][0] struct rb_node rb_node; [0] struct rb_node rb_node; union { union { struct { struct { [16] block_t lstart; [12] unsigned int ofs; block_t len; unsigned int len; }; unsigned long long key; } __packed;
Quoted 3 lines
Cc <[email protected]>Fixes 004b68621897 ("f2fs: use rb-tree to track pending discard commands")Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/3] f2fs: remove entire rb_entry sharing
In reply to Jaegeuk KimQuoted 14 lines · Jaegeuk Kim
This is a last part to remove the memory sharing for
rb_treeinextent_cache.This should also fix arm32 memory alignment issue.
[struct
extent_node] [structrb_entry][0] struct rb_node rb_node; [0] struct rb_node rb_node; union { union { struct { struct { [16] unsigned int fofs; [12] unsigned int ofs; unsigned int len; unsigned int len; }; unsigned long long key; } __packed;
Quoted 3 lines
Cc <[email protected]>Fixes 13054c548a1c ("f2fs: introduce infra macro and data structure of rb-tree extent cache")Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
Jaegeuk Kim
maintainerRe: [PATCH 2/3 v2] f2fs: factor out discard_cmd usage from general rb_tree use
In reply to Jaegeuk KimThis is a second part to remove the mixed use of rb_tree in discard_cmd from extent_cache.
This should also fix arm32 memory alignment issue caused by shared rb_entry.
[struct discard_cmd] [struct rb_entry]
[0] struct rb_node rb_node; [0] struct rb_node rb_node;
union { union {
struct { struct {
[16] block_t lstart; [12] unsigned int ofs;
block_t len; unsigned int len;
};
unsigned long long key;
} __packed;---
Change log from v1:
- fix a bug when spliting/merging discard commands
fs/f2fs/extent_cache.c | 36 +----- fs/f2fs/f2fs.h | 23 +--- fs/f2fs/segment.c | 249 +++++++++++++++++++++++++++-------------- 3 files changed, 169 insertions(+), 139 deletions(-)
fs/f2fs/extent_cache.c +3 -33
@@ -192,7 +192,7 @@ static struct rb_entry *__lookup_rb_tree_slow(struct rb_root_cached *root,return NULL ; } -struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root, +static struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root,struct rb_entry *cached_re,unsigned int ofs) {struct rb_entry *re;
@@ -204,7 +204,7 @@ struct rb_entry *f2fs_lookup_rb_tree(struct rb_root_cached *root,return re; } -struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi, +static struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi,struct rb_root_cached *root,struct rb_node **parent,unsigned int ofs,bool *leftmost)
@@ -238,7 +238,7 @@ struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,* in order to simplify the insertion after. * tree must stay unchanged between lookup and insertion. */ -struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, +static struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root, struct rb_entry *cached_re, unsigned int ofs, struct rb_entry **prev_entry,
@@ -311,36 +311,6 @@ struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root_cached *root,return re; } -bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root) -{ -#ifdef CONFIG_F2FS_CHECK_FS -struct rb_node *cur =rb_first_cached (root), *next; -struct rb_entry *cur_re, *next_re; - -if (!cur) -return true; - -while (cur) { - next =rb_next (cur); -if (!next) -return true; - - cur_re = rb_entry(cur, struct rb_entry, rb_node); - next_re = rb_entry(next, struct rb_entry, rb_node); - -if (cur_re->ofs + cur_re->len > next_re->ofs) { -f2fs_info (sbi,"inconsistent rbtree, cur(%u, %u) next(%u, %u)" , - cur_re->ofs, cur_re->len, - next_re->ofs, next_re->len); -return false; - } - cur = next; - } -#endif -return true; -} -static struct kmem_cache *extent_tree_slab;static struct kmem_cache *extent_node_slab;
fs/f2fs/f2fs.h +1 -22
@@ -353,15 +353,7 @@ struct discard_info {struct discard_cmd {struct rb_node rb_node;/* rb node located in rb-tree */ -union { -struct { -block_t lstart;/* logical start address */ -block_t len;/* length */ -block_t start;/* actual start address in dev */ - }; -struct discard_info di;/* discard info */ - - }; +struct discard_info di;/* discard info */ struct list_head list;/* command list */ struct completion wait;/* compleation */ struct block_device *bdev;/* bdev */
@@ -4132,19 +4124,6 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);* extent_cache.c */ bool sanity_check_extent_cache (struct inode *inode); -struct rb_entry *f2fs_lookup_rb_tree (struct rb_root_cached *root, -struct rb_entry *cached_re,unsigned int ofs); -struct rb_node **f2fs_lookup_rb_tree_for_insert (struct f2fs_sb_info *sbi, -struct rb_root_cached *root, -struct rb_node **parent, -unsigned int ofs,bool *leftmost); -struct rb_entry *f2fs_lookup_rb_tree_ret (struct rb_root_cached *root, -struct rb_entry *cached_re,unsigned int ofs, -struct rb_entry **prev_entry,struct rb_entry **next_entry, -struct rb_node ***insert_p,struct rb_node **insert_parent, -bool force,bool *leftmost); -bool f2fs_check_rb_tree_consistence (struct f2fs_sb_info *sbi, -struct rb_root_cached *root);void f2fs_init_extent_tree (struct inode *inode);void f2fs_drop_extent_tree (struct inode *inode);void f2fs_destroy_extent_node (struct inode *inode);
fs/f2fs/segment.c +165 -84
433 lines not on this page · raw message
Signature · 1 line
2.40.0.348.gf938b09366-goog
Re: [f2fs-dev] [PATCH 2/3 v2] f2fs: factor out discard_cmd usage from general rb_tree use
Quoted 15 lines · Jaegeuk Kim
This is a second part to remove the mixed use of
rb_treeindiscard_cmdfromextent_cache.This should also fix arm32 memory alignment issue caused by shared
rb_entry.[struct
discard_cmd] [structrb_entry][0] struct rb_node rb_node; [0] struct rb_node rb_node; union { union { struct { struct { [16] block_t lstart; [12] unsigned int ofs; block_t len; unsigned int len; }; unsigned long long key; } __packed;
Quoted 3 lines
Cc <[email protected]>Fixes 004b68621897 ("f2fs: use rb-tree to track pending discard commands")Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel