aboutsummaryrefslogtreecommitdiffstats
path: root/extent-cache.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-12-09 16:27:23 +0800
committerDavid Sterba <dsterba@suse.cz>2014-12-10 11:54:10 +0100
commit378eacf815893cad989463b0917dcd2dd6553438 (patch)
treef310c95c82b110db1a907a45e05372ffec77910b /extent-cache.c
parentc0af17d07f1122eff07c751dafef3954bcffc822 (diff)
downloadbtrfs-progs-378eacf815893cad989463b0917dcd2dd6553438.tar.gz
btrfs-progs-378eacf815893cad989463b0917dcd2dd6553438.tar.xz
btrfs-progs-378eacf815893cad989463b0917dcd2dd6553438.zip
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>
Diffstat (limited to 'extent-cache.c')
-rw-r--r--extent-cache.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/extent-cache.c b/extent-cache.c
index 7656ab2..d80aead 100644
--- a/extent-cache.c
+++ b/extent-cache.c
@@ -230,6 +230,15 @@ struct cache_extent *first_cache_extent(struct cache_tree *tree)
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 rb_node *node = rb_prev(&pe->rb_node);