[Ocfs2-devel] [PATCH 08/14] ocfs2: allow per-resource callbacks
Jeff Mahoney
jeffm at suse.com
Tue Feb 21 10:57:31 CST 2006
The following patch adds a heartbeat resource pointer to callbacks and
events, allowing users to specify on a per-callback function basis whether
to listen to a specific heartbeat resource or receive events for any
resource.
This functionality is not used by this patch, but will be with the next patch.
fs/ocfs2/cluster/heartbeat.c | 14 +++++++++-----
fs/ocfs2/cluster/heartbeat.h | 4 +++-
fs/ocfs2/cluster/quorum.c | 4 ++--
fs/ocfs2/cluster/tcp.c | 4 ++--
fs/ocfs2/dlm/dlmdomain.c | 5 +++--
fs/ocfs2/heartbeat.c | 5 +++--
6 files changed, 22 insertions(+), 14 deletions(-)
Signed-off-by: Jeff Mahoney <jeffm at suse.com>
diff -ruNpX ../dontdiff linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/heartbeat.c linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/heartbeat.c
--- linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/heartbeat.c 2006-02-21 11:44:38.000000000 -0500
+++ linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/heartbeat.c 2006-02-21 11:44:41.000000000 -0500
@@ -68,16 +68,18 @@ static struct o2hb_callback {
static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type);
static void o2hb_fire_callbacks(struct o2hb_callback *hbcall,
- struct o2nm_node *node,
- int idx)
+ struct o2hb_node_event *event)
{
struct list_head *iter;
struct o2hb_callback_func *f;
+ struct o2nm_node *node = event->hn_node;
+ int idx = event->hn_node_num;
list_for_each(iter, &hbcall->list) {
f = list_entry(iter, struct o2hb_callback_func, hc_item);
mlog(ML_HEARTBEAT, "calling funcs %p\n", f);
- (f->hc_func)(node, idx, f->hc_data);
+ if (f->hc_res == NULL || f->hc_res == event->hn_res)
+ (f->hc_func)(node, idx, f->hc_data);
}
}
@@ -119,7 +121,7 @@ void o2hb_run_event_list(struct o2hb_nod
* to recover from. */
BUG_ON(IS_ERR(hbcall));
- o2hb_fire_callbacks(hbcall, event->hn_node, event->hn_node_num);
+ o2hb_fire_callbacks(hbcall, event);
spin_lock(&o2hb_live_lock);
}
@@ -262,7 +264,8 @@ void o2hb_setup_callback(struct o2hb_cal
enum o2hb_callback_type type,
o2hb_cb_func *func,
void *data,
- int priority)
+ int priority,
+ struct o2hb_heartbeat_resource *res)
{
INIT_LIST_HEAD(&hc->hc_item);
hc->hc_func = func;
@@ -270,6 +273,7 @@ void o2hb_setup_callback(struct o2hb_cal
hc->hc_priority = priority;
hc->hc_type = type;
hc->hc_magic = O2HB_CB_MAGIC;
+ hc->hc_res = res;
}
EXPORT_SYMBOL_GPL(o2hb_setup_callback);
diff -ruNpX ../dontdiff linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/heartbeat.h linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/heartbeat.h
--- linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/heartbeat.h 2006-02-21 11:44:38.000000000 -0500
+++ linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/heartbeat.h 2006-02-21 11:44:41.000000000 -0500
@@ -68,6 +68,7 @@ struct o2hb_callback_func {
void *hc_data;
int hc_priority;
enum o2hb_callback_type hc_type;
+ struct o2hb_heartbeat_resource *hc_res;
};
struct o2hb_node_event {
@@ -75,6 +76,7 @@ struct o2hb_node_event {
enum o2hb_callback_type hn_event_type;
struct o2nm_node *hn_node;
int hn_node_num;
+ struct o2hb_heartbeat_resource *hn_res;
};
void o2hb_queue_node_event(struct o2hb_node_event *event,
enum o2hb_callback_type type,
@@ -91,7 +93,7 @@ void o2hb_setup_callback(struct o2hb_cal
enum o2hb_callback_type type,
o2hb_cb_func *func,
void *data,
- int priority);
+ int priority, struct o2hb_heartbeat_resource *res);
int o2hb_register_callback(struct o2hb_callback_func *hc);
int o2hb_unregister_callback(struct o2hb_callback_func *hc);
void o2hb_fill_node_map(unsigned long *map,
diff -ruNpX ../dontdiff linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/quorum.c linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/quorum.c
--- linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/quorum.c 2006-02-21 11:44:38.000000000 -0500
+++ linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/quorum.c 2006-02-21 11:44:41.000000000 -0500
@@ -362,9 +362,9 @@ static int o2quo_register_hb_callbacks(v
int ret;
o2hb_setup_callback(&o2quo_hb_down_cb, O2HB_NODE_DOWN_CB,
- o2quo_hb_down, NULL, O2QUO_HB_PRI);
+ o2quo_hb_down, NULL, O2QUO_HB_PRI, NULL);
o2hb_setup_callback(&o2quo_hb_up_cb, O2HB_NODE_UP_CB,
- o2quo_hb_up, NULL, O2QUO_HB_PRI);
+ o2quo_hb_up, NULL, O2QUO_HB_PRI, NULL);
ret = o2hb_register_callback(&o2quo_hb_up_cb);
if (ret == 0)
diff -ruNpX ../dontdiff linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/tcp.c linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/tcp.c
--- linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/cluster/tcp.c 2006-02-21 11:44:31.000000000 -0500
+++ linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/cluster/tcp.c 2006-02-21 11:44:41.000000000 -0500
@@ -1522,9 +1522,9 @@ int o2net_register_hb_callbacks(void)
int ret;
o2hb_setup_callback(&o2net_hb_down, O2HB_NODE_DOWN_CB,
- o2net_hb_node_down_cb, NULL, O2NET_HB_PRI);
+ o2net_hb_node_down_cb, NULL, O2NET_HB_PRI, NULL);
o2hb_setup_callback(&o2net_hb_up, O2HB_NODE_UP_CB,
- o2net_hb_node_up_cb, NULL, O2NET_HB_PRI);
+ o2net_hb_node_up_cb, NULL, O2NET_HB_PRI, NULL);
ret = o2hb_register_callback(&o2net_hb_up);
if (ret == 0)
diff -ruNpX ../dontdiff linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/dlm/dlmdomain.c linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/dlm/dlmdomain.c
--- linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/dlm/dlmdomain.c 2006-02-21 11:41:25.000000000 -0500
+++ linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/dlm/dlmdomain.c 2006-02-21 11:44:41.000000000 -0500
@@ -991,13 +991,14 @@ static int dlm_register_domain_handlers(
mlog(0, "registering handlers.\n");
o2hb_setup_callback(&dlm->dlm_hb_down, O2HB_NODE_DOWN_CB,
- dlm_hb_node_down_cb, dlm, DLM_HB_NODE_DOWN_PRI);
+ dlm_hb_node_down_cb, dlm,
+ DLM_HB_NODE_DOWN_PRI, NULL);
status = o2hb_register_callback(&dlm->dlm_hb_down);
if (status)
goto bail;
o2hb_setup_callback(&dlm->dlm_hb_up, O2HB_NODE_UP_CB,
- dlm_hb_node_up_cb, dlm, DLM_HB_NODE_UP_PRI);
+ dlm_hb_node_up_cb, dlm, DLM_HB_NODE_UP_PRI, NULL);
status = o2hb_register_callback(&dlm->dlm_hb_up);
if (status)
goto bail;
diff -ruNpX ../dontdiff linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/heartbeat.c linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/heartbeat.c
--- linux-2.6.16-rc4.ocfs2-staging1/fs/ocfs2/heartbeat.c 2006-02-20 13:51:25.000000000 -0500
+++ linux-2.6.16-rc4.ocfs2-staging2/fs/ocfs2/heartbeat.c 2006-02-21 11:44:41.000000000 -0500
@@ -136,10 +136,11 @@ void ocfs2_setup_hb_callbacks(struct ocf
{
o2hb_setup_callback(&osb->osb_hb_down, O2HB_NODE_DOWN_CB,
ocfs2_hb_node_down_cb, osb,
- OCFS2_HB_NODE_DOWN_PRI);
+ OCFS2_HB_NODE_DOWN_PRI, NULL);
o2hb_setup_callback(&osb->osb_hb_up, O2HB_NODE_UP_CB,
- ocfs2_hb_node_up_cb, osb, OCFS2_HB_NODE_UP_PRI);
+ ocfs2_hb_node_up_cb, osb,
+ OCFS2_HB_NODE_UP_PRI, NULL);
/* Not exactly a heartbeat callback, but leads to essentially
* the same path so we set it up here. */
More information about the Ocfs2-devel
mailing list