Lines Matching refs:g

68 	struct trans_waiting_for_lock	g[8];  member
72 static noinline void print_cycle(struct printbuf *out, struct lock_graph *g) in print_cycle() argument
76 prt_printf(out, "Found lock cycle (%u entries):\n", g->nr); in print_cycle()
78 for (i = g->g; i < g->g + g->nr; i++) { in print_cycle()
84 bch2_prt_task_backtrace(out, task, i == g->g ? 5 : 1, GFP_NOWAIT); in print_cycle()
88 static noinline void print_chain(struct printbuf *out, struct lock_graph *g) in print_chain() argument
92 for (i = g->g; i != g->g + g->nr; i++) { in print_chain()
94 if (i != g->g) in print_chain()
101 static void lock_graph_up(struct lock_graph *g) in lock_graph_up() argument
103 closure_put(&g->g[--g->nr].trans->ref); in lock_graph_up()
106 static noinline void lock_graph_pop_all(struct lock_graph *g) in lock_graph_pop_all() argument
108 while (g->nr) in lock_graph_pop_all()
109 lock_graph_up(g); in lock_graph_pop_all()
112 static void __lock_graph_down(struct lock_graph *g, struct btree_trans *trans) in __lock_graph_down() argument
114 g->g[g->nr++] = (struct trans_waiting_for_lock) { in __lock_graph_down()
121 static void lock_graph_down(struct lock_graph *g, struct btree_trans *trans) in lock_graph_down() argument
124 __lock_graph_down(g, trans); in lock_graph_down()
127 static bool lock_graph_remove_non_waiters(struct lock_graph *g) in lock_graph_remove_non_waiters() argument
131 for (i = g->g + 1; i < g->g + g->nr; i++) in lock_graph_remove_non_waiters()
134 while (g->g + g->nr > i) in lock_graph_remove_non_waiters()
135 lock_graph_up(g); in lock_graph_remove_non_waiters()
142 static void trace_would_deadlock(struct lock_graph *g, struct btree_trans *trans) in trace_would_deadlock() argument
152 print_cycle(&buf, g); in trace_would_deadlock()
159 static int abort_lock(struct lock_graph *g, struct trans_waiting_for_lock *i) in abort_lock() argument
161 if (i == g->g) { in abort_lock()
162 trace_would_deadlock(g, i->trans); in abort_lock()
182 static noinline int break_cycle(struct lock_graph *g, struct printbuf *cycle) in break_cycle() argument
188 if (lock_graph_remove_non_waiters(g)) in break_cycle()
193 print_cycle(cycle, g); in break_cycle()
198 for (i = g->g; i < g->g + g->nr; i++) { in break_cycle()
210 prt_printf(&buf, bch2_fmt(g->g->trans->c, "cycle of nofail locks")); in break_cycle()
212 for (i = g->g; i < g->g + g->nr; i++) { in break_cycle()
229 ret = abort_lock(g, abort); in break_cycle()
232 while (g->nr) in break_cycle()
233 lock_graph_up(g); in break_cycle()
237 static int lock_graph_descend(struct lock_graph *g, struct btree_trans *trans, in lock_graph_descend() argument
240 struct btree_trans *orig_trans = g->g->trans; in lock_graph_descend()
243 for (i = g->g; i < g->g + g->nr; i++) in lock_graph_descend()
246 return break_cycle(g, cycle); in lock_graph_descend()
249 if (g->nr == ARRAY_SIZE(g->g)) { in lock_graph_descend()
255 while (g->nr) in lock_graph_descend()
256 lock_graph_up(g); in lock_graph_descend()
265 __lock_graph_down(g, trans); in lock_graph_descend()
276 struct lock_graph g; in bch2_check_for_deadlock() local
282 g.nr = 0; in bch2_check_for_deadlock()
288 trace_would_deadlock(&g, trans); in bch2_check_for_deadlock()
292 lock_graph_down(&g, trans); in bch2_check_for_deadlock()
299 if (!g.nr) in bch2_check_for_deadlock()
302 top = &g.g[g.nr - 1]; in bch2_check_for_deadlock()
339 if (!lock_graph_remove_non_waiters(&g)) { in bch2_check_for_deadlock()
349 lock_graph_pop_all(&g); in bch2_check_for_deadlock()
376 ret = lock_graph_descend(&g, trans, cycle); in bch2_check_for_deadlock()
386 if (g.nr > 1 && cycle) in bch2_check_for_deadlock()
387 print_chain(cycle, &g); in bch2_check_for_deadlock()
388 lock_graph_up(&g); in bch2_check_for_deadlock()