Skip to content

Commit 6853a5e

Browse files
alanskindKent Overstreet
authored andcommitted
bcachefs: Introduce lock_graph_pop_from
This patch introduces a helper function called lock_graph_pop_from, it pops the graph from i. Signed-off-by: Alan Huang <mmpgouride@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent b5c3dcd commit 6853a5e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/bcachefs/btree_locking.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ static noinline void lock_graph_pop_all(struct lock_graph *g)
109109
lock_graph_up(g);
110110
}
111111

112+
static noinline void lock_graph_pop_from(struct lock_graph *g, struct trans_waiting_for_lock *i)
113+
{
114+
while (g->g + g->nr > i)
115+
lock_graph_up(g);
116+
}
117+
112118
static void __lock_graph_down(struct lock_graph *g, struct btree_trans *trans)
113119
{
114120
g->g[g->nr++] = (struct trans_waiting_for_lock) {
@@ -131,8 +137,7 @@ static bool lock_graph_remove_non_waiters(struct lock_graph *g)
131137
for (i = g->g + 1; i < g->g + g->nr; i++)
132138
if (i->trans->locking != i->node_want ||
133139
i->trans->locking_wait.start_time != i[-1].lock_start_time) {
134-
while (g->g + g->nr > i)
135-
lock_graph_up(g);
140+
lock_graph_pop_from(g, i);
136141
return true;
137142
}
138143

0 commit comments

Comments
 (0)