[Ocfs2-commits] khackel commits r1915 - in branches/dlm-reco-mig/fs/ocfs2: . cluster dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Feb 28 13:24:56 CST 2005


Author: khackel
Date: 2005-02-28 13:24:54 -0600 (Mon, 28 Feb 2005)
New Revision: 1915

Modified:
   branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.c
   branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.h
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmfs.c
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h
   branches/dlm-reco-mig/fs/ocfs2/dlm/userdlm.c
   branches/dlm-reco-mig/fs/ocfs2/heartbeat.c
   branches/dlm-reco-mig/fs/ocfs2/ocfs.h
Log:
o Merged revision 1911:1914 from trunk
        - [1914] heartbeat registration cleanups



Modified: branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.c	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.c	2005-02-28 19:24:54 UTC (rev 1915)
@@ -899,57 +899,58 @@
 	return &hb_callbacks[type];
 }
 
-int hb_register_callback(int type, hb_cb_func *func, void *data, int priority)
+void hb_setup_callback(struct hb_callback_func *hc, int type, hb_cb_func *func,
+		       void *data, int priority)
 {
-	hb_callback_func *f, *tmp;
+	INIT_LIST_HEAD(&hc->hc_item);
+	hc->hc_func = func;
+	hc->hc_data = data;
+	hc->hc_priority = priority;
+	hc->hc_type = type;
+}
+EXPORT_SYMBOL(hb_setup_callback);
+
+int hb_register_callback(struct hb_callback_func *hc)
+{
+	struct hb_callback_func *tmp;
 	struct list_head *iter;
 	struct hb_callback *hbcall;
 	int ret;
 
-	hbcall = hbcall_from_type(type);
+	BUG_ON(!list_empty(&hc->hc_item));
+
+	hbcall = hbcall_from_type(hc->hc_type);
 	if (IS_ERR(hbcall))
 		return PTR_ERR(hbcall);
 
-	f = kmalloc(sizeof(hb_callback_func), GFP_KERNEL);
-	if (f == NULL)
-		return -ENOMEM;
-	memset(f, 0, sizeof(hb_callback_func));
-	f->func = func;
-	f->data = data;
-	f->priority = priority;
-	INIT_LIST_HEAD(&f->list);
-
 	ret = down_interruptible(&hbcall->sem);
 	if (ret)
 		goto out;
 	
 	list_for_each(iter, &hbcall->list) {
-		tmp = list_entry (iter, hb_callback_func, list);
-		if (priority < tmp->priority) {
-			list_add_tail(&f->list, iter);
+		tmp = list_entry(iter, struct hb_callback_func, hc_item);
+		if (hc->hc_priority < tmp->hc_priority) {
+			list_add_tail(&hc->hc_item, iter);
 			break;
 		}
 	}
-	if (list_empty(&f->list)) 
-		list_add_tail(&f->list, &hbcall->list);
+	if (list_empty(&hc->hc_item)) 
+		list_add_tail(&hc->hc_item, &hbcall->list);
 
-	f = NULL;
 	up(&hbcall->sem);
 out:
-	if (f)
-		kfree(f);
 	return ret;
 }
 EXPORT_SYMBOL(hb_register_callback);
 
-int hb_unregister_callback(int type, hb_cb_func *func, void *data)
+int hb_unregister_callback(struct hb_callback_func *hc)
 {
-	struct list_head *iter, *tmpiter;
-	int ret = -EINVAL;
-	hb_callback_func *f = NULL;
 	struct hb_callback *hbcall;
+	int ret;
 
-	hbcall = hbcall_from_type(type);
+	BUG_ON(list_empty(&hc->hc_item));
+
+	hbcall = hbcall_from_type(hc->hc_type);
 	if (IS_ERR(hbcall))
 		return PTR_ERR(hbcall);
 
@@ -957,21 +958,11 @@
 	if (ret)
 		goto out;
 
-	list_for_each_safe(iter, tmpiter, &hbcall->list) {
-		f = list_entry (iter, hb_callback_func, list);
-		if (f->func == func && f->data == data) {
-			list_del(&f->list);
-			ret = 0;
-			break;
-		}
-	}
+	list_del_init(&hc->hc_item);
 
 	up(&hbcall->sem);
 
 out:
-	if (f)
-		kfree(f);
-
 	return ret;
 }
 EXPORT_SYMBOL(hb_unregister_callback);
@@ -979,7 +970,7 @@
 static void hb_do_callbacks(int type, void *ptr1, void *ptr2, int idx)
 {
 	struct list_head *iter;
-	hb_callback_func *f;
+	struct hb_callback_func *f;
 	struct hb_callback *hbcall;
 
 	hbcall = hbcall_from_type(type);
@@ -992,8 +983,8 @@
 	}
 	
 	list_for_each(iter, &hbcall->list) {
-		f = list_entry (iter, hb_callback_func, list);
-		(f->func) (ptr1, ptr2, idx, f->data);
+		f = list_entry(iter, struct hb_callback_func, hc_item);
+		(f->hc_func)(ptr1, ptr2, idx, f->hc_data);
 	}
 
 	up(&hbcall->sem);

Modified: branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.h	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/cluster/heartbeat.h	2005-02-28 19:24:54 UTC (rev 1915)
@@ -73,15 +73,14 @@
 
 typedef void (hb_cb_func)(struct inode *, struct inode *, int, void *);
 
-typedef struct _hb_callback_func
-{
-	struct list_head list;
-	hb_cb_func *func;
-	void *data;
-	int priority;
-} hb_callback_func;
+struct hb_callback_func {
+	struct list_head	hc_item;
+	hb_cb_func		*hc_func;
+	void			*hc_data;
+	int			hc_priority;
+	int			hc_type;
+};
 
-
 enum {
 	HB_Root = 1,
 	HB_Disk,
@@ -98,8 +97,10 @@
 #define HB_NET_MARGIN              30
 
 
-int hb_unregister_callback(int type, hb_cb_func *func, void *data);
-int hb_register_callback(int type, hb_cb_func *func, void *data, int priority);
+void hb_setup_callback(struct hb_callback_func *hc, int type, hb_cb_func *func,
+		      void *data, int priority);
+int hb_register_callback(struct hb_callback_func *hc);
+int hb_unregister_callback(struct hb_callback_func *hc); 
 int hb_fill_node_map(struct inode *group, void *map, int size);
 
 

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmfs.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmfs.c	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmfs.c	2005-02-28 19:24:54 UTC (rev 1915)
@@ -42,6 +42,7 @@
 
 #include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
+#include "cluster/heartbeat.h"
 #include "cluster/tcp.h"
 
 #include "dlmcommon.h"

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c	2005-02-28 19:24:54 UTC (rev 1915)
@@ -77,8 +77,8 @@
 	if (atomic_dec_and_lock(&mle->refcnt, &dlm_master_lock)) {
 		list_del(&mle->list);
 		spin_unlock(&dlm_master_lock);
-		hb_unregister_callback(HB_NODE_DOWN_CB, dlm_mle_node_down, mle);
-		hb_unregister_callback(HB_NODE_UP_CB, dlm_mle_node_up, mle);
+		hb_unregister_callback(&mle->mle_hb_down);
+		hb_unregister_callback(&mle->mle_hb_up);
 		kfree(mle);
 	}
 }
@@ -124,12 +124,13 @@
 	clear_bit(dlm->group_index, mle->vote_map);
 	clear_bit(dlm->group_index, mle->node_map);
 
-#warning cannot do this here cuz this kmallocs and we are under a spinlock 
-	if (hb_register_callback(HB_NODE_DOWN_CB, dlm_mle_node_down, mle, 
-				 DLM_HB_NODE_DOWN_PRI+1) 
-	    ||
-	    hb_register_callback(HB_NODE_UP_CB, dlm_mle_node_up, mle, 
-				 DLM_HB_NODE_UP_PRI+1)) {
+	hb_setup_callback(&mle->mle_hb_down, HB_NODE_DOWN_CB,
+			  dlm_mle_node_down, mle, DLM_HB_NODE_DOWN_PRI+1);
+	hb_setup_callback(&mle->mle_hb_up, HB_NODE_UP_CB,
+			  dlm_mle_node_up, mle, DLM_HB_NODE_UP_PRI+1);
+
+	if (hb_register_callback(&mle->mle_hb_down) || 
+	    hb_register_callback(&mle->mle_hb_up)) {
 		ret = -EINVAL;
 	}
 

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c	2005-02-28 19:24:54 UTC (rev 1915)
@@ -574,8 +574,8 @@
 	/* TODO: Any network communication involving shutting this guy
 	 * down happens here. */
 
-	hb_unregister_callback(HB_NODE_UP_CB, dlm_hb_node_up_cb, dlm);
-	hb_unregister_callback(HB_NODE_DOWN_CB, dlm_hb_node_down_cb, dlm);
+	hb_unregister_callback(&dlm->dlm_hb_up);
+	hb_unregister_callback(&dlm->dlm_hb_down);
 
 	/* if the network code had any unregister calls, they would be here. */
 
@@ -681,17 +681,15 @@
 
 	dlmprintk("Join domain %s\n", dlm->name);
 
-	status = hb_register_callback(HB_NODE_DOWN_CB,
-				      dlm_hb_node_down_cb,
-				      dlm,
-				      DLM_HB_NODE_DOWN_PRI);
+	hb_setup_callback(&dlm->dlm_hb_down, HB_NODE_DOWN_CB,
+			  dlm_hb_node_down_cb, dlm, DLM_HB_NODE_DOWN_PRI);
+	status = hb_register_callback(&dlm->dlm_hb_down);
 	if (status)
 		goto bail;
 
-	status = hb_register_callback(HB_NODE_UP_CB,
-				      dlm_hb_node_up_cb,
-				      dlm, 
-				      DLM_HB_NODE_UP_PRI);
+	hb_setup_callback(&dlm->dlm_hb_up, HB_NODE_UP_CB, dlm_hb_node_up_cb,
+			  dlm, DLM_HB_NODE_UP_PRI);
+	status = hb_register_callback(&dlm->dlm_hb_up);
 	if (status)
 		goto bail;
 

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h	2005-02-28 19:24:54 UTC (rev 1915)
@@ -220,6 +220,8 @@
 	struct kref dlm_refs;
 	dlm_ctxt_state dlm_state;
 	unsigned int num_joins;
+	struct hb_callback_func dlm_hb_up;
+	struct hb_callback_func dlm_hb_down;
 };
 
 #define DLM_LOCK_RES_UNINITED             0x00000001
@@ -337,6 +339,8 @@
 		dlm_lock_resource *res;
 		dlm_lock_name name;
 	} u;
+	struct hb_callback_func mle_hb_up;
+	struct hb_callback_func mle_hb_down;
 } dlm_master_list_entry;
 
 

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/userdlm.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/userdlm.c	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/userdlm.c	2005-02-28 19:24:54 UTC (rev 1915)
@@ -39,6 +39,7 @@
 
 #include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
+#include "cluster/heartbeat.h"
 #include "cluster/tcp.h"
 
 #include "dlmcommon.h"

Modified: branches/dlm-reco-mig/fs/ocfs2/heartbeat.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/heartbeat.c	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/heartbeat.c	2005-02-28 19:24:54 UTC (rev 1915)
@@ -129,19 +129,17 @@
 {
 	int status;
 
-	status = hb_register_callback(HB_NODE_DOWN_CB,
-				      ocfs2_hb_node_down_cb,
-				      osb,
-				      OCFS2_HB_NODE_DOWN_PRI);
+	hb_setup_callback(&osb->osb_hb_down, HB_NODE_DOWN_CB,
+			  ocfs2_hb_node_down_cb, osb, OCFS2_HB_NODE_DOWN_PRI);
+	status = hb_register_callback(&osb->osb_hb_down);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
 
-	status = hb_register_callback(HB_NODE_UP_CB,
-				      ocfs2_hb_node_up_cb,
-				      osb,
-				      OCFS2_HB_NODE_UP_PRI);
+	hb_setup_callback(&osb->osb_hb_up, HB_NODE_UP_CB, ocfs2_hb_node_up_cb,
+			  osb, OCFS2_HB_NODE_UP_PRI);
+	status = hb_register_callback(&osb->osb_hb_up);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 
@@ -153,13 +151,11 @@
 {
 	int status;
 
-	status = hb_unregister_callback(HB_NODE_DOWN_CB,
-					ocfs2_hb_node_down_cb, osb);
+	status = hb_unregister_callback(&osb->osb_hb_down);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 
-	status = hb_unregister_callback(HB_NODE_UP_CB,
-					ocfs2_hb_node_up_cb, osb);
+	status = hb_unregister_callback(&osb->osb_hb_up);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 

Modified: branches/dlm-reco-mig/fs/ocfs2/ocfs.h
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/ocfs.h	2005-02-25 22:28:25 UTC (rev 1914)
+++ branches/dlm-reco-mig/fs/ocfs2/ocfs.h	2005-02-28 19:24:54 UTC (rev 1915)
@@ -45,6 +45,7 @@
 #include "cluster/util.h"
 #include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
+#include "cluster/heartbeat.h"
 #include "cluster/tcp.h"
 #include "dlm/dlmcommon.h"
 #include "dlm/dlmmod.h"
@@ -388,6 +389,9 @@
 	spinlock_t net_response_lock;
 	unsigned int net_response_ids;
 	struct list_head net_response_list;
+
+	struct hb_callback_func	osb_hb_up;
+	struct hb_callback_func	osb_hb_down;
 };
 
 typedef struct _ocfs_global_ctxt



More information about the Ocfs2-commits mailing list