1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Register ourselves with the heartbaet service, keep our node maps
6 * up to date, and fire off recovery when needed.
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
12 #include <linux/types.h>
13 #include <linux/highmem.h>
15 #include <cluster/masklog.h>
20 #include "heartbeat.h"
23 #include "ocfs2_trace.h"
25 #include "buffer_head_io.h"
27 static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map
*map
,
29 static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map
*map
,
32 /* special case -1 for now
33 * TODO: should *really* make sure the calling func never passes -1!! */
34 static void ocfs2_node_map_init(struct ocfs2_node_map
*map
)
36 map
->num_nodes
= OCFS2_NODE_MAP_MAX_NODES
;
37 memset(map
->map
, 0, BITS_TO_LONGS(OCFS2_NODE_MAP_MAX_NODES
) *
38 sizeof(unsigned long));
41 void ocfs2_init_node_maps(struct ocfs2_super
*osb
)
43 spin_lock_init(&osb
->node_map_lock
);
44 ocfs2_node_map_init(&osb
->osb_recovering_orphan_dirs
);
47 void ocfs2_do_node_down(int node_num
, void *data
)
49 struct ocfs2_super
*osb
= data
;
51 BUG_ON(osb
->node_num
== node_num
);
53 trace_ocfs2_do_node_down(node_num
);
57 * No cluster connection means we're not even ready to
58 * participate yet. We check the slots after the cluster
59 * comes up, so we will notice the node death then. We
60 * can safely ignore it here.
65 ocfs2_recovery_thread(osb
, node_num
);
68 static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map
*map
,
71 set_bit(bit
, map
->map
);
74 void ocfs2_node_map_set_bit(struct ocfs2_super
*osb
,
75 struct ocfs2_node_map
*map
,
80 BUG_ON(bit
>= map
->num_nodes
);
81 spin_lock(&osb
->node_map_lock
);
82 __ocfs2_node_map_set_bit(map
, bit
);
83 spin_unlock(&osb
->node_map_lock
);
86 static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map
*map
,
89 clear_bit(bit
, map
->map
);
92 void ocfs2_node_map_clear_bit(struct ocfs2_super
*osb
,
93 struct ocfs2_node_map
*map
,
98 BUG_ON(bit
>= map
->num_nodes
);
99 spin_lock(&osb
->node_map_lock
);
100 __ocfs2_node_map_clear_bit(map
, bit
);
101 spin_unlock(&osb
->node_map_lock
);
104 int ocfs2_node_map_test_bit(struct ocfs2_super
*osb
,
105 struct ocfs2_node_map
*map
,
109 if (bit
>= map
->num_nodes
) {
110 mlog(ML_ERROR
, "bit=%d map->num_nodes=%d\n", bit
, map
->num_nodes
);
113 spin_lock(&osb
->node_map_lock
);
114 ret
= test_bit(bit
, map
->map
);
115 spin_unlock(&osb
->node_map_lock
);