1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Register ourselves with the heartbeat service, keep our node maps
6 * up to date, and fire off recovery when needed.
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
11 #include <linux/bitmap.h>
13 #include <linux/types.h>
14 #include <linux/highmem.h>
16 #include <cluster/masklog.h>
21 #include "heartbeat.h"
24 #include "ocfs2_trace.h"
26 #include "buffer_head_io.h"
28 /* special case -1 for now
29 * TODO: should *really* make sure the calling func never passes -1!! */
30 static void ocfs2_node_map_init(struct ocfs2_node_map
*map
)
32 map
->num_nodes
= OCFS2_NODE_MAP_MAX_NODES
;
33 bitmap_zero(map
->map
, OCFS2_NODE_MAP_MAX_NODES
);
36 void ocfs2_init_node_maps(struct ocfs2_super
*osb
)
38 spin_lock_init(&osb
->node_map_lock
);
39 ocfs2_node_map_init(&osb
->osb_recovering_orphan_dirs
);
42 void ocfs2_do_node_down(int node_num
, void *data
)
44 struct ocfs2_super
*osb
= data
;
46 BUG_ON(osb
->node_num
== node_num
);
48 trace_ocfs2_do_node_down(node_num
);
52 * No cluster connection means we're not even ready to
53 * participate yet. We check the slots after the cluster
54 * comes up, so we will notice the node death then. We
55 * can safely ignore it here.
60 ocfs2_recovery_thread(osb
, node_num
);
63 void ocfs2_node_map_set_bit(struct ocfs2_super
*osb
,
64 struct ocfs2_node_map
*map
,
69 BUG_ON(bit
>= map
->num_nodes
);
70 spin_lock(&osb
->node_map_lock
);
71 set_bit(bit
, map
->map
);
72 spin_unlock(&osb
->node_map_lock
);
75 void ocfs2_node_map_clear_bit(struct ocfs2_super
*osb
,
76 struct ocfs2_node_map
*map
,
81 BUG_ON(bit
>= map
->num_nodes
);
82 spin_lock(&osb
->node_map_lock
);
83 clear_bit(bit
, map
->map
);
84 spin_unlock(&osb
->node_map_lock
);
87 int ocfs2_node_map_test_bit(struct ocfs2_super
*osb
,
88 struct ocfs2_node_map
*map
,
92 if (bit
>= map
->num_nodes
) {
93 mlog(ML_ERROR
, "bit=%d map->num_nodes=%d\n", bit
, map
->num_nodes
);
96 spin_lock(&osb
->node_map_lock
);
97 ret
= test_bit(bit
, map
->map
);
98 spin_unlock(&osb
->node_map_lock
);