Lines Matching refs:qs
109 struct o2quo_state *qs = &o2quo_state; in o2quo_make_decision() local
111 spin_lock(&qs->qs_lock); in o2quo_make_decision()
113 lowest_hb = find_first_bit(qs->qs_hb_bm, O2NM_MAX_NODES); in o2quo_make_decision()
115 lowest_reachable = test_bit(lowest_hb, qs->qs_conn_bm); in o2quo_make_decision()
118 "lowest: %d (%sreachable)\n", qs->qs_heartbeating, in o2quo_make_decision()
119 qs->qs_connected, lowest_hb, lowest_reachable ? "" : "un"); in o2quo_make_decision()
121 if (!test_bit(o2nm_this_node(), qs->qs_hb_bm) || in o2quo_make_decision()
122 qs->qs_heartbeating == 1) in o2quo_make_decision()
125 if (qs->qs_heartbeating & 1) { in o2quo_make_decision()
128 quorum = (qs->qs_heartbeating + 1)/2; in o2quo_make_decision()
129 if (qs->qs_connected < quorum) { in o2quo_make_decision()
133 qs->qs_connected, quorum, in o2quo_make_decision()
134 qs->qs_heartbeating); in o2quo_make_decision()
142 quorum = qs->qs_heartbeating / 2; in o2quo_make_decision()
143 if (qs->qs_connected < quorum) { in o2quo_make_decision()
147 qs->qs_connected, quorum, in o2quo_make_decision()
148 qs->qs_heartbeating); in o2quo_make_decision()
151 else if ((qs->qs_connected == quorum) && in o2quo_make_decision()
156 "node %u\n", quorum, qs->qs_heartbeating, in o2quo_make_decision()
164 spin_unlock(&qs->qs_lock); in o2quo_make_decision()
169 qs->qs_heartbeating, qs->qs_connected, lowest_hb, in o2quo_make_decision()
171 spin_unlock(&qs->qs_lock); in o2quo_make_decision()
177 static void o2quo_set_hold(struct o2quo_state *qs, u8 node) in o2quo_set_hold() argument
179 assert_spin_locked(&qs->qs_lock); in o2quo_set_hold()
181 if (!test_and_set_bit(node, qs->qs_hold_bm)) { in o2quo_set_hold()
182 qs->qs_holds++; in o2quo_set_hold()
183 mlog_bug_on_msg(qs->qs_holds == O2NM_MAX_NODES, in o2quo_set_hold()
185 mlog(0, "node %u, %d total\n", node, qs->qs_holds); in o2quo_set_hold()
189 static void o2quo_clear_hold(struct o2quo_state *qs, u8 node) in o2quo_clear_hold() argument
191 assert_spin_locked(&qs->qs_lock); in o2quo_clear_hold()
193 if (test_and_clear_bit(node, qs->qs_hold_bm)) { in o2quo_clear_hold()
194 mlog(0, "node %u, %d total\n", node, qs->qs_holds - 1); in o2quo_clear_hold()
195 if (--qs->qs_holds == 0) { in o2quo_clear_hold()
196 if (qs->qs_pending) { in o2quo_clear_hold()
197 qs->qs_pending = 0; in o2quo_clear_hold()
198 schedule_work(&qs->qs_work); in o2quo_clear_hold()
201 mlog_bug_on_msg(qs->qs_holds < 0, "node %u, holds %d\n", in o2quo_clear_hold()
202 node, qs->qs_holds); in o2quo_clear_hold()
212 struct o2quo_state *qs = &o2quo_state; in o2quo_hb_up() local
214 spin_lock(&qs->qs_lock); in o2quo_hb_up()
216 qs->qs_heartbeating++; in o2quo_hb_up()
217 mlog_bug_on_msg(qs->qs_heartbeating == O2NM_MAX_NODES, in o2quo_hb_up()
219 mlog_bug_on_msg(test_bit(node, qs->qs_hb_bm), "node %u\n", node); in o2quo_hb_up()
220 set_bit(node, qs->qs_hb_bm); in o2quo_hb_up()
222 mlog(0, "node %u, %d total\n", node, qs->qs_heartbeating); in o2quo_hb_up()
224 if (!test_bit(node, qs->qs_conn_bm)) in o2quo_hb_up()
225 o2quo_set_hold(qs, node); in o2quo_hb_up()
227 o2quo_clear_hold(qs, node); in o2quo_hb_up()
229 spin_unlock(&qs->qs_lock); in o2quo_hb_up()
236 struct o2quo_state *qs = &o2quo_state; in o2quo_hb_down() local
238 spin_lock(&qs->qs_lock); in o2quo_hb_down()
240 qs->qs_heartbeating--; in o2quo_hb_down()
241 mlog_bug_on_msg(qs->qs_heartbeating < 0, in o2quo_hb_down()
243 node, qs->qs_heartbeating); in o2quo_hb_down()
244 mlog_bug_on_msg(!test_bit(node, qs->qs_hb_bm), "node %u\n", node); in o2quo_hb_down()
245 clear_bit(node, qs->qs_hb_bm); in o2quo_hb_down()
247 mlog(0, "node %u, %d total\n", node, qs->qs_heartbeating); in o2quo_hb_down()
249 o2quo_clear_hold(qs, node); in o2quo_hb_down()
251 spin_unlock(&qs->qs_lock); in o2quo_hb_down()
261 struct o2quo_state *qs = &o2quo_state; in o2quo_hb_still_up() local
263 spin_lock(&qs->qs_lock); in o2quo_hb_still_up()
267 qs->qs_pending = 1; in o2quo_hb_still_up()
268 o2quo_clear_hold(qs, node); in o2quo_hb_still_up()
270 spin_unlock(&qs->qs_lock); in o2quo_hb_still_up()
280 struct o2quo_state *qs = &o2quo_state; in o2quo_conn_up() local
282 spin_lock(&qs->qs_lock); in o2quo_conn_up()
284 qs->qs_connected++; in o2quo_conn_up()
285 mlog_bug_on_msg(qs->qs_connected == O2NM_MAX_NODES, in o2quo_conn_up()
287 mlog_bug_on_msg(test_bit(node, qs->qs_conn_bm), "node %u\n", node); in o2quo_conn_up()
288 set_bit(node, qs->qs_conn_bm); in o2quo_conn_up()
290 mlog(0, "node %u, %d total\n", node, qs->qs_connected); in o2quo_conn_up()
292 if (!test_bit(node, qs->qs_hb_bm)) in o2quo_conn_up()
293 o2quo_set_hold(qs, node); in o2quo_conn_up()
295 o2quo_clear_hold(qs, node); in o2quo_conn_up()
297 spin_unlock(&qs->qs_lock); in o2quo_conn_up()
306 struct o2quo_state *qs = &o2quo_state; in o2quo_conn_err() local
308 spin_lock(&qs->qs_lock); in o2quo_conn_err()
310 if (test_bit(node, qs->qs_conn_bm)) { in o2quo_conn_err()
311 qs->qs_connected--; in o2quo_conn_err()
312 mlog_bug_on_msg(qs->qs_connected < 0, in o2quo_conn_err()
314 node, qs->qs_connected); in o2quo_conn_err()
316 clear_bit(node, qs->qs_conn_bm); in o2quo_conn_err()
318 if (test_bit(node, qs->qs_hb_bm)) in o2quo_conn_err()
319 o2quo_set_hold(qs, node); in o2quo_conn_err()
322 mlog(0, "node %u, %d total\n", node, qs->qs_connected); in o2quo_conn_err()
325 spin_unlock(&qs->qs_lock); in o2quo_conn_err()
330 struct o2quo_state *qs = &o2quo_state; in o2quo_init() local
332 spin_lock_init(&qs->qs_lock); in o2quo_init()
333 INIT_WORK(&qs->qs_work, o2quo_make_decision); in o2quo_init()
338 struct o2quo_state *qs = &o2quo_state; in o2quo_exit() local
340 flush_work(&qs->qs_work); in o2quo_exit()