btrfs-progs: Remove extent_buffer::tree member
PATCH 1/1 btrfs-progs: Remove extent_buffer::tree member
This member can be fetched from eb::fs_info, and no caller really depends on that member to determine if an eb is dummy. We have eb::flags to determine that.
Kernel doesn't have such member either.
---
NOTE: Another candidate to cleanup is eb::cache_node, in kernel we use radix tree, thus no need for any structure in eb.
But in btrfs-progs, we also rely on extent_io_tree to do cache size limitation, and for U-boot there is no radix tree implemented yet.
Thus eb::cache_node may live for a longer time.
--- disk-io.c | 7 ++++--- extent_io.c | 14 +++++--------- extent_io.h | 1 - 3 files changed, 9 insertions(+), 13 deletions(-)
disk-io.c +4 -3
@@ -371,8 +371,8 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, ret =read_whole_eb (fs_info, eb, mirror_num);if (ret ==0 &&csum_tree_block (fs_info, eb,1 ) ==0 &&check_tree_block (fs_info, eb) ==0 && -verify_parent_transid (eb->tree, eb, parent_transid, ignore) - ==0 ) { +verify_parent_transid (&fs_info->extent_cache, eb, + parent_transid, ignore) ==0 ) {if (eb->flags &EXTENT_BAD_TRANSID &&list_empty (&eb->recow)) { list_add_tail(&eb->recow,
@@ -1951,7 +1951,8 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)if (!ret)return ret; - ret =verify_parent_transid (buf->tree, buf, parent_transid,1 ); + ret =verify_parent_transid (&buf->fs_info->extent_cache, buf, + parent_transid,1 );return !ret; }
extent_io.c +5 -9
@@ -619,7 +619,6 @@ static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *info, eb->cache_node.start = bytenr; eb->cache_node.size = blocksize; eb->fs_info = info; - eb->tree = &info->extent_cache;INIT_LIST_HEAD (&eb->recow);INIT_LIST_HEAD (&eb->lru);memset_extent_buffer (eb,0 ,0 , blocksize);
@@ -634,8 +633,6 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src) new =__alloc_extent_buffer (src->fs_info, src->start, src->len);if (!new)return NULL ; -/* cloned eb is not linked into fs_info->extent_cache */ - new->tree =NULL ;copy_extent_buffer (new, src,0 ,0 , src->len); new->flags |=EXTENT_BUFFER_DUMMY ;
@@ -645,13 +642,13 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src)static void free_extent_buffer_final (struct extent_buffer *eb) { -struct extent_io_tree *tree = eb->tree; -BUG_ON (eb->refs); -BUG_ON (tree && tree->cache_size < eb->len);list_del_init (&eb->lru);if (!(eb->flags &EXTENT_BUFFER_DUMMY )) { +struct extent_io_tree *tree = &eb->fs_info->extent_cache; +remove_cache_extent (&tree->cache, &eb->cache_node); +BUG_ON (tree->cache_size < eb->len); tree->cache_size -= eb->len; }free (eb);
@@ -786,7 +783,6 @@ struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,if (!ret)return NULL ; - ret->tree =NULL ; ret->flags |=EXTENT_BUFFER_DUMMY ;return ret;
@@ -970,7 +966,7 @@ out:int set_extent_buffer_dirty (struct extent_buffer *eb) { -struct extent_io_tree *tree = eb->tree; +struct extent_io_tree *tree = &eb->fs_info->extent_cache;if (!(eb->flags &EXTENT_DIRTY )) { eb->flags |=EXTENT_DIRTY ;set_extent_dirty (tree, eb->start, eb->start + eb->len -1 );
@@ -981,7 +977,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb)int clear_extent_buffer_dirty (struct extent_buffer *eb) { -struct extent_io_tree *tree = eb->tree; +struct extent_io_tree *tree = &eb->fs_info->extent_cache;if (eb->flags &EXTENT_DIRTY ) { eb->flags &= ~EXTENT_DIRTY ;clear_extent_dirty (tree, eb->start, eb->start + eb->len -1 );
extent_io.h +0 -1
@@ -89,7 +89,6 @@ struct extent_buffer {struct cache_extent cache_node;u64 start;u64 dev_bytenr; -struct extent_io_tree *tree;struct list_head lru;struct list_head recow;u32 len;
Signature · 1 line
2.26.0
Quoted 7 lines · Qu Wenruo
This member can be fetched from
eb::fs_info, and no caller really depends on that member to determine if an eb is dummy. We haveeb::flagsto determine that.Kernel doesn't have such member either.
Signed-off-by Qu Wenruo <[email protected]>
Added to devel, thanks.
Quoted 7 lines
NOTE: Another candidate to cleanup is
eb::cache_node, in kernel we use radix tree, thus no need for any structure in eb.But in btrfs-progs, we also rely on
extent_io_treeto do cache size limitation, and for U-boot there is no radix tree implemented yet.Thus
eb::cache_nodemay live for a longer time.
Ok. There will be differences among the implementations, we might add some thin API to hide the caching or underlying strcutres but for now I don't have anything specific in mind.