aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2007-06-15 00:40:49 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2007-07-10 20:19:40 -0400
commit14829422be6d6b6721f61b1e749acf5a9cb664d8 (patch)
tree4a8c931b431653aa5e35523f43ebcddffa8641b8 /fs
parent631d1febab8e546e3bb800bdfe2c212b8adf87de (diff)
ocfs2: Depend on configfs heartbeat items.
ocfs2 mounts require a heartbeat region. Use the new configfs_depend_item() facility to actually depend on them so they can't go away from under us. First, teach cluster/nodemanager.c to depend an item on the o2cb subsystem. Then teach o2hb_register_callbacks to take a UUID and depend on the appropriate region. Finally, teach all users of o2hb to pass a UUID or NULL if they don't require a pin. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs')
-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
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c8
-rw-r--r--fs/ocfs2/heartbeat.c10
7 files changed, 92 insertions, 17 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();
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index d836b98dd99a..6954565b8ccb 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -1128,8 +1128,8 @@ bail:
1128 1128
1129static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm) 1129static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm)
1130{ 1130{
1131 o2hb_unregister_callback(&dlm->dlm_hb_up); 1131 o2hb_unregister_callback(NULL, &dlm->dlm_hb_up);
1132 o2hb_unregister_callback(&dlm->dlm_hb_down); 1132 o2hb_unregister_callback(NULL, &dlm->dlm_hb_down);
1133 o2net_unregister_handler_list(&dlm->dlm_domain_handlers); 1133 o2net_unregister_handler_list(&dlm->dlm_domain_handlers);
1134} 1134}
1135 1135
@@ -1141,13 +1141,13 @@ static int dlm_register_domain_handlers(struct dlm_ctxt *dlm)
1141 1141
1142 o2hb_setup_callback(&dlm->dlm_hb_down, O2HB_NODE_DOWN_CB, 1142 o2hb_setup_callback(&dlm->dlm_hb_down, O2HB_NODE_DOWN_CB,
1143 dlm_hb_node_down_cb, dlm, DLM_HB_NODE_DOWN_PRI); 1143 dlm_hb_node_down_cb, dlm, DLM_HB_NODE_DOWN_PRI);
1144 status = o2hb_register_callback(&dlm->dlm_hb_down); 1144 status = o2hb_register_callback(NULL, &dlm->dlm_hb_down);
1145 if (status) 1145 if (status)
1146 goto bail; 1146 goto bail;
1147 1147
1148 o2hb_setup_callback(&dlm->dlm_hb_up, O2HB_NODE_UP_CB, 1148 o2hb_setup_callback(&dlm->dlm_hb_up, O2HB_NODE_UP_CB,
1149 dlm_hb_node_up_cb, dlm, DLM_HB_NODE_UP_PRI); 1149 dlm_hb_node_up_cb, dlm, DLM_HB_NODE_UP_PRI);
1150 status = o2hb_register_callback(&dlm->dlm_hb_up); 1150 status = o2hb_register_callback(NULL, &dlm->dlm_hb_up);
1151 if (status) 1151 if (status)
1152 goto bail; 1152 goto bail;
1153 1153
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c
index b25ef63781ba..352eb4a13f98 100644
--- a/fs/ocfs2/heartbeat.c
+++ b/fs/ocfs2/heartbeat.c
@@ -157,16 +157,16 @@ int ocfs2_register_hb_callbacks(struct ocfs2_super *osb)
157 if (ocfs2_mount_local(osb)) 157 if (ocfs2_mount_local(osb))
158 return 0; 158 return 0;
159 159
160 status = o2hb_register_callback(&osb->osb_hb_down); 160 status = o2hb_register_callback(osb->uuid_str, &osb->osb_hb_down);
161 if (status < 0) { 161 if (status < 0) {
162 mlog_errno(status); 162 mlog_errno(status);
163 goto bail; 163 goto bail;
164 } 164 }
165 165
166 status = o2hb_register_callback(&osb->osb_hb_up); 166 status = o2hb_register_callback(osb->uuid_str, &osb->osb_hb_up);
167 if (status < 0) { 167 if (status < 0) {
168 mlog_errno(status); 168 mlog_errno(status);
169 o2hb_unregister_callback(&osb->osb_hb_down); 169 o2hb_unregister_callback(osb->uuid_str, &osb->osb_hb_down);
170 } 170 }
171 171
172bail: 172bail:
@@ -178,8 +178,8 @@ void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb)
178 if (ocfs2_mount_local(osb)) 178 if (ocfs2_mount_local(osb))
179 return; 179 return;
180 180
181 o2hb_unregister_callback(&osb->osb_hb_down); 181 o2hb_unregister_callback(osb->uuid_str, &osb->osb_hb_down);
182 o2hb_unregister_callback(&osb->osb_hb_up); 182 o2hb_unregister_callback(osb->uuid_str, &osb->osb_hb_up);
183} 183}
184 184
185void ocfs2_stop_heartbeat(struct ocfs2_super *osb) 185void ocfs2_stop_heartbeat(struct ocfs2_super *osb)