btrfs-progs: Add last_cache_extent() for extent-cache.
Allow direct search for the last cache extent. Provide the basis for finding the last ino in inode_cache. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
c0af17d07f
commit
378eacf815
|
@ -230,6 +230,15 @@ struct cache_extent *first_cache_extent(struct cache_tree *tree)
|
||||||
return rb_entry(node, struct cache_extent, rb_node);
|
return rb_entry(node, struct cache_extent, rb_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct cache_extent *last_cache_extent(struct cache_tree *tree)
|
||||||
|
{
|
||||||
|
struct rb_node *node = rb_last(&tree->root);
|
||||||
|
|
||||||
|
if (!node)
|
||||||
|
return NULL;
|
||||||
|
return rb_entry(node, struct cache_extent, rb_node);
|
||||||
|
}
|
||||||
|
|
||||||
struct cache_extent *prev_cache_extent(struct cache_extent *pe)
|
struct cache_extent *prev_cache_extent(struct cache_extent *pe)
|
||||||
{
|
{
|
||||||
struct rb_node *node = rb_prev(&pe->rb_node);
|
struct rb_node *node = rb_prev(&pe->rb_node);
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct cache_extent {
|
||||||
void cache_tree_init(struct cache_tree *tree);
|
void cache_tree_init(struct cache_tree *tree);
|
||||||
|
|
||||||
struct cache_extent *first_cache_extent(struct cache_tree *tree);
|
struct cache_extent *first_cache_extent(struct cache_tree *tree);
|
||||||
|
struct cache_extent *last_cache_extent(struct cache_tree *tree);
|
||||||
struct cache_extent *prev_cache_extent(struct cache_extent *pe);
|
struct cache_extent *prev_cache_extent(struct cache_extent *pe);
|
||||||
struct cache_extent *next_cache_extent(struct cache_extent *pe);
|
struct cache_extent *next_cache_extent(struct cache_extent *pe);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue