46 #include <linux/kernel.h>
48 #include <linux/reboot.h>
52 #define MLOG_MASK_PREFIX ML_QUORUM
56 static struct o2quo_state {
70 static void o2quo_fence_self(
void)
78 panic(
"*** ocfs2 is very sorry to be fencing this system by "
86 "system by restarting ***\n");
108 int lowest_hb, lowest_reachable = 0, fence = 0;
109 struct o2quo_state *
qs = &o2quo_state;
111 spin_lock(&qs->qs_lock);
115 lowest_reachable =
test_bit(lowest_hb, qs->qs_conn_bm);
117 mlog(0,
"heartbeating: %d, connected: %d, "
118 "lowest: %d (%sreachable)\n", qs->qs_heartbeating,
119 qs->qs_connected, lowest_hb, lowest_reachable ?
"" :
"un");
122 qs->qs_heartbeating == 1)
125 if (qs->qs_heartbeating & 1) {
128 quorum = (qs->qs_heartbeating + 1)/2;
129 if (qs->qs_connected < quorum) {
131 "only connected to %u nodes and %u is needed "
132 "to make a quorum out of %u heartbeating nodes\n",
133 qs->qs_connected, quorum,
134 qs->qs_heartbeating);
142 quorum = qs->qs_heartbeating / 2;
143 if (qs->qs_connected < quorum) {
145 "only connected to %u nodes and %u is needed "
146 "to make a quorum out of %u heartbeating nodes\n",
147 qs->qs_connected, quorum,
148 qs->qs_heartbeating);
151 else if ((qs->qs_connected == quorum) &&
154 "connected to a half-quorum of %u out of %u "
155 "nodes which doesn't include the lowest active "
156 "node %u\n", quorum, qs->qs_heartbeating,
163 spin_unlock(&qs->qs_lock);
168 static void o2quo_set_hold(
struct o2quo_state *qs,
u8 node)
176 mlog(0,
"node %u, %d total\n", node, qs->qs_holds);
180 static void o2quo_clear_hold(
struct o2quo_state *qs,
u8 node)
185 mlog(0,
"node %u, %d total\n", node, qs->qs_holds - 1);
186 if (--qs->qs_holds == 0) {
187 if (qs->qs_pending) {
203 struct o2quo_state *qs = &o2quo_state;
205 spin_lock(&qs->qs_lock);
207 qs->qs_heartbeating++;
213 mlog(0,
"node %u, %d total\n", node, qs->qs_heartbeating);
215 if (!
test_bit(node, qs->qs_conn_bm))
216 o2quo_set_hold(qs, node);
218 o2quo_clear_hold(qs, node);
220 spin_unlock(&qs->qs_lock);
227 struct o2quo_state *qs = &o2quo_state;
229 spin_lock(&qs->qs_lock);
231 qs->qs_heartbeating--;
233 "node %u, %d heartbeating\n",
234 node, qs->qs_heartbeating);
238 mlog(0,
"node %u, %d total\n", node, qs->qs_heartbeating);
240 o2quo_clear_hold(qs, node);
242 spin_unlock(&qs->qs_lock);
252 struct o2quo_state *qs = &o2quo_state;
254 spin_lock(&qs->qs_lock);
256 mlog(0,
"node %u\n", node);
259 o2quo_clear_hold(qs, node);
261 spin_unlock(&qs->qs_lock);
271 struct o2quo_state *qs = &o2quo_state;
273 spin_lock(&qs->qs_lock);
281 mlog(0,
"node %u, %d total\n", node, qs->qs_connected);
284 o2quo_set_hold(qs, node);
286 o2quo_clear_hold(qs, node);
288 spin_unlock(&qs->qs_lock);
297 struct o2quo_state *qs = &o2quo_state;
299 spin_lock(&qs->qs_lock);
301 if (
test_bit(node, qs->qs_conn_bm)) {
304 "node %u, connected %d\n",
305 node, qs->qs_connected);
310 mlog(0,
"node %u, %d total\n", node, qs->qs_connected);
313 o2quo_set_hold(qs, node);
315 spin_unlock(&qs->qs_lock);
320 struct o2quo_state *qs = &o2quo_state;
323 INIT_WORK(&qs->qs_work, o2quo_make_decision);
328 struct o2quo_state *qs = &o2quo_state;