diff options
Diffstat (limited to 'fs/ocfs2/heartbeat.c')
-rw-r--r-- | fs/ocfs2/heartbeat.c | 184 |
1 files changed, 8 insertions, 176 deletions
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c index 0758daf64da0..c6e7213db868 100644 --- a/fs/ocfs2/heartbeat.c +++ b/fs/ocfs2/heartbeat.c | |||
@@ -28,9 +28,6 @@ | |||
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/highmem.h> | 30 | #include <linux/highmem.h> |
31 | #include <linux/kmod.h> | ||
32 | |||
33 | #include <dlm/dlmapi.h> | ||
34 | 31 | ||
35 | #define MLOG_MASK_PREFIX ML_SUPER | 32 | #define MLOG_MASK_PREFIX ML_SUPER |
36 | #include <cluster/masklog.h> | 33 | #include <cluster/masklog.h> |
@@ -48,7 +45,6 @@ static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, | |||
48 | int bit); | 45 | int bit); |
49 | static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map *map, | 46 | static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map *map, |
50 | int bit); | 47 | int bit); |
51 | static inline int __ocfs2_node_map_is_empty(struct ocfs2_node_map *map); | ||
52 | 48 | ||
53 | /* special case -1 for now | 49 | /* special case -1 for now |
54 | * TODO: should *really* make sure the calling func never passes -1!! */ | 50 | * TODO: should *really* make sure the calling func never passes -1!! */ |
@@ -62,23 +58,23 @@ static void ocfs2_node_map_init(struct ocfs2_node_map *map) | |||
62 | void ocfs2_init_node_maps(struct ocfs2_super *osb) | 58 | void ocfs2_init_node_maps(struct ocfs2_super *osb) |
63 | { | 59 | { |
64 | spin_lock_init(&osb->node_map_lock); | 60 | spin_lock_init(&osb->node_map_lock); |
65 | ocfs2_node_map_init(&osb->recovery_map); | ||
66 | ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs); | 61 | ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs); |
67 | } | 62 | } |
68 | 63 | ||
69 | static void ocfs2_do_node_down(int node_num, | 64 | void ocfs2_do_node_down(int node_num, void *data) |
70 | struct ocfs2_super *osb) | ||
71 | { | 65 | { |
66 | struct ocfs2_super *osb = data; | ||
67 | |||
72 | BUG_ON(osb->node_num == node_num); | 68 | BUG_ON(osb->node_num == node_num); |
73 | 69 | ||
74 | mlog(0, "ocfs2: node down event for %d\n", node_num); | 70 | mlog(0, "ocfs2: node down event for %d\n", node_num); |
75 | 71 | ||
76 | if (!osb->dlm) { | 72 | if (!osb->cconn) { |
77 | /* | 73 | /* |
78 | * No DLM means we're not even ready to participate yet. | 74 | * No cluster connection means we're not even ready to |
79 | * We check the slots after the DLM comes up, so we will | 75 | * participate yet. We check the slots after the cluster |
80 | * notice the node death then. We can safely ignore it | 76 | * comes up, so we will notice the node death then. We |
81 | * here. | 77 | * can safely ignore it here. |
82 | */ | 78 | */ |
83 | return; | 79 | return; |
84 | } | 80 | } |
@@ -86,61 +82,6 @@ static void ocfs2_do_node_down(int node_num, | |||
86 | ocfs2_recovery_thread(osb, node_num); | 82 | ocfs2_recovery_thread(osb, node_num); |
87 | } | 83 | } |
88 | 84 | ||
89 | /* Called from the dlm when it's about to evict a node. We may also | ||
90 | * get a heartbeat callback later. */ | ||
91 | static void ocfs2_dlm_eviction_cb(int node_num, | ||
92 | void *data) | ||
93 | { | ||
94 | struct ocfs2_super *osb = (struct ocfs2_super *) data; | ||
95 | struct super_block *sb = osb->sb; | ||
96 | |||
97 | mlog(ML_NOTICE, "device (%u,%u): dlm has evicted node %d\n", | ||
98 | MAJOR(sb->s_dev), MINOR(sb->s_dev), node_num); | ||
99 | |||
100 | ocfs2_do_node_down(node_num, osb); | ||
101 | } | ||
102 | |||
103 | void ocfs2_setup_hb_callbacks(struct ocfs2_super *osb) | ||
104 | { | ||
105 | /* Not exactly a heartbeat callback, but leads to essentially | ||
106 | * the same path so we set it up here. */ | ||
107 | dlm_setup_eviction_cb(&osb->osb_eviction_cb, | ||
108 | ocfs2_dlm_eviction_cb, | ||
109 | osb); | ||
110 | } | ||
111 | |||
112 | void ocfs2_stop_heartbeat(struct ocfs2_super *osb) | ||
113 | { | ||
114 | int ret; | ||
115 | char *argv[5], *envp[3]; | ||
116 | |||
117 | if (ocfs2_mount_local(osb)) | ||
118 | return; | ||
119 | |||
120 | if (!osb->uuid_str) { | ||
121 | /* This can happen if we don't get far enough in mount... */ | ||
122 | mlog(0, "No UUID with which to stop heartbeat!\n\n"); | ||
123 | return; | ||
124 | } | ||
125 | |||
126 | argv[0] = (char *)o2nm_get_hb_ctl_path(); | ||
127 | argv[1] = "-K"; | ||
128 | argv[2] = "-u"; | ||
129 | argv[3] = osb->uuid_str; | ||
130 | argv[4] = NULL; | ||
131 | |||
132 | mlog(0, "Run: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]); | ||
133 | |||
134 | /* minimal command environment taken from cpu_run_sbin_hotplug */ | ||
135 | envp[0] = "HOME=/"; | ||
136 | envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | ||
137 | envp[2] = NULL; | ||
138 | |||
139 | ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); | ||
140 | if (ret < 0) | ||
141 | mlog_errno(ret); | ||
142 | } | ||
143 | |||
144 | static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, | 85 | static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, |
145 | int bit) | 86 | int bit) |
146 | { | 87 | { |
@@ -192,112 +133,3 @@ int ocfs2_node_map_test_bit(struct ocfs2_super *osb, | |||
192 | return ret; | 133 | return ret; |
193 | } | 134 | } |
194 | 135 | ||
195 | static inline int __ocfs2_node_map_is_empty(struct ocfs2_node_map *map) | ||
196 | { | ||
197 | int bit; | ||
198 | bit = find_next_bit(map->map, map->num_nodes, 0); | ||
199 | if (bit < map->num_nodes) | ||
200 | return 0; | ||
201 | return 1; | ||
202 | } | ||
203 | |||
204 | int ocfs2_node_map_is_empty(struct ocfs2_super *osb, | ||
205 | struct ocfs2_node_map *map) | ||
206 | { | ||
207 | int ret; | ||
208 | BUG_ON(map->num_nodes == 0); | ||
209 | spin_lock(&osb->node_map_lock); | ||
210 | ret = __ocfs2_node_map_is_empty(map); | ||
211 | spin_unlock(&osb->node_map_lock); | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | #if 0 | ||
216 | |||
217 | static void __ocfs2_node_map_dup(struct ocfs2_node_map *target, | ||
218 | struct ocfs2_node_map *from) | ||
219 | { | ||
220 | BUG_ON(from->num_nodes == 0); | ||
221 | ocfs2_node_map_init(target); | ||
222 | __ocfs2_node_map_set(target, from); | ||
223 | } | ||
224 | |||
225 | /* returns 1 if bit is the only bit set in target, 0 otherwise */ | ||
226 | int ocfs2_node_map_is_only(struct ocfs2_super *osb, | ||
227 | struct ocfs2_node_map *target, | ||
228 | int bit) | ||
229 | { | ||
230 | struct ocfs2_node_map temp; | ||
231 | int ret; | ||
232 | |||
233 | spin_lock(&osb->node_map_lock); | ||
234 | __ocfs2_node_map_dup(&temp, target); | ||
235 | __ocfs2_node_map_clear_bit(&temp, bit); | ||
236 | ret = __ocfs2_node_map_is_empty(&temp); | ||
237 | spin_unlock(&osb->node_map_lock); | ||
238 | |||
239 | return ret; | ||
240 | } | ||
241 | |||
242 | static void __ocfs2_node_map_set(struct ocfs2_node_map *target, | ||
243 | struct ocfs2_node_map *from) | ||
244 | { | ||
245 | int num_longs, i; | ||
246 | |||
247 | BUG_ON(target->num_nodes != from->num_nodes); | ||
248 | BUG_ON(target->num_nodes == 0); | ||
249 | |||
250 | num_longs = BITS_TO_LONGS(target->num_nodes); | ||
251 | for (i = 0; i < num_longs; i++) | ||
252 | target->map[i] = from->map[i]; | ||
253 | } | ||
254 | |||
255 | #endif /* 0 */ | ||
256 | |||
257 | /* Returns whether the recovery bit was actually set - it may not be | ||
258 | * if a node is still marked as needing recovery */ | ||
259 | int ocfs2_recovery_map_set(struct ocfs2_super *osb, | ||
260 | int num) | ||
261 | { | ||
262 | int set = 0; | ||
263 | |||
264 | spin_lock(&osb->node_map_lock); | ||
265 | |||
266 | if (!test_bit(num, osb->recovery_map.map)) { | ||
267 | __ocfs2_node_map_set_bit(&osb->recovery_map, num); | ||
268 | set = 1; | ||
269 | } | ||
270 | |||
271 | spin_unlock(&osb->node_map_lock); | ||
272 | |||
273 | return set; | ||
274 | } | ||
275 | |||
276 | void ocfs2_recovery_map_clear(struct ocfs2_super *osb, | ||
277 | int num) | ||
278 | { | ||
279 | ocfs2_node_map_clear_bit(osb, &osb->recovery_map, num); | ||
280 | } | ||
281 | |||
282 | int ocfs2_node_map_iterate(struct ocfs2_super *osb, | ||
283 | struct ocfs2_node_map *map, | ||
284 | int idx) | ||
285 | { | ||
286 | int i = idx; | ||
287 | |||
288 | idx = O2NM_INVALID_NODE_NUM; | ||
289 | spin_lock(&osb->node_map_lock); | ||
290 | if ((i != O2NM_INVALID_NODE_NUM) && | ||
291 | (i >= 0) && | ||
292 | (i < map->num_nodes)) { | ||
293 | while(i < map->num_nodes) { | ||
294 | if (test_bit(i, map->map)) { | ||
295 | idx = i; | ||
296 | break; | ||
297 | } | ||
298 | i++; | ||
299 | } | ||
300 | } | ||
301 | spin_unlock(&osb->node_map_lock); | ||
302 | return idx; | ||
303 | } | ||