|
|
f239de |
From 1a95588e8090a2ac6cab364e5a24be219f50710b Mon Sep 17 00:00:00 2001
|
|
|
f239de |
From: Lukas Czerner <lczerner@redhat.com>
|
|
|
f239de |
Date: Fri, 6 Aug 2021 11:58:17 +0200
|
|
|
f239de |
Subject: [PATCH 41/46] libext2fs: remove augmented rbtree functionality
|
|
|
f239de |
Content-Type: text/plain
|
|
|
f239de |
|
|
|
f239de |
Rbtree code was originally taken from linux kernel. This includes the
|
|
|
f239de |
augmented rbtree functionality, however this was never intended to be
|
|
|
f239de |
used and is not used still. Just remove it.
|
|
|
f239de |
|
|
|
f239de |
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
|
|
|
f239de |
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
|
|
f239de |
---
|
|
|
f239de |
lib/ext2fs/rbtree.c | 68 ---------------------------------------------
|
|
|
f239de |
lib/ext2fs/rbtree.h | 8 ------
|
|
|
f239de |
2 files changed, 76 deletions(-)
|
|
|
f239de |
|
|
|
f239de |
diff --git a/lib/ext2fs/rbtree.c b/lib/ext2fs/rbtree.c
|
|
|
f239de |
index 5b92099d..74426fa6 100644
|
|
|
f239de |
--- a/lib/ext2fs/rbtree.c
|
|
|
f239de |
+++ b/lib/ext2fs/rbtree.c
|
|
|
f239de |
@@ -280,74 +280,6 @@ void ext2fs_rb_erase(struct rb_node *node, struct rb_root *root)
|
|
|
f239de |
__rb_erase_color(child, parent, root);
|
|
|
f239de |
}
|
|
|
f239de |
|
|
|
f239de |
-static void ext2fs_rb_augment_path(struct rb_node *node, rb_augment_f func, void *data)
|
|
|
f239de |
-{
|
|
|
f239de |
- struct rb_node *parent;
|
|
|
f239de |
-
|
|
|
f239de |
-up:
|
|
|
f239de |
- func(node, data);
|
|
|
f239de |
- parent = ext2fs_rb_parent(node);
|
|
|
f239de |
- if (!parent)
|
|
|
f239de |
- return;
|
|
|
f239de |
-
|
|
|
f239de |
- if (node == parent->rb_left && parent->rb_right)
|
|
|
f239de |
- func(parent->rb_right, data);
|
|
|
f239de |
- else if (parent->rb_left)
|
|
|
f239de |
- func(parent->rb_left, data);
|
|
|
f239de |
-
|
|
|
f239de |
- node = parent;
|
|
|
f239de |
- goto up;
|
|
|
f239de |
-}
|
|
|
f239de |
-
|
|
|
f239de |
-/*
|
|
|
f239de |
- * after inserting @node into the tree, update the tree to account for
|
|
|
f239de |
- * both the new entry and any damage done by rebalance
|
|
|
f239de |
- */
|
|
|
f239de |
-void ext2fs_rb_augment_insert(struct rb_node *node, rb_augment_f func, void *data)
|
|
|
f239de |
-{
|
|
|
f239de |
- if (node->rb_left)
|
|
|
f239de |
- node = node->rb_left;
|
|
|
f239de |
- else if (node->rb_right)
|
|
|
f239de |
- node = node->rb_right;
|
|
|
f239de |
-
|
|
|
f239de |
- ext2fs_rb_augment_path(node, func, data);
|
|
|
f239de |
-}
|
|
|
f239de |
-
|
|
|
f239de |
-/*
|
|
|
f239de |
- * before removing the node, find the deepest node on the rebalance path
|
|
|
f239de |
- * that will still be there after @node gets removed
|
|
|
f239de |
- */
|
|
|
f239de |
-struct rb_node *ext2fs_rb_augment_erase_begin(struct rb_node *node)
|
|
|
f239de |
-{
|
|
|
f239de |
- struct rb_node *deepest;
|
|
|
f239de |
-
|
|
|
f239de |
- if (!node->rb_right && !node->rb_left)
|
|
|
f239de |
- deepest = ext2fs_rb_parent(node);
|
|
|
f239de |
- else if (!node->rb_right)
|
|
|
f239de |
- deepest = node->rb_left;
|
|
|
f239de |
- else if (!node->rb_left)
|
|
|
f239de |
- deepest = node->rb_right;
|
|
|
f239de |
- else {
|
|
|
f239de |
- deepest = ext2fs_rb_next(node);
|
|
|
f239de |
- if (deepest->rb_right)
|
|
|
f239de |
- deepest = deepest->rb_right;
|
|
|
f239de |
- else if (ext2fs_rb_parent(deepest) != node)
|
|
|
f239de |
- deepest = ext2fs_rb_parent(deepest);
|
|
|
f239de |
- }
|
|
|
f239de |
-
|
|
|
f239de |
- return deepest;
|
|
|
f239de |
-}
|
|
|
f239de |
-
|
|
|
f239de |
-/*
|
|
|
f239de |
- * after removal, update the tree to account for the removed entry
|
|
|
f239de |
- * and any rebalance damage.
|
|
|
f239de |
- */
|
|
|
f239de |
-void ext2fs_rb_augment_erase_end(struct rb_node *node, rb_augment_f func, void *data)
|
|
|
f239de |
-{
|
|
|
f239de |
- if (node)
|
|
|
f239de |
- ext2fs_rb_augment_path(node, func, data);
|
|
|
f239de |
-}
|
|
|
f239de |
-
|
|
|
f239de |
/*
|
|
|
f239de |
* This function returns the first node (in sort order) of the tree.
|
|
|
f239de |
*/
|
|
|
f239de |
diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h
|
|
|
f239de |
index 9e806779..a4eb35ae 100644
|
|
|
f239de |
--- a/lib/ext2fs/rbtree.h
|
|
|
f239de |
+++ b/lib/ext2fs/rbtree.h
|
|
|
f239de |
@@ -161,14 +161,6 @@ static inline void ext2fs_rb_clear_node(struct rb_node *node)
|
|
|
f239de |
extern void ext2fs_rb_insert_color(struct rb_node *, struct rb_root *);
|
|
|
f239de |
extern void ext2fs_rb_erase(struct rb_node *, struct rb_root *);
|
|
|
f239de |
|
|
|
f239de |
-typedef void (*rb_augment_f)(struct rb_node *node, void *data);
|
|
|
f239de |
-
|
|
|
f239de |
-extern void ext2fs_rb_augment_insert(struct rb_node *node,
|
|
|
f239de |
- rb_augment_f func, void *data);
|
|
|
f239de |
-extern struct rb_node *ext2fs_rb_augment_erase_begin(struct rb_node *node);
|
|
|
f239de |
-extern void ext2fs_rb_augment_erase_end(struct rb_node *node,
|
|
|
f239de |
- rb_augment_f func, void *data);
|
|
|
f239de |
-
|
|
|
f239de |
/* Find logical next and previous nodes in a tree */
|
|
|
f239de |
extern struct rb_node *ext2fs_rb_next(struct rb_node *);
|
|
|
f239de |
extern struct rb_node *ext2fs_rb_prev(struct rb_node *);
|
|
|
f239de |
--
|
|
|
f239de |
2.35.1
|
|
|
f239de |
|