diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-02-01 15:03:57 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:02 -0400 |
commit | 553abd046af609191a91af7289d87d477adc659f (patch) | |
tree | cff21f65d49c0041993095a051edf76840c2af28 /fs/ocfs2/heartbeat.c | |
parent | d85b20e4b300edfd290f21fc2d790ba16d2f225b (diff) |
ocfs2: Change the recovery map to an array of node numbers.
The old recovery map was a bitmap of node numbers. This was sufficient
for the maximum node number of 254. Going forward, we want node numbers
to be UINT32. Thus, we need a new recovery map.
Note that we can't keep track of slots here. We must write down the
node number to recovery *before* we get the locks needed to convert a
node number into a slot number.
The recovery map is now an array of unsigned ints, max_slots in size.
It moves to journal.c with the rest of recovery.
Because it needs to be initialized, we move all of recovery initialization
into a new function, ocfs2_recovery_init(). This actually cleans up
ocfs2_initialize_super() a little as well. Following on, recovery cleaup
becomes part of ocfs2_recovery_exit().
A number of node map functions are rendered obsolete and are removed.
Finally, waiting on recovery is wrapped in a function rather than naked
checks on the recovery_event. This is a cleanup from Mark.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/heartbeat.c')
-rw-r--r-- | fs/ocfs2/heartbeat.c | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c index 0758daf64da0..80de2397c161 100644 --- a/fs/ocfs2/heartbeat.c +++ b/fs/ocfs2/heartbeat.c | |||
@@ -48,7 +48,6 @@ static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, | |||
48 | int bit); | 48 | int bit); |
49 | static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map *map, | 49 | static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map *map, |
50 | int bit); | 50 | int bit); |
51 | static inline int __ocfs2_node_map_is_empty(struct ocfs2_node_map *map); | ||
52 | 51 | ||
53 | /* special case -1 for now | 52 | /* special case -1 for now |
54 | * TODO: should *really* make sure the calling func never passes -1!! */ | 53 | * TODO: should *really* make sure the calling func never passes -1!! */ |
@@ -62,7 +61,6 @@ static void ocfs2_node_map_init(struct ocfs2_node_map *map) | |||
62 | void ocfs2_init_node_maps(struct ocfs2_super *osb) | 61 | void ocfs2_init_node_maps(struct ocfs2_super *osb) |
63 | { | 62 | { |
64 | spin_lock_init(&osb->node_map_lock); | 63 | 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); | 64 | ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs); |
67 | } | 65 | } |
68 | 66 | ||
@@ -192,112 +190,3 @@ int ocfs2_node_map_test_bit(struct ocfs2_super *osb, | |||
192 | return ret; | 190 | return ret; |
193 | } | 191 | } |
194 | 192 | ||
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 | } | ||