0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/bitmap.h>
0012 #include <linux/fs.h>
0013 #include <linux/types.h>
0014 #include <linux/highmem.h>
0015
0016 #include <cluster/masklog.h>
0017
0018 #include "ocfs2.h"
0019
0020 #include "alloc.h"
0021 #include "heartbeat.h"
0022 #include "inode.h"
0023 #include "journal.h"
0024 #include "ocfs2_trace.h"
0025
0026 #include "buffer_head_io.h"
0027
0028
0029
0030 static void ocfs2_node_map_init(struct ocfs2_node_map *map)
0031 {
0032 map->num_nodes = OCFS2_NODE_MAP_MAX_NODES;
0033 bitmap_zero(map->map, OCFS2_NODE_MAP_MAX_NODES);
0034 }
0035
0036 void ocfs2_init_node_maps(struct ocfs2_super *osb)
0037 {
0038 spin_lock_init(&osb->node_map_lock);
0039 ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs);
0040 }
0041
0042 void ocfs2_do_node_down(int node_num, void *data)
0043 {
0044 struct ocfs2_super *osb = data;
0045
0046 BUG_ON(osb->node_num == node_num);
0047
0048 trace_ocfs2_do_node_down(node_num);
0049
0050 if (!osb->cconn) {
0051
0052
0053
0054
0055
0056
0057 return;
0058 }
0059
0060 ocfs2_recovery_thread(osb, node_num);
0061 }
0062
0063 void ocfs2_node_map_set_bit(struct ocfs2_super *osb,
0064 struct ocfs2_node_map *map,
0065 int bit)
0066 {
0067 if (bit==-1)
0068 return;
0069 BUG_ON(bit >= map->num_nodes);
0070 spin_lock(&osb->node_map_lock);
0071 set_bit(bit, map->map);
0072 spin_unlock(&osb->node_map_lock);
0073 }
0074
0075 void ocfs2_node_map_clear_bit(struct ocfs2_super *osb,
0076 struct ocfs2_node_map *map,
0077 int bit)
0078 {
0079 if (bit==-1)
0080 return;
0081 BUG_ON(bit >= map->num_nodes);
0082 spin_lock(&osb->node_map_lock);
0083 clear_bit(bit, map->map);
0084 spin_unlock(&osb->node_map_lock);
0085 }
0086
0087 int ocfs2_node_map_test_bit(struct ocfs2_super *osb,
0088 struct ocfs2_node_map *map,
0089 int bit)
0090 {
0091 int ret;
0092 if (bit >= map->num_nodes) {
0093 mlog(ML_ERROR, "bit=%d map->num_nodes=%d\n", bit, map->num_nodes);
0094 BUG();
0095 }
0096 spin_lock(&osb->node_map_lock);
0097 ret = test_bit(bit, map->map);
0098 spin_unlock(&osb->node_map_lock);
0099 return ret;
0100 }
0101