22 #include <linux/kernel.h>
23 #include <linux/module.h>
47 static struct r2hb_callback {
70 static void r2hb_dead_threshold_set(
unsigned int threshold)
73 spin_lock(&r2hb_live_lock);
75 spin_unlock(&r2hb_live_lock);
79 static int r2hb_global_hearbeat_mode_set(
unsigned int hb_mode)
84 spin_lock(&r2hb_live_lock);
87 spin_unlock(&r2hb_live_lock);
101 for (i = 0; i <
ARRAY_SIZE(r2hb_callbacks); i++)
102 INIT_LIST_HEAD(&r2hb_callbacks[i].
list);
104 memset(r2hb_live_node_bitmap, 0,
sizeof(r2hb_live_node_bitmap));
110 static void r2hb_fill_node_map_from_callback(
unsigned long *
map,
115 memcpy(map, &r2hb_live_node_bitmap, bytes);
126 spin_lock(&r2hb_live_lock);
127 r2hb_fill_node_map_from_callback(map, bytes);
128 spin_unlock(&r2hb_live_lock);
166 return &r2hb_config_item;
171 static void r2hb_hb_group_drop_item(
struct config_group *group,
175 pr_notice(
"ramster: Heartbeat %s on region %s (%s)\n",
176 "stopped/aborted", config_item_name(item),
198 if (r2hb_hb_group_attr->
show)
199 ret = r2hb_hb_group_attr->
show(reg, page);
212 if (r2hb_hb_group_attr->
store)
213 ret = r2hb_hb_group_attr->
store(reg, page, count);
228 char *
p = (
char *)page;
231 err = kstrtoul(p, 10, &tmp);
236 r2hb_dead_threshold_set((
unsigned int) tmp);
251 const char *page,
size_t count)
257 len = (page[count - 1] ==
'\n') ? count - 1 : count;
265 ret = r2hb_global_hearbeat_mode_set(i);
267 pr_notice(
"ramster: Heartbeat mode set to %s\n",
278 .ca_name =
"dead_threshold",
280 .show = r2hb_hb_group_threshold_show,
281 .store = r2hb_hb_group_threshold_store,
288 .show = r2hb_hb_group_mode_show,
289 .store = r2hb_hb_group_mode_store,
293 &r2hb_hb_group_attr_threshold.
attr,
294 &r2hb_hb_group_attr_mode.
attr,
299 .show_attribute = r2hb_hb_group_show,
300 .store_attribute = r2hb_hb_group_store,
304 .make_item = r2hb_hb_group_make_item,
305 .drop_item = r2hb_hb_group_drop_item,
309 .ct_group_ops = &r2hb_hb_group_group_ops,
310 .ct_item_ops = &r2hb_hearbeat_group_item_ops,
311 .ct_attrs = r2hb_hb_group_attrs,
327 &r2hb_hb_group_type);
349 return &r2hb_callbacks[
type];
372 struct r2hb_callback *hbcall;
378 hbcall = hbcall_from_type(hc->
hc_type);
379 if (IS_ERR(hbcall)) {
380 ret = PTR_ERR(hbcall);
400 ret, __builtin_return_address(0), hc);
411 __builtin_return_address(0), hc);
429 r2hb_fill_node_map_from_callback(testing_map,
sizeof(testing_map));
430 if (!
test_bit(node_num, testing_map)) {
432 "node (%u) does not have heartbeating enabled.\n",
460 set_bit(node_num, r2hb_live_node_bitmap);