summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Huang <mmpgouride@gmail.com>2024-10-03 03:06:31 +0800
committerKent Overstreet <kent.overstreet@linux.dev>2025-01-14 10:45:13 -0500
commit6853a5e5d48b54127166291b1fc2cc7030fbcc38 (patch)
treeb0cd5e123f7dfb7637ab93ed84ede5ac64cba738
parentb5c3dcd0db0452b13a4799b9c2be751e75b541f9 (diff)
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>
-rw-r--r--fs/bcachefs/btree_locking.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c
index 8174799dd4b3..ec72a8adf713 100644
--- a/fs/bcachefs/btree_locking.c
+++ b/fs/bcachefs/btree_locking.c
@@ -109,6 +109,12 @@ static noinline void lock_graph_pop_all(struct lock_graph *g)
lock_graph_up(g);
}
+static noinline void lock_graph_pop_from(struct lock_graph *g, struct trans_waiting_for_lock *i)
+{
+ while (g->g + g->nr > i)
+ lock_graph_up(g);
+}
+
static void __lock_graph_down(struct lock_graph *g, struct btree_trans *trans)
{
g->g[g->nr++] = (struct trans_waiting_for_lock) {
@@ -131,8 +137,7 @@ static bool lock_graph_remove_non_waiters(struct lock_graph *g)
for (i = g->g + 1; i < g->g + g->nr; i++)
if (i->trans->locking != i->node_want ||
i->trans->locking_wait.start_time != i[-1].lock_start_time) {
- while (g->g + g->nr > i)
- lock_graph_up(g);
+ lock_graph_pop_from(g, i);
return true;
}