aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/cluster')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c64
-rw-r--r--fs/ocfs2/cluster/heartbeat.h6
-rw-r--r--fs/ocfs2/cluster/nodemanager.c10
-rw-r--r--fs/ocfs2/cluster/nodemanager.h3
-rw-r--r--fs/ocfs2/cluster/tcp.c8
5 files changed, 83 insertions, 8 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 979113479c66..e331f4cb2c81 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1665,7 +1665,56 @@ void o2hb_setup_callback(struct o2hb_callback_func *hc,
1665} 1665}
1666EXPORT_SYMBOL_GPL(o2hb_setup_callback); 1666EXPORT_SYMBOL_GPL(o2hb_setup_callback);
1667 1667
1668int o2hb_register_callback(struct o2hb_callback_func *hc) 1668static struct o2hb_region *o2hb_find_region(const char *region_uuid)
1669{
1670 struct o2hb_region *p, *reg = NULL;
1671
1672 assert_spin_locked(&o2hb_live_lock);
1673
1674 list_for_each_entry(p, &o2hb_all_regions, hr_all_item) {
1675 if (!strcmp(region_uuid, config_item_name(&p->hr_item))) {
1676 reg = p;
1677 break;
1678 }
1679 }
1680
1681 return reg;
1682}
1683
1684static int o2hb_region_get(const char *region_uuid)
1685{
1686 int ret = 0;
1687 struct o2hb_region *reg;
1688
1689 spin_lock(&o2hb_live_lock);
1690
1691 reg = o2hb_find_region(region_uuid);
1692 if (!reg)
1693 ret = -ENOENT;
1694 spin_unlock(&o2hb_live_lock);
1695
1696 if (!ret)
1697 ret = o2nm_depend_item(&reg->hr_item);
1698
1699 return ret;
1700}
1701
1702static void o2hb_region_put(const char *region_uuid)
1703{
1704 struct o2hb_region *reg;
1705
1706 spin_lock(&o2hb_live_lock);
1707
1708 reg = o2hb_find_region(region_uuid);
1709
1710 spin_unlock(&o2hb_live_lock);
1711
1712 if (reg)
1713 o2nm_undepend_item(&reg->hr_item);
1714}
1715
1716int o2hb_register_callback(const char *region_uuid,
1717 struct o2hb_callback_func *hc)
1669{ 1718{
1670 struct o2hb_callback_func *tmp; 1719 struct o2hb_callback_func *tmp;
1671 struct list_head *iter; 1720 struct list_head *iter;
@@ -1681,6 +1730,12 @@ int o2hb_register_callback(struct o2hb_callback_func *hc)
1681 goto out; 1730 goto out;
1682 } 1731 }
1683 1732
1733 if (region_uuid) {
1734 ret = o2hb_region_get(region_uuid);
1735 if (ret)
1736 goto out;
1737 }
1738
1684 down_write(&o2hb_callback_sem); 1739 down_write(&o2hb_callback_sem);
1685 1740
1686 list_for_each(iter, &hbcall->list) { 1741 list_for_each(iter, &hbcall->list) {
@@ -1702,16 +1757,21 @@ out:
1702} 1757}
1703EXPORT_SYMBOL_GPL(o2hb_register_callback); 1758EXPORT_SYMBOL_GPL(o2hb_register_callback);
1704 1759
1705void o2hb_unregister_callback(struct o2hb_callback_func *hc) 1760void o2hb_unregister_callback(const char *region_uuid,
1761 struct o2hb_callback_func *hc)
1706{ 1762{
1707 BUG_ON(hc->hc_magic != O2HB_CB_MAGIC); 1763 BUG_ON(hc->hc_magic != O2HB_CB_MAGIC);
1708 1764
1709 mlog(ML_HEARTBEAT, "on behalf of %p for funcs %p\n", 1765 mlog(ML_HEARTBEAT, "on behalf of %p for funcs %p\n",
1710 __builtin_return_address(0), hc); 1766 __builtin_return_address(0), hc);
1711 1767
1768 /* XXX Can this happen _with_ a region reference? */
1712 if (list_empty(&hc->hc_item)) 1769 if (list_empty(&hc->hc_item))
1713 return; 1770 return;
1714 1771
1772 if (region_uuid)
1773 o2hb_region_put(region_uuid);
1774
1715 down_write(&o2hb_callback_sem); 1775 down_write(&o2hb_callback_sem);
1716 1776
1717 list_del_init(&hc->hc_item); 1777 list_del_init(&hc->hc_item);
diff --git a/fs/ocfs2/cluster/heartbeat.h b/fs/ocfs2/cluster/heartbeat.h
index cc6d40b39771..35397dd5ecdb 100644
--- a/fs/ocfs2/cluster/heartbeat.h
+++ b/fs/ocfs2/cluster/heartbeat.h
@@ -69,8 +69,10 @@ void o2hb_setup_callback(struct o2hb_callback_func *hc,
69 o2hb_cb_func *func, 69 o2hb_cb_func *func,
70 void *data, 70 void *data,
71 int priority); 71 int priority);
72int o2hb_register_callback(struct o2hb_callback_func *hc); 72int o2hb_register_callback(const char *region_uuid,
73void o2hb_unregister_callback(struct o2hb_callback_func *hc); 73 struct o2hb_callback_func *hc);
74void o2hb_unregister_callback(const char *region_uuid,
75 struct o2hb_callback_func *hc);
74void o2hb_fill_node_map(unsigned long *map, 76void o2hb_fill_node_map(unsigned long *map,
75 unsigned bytes); 77 unsigned bytes);
76void o2hb_init(void); 78void o2hb_init(void);
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 48b77d113cb2..eab46d8a7c8c 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -900,6 +900,16 @@ static struct o2nm_cluster_group o2nm_cluster_group = {
900 }, 900 },
901}; 901};
902 902
903int o2nm_depend_item(struct config_item *item)
904{
905 return configfs_depend_item(&o2nm_cluster_group.cs_subsys, item);
906}
907
908void o2nm_undepend_item(struct config_item *item)
909{
910 configfs_undepend_item(&o2nm_cluster_group.cs_subsys, item);
911}
912
903static void __exit exit_o2nm(void) 913static void __exit exit_o2nm(void)
904{ 914{
905 if (ocfs2_table_header) 915 if (ocfs2_table_header)
diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h
index 070522138ae2..55ae1a00d735 100644
--- a/fs/ocfs2/cluster/nodemanager.h
+++ b/fs/ocfs2/cluster/nodemanager.h
@@ -77,4 +77,7 @@ struct o2nm_node *o2nm_get_node_by_ip(__be32 addr);
77void o2nm_node_get(struct o2nm_node *node); 77void o2nm_node_get(struct o2nm_node *node);
78void o2nm_node_put(struct o2nm_node *node); 78void o2nm_node_put(struct o2nm_node *node);
79 79
80int o2nm_depend_item(struct config_item *item);
81void o2nm_undepend_item(struct config_item *item);
82
80#endif /* O2CLUSTER_NODEMANAGER_H */ 83#endif /* O2CLUSTER_NODEMANAGER_H */
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 0b229a9c7952..d58c7dddb853 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -1638,8 +1638,8 @@ static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num,
1638 1638
1639void o2net_unregister_hb_callbacks(void) 1639void o2net_unregister_hb_callbacks(void)
1640{ 1640{
1641 o2hb_unregister_callback(&o2net_hb_up); 1641 o2hb_unregister_callback(NULL, &o2net_hb_up);
1642 o2hb_unregister_callback(&o2net_hb_down); 1642 o2hb_unregister_callback(NULL, &o2net_hb_down);
1643} 1643}
1644 1644
1645int o2net_register_hb_callbacks(void) 1645int o2net_register_hb_callbacks(void)
@@ -1651,9 +1651,9 @@ int o2net_register_hb_callbacks(void)
1651 o2hb_setup_callback(&o2net_hb_up, O2HB_NODE_UP_CB, 1651 o2hb_setup_callback(&o2net_hb_up, O2HB_NODE_UP_CB,
1652 o2net_hb_node_up_cb, NULL, O2NET_HB_PRI); 1652 o2net_hb_node_up_cb, NULL, O2NET_HB_PRI);
1653 1653
1654 ret = o2hb_register_callback(&o2net_hb_up); 1654 ret = o2hb_register_callback(NULL, &o2net_hb_up);
1655 if (ret == 0) 1655 if (ret == 0)
1656 ret = o2hb_register_callback(&o2net_hb_down); 1656 ret = o2hb_register_callback(NULL, &o2net_hb_down);
1657 1657
1658 if (ret) 1658 if (ret)
1659 o2net_unregister_hb_callbacks(); 1659 o2net_unregister_hb_callbacks();