Skip to content

Commit

Permalink
ocfs2: Proper cleanup in case of error in ocfs2_register_hb_callbacks()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Mar 14, 2007
1 parent c3442e2 commit c24f72c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
6 changes: 2 additions & 4 deletions fs/ocfs2/cluster/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,23 +1682,21 @@ int o2hb_register_callback(struct o2hb_callback_func *hc)
}
EXPORT_SYMBOL_GPL(o2hb_register_callback);

int o2hb_unregister_callback(struct o2hb_callback_func *hc)
void o2hb_unregister_callback(struct o2hb_callback_func *hc)
{
BUG_ON(hc->hc_magic != O2HB_CB_MAGIC);

mlog(ML_HEARTBEAT, "on behalf of %p for funcs %p\n",
__builtin_return_address(0), hc);

if (list_empty(&hc->hc_item))
return 0;
return;

down_write(&o2hb_callback_sem);

list_del_init(&hc->hc_item);

up_write(&o2hb_callback_sem);

return 0;
}
EXPORT_SYMBOL_GPL(o2hb_unregister_callback);

Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/cluster/heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void o2hb_setup_callback(struct o2hb_callback_func *hc,
void *data,
int priority);
int o2hb_register_callback(struct o2hb_callback_func *hc);
int o2hb_unregister_callback(struct o2hb_callback_func *hc);
void o2hb_unregister_callback(struct o2hb_callback_func *hc);
void o2hb_fill_node_map(unsigned long *map,
unsigned bytes);
void o2hb_init(void);
Expand Down
13 changes: 2 additions & 11 deletions fs/ocfs2/cluster/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1638,17 +1638,8 @@ static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num,

void o2net_unregister_hb_callbacks(void)
{
int ret;

ret = o2hb_unregister_callback(&o2net_hb_up);
if (ret < 0)
mlog(ML_ERROR, "Status return %d unregistering heartbeat up "
"callback!\n", ret);

ret = o2hb_unregister_callback(&o2net_hb_down);
if (ret < 0)
mlog(ML_ERROR, "Status return %d unregistering heartbeat down "
"callback!\n", ret);
o2hb_unregister_callback(&o2net_hb_up);
o2hb_unregister_callback(&o2net_hb_down);
}

int o2net_register_hb_callbacks(void)
Expand Down
15 changes: 5 additions & 10 deletions fs/ocfs2/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,27 +164,22 @@ int ocfs2_register_hb_callbacks(struct ocfs2_super *osb)
}

status = o2hb_register_callback(&osb->osb_hb_up);
if (status < 0)
if (status < 0) {
mlog_errno(status);
o2hb_unregister_callback(&osb->osb_hb_down);
}

bail:
return status;
}

void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb)
{
int status;

if (ocfs2_mount_local(osb))
return;

status = o2hb_unregister_callback(&osb->osb_hb_down);
if (status < 0)
mlog_errno(status);

status = o2hb_unregister_callback(&osb->osb_hb_up);
if (status < 0)
mlog_errno(status);
o2hb_unregister_callback(&osb->osb_hb_down);
o2hb_unregister_callback(&osb->osb_hb_up);
}

void ocfs2_stop_heartbeat(struct ocfs2_super *osb)
Expand Down

0 comments on commit c24f72c

Please sign in to comment.