ocfs2: Proper cleanup in case of error in ocfs2_register_hb_callbacks()

If ocfs2_register_hb_callbacks() succeeds on its first callback but fails
its second, it doesn't release the first on the way out. Fix that.

While we're at it, o2hb_unregister_callback() never returns anything but
0, so let's make it void.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

authored by Joel Becker and committed by Mark Fasheh c24f72cc c3442e29

+10 -26
+2 -4
fs/ocfs2/cluster/heartbeat.c
··· 1682 } 1683 EXPORT_SYMBOL_GPL(o2hb_register_callback); 1684 1685 - int o2hb_unregister_callback(struct o2hb_callback_func *hc) 1686 { 1687 BUG_ON(hc->hc_magic != O2HB_CB_MAGIC); 1688 ··· 1690 __builtin_return_address(0), hc); 1691 1692 if (list_empty(&hc->hc_item)) 1693 - return 0; 1694 1695 down_write(&o2hb_callback_sem); 1696 1697 list_del_init(&hc->hc_item); 1698 1699 up_write(&o2hb_callback_sem); 1700 - 1701 - return 0; 1702 } 1703 EXPORT_SYMBOL_GPL(o2hb_unregister_callback); 1704
··· 1682 } 1683 EXPORT_SYMBOL_GPL(o2hb_register_callback); 1684 1685 + void o2hb_unregister_callback(struct o2hb_callback_func *hc) 1686 { 1687 BUG_ON(hc->hc_magic != O2HB_CB_MAGIC); 1688 ··· 1690 __builtin_return_address(0), hc); 1691 1692 if (list_empty(&hc->hc_item)) 1693 + return; 1694 1695 down_write(&o2hb_callback_sem); 1696 1697 list_del_init(&hc->hc_item); 1698 1699 up_write(&o2hb_callback_sem); 1700 } 1701 EXPORT_SYMBOL_GPL(o2hb_unregister_callback); 1702
+1 -1
fs/ocfs2/cluster/heartbeat.h
··· 70 void *data, 71 int priority); 72 int o2hb_register_callback(struct o2hb_callback_func *hc); 73 - int o2hb_unregister_callback(struct o2hb_callback_func *hc); 74 void o2hb_fill_node_map(unsigned long *map, 75 unsigned bytes); 76 void o2hb_init(void);
··· 70 void *data, 71 int priority); 72 int o2hb_register_callback(struct o2hb_callback_func *hc); 73 + void o2hb_unregister_callback(struct o2hb_callback_func *hc); 74 void o2hb_fill_node_map(unsigned long *map, 75 unsigned bytes); 76 void o2hb_init(void);
+2 -11
fs/ocfs2/cluster/tcp.c
··· 1638 1639 void o2net_unregister_hb_callbacks(void) 1640 { 1641 - int ret; 1642 - 1643 - ret = o2hb_unregister_callback(&o2net_hb_up); 1644 - if (ret < 0) 1645 - mlog(ML_ERROR, "Status return %d unregistering heartbeat up " 1646 - "callback!\n", ret); 1647 - 1648 - ret = o2hb_unregister_callback(&o2net_hb_down); 1649 - if (ret < 0) 1650 - mlog(ML_ERROR, "Status return %d unregistering heartbeat down " 1651 - "callback!\n", ret); 1652 } 1653 1654 int o2net_register_hb_callbacks(void)
··· 1638 1639 void o2net_unregister_hb_callbacks(void) 1640 { 1641 + o2hb_unregister_callback(&o2net_hb_up); 1642 + o2hb_unregister_callback(&o2net_hb_down); 1643 } 1644 1645 int o2net_register_hb_callbacks(void)
+5 -10
fs/ocfs2/heartbeat.c
··· 164 } 165 166 status = o2hb_register_callback(&osb->osb_hb_up); 167 - if (status < 0) 168 mlog_errno(status); 169 170 bail: 171 return status; ··· 175 176 void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb) 177 { 178 - int status; 179 - 180 if (ocfs2_mount_local(osb)) 181 return; 182 183 - status = o2hb_unregister_callback(&osb->osb_hb_down); 184 - if (status < 0) 185 - mlog_errno(status); 186 - 187 - status = o2hb_unregister_callback(&osb->osb_hb_up); 188 - if (status < 0) 189 - mlog_errno(status); 190 } 191 192 void ocfs2_stop_heartbeat(struct ocfs2_super *osb)
··· 164 } 165 166 status = o2hb_register_callback(&osb->osb_hb_up); 167 + if (status < 0) { 168 mlog_errno(status); 169 + o2hb_unregister_callback(&osb->osb_hb_down); 170 + } 171 172 bail: 173 return status; ··· 173 174 void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb) 175 { 176 if (ocfs2_mount_local(osb)) 177 return; 178 179 + o2hb_unregister_callback(&osb->osb_hb_down); 180 + o2hb_unregister_callback(&osb->osb_hb_up); 181 } 182 183 void ocfs2_stop_heartbeat(struct ocfs2_super *osb)