Commit 73d2ae78 authored by Nils Goroll's avatar Nils Goroll

rework tree traversal

parent 07e55326
...@@ -1302,15 +1302,8 @@ ved_decode_len(struct req *req, const uint8_t **pp) ...@@ -1302,15 +1302,8 @@ ved_decode_len(struct req *req, const uint8_t **pp)
return (l); return (l);
} }
/* VDP pesi_buf */
/* /*
* to minimize lock contention, we walk the tree looking for work * to minimize lock contention, we walk the tree and gather work on a list
*
* because pointers in data nodes may depend on objcore refs, we return when we
* are done with a subtree (iow, when we need to go to an undelivered node)
*
* so basically we work depth first, then right, but not up
*/ */
static void static void
...@@ -1337,8 +1330,6 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1337,8 +1330,6 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
CHECK_OBJ_NOTNULL(tree->front, NODE_MAGIC); CHECK_OBJ_NOTNULL(tree->front, NODE_MAGIC);
CHECK_OBJ_NOTNULL(tree->root, NODE_MAGIC); CHECK_OBJ_NOTNULL(tree->root, NODE_MAGIC);
assert(req == tree->root->nexus.req);
assert(req->esi_level == 0); assert(req->esi_level == 0);
if (tree->root->state == ST_DELIVERED) { if (tree->root->state == ST_DELIVERED) {
...@@ -1347,6 +1338,8 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1347,6 +1338,8 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
return; return;
} }
/* XXX what if we are a different worker and within a tree ?*/
/* when starting, we do not want to see any ST_UNPENDING nodes */ /* when starting, we do not want to see any ST_UNPENDING nodes */
check = CHK_DELI; check = CHK_DELI;
...@@ -1366,26 +1359,28 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1366,26 +1359,28 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
continue; continue;
} }
if (node->parent && node->parent->state != ST_OPEN) { if (node->parent && node->parent->state == ST_OPEN) {
if (VSTAILQ_EMPTY(work)) { tree->front = node;
node = node->parent;
continue;
}
/* need to DELIVER children of this parent
* first, so we can unref any storage
* XXX this comment is probably obsolete -
* rethink
*/
tree->front = node->parent;
VSLdbgv(req, "bytes_unpend: return at " VSLdbgv(req, "bytes_unpend: return at "
"node %p state %u", node, node->state); "node %p state %u - await sibling",
node, node->state);
return; return;
} }
tree->front = node; /* up and right */
VSLdbgv(req, "bytes_unpend: return at " node = node->parent;
"node %p state %u - await sibling", while (node != NULL) {
node, node->state); next = VSTAILQ_NEXT(node, sibling);
if (next != NULL) {
node = next;
continue;
}
node = node->parent;
}
AZ(node);
VSLdbgv(req, "bytes_unpend: reached root");
tree->front = tree->root;
return; return;
} }
...@@ -1399,6 +1394,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree, ...@@ -1399,6 +1394,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
assert_node(node, CHK_PEND); assert_node(node, CHK_PEND);
/* XXX only enter ST_OPEN if we own it */
if (node->type == T_NEXUS) { if (node->type == T_NEXUS) {
node = VSTAILQ_FIRST(&node->nexus.children); node = VSTAILQ_FIRST(&node->nexus.children);
continue; continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment