summaryrefslogtreecommitdiff
path: root/fs/btrfs/backref.h
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2020-03-03 08:35:27 +0300
committerDavid Sterba <dsterba@suse.com>2020-05-25 12:25:20 +0300
commitb0fe7078d62c23bc94d0203887d9ad7b128f684b (patch)
tree688f3771f9506e512aca4ca0361b728b647a989e /fs/btrfs/backref.h
parent741188d3a549af328cc7946ce9650dd33a25087b (diff)
downloadlinux-b0fe7078d62c23bc94d0203887d9ad7b128f684b.tar.xz
btrfs: backref: rename and move drop_backref_node()
With extra comment for drop_backref_node() as it has some similarity with remove_backref_node(), thus we need extra comment explaining the difference. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/backref.h')
-rw-r--r--fs/btrfs/backref.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
index 0a1f296b1f26..a14c79bbbeb9 100644
--- a/fs/btrfs/backref.h
+++ b/fs/btrfs/backref.h
@@ -311,4 +311,43 @@ static inline void btrfs_backref_free_edge(struct btrfs_backref_cache *cache,
}
}
+static inline void btrfs_backref_unlock_node_buffer(
+ struct btrfs_backref_node *node)
+{
+ if (node->locked) {
+ btrfs_tree_unlock(node->eb);
+ node->locked = 0;
+ }
+}
+
+static inline void btrfs_backref_drop_node_buffer(
+ struct btrfs_backref_node *node)
+{
+ if (node->eb) {
+ btrfs_backref_unlock_node_buffer(node);
+ free_extent_buffer(node->eb);
+ node->eb = NULL;
+ }
+}
+
+/*
+ * Drop the backref node from cache without cleaning up its children
+ * edges.
+ *
+ * This can only be called on node without parent edges.
+ * The children edges are still kept as is.
+ */
+static inline void btrfs_backref_drop_node(struct btrfs_backref_cache *tree,
+ struct btrfs_backref_node *node)
+{
+ BUG_ON(!list_empty(&node->upper));
+
+ btrfs_backref_drop_node_buffer(node);
+ list_del(&node->list);
+ list_del(&node->lower);
+ if (!RB_EMPTY_NODE(&node->rb_node))
+ rb_erase(&node->rb_node, &tree->rb_root);
+ btrfs_backref_free_node(tree, node);
+}
+
#endif