ocfs2: allow per-resource node status queries
PATCH 9/14 ocfs2: allow per-resource node status queries
This patch allows callers of o2hb_fill_node_map* and o2hb_check_{,local_}node_heartbeating* to specify a particular heartbeat resource to find status on.
If the query is just to discover if the node is up *at all*, NULL can be specified.
The disk heartbeat currently doesn't make a distinction between different resources and simply maintains a unified node map. The userspace heartbeat resource will allow distinct per-resource membership, so this is needed to lay the groundwork.
The actual file system now queries the UUID sooner and uses it to discover membership in the resource for that UUID.
fs/ocfs2/cluster/disk_heartbeat.c | 4 +- fs/ocfs2/cluster/heartbeat.c | 62 +++++++++++++++++++++++++++++------- fs/ocfs2/cluster/heartbeat.h | 29 +++++++++++++---- fs/ocfs2/cluster/nodemanager.c | 13 ------- fs/ocfs2/cluster/nodemanager.h | 12 +++++++ fs/ocfs2/cluster/tcp.c | 2 - fs/ocfs2/dlm/dlmdomain.c | 7 ++-- fs/ocfs2/heartbeat.c | 24 ++++++++++++-- fs/ocfs2/heartbeat.h | 2 - fs/ocfs2/ocfs2.h | 1 fs/ocfs2/super.c | 64 ++++++++++++++++++++++++++++---------- 11 files changed, 164 insertions(+), 56 deletions(-)
Signed-off-by Jeff Mahoney <[email protected]>
fs/ocfs2/cluster/disk_heartbeat.c +3 -1
@@ -850,11 +850,13 @@ static int o2hb_thread(void *data) }/* if we're already in a callback then we're already serialized by the sem */ -static void o2hb_disk_fill_node_map (unsigned long *map,size_t bytes) +static int o2hb_disk_fill_node_map (const char *resource,unsigned long *map, +size_t bytes) {BUG_ON (bytes < (BITS_TO_LONGS (O2NM_MAX_NODES ) *sizeof (unsigned long )));memcpy (map, &o2hb_live_node_bitmap, bytes); +return 0 ; }/*
fs/ocfs2/cluster/heartbeat.c +50 -12
127 lines not on this page · raw message
fs/ocfs2/cluster/heartbeat.h +22 -7
@@ -47,7 +47,8 @@ struct o2hb_heartbeat_group {const char *hs_name;int (*init)(struct o2hb_heartbeat_group *hs);void (*exit)(struct o2hb_heartbeat_group *hs); -void (*fill_node_map)(unsigned long *map,size_t bytes); +int (*fill_node_map)(const char *resource,unsigned long *map, +size_t bytes);atomic_t hs_count;struct list_head hs_list; };
@@ -96,14 +97,18 @@ void o2hb_setup_callback(struct o2hb_cal 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, +int o2hb_fill_node_map (const char *resource,unsigned long *map,unsigned bytes); -void o2hb_fill_node_map_from_callback (unsigned long *map,unsigned bytes); +int o2hb_fill_node_map_from_callback (const char *resource,unsigned long *map, +unsigned bytes);void o2hb_init (void ); -int o2hb_check_node_heartbeating (u8 node_num); -int o2hb_check_node_heartbeating_from_callback (u8 node_num); -int o2hb_check_local_node_heartbeating (void ); -int o2hb_check_local_node_heartbeating_from_callback (void ); +int o2hb_check_node_heartbeating (const char *resource,u8 node_num); +int o2hb_check_node_heartbeating_from_callback (const char *resource, +u8 node_num); +int o2hb_check_local_node_heartbeating (const char *resource); +int o2hb_check_local_node_heartbeating_from_callback (const char *resource); + +struct o2hb_heartbeat_resource *o2hb_heartbeat_resource_get_by_name (const char * name);static inline struct o2hb_heartbeat_group *to_o2hb_heartbeat_group (struct config_group *group) {
@@ -114,4 +119,14 @@ static inline struct o2hb_heartbeat_reso { return container_of(item, struct o2hb_heartbeat_resource, hr_item); } + +static inline void o2hb_heartbeat_resource_get (struct o2hb_heartbeat_resource *hbres) +{ +config_item_get (&hbres->hr_item); +} + +static inline void o2hb_heartbeat_resource_put (struct o2hb_heartbeat_resource *hbres) +{ +config_item_put (&hbres->hr_item); +}#endif /* O2CLUSTER_HEARTBEAT_H */
fs/ocfs2/cluster/nodemanager.c +1 -12
@@ -36,7 +36,7 @@/* for now we operate under the assertion that there can be only one * cluster active at a time. Changing this will require trickling * cluster references throughout where nodes are looked up */ -static struct o2nm_cluster *o2nm_single_cluster =NULL ; +struct o2nm_cluster *o2nm_single_cluster =NULL ;#define OCFS2_MAX_HB_CTL_PATH 256static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH ] ="/sbin/ocfs2_hb_ctl" ;
@@ -98,17 +98,6 @@ const char *o2nm_get_hb_ctl_path(void) }EXPORT_SYMBOL_GPL (o2nm_get_hb_ctl_path); -struct o2nm_cluster { -struct config_group cl_group; -unsigned cl_has_local:1 ; -u8 cl_local_node; -rwlock_t cl_nodes_lock; -struct o2nm_node *cl_nodes[O2NM_MAX_NODES ]; -struct rb_root cl_node_ip_tree; -/* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */ -unsigned long cl_nodes_bitmap[BITS_TO_LONGS (O2NM_MAX_NODES )]; -}; -struct o2nm_node *o2nm_get_node_by_num (u8 node_num) {struct o2nm_node *node =NULL ;
fs/ocfs2/cluster/nodemanager.h +12 -0
@@ -53,6 +53,18 @@ struct o2nm_node {unsigned long nd_set_attributes; }; +struct o2nm_cluster { +struct config_group cl_group; +unsigned cl_has_local:1 ; +u8 cl_local_node; +rwlock_t cl_nodes_lock; +struct o2nm_node *cl_nodes[O2NM_MAX_NODES ]; +struct rb_root cl_node_ip_tree; +/* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */ +unsigned long cl_nodes_bitmap[BITS_TO_LONGS (O2NM_MAX_NODES )]; +}; +extern struct o2nm_cluster *o2nm_single_cluster; +u8 o2nm_this_node (void );int o2nm_configured_node_map (unsigned long *map,unsigned bytes);
fs/ocfs2/cluster/tcp.c +1 -1
@@ -1609,7 +1609,7 @@ static int o2net_accept_one(struct socke/* this happens all the time when the other node sees our heartbeat * and tries to connect before we see their heartbeat */ -if (!o2hb_check_node_heartbeating_from_callback (node->nd_num)) { +if (!o2hb_check_node_heartbeating_from_callback (NULL , node->nd_num)) { mlog(ML_CONN, "attempt to connect from node '%s' at " "%u.%u.%u.%u:%d but it isn't heartbeating\n", node->nd_name, NIPQUAD(sin.sin_addr.s_addr),
fs/ocfs2/dlm/dlmdomain.c +4 -3
@@ -567,7 +567,7 @@ static int dlm_query_join_handler(struct* to back off and try again. This gives heartbeat a chance * to catch up. */ -if (!o2hb_check_node_heartbeating (query->node_idx)) { +if (!o2hb_check_node_heartbeating (query->domain, query->node_idx)) {mlog (0 ,"node %u is not in our live map yet\n" , query->node_idx);
@@ -899,7 +899,8 @@ static int dlm_try_to_join_domain(struct/* group sem locking should work for us here -- we're already * registered for heartbeat events so filling this should be * atomic wrt getting those handlers called. */ -o2hb_fill_node_map (dlm->live_nodes_map,sizeof (dlm->live_nodes_map)); +o2hb_fill_node_map (dlm->name, dlm->live_nodes_map, +sizeof (dlm->live_nodes_map));spin_lock (&dlm->spinlock);memcpy (ctxt->live_map, dlm->live_nodes_map,sizeof (ctxt->live_map));
@@ -1289,7 +1290,7 @@ struct dlm_ctxt * dlm_register_domain(co goto leave; } -if (!o2hb_check_local_node_heartbeating ()) { +if (!o2hb_check_local_node_heartbeating (domain)) {mlog (ML_ERROR ,"the local node has not been configured, or is " "not heartbeating\n" ); ret = -EPROTO ;
fs/ocfs2/heartbeat.c +21 -3
@@ -76,6 +76,13 @@ static void ocfs2_do_node_down(int node_mlog (0 ,"ocfs2: node down event for %d\n" , node_num); +#if 0 +if (osb->node_num == node_num) { +ocfs2_handle_fencing (node_num, osb); +return ; + } +#endif +if (!osb->dlm) {/* * No DLM means we're not even ready to participate yet.
@@ -132,21 +139,27 @@ static void ocfs2_hb_node_up_cb(struct oocfs2_node_map_clear_bit (osb, &osb->umount_map, node_num); } -void ocfs2_setup_hb_callbacks (struct ocfs2_super *osb) +int ocfs2_setup_hb_callbacks (struct ocfs2_super *osb) { + osb->osb_hb_res =o2hb_heartbeat_resource_get_by_name (osb->uuid_str); + +if (!osb->osb_hb_res) +return -EINVAL ; +o2hb_setup_callback (&osb->osb_hb_down,O2HB_NODE_DOWN_CB , ocfs2_hb_node_down_cb, osb, -OCFS2_HB_NODE_DOWN_PRI ,NULL ); +OCFS2_HB_NODE_DOWN_PRI , osb->osb_hb_res);o2hb_setup_callback (&osb->osb_hb_up,O2HB_NODE_UP_CB , ocfs2_hb_node_up_cb, osb, -OCFS2_HB_NODE_UP_PRI ,NULL ); +OCFS2_HB_NODE_UP_PRI , osb->osb_hb_res);/* Not exactly a heartbeat callback, but leads to essentially * the same path so we set it up here. */ dlm_setup_eviction_cb (&osb->osb_eviction_cb, ocfs2_dlm_eviction_cb, osb); +return 0 ; }/* Most functions here are just stubs for now... */
@@ -172,6 +185,9 @@ void ocfs2_clear_hb_callbacks(struct ocf {int status; +if (osb->osb_hb_res ==NULL ) +return ; + status =o2hb_unregister_callback (&osb->osb_hb_down);if (status <0 )mlog_errno (status);
@@ -179,6 +195,8 @@ void ocfs2_clear_hb_callbacks(struct ocf status =o2hb_unregister_callback (&osb->osb_hb_up);if (status <0 )mlog_errno (status); + +o2hb_heartbeat_resource_put (osb->osb_hb_res); }void ocfs2_stop_heartbeat (struct ocfs2_super *osb)
fs/ocfs2/heartbeat.h +1 -1
@@ -28,7 +28,7 @@void ocfs2_init_node_maps (struct ocfs2_super *osb); -void ocfs2_setup_hb_callbacks (struct ocfs2_super *osb); +int ocfs2_setup_hb_callbacks (struct ocfs2_super *osb);int ocfs2_register_hb_callbacks (struct ocfs2_super *osb);void ocfs2_clear_hb_callbacks (struct ocfs2_super *osb);void ocfs2_stop_heartbeat (struct ocfs2_super *osb);
fs/ocfs2/ocfs2.h +1 -0
@@ -288,6 +288,7 @@ struct ocfs2_superunsigned int net_response_ids;struct list_head net_response_list; +struct o2hb_heartbeat_resource *osb_hb_res;struct o2hb_callback_func osb_hb_up;struct o2hb_callback_func osb_hb_down;
fs/ocfs2/super.c +48 -16
103 lines not on this page · raw message