Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167849325
D51057.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D51057.diff
View Options
diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c
--- a/sys/kern/subr_pctrie.c
+++ b/sys/kern/subr_pctrie.c
@@ -872,19 +872,17 @@
* 'node'. If doing so causes 'node' to have only one child, purge it from the
* pctrie and save it in *freenode for later disposal.
*/
-static void
-pctrie_remove(struct pctrie *ptree, struct pctrie_node *node, uint64_t index,
- struct pctrie_node **freenode)
+static bool
+pctrie_remove(struct pctrie *ptree, struct pctrie_node *node, uint64_t index)
{
smr_pctnode_t *parentp;
struct pctrie_node *child;
int slot;
- *freenode = NULL;
parentp = pctrie_child(ptree, node, index);
if (node == NULL) {
pctrie_node_store(parentp, PCTRIE_NULL, PCTRIE_LOCKED);
- return;
+ return (false);
}
slot = pctrie_slot(node, index);
KASSERT((node->pn_popmap & (1 << slot)) != 0,
@@ -893,12 +891,11 @@
node->pn_popmap ^= 1 << slot;
if (!powerof2(node->pn_popmap)) {
pctrie_node_store(parentp, PCTRIE_NULL, PCTRIE_LOCKED);
- return;
+ return (false);
}
pctrie_node_store(parentp, PCTRIE_NULL, PCTRIE_UNSERIALIZED);
KASSERT(node->pn_popmap != 0, ("%s: bad popmap all zeroes", __func__));
slot = ffs(node->pn_popmap) - 1;
- *freenode = node;
child = pctrie_node_load(&node->pn_child[slot], NULL, PCTRIE_LOCKED);
KASSERT(child != PCTRIE_NULL,
("%s: bad popmap slot %d in node %p", __func__, slot, node));
@@ -907,6 +904,7 @@
pctrie_setparent(child, node);
parentp = pctrie_child(ptree, node, index);
pctrie_node_store(parentp, child, PCTRIE_LOCKED);
+ return (true);
}
/*
@@ -923,8 +921,8 @@
node = _pctrie_lookup_node(ptree, NULL, index, &parent, NULL,
PCTRIE_LOCKED);
m = pctrie_match_value(node, index);
- if (m != NULL)
- pctrie_remove(ptree, parent, index, freenode);
+ if (m != NULL && pctrie_remove(ptree, parent, index))
+ *freenode = parent;
else
*freenode = NULL;
return (m);
@@ -941,9 +939,11 @@
it->ptree, it->node, it->index), NULL, PCTRIE_LOCKED), it->index),
("%s: removing value %jx not at iter", __func__,
(uintmax_t)it->index));
- pctrie_remove(it->ptree, it->node, it->index, freenode);
- if (*freenode != NULL)
+ if (pctrie_remove(it->ptree, it->node, it->index)) {
+ *freenode = it->node;
it->node = pctrie_parent(it->node);
+ } else
+ *freenode = NULL;
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 26, 12:01 AM (13 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37257049
Default Alt Text
D51057.diff (2 KB)
Attached To
Mode
D51057: pctrie: drop freenode param to pctrie_remove
Attached
Detach File
Event Timeline
Log In to Comment