[Ocfs2-commits] zab commits r1984 - in branches/usysfsify/fs/ocfs2: . cluster dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Mar 16 13:14:59 CST 2005


Author: zab
Date: 2005-03-16 13:14:57 -0600 (Wed, 16 Mar 2005)
New Revision: 1984

Removed:
   branches/usysfsify/fs/ocfs2/cluster/clcommon.h
Modified:
   branches/usysfsify/fs/ocfs2/cluster/Makefile
   branches/usysfsify/fs/ocfs2/cluster/gsd.c
   branches/usysfsify/fs/ocfs2/cluster/heartbeat.c
   branches/usysfsify/fs/ocfs2/cluster/heartbeat.h
   branches/usysfsify/fs/ocfs2/cluster/nodemanager.c
   branches/usysfsify/fs/ocfs2/cluster/tcp.h
   branches/usysfsify/fs/ocfs2/dlm/dlmast.c
   branches/usysfsify/fs/ocfs2/dlm/dlmconvert.c
   branches/usysfsify/fs/ocfs2/dlm/dlmfs.c
   branches/usysfsify/fs/ocfs2/dlm/dlmfs_compat.c
   branches/usysfsify/fs/ocfs2/dlm/dlmlock.c
   branches/usysfsify/fs/ocfs2/dlm/dlmmaster.c
   branches/usysfsify/fs/ocfs2/dlm/dlmmod.c
   branches/usysfsify/fs/ocfs2/dlm/dlmrecovery.c
   branches/usysfsify/fs/ocfs2/dlm/dlmthread.c
   branches/usysfsify/fs/ocfs2/dlm/dlmunlock.c
   branches/usysfsify/fs/ocfs2/dlm/userdlm.c
   branches/usysfsify/fs/ocfs2/dlmglue.c
   branches/usysfsify/fs/ocfs2/heartbeat.c
   branches/usysfsify/fs/ocfs2/ocfs.h
   branches/usysfsify/fs/ocfs2/super.c
   branches/usysfsify/fs/ocfs2/vote.c
Log:
simplify and usysify heartbeat.
                                                                                
o hb only deals in global node numbers in our single cluster
o mkdir heartbeat/$name builds a heartbeat region
o once its dev attribute is filled, a thread is brought up
o all disk slots are watched, only those with nodemanager nodes are reported
o hb_fill_node_map reports active nodes from *all* regions


Modified: branches/usysfsify/fs/ocfs2/cluster/Makefile
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/Makefile	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/Makefile	2005-03-16 19:14:57 UTC (rev 1984)
@@ -47,7 +47,6 @@
 	util.c
 
 HEADERS = 			\
-	clcommon.h		\
 	cl_compat.h		\
 	compat_libfs.h		\
 	gsd.h			\

Deleted: branches/usysfsify/fs/ocfs2/cluster/clcommon.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/clcommon.h	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/clcommon.h	2005-03-16 19:14:57 UTC (rev 1984)
@@ -1,47 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * clcommon.h
- *
- * Common stuff
- *
- * Copyright (C) 2004 Oracle.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#ifndef CLUSTER_CLCOMMON_H
-#define CLUSTER_CLCOMMON_H
-
-typedef struct _heartbeat_ctxt heartbeat_ctxt;
-
-#define CLUSTER_DISK_UUID_LEN      32      // 16 byte binary == 32 char hex string
-
-typedef struct _cluster_disk
-{
-	// uuid of disk
-	char uuid[CLUSTER_DISK_UUID_LEN+1];
-	// all the rest are for heartbeat
-	u32 blocksize_bits;
-	u32 num_blocks;
-	u64 start_block;
-	util_rarray slots;
-} cluster_disk;
-
-
-#endif /* CLUSTER_CLCOMMON_H */

Modified: branches/usysfsify/fs/ocfs2/cluster/gsd.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/gsd.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/gsd.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -28,7 +28,6 @@
 
 #include "cl_compat.h"
 #include "util.h"
-#include "clcommon.h"
 #include "nodemanager.h"
 #include "tcp.h"
 #include "gsd.h"

Modified: branches/usysfsify/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/heartbeat.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/heartbeat.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -1,12 +1,8 @@
 /* -*- mode: c; c-basic-offset: 8; -*-
  * vim: noexpandtab sw=8 ts=8 sts=0:
  *
- * heartbeat.c
+ * Copyright (C) 2004, 2005 Oracle.  All rights reserved.
  *
- * Keeps track of alive nodes in the cluster.
- *
- * Copyright (C) 2004 Oracle.  All rights reserved.
- *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
  * License as published by the Free Software Foundation; either
@@ -22,11 +18,10 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 021110-1307, USA.
  *
- * Authors: Kurt Hackel
+ * TODO:
+ * 	- make sure attributes can't be written to after object commital 
  */
 
-
-
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -64,10 +59,10 @@
 #include "usysfs.h"
 
 #include <asm/uaccess.h>
+#include <asm/bitops.h>
 
 #include "cl_compat.h"
 #include "util.h"
-#include "clcommon.h"
 
 #include "heartbeat.h"
 #include "tcp.h"
@@ -80,29 +75,21 @@
 #define __user
 #endif
 
+static void hb_do_callbacks(int type, struct nm_node *node, int idx);
 
-static void hb_teardown(void);
-static void hb_nm_node_add_cb(void *ptr1, void *ptr2, u8 idx);
-static void hb_nm_group_add_cb(void *ptr1, void *ptr2, u8 idx);
-static int hb_init_disk_hb_group(struct inode *group, dev_t dev, u32 bits, 
-				 u32 blocks, u64 start);
-static ssize_t write_disk(struct file *file, char *buf, size_t size);
-static void hb_do_callbacks(int type, struct nm_group *group,
-			    struct nm_node *node, int idx);
-static void hb_end_buffer_io_sync(struct buffer_head *bh, int uptodate);
-static int hb_do_disk_heartbeat(void *page);
-static int hb_thread(void *data);
-static void hb_complete_thread(void);
-static int hb_launch_thread(void);
-static int hb_fill_node_bytemap(struct inode *group, void *map, int size);
+/* 
+ * The first heartbeat pass had one global thread that would serialize all hb
+ * callback calls.  This global serializing sem should only be removed once
+ * we've made sure that all callees can deal with being called concurrently
+ * from multiple hb region threads.
+ */
+static DECLARE_RWSEM(hb_callback_sem);
+/*
+ * region setup and teardown races with node_fill_map here.  We use
+ * the callback sem to protect them.
+ */
+static LIST_HEAD(hb_active_regions);
 
-
-/* globals */
-static spinlock_t hb_lock = SPIN_LOCK_UNLOCKED;
-static LIST_HEAD(hb_net_groups);
-static LIST_HEAD(hb_disk_groups);
-static struct task_struct *hb_task = NULL;
-
 static struct hb_callback {
 	struct list_head list;
 	struct semaphore sem;
@@ -119,23 +106,34 @@
 
 #define HB_THREAD_MS                  2000   // every 2 seconds
 
-struct hb_disk_slot
-{
-	struct inode *inode;
-	struct buffer_head *bh;
-	struct list_head list;
-	unsigned long last_time;
-	u16 margin;
-	u16 state;
+struct hb_disk_slot {
+	struct buffer_head	*ds_bh;
+	u64			ds_block;
+	u8			ds_node_num;
+	unsigned long		ds_last_time;
+	u16			ds_margin;
+	/* the single hb-thread only ever touches these items, no locking */
+	struct list_head	ds_dead_item;
+	struct list_head	ds_alive_item;
 };
 
+/* each thread owns a region.. when we're asked to tear down the region
+ * we ask the thread to stop, who cleans up the region */
 struct hb_region {
-	struct kobj		hr_kobj;
+	struct kobject		hr_kobj;
+	struct list_head	hr_active_item;
+	struct task_struct 	*hr_task;
 	u64			hr_block_bytes;
+	u64			hr_block_bits;
 	u64			hr_start_block;
-	u64			hr_blocks;
-	dev_t			hr_dev;
+	u8			hr_blocks;
+
+	struct block_device	*hr_bdev;
 	struct hb_disk_slot	*hr_slots;
+	/* a single hb-thread writer and many fill_node readers are protected */
+	rwlock_t		hr_slot_list_lock;
+	struct list_head	hr_alive_list;
+	struct list_head	hr_dead_list;
 };
 
 static void hb_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
@@ -177,28 +175,27 @@
 }
 
 /* 
- * hb_init_disk_hb_group() sets disk->blocksize_bits which defines the block
- * size that we'll use to calculate block offsets.  The blocksize of the
- * device might change under us, though.  this detects when that happens
- * and tries to lookup the bh again with the newer blocksize.  The exciting
- * wrinkle here is that its fatal to call __getblk() with the wrong block
- * size in some 2.6 kernels.
+ * hr_region's block_bytes attribute defines the block size that we'll use to
+ * calculate block offsets.  The blocksize of the device might change under us,
+ * though.  this detects when that happens and tries to lookup the bh again
+ * with the newer blocksize.  The exciting wrinkle here is that its fatal to
+ * call __getblk() with the wrong block size in some 2.6 kernels.
  *
- * We only ever use a few bytes of the block so it is ok that we return
- * a smaller bh than what is implied by blocksize_bits.  We're just fixing
- * up addressing here.
+ * We only ever use a few bytes of the block so it is ok that we return a
+ * smaller bh than what is implied by blocksize_bits.  We're just fixing up
+ * addressing here.
  */
-static struct buffer_head *hb_getblk(int orig_blkno, cluster_disk *disk)
+static struct buffer_head *hb_getblk(struct block_device *bdev, int orig_blkno,
+				     int bits)
 {
 	/* XXX getblk() takes an int block in 2.4 :/ */
 	int blkno;
-	int bits, dev_bits;
+	int dev_bits;
 	struct buffer_head *bh = NULL;
 
-	bits = disk->blocksize_bits;
 	blkno = orig_blkno;
 
-	dev_bits = ocfs_dev_bits(disk->dev);
+	dev_bits = bdev->bd_inode->i_blkbits;
 	if (dev_bits < 0)
 		goto out;
 
@@ -207,606 +204,216 @@
 	else if (dev_bits > bits)
 		blkno >>= dev_bits - bits;
 
-	bh = getblk(disk->dev, blkno, 1 << dev_bits);
+	bh = __getblk(bdev, blkno, 1 << dev_bits);
 out:
 	return bh;
 }
 
-static struct buffer_head *hb_get_locked_mapped(hb_disk_slot *slot,
-						int ino,
-						cluster_disk *disk)
+static struct buffer_head *hb_get_locked_mapped(struct hb_region *reg,
+						struct hb_disk_slot *slot)
 {
 	struct buffer_head *bh = NULL;
 
-	bh = slot->bh;
+	bh = slot->ds_bh;
 	if (bh) {
 		lock_buffer(bh);
 		if (buffer_mapped(bh))
 			goto out;
-		slot->bh = NULL;
+		slot->ds_bh = NULL;
 		unlock_buffer(bh);
 		brelse(bh);
 	}
 
-	slot->bh = hb_getblk(ino + disk->start_block, disk);
-	if (slot->bh) {
-		bh = slot->bh;
+	slot->ds_bh = hb_getblk(reg->hr_bdev, slot->ds_block,
+				reg->hr_block_bits);
+	if (slot->ds_bh) {
+		bh = slot->ds_bh;
 		lock_buffer(bh);
 	}
 out:
 	return bh;
 }
 
-/* 
- * heartbeats/block_regions/foo/
- * 				block_bytes
- * 				start_block
- * 				num_blocks
- * 				active_nodes/
- *
- * for now require that we have the local node defined
- *
- * heartbeat bits need to pin other node bits, I guess
- */
-
-static int hb_do_disk_heartbeat(void *page)
+static void hb_do_disk_heartbeat(struct hb_region *reg)
 {
-	nm_group_inode_private *priv;
-	struct nm_group *group;
 	struct nm_node *node;
-	struct list_head *iter;
 	struct buffer_head *bh;
-	hb_disk_slot *slot;
+	struct hb_disk_slot *slot;
 	hb_disk_heartbeat_block *hb_block;
-	int rw, ino, idx, ret, i;
-	struct inode **dead_nodes, **live_nodes;
-	LIST_HEAD(tmplist);
-	cluster_disk *disk;
+	/* only need to worry about locking when we touch the reg lists
+	 * which fill_node_map sees.  otherwise only we touch these
+	 * lists and the slot items */
+	LIST_HEAD(newborn);
+	LIST_HEAD(deceased);
 	u64 cputime;
+	u8 i;
+	int rw;
 
-	// NM_MAX_NODES is 255
-	dead_nodes = page;
-	live_nodes = page + (sizeof(struct inode *) * 256);
-	
-	spin_lock(&hb_lock);
-	list_splice_init(&hb_disk_groups, &tmplist);
-	spin_unlock(&hb_lock);
+	/* first we clear uptodate on other nodes slots and write our slot */
+	for(i = 0; i < reg->hr_blocks; i++) {
+		slot = &reg->hr_slots[i];
 
-	list_for_each(iter, &tmplist) {
-		priv = list_entry(iter, nm_group_inode_private, disk_list);
-		group = priv->inode;
-		disk = &priv->disk;
+		bh = hb_get_locked_mapped(reg, slot);
+		if (bh == NULL) {
+			hbprintk("getblk failed in slot %d!\n", i);
+			continue;
+		}
 
-		memset(page, 0, PAGE_SIZE);
-		down(&group->i_sem);
+		if (slot->ds_node_num == nm_this_node()) {
+			memset(bh->b_data, 0, bh->b_size);
+			hb_block = (hb_disk_heartbeat_block *)bh->b_data;
+			BUG_ON(bh->b_size < sizeof(*hb_block));
 
-		idx = 0;
-		while ((slot = nm_iterate_group_disk_slots(group, &idx))) {
+			/* TODO: time stuff */
+			cputime = OCFS_CURRENT_SECONDS;
+			if (!cputime)
+				cputime = 1;
+			hb_block->time = cpu_to_le64(cputime);
 
-			node = slot->inode;
-			if (!node) {
-				hbprintk("no inode in slot %d!\n", idx);
-				idx++;
-				continue;
-			}
-			ino = nm_get_node_global_index(node);
+			set_buffer_uptodate(bh);
+			clear_buffer_dirty(bh);
+			rw = WRITE;
+		} else {
+			clear_buffer_uptodate(bh);
+			rw = READ;
+		}
 
-			bh = hb_get_locked_mapped(slot, ino, disk);
-			if (bh == NULL) {
-				hbprintk("getblk failed in slot %d!\n",
-					 idx);
-				idx++;
-				continue;
-			}
-			
-			if (ino == nm_this_node(group)) {
-				memset(bh->b_data, 0, bh->b_size);
-				hb_block= (hb_disk_heartbeat_block *)bh->b_data;
-				BUG_ON(bh->b_size < sizeof(*hb_block));
+		bh->b_end_io = hb_end_buffer_io_sync;
+		hb_submit_bh(rw, bh);
+	}
 
-				/* TODO: time stuff */
-				cputime = OCFS_CURRENT_SECONDS;
-				if (!cputime)
-					cputime = 1;
-				hb_block->time = cpu_to_le64(cputime);
+	/* now we read again and see what other nodes have done */
+	for(i = 0; i < reg->hr_blocks; i++) {
+		slot = &reg->hr_slots[i];
 
-				set_buffer_uptodate(bh);
-				clear_buffer_dirty(bh);
-				rw = WRITE;
-			} else {
-				clear_buffer_uptodate(bh);
-				rw = READ;
-			}
-
-			bh->b_end_io = hb_end_buffer_io_sync;
-			hb_submit_bh(rw, bh);
-			idx++;
+		bh = slot->ds_bh;
+		if (bh == NULL) {
+			hbprintk("no bh in slot %d!\n", i);
+			continue;
 		}
-	
-		idx = 0;
-		while ((slot = nm_iterate_group_disk_slots(group, &idx))) {
-			bh = slot->bh;
-			if (!bh) {
-				hbprintk("no bh in slot %d!\n", idx);
-				idx++;
-				continue;
-			}
+		wait_on_buffer(bh);
+		hb_block = (hb_disk_heartbeat_block *)bh->b_data;
 
-			node = slot->inode;
-			if (!node) {
-				hbprintk("no inode in slot %d!\n", idx);
-				idx++;
-				continue;
-			}
+		cputime = le64_to_cpu(hb_block->time);
+		if (slot->ds_last_time != cputime) {
+			/* the node is active */
+			if (!list_empty(&slot->ds_dead_item))
+				list_del_init(&slot->ds_dead_item);
 
-			ino = nm_get_node_global_index(node);
+			if (list_empty(&slot->ds_alive_item))
+				list_add_tail(&newborn, &slot->ds_alive_item);
 
-			wait_on_buffer(bh);
-			hb_block = (hb_disk_heartbeat_block *)bh->b_data;
+			slot->ds_last_time = cputime;
+			slot->ds_margin = HB_DISK_MARGIN;
+			continue;
+		} 
 
-			/* TODO: time stuff */
-			cputime = le64_to_cpu(hb_block->time);
-			if (slot->last_time != cputime) {
-				if (slot->state == HB_NODE_STATE_INIT) {
-					hbprintk("first time for this node!\n");
-					live_nodes[ino] = node;
-					slot->state = HB_NODE_STATE_UP;
-				}
-				node->i_atime = mk_inode_time(cputime, 0);
-				slot->last_time = cputime;
-				slot->margin = HB_DISK_MARGIN;
-				hb_do_callbacks(HB_NODE_RESPONDED_CB, 
-						group, node, idx);
-			} else {
-				slot->margin--;
-				hbprintk("node %d missed.  margin=%d\n", 
-					 ino, slot->margin);
-			}
+		/* don't bother checking if our node is dead */
+		if (slot->ds_node_num == nm_this_node())
+			continue;
 
-			if (ino != nm_this_node(group) && slot->margin <= 0) {
-				hbprintk("node %d JUST DIED!!!!\n", ino);
-				dead_nodes[ino] = node;
-				slot->state = HB_NODE_STATE_DOWN;
-			}
-			idx++;
+		/* decrease slot margin to zero as long as we don't
+		 * see any updates */
+		if (slot->ds_margin) {
+			if (--slot->ds_margin)
+				continue;
 		}
 
-		up(&group->i_sem);
+		/* ok, margin is 0, it's really dead */ 
+		if (list_empty(&slot->ds_dead_item)) {
+			hbprintk("node %d JUST DIED!!!!\n", i);
+			list_add_tail(&deceased, &slot->ds_dead_item);
+		}
+	}
 
-		/* Do holding group i_sem while doing node-up/down.
-		 * Changes may need to be made to the group, so 
-		 * i_sem will be needed... */
-		for (i=0; i<NM_MAX_NODES; i++) {
-			if (live_nodes[i])
-				ret = hb_do_node_up(group, live_nodes[i], i);
-			else if (dead_nodes[i])
-				ret = hb_do_node_down(group, dead_nodes[i], i);
+	/* we're the only thing that modifies the lists, we don't have to lock
+	 * while we're just reading them.  the write locks protect the
+	 * fill_node_map readers.  */
+	list_for_each_entry(slot, &newborn, ds_alive_item) {
+		node = nm_get_node_by_num(slot->ds_node_num);
+		if (node == NULL) {
+			hbprintk("saw hb for node %d but don't have a node\n",
+				 slot->ds_node_num);
+			continue;	
 		}
+		hb_do_node_up(node, slot->ds_node_num);
+		nm_node_put(node);
 	}
-	
-	spin_lock(&hb_lock);
-	list_splice(&tmplist, &hb_disk_groups);
-	spin_unlock(&hb_lock);
-	return 0;
+	list_for_each_entry(slot, &deceased, ds_dead_item) {
+		node = nm_get_node_by_num(slot->ds_node_num);
+		if (node == NULL) {
+			hbprintk("node %d went down but don't have a node\n",
+				 slot->ds_node_num);
+			continue;	
+		}
+		hb_do_node_down(node, slot->ds_node_num);
+		nm_node_put(node);
+	}
+
+	write_lock(&reg->hr_slot_list_lock);
+	list_splice_init(&newborn, &reg->hr_alive_list);
+	list_splice_init(&deceased, &reg->hr_dead_list);
+	write_unlock(&reg->hr_slot_list_lock);
 }
 
+/*
+ * we ride the region ref that the region dir holds.  before the region
+ * dir is removed and drops it ref it will wait to tear down this
+ * thread.
+ */
 static int hb_thread(void *data)
 {
-	void *page = data;
+	struct hb_region *reg = data;
 
 	hbprintk("hb thread running\n");
 	
 	while (!kthread_should_stop()) {
-		hb_do_disk_heartbeat(page);
+		hb_do_disk_heartbeat(reg);
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(msecs_to_jiffies(HB_THREAD_MS));
 	}
 
 	hbprintk("hb thread exiting\n");
-	free_page((unsigned long)page);
+
 	return 0;
 }
 
-/* Launch the hb thread for the mounted volume */
-static int hb_launch_thread(void)
+void hb_init(void)
 {
-	void *page;
-	int ret;
+	int i;
 
-	page = (void *)__get_free_page(GFP_KERNEL);
-	if (!page) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	hbprintk("starting hb thread...\n");
-	hb_task = kthread_run(hb_thread, page, "hb_thread");
-	if (IS_ERR(hb_task)) {
-		hb_task = NULL;
-		hbprintk("unable to launch hb thread, error=%ld",
-			 PTR_ERR(hb_task));
-		ret = -EINVAL;
-		goto out;
-	}
-
-	/* hb_thread is responsible for freeing the page if it runs */
-	page = NULL;
-	ret = 0;
-
-out:
-	if (page)
-		free_page((unsigned long)page);
-	return ret;
-}
-
-static void hb_complete_thread(void)
-{
-	if (hb_task) {
-		hbprintk("waiting for hb thread to exit\n");
-		kthread_stop(hb_task);
-		hb_task = NULL;
-	}
-}
-
-static int hb_init_disk_hb_group(struct inode *group, dev_t dev, u32 bits, 
-				 u32 blocks, u64 start)
-{
-	int ret = -EINVAL;
-	cluster_disk *disk;
-	nm_group_inode_private *priv;
-
-	priv = group->u.generic_ip;
-	if (!priv)
-		goto leave;
-
-	if (priv->state == NM_GROUP_READY)
-		return 0;
-
-	/* hold an extra ref as long as hb keeps track of the group */
-	igrab(group);
-
-	disk = &priv->disk;
-	if (blocks > NM_MAX_NODES)
-	       blocks = NM_MAX_NODES;
-	disk->dev = dev;
-	disk->blocksize_bits = bits;
-	disk->num_blocks = blocks;
-	disk->start_block = start;
-	util_init_rarray(&disk->slots, sizeof(hb_disk_slot));
-
-	/* start allowing group additions */
-	ret = nm_make_group_ready(group);
-
-leave:
-	if (ret < 0)
-		iput(group);
-
-	return ret;
-}
-	
-
-#if 0
-static ssize_t write_disk(struct file *file, char *buf, size_t size)
-{
-	hb_op *data;
-	struct inode *group = NULL;
-	struct file *filp = NULL;
-	dev_t dev;
-	int ret, tmpret;
-	nm_group_inode_private *priv;
-	u8 tmpmap[NM_MAX_NODES];
-	
-	hbprintk("write_disk\n");
-
-        if (size < sizeof(*data))
-                return -EINVAL;
-	data = (hb_op *) buf; if (data->magic != HB_OP_MAGIC)
-		return -EINVAL;
-
-	switch (data->opcode)
-	{
-		case HB_OP_START_DISK_HEARTBEAT:
-			if (data->bits < 9 || data->bits > 12) {
-				ret = sprintf(buf, "%d: bad blocksize bits! %u",
-					      -EINVAL, data->bits);
-				break;
-			}
-			group = nm_get_group_by_num(data->group_num);
-			if (!group || !group->u.generic_ip) {
-				ret = sprintf(buf, "%d: bad group number! %u", 
-					      -EINVAL, data->group_num);
-				break;
-			}
-			priv = group->u.generic_ip;
-			if (strncmp(priv->disk.uuid, data->disk_uuid, 
-				    CLUSTER_DISK_UUID_LEN) != 0) {
-				ret = sprintf(buf, "%d: bad disk uuid!", 
-					      -EINVAL);
-				break;
-			}
-			filp = fget(data->fd);
-			if (!filp) {
-				ret = sprintf(buf, "%d: bad fd!", -EINVAL);
-				break;
-			}
-			dev = filp->f_dentry->d_inode->i_rdev;
-			tmpret = hb_init_disk_hb_group(group, dev, data->bits, 
-						       data->blocks, 
-						       data->start);
-			if (tmpret < 0) {
-				fput(filp);
-				ret = sprintf(buf, "%d: failed to init disk "
-					      "heartbeat for group %u!", 
-					      -EINVAL, data->group_num);
-			} else {
-				ret = sprintf(buf, "0: disk heartbeat started "
-					      "for group %u!", data->group_num);
-			}
-			break;
-
-		case HB_OP_GET_NODE_MAP:
-			group = nm_get_group_by_num(data->group_num);
-			if (!group || !group->u.generic_ip) {
-				ret = sprintf(buf, "%d: bad group number! %u", 
-					      -EINVAL, data->group_num);
-				break;
-			}
-
-			memset(tmpmap, 0, sizeof(tmpmap));
-			if ((ret = hb_fill_node_bytemap(group, tmpmap,
-							NM_MAX_NODES)) == 0) {
-				ret = sprintf(buf, "0: ");
-				buf += ret;
-				memcpy(buf, tmpmap, sizeof(tmpmap));
-				ret += sizeof(tmpmap);
-			} else {
-				ret = sprintf(buf, "%d: error occurred in "
-					      "hb_fill_node_bytemap", ret);
-			}
-			break;
-
-		default:
-			ret = sprintf(buf, "%d: bad opcode! %u", -EINVAL, 
-				      data->opcode);
-			break;
-	}
-
-	if (group)
-		iput(group);
-	
-	return ret;
-}
-
-/* TODO: make callbacks all return int */
-static void hb_nm_group_node_add_cb(void *ptr1, void *ptr2, u8 idx)
-{
-	hb_disk_slot *slot;
-	struct inode *group = ptr1;
-	struct inode *node = ptr2;
-	cluster_disk *disk;
-	nm_group_inode_private *priv;
-	int ino, ret = 0;
-	u64 block;
-
-	hbprintk("hb_nm_group_node_add_cb: group=%lu, node=%lu, idx=%u\n",
-	       group->i_ino, node->i_ino, idx);
-
-	down(&group->i_sem);	
-	priv = group->u.generic_ip;
-	if (!priv) {
-		hbprintk("eek! bad group inode!\n");
-		goto leave;
-	}
-	disk = &priv->disk;
-	if (disk->uuid[0]) {
-		ret = util_resize_rarray(&disk->slots, idx+1);
-		if (ret < 0) {
-			hbprintk("eeeeeeek!!!! failed to resize disk state "
-				 "data\n");
-			goto leave;
-		}
-	
-		ino = nm_get_node_global_index(node);
-		if (ino > disk->num_blocks) {
-			hbprintk("disk heartbeat area does not have enough "
-				 "blocks!\n");
-			goto leave;
-		}
-		block = ino + disk->start_block;
-	
-		slot = util_rarray_idx_to_slot(&disk->slots, idx);
-		if (!slot) {
-			hbprintk("eeeeeeek!!!! failed to get disk state data "
-				 "pointer: %d\n", idx);
-			goto leave;
-		}
-		slot->inode = igrab(node);
-		slot->last_time = 0;
-		slot->margin = HB_INITIAL_DISK_MARGIN;
-#warning needs to change for 2.6
-		slot->bh = hb_getblk(block, disk);
-		slot->state = HB_NODE_STATE_INIT;
-	} else {
-		hbprintk("doing nothing for group add for non-disk heartbeat "
-			 "group\n");
-	}
-	
-leave:
-	up(&group->i_sem);
-	return;	
-}
-
-static void hb_nm_group_node_del_cb(void *ptr1, void *ptr2, u8 idx)
-{
-	hb_disk_slot *slot;
-	struct inode *group = ptr1;
-	struct inode *node = ptr2;
-	cluster_disk *disk;
-	nm_group_inode_private *priv;
-	int ret = -EINVAL;
-
-	hbprintk("hb_nm_group_node_del_cb: group=%lu, node=%lu, idx=%u\n",
-	       group->i_ino, node->i_ino, idx);
-
-	down(&group->i_sem);
-	priv = group->u.generic_ip;
-	if (!priv) {
-		hbprintk("eek! bad group inode!\n");
-		goto leave;
-	}
-	disk = &priv->disk;
-	slot = util_rarray_idx_to_slot(&disk->slots, idx);
-	if (!slot) {
-		hbprintk("eeeeeeek!!!! failed to get disk state data "
-			 "pointer: %d\n", idx);
-		goto leave;
-	}
-	if (slot->inode!=node) {
-		hbprintk("eeeeeeek!!!! node inode changed!\n");
-		goto leave;
-	}
-	iput(node);
-	if (slot->bh) {
-		wait_on_buffer(slot->bh);
-		brelse(slot->bh);
-	}
-	memset(slot, 0, sizeof(hb_disk_slot));
-	ret = 0;
-leave:
-
-	up(&group->i_sem);
-	hbprintk("hb_nm_group_node_del_cb done: %d\n", ret);
-	return;
-}
-#endif
-
-#if 0
-static void hb_teardown(void)
-{
-	/* XXX are there thread/cb dependencies? */
-	hb_complete_thread();
-	nm_unregister_callback(NM_GROUP_NODE_DEL_CB, hb_nm_group_node_del_cb);
-	nm_unregister_callback(NM_GROUP_NODE_ADD_CB, hb_nm_group_node_add_cb);
-	nm_unregister_callback(NM_NODE_ADD_CB, hb_nm_node_add_cb);
-	nm_unregister_callback(NM_GROUP_ADD_CB, hb_nm_group_add_cb);
-}
-
-static int __init init_hb(void)
-{
-	int ret, i;
-
-	for (i = HB_NODE_DOWN_CB; i < HB_NUM_CB; i++) {
+	for (i = 0; i < ARRAY_SIZE(hb_callbacks); i++) {
 		INIT_LIST_HEAD(&hb_callbacks[i].list);
 		init_MUTEX(&hb_callbacks[i].sem);
 	}
-
-	ret = nm_register_callback(NM_GROUP_NODE_DEL_CB,
-	      hb_nm_group_node_del_cb);
-	if (ret)
-		goto done;
-	ret = nm_register_callback(NM_GROUP_NODE_ADD_CB,
-				   hb_nm_group_node_add_cb);
-	if (ret)
-		goto done;
-	ret = nm_register_callback(NM_NODE_ADD_CB, hb_nm_node_add_cb);
-	if (ret)
-		goto done;
-	ret = nm_register_callback(NM_GROUP_ADD_CB, hb_nm_group_add_cb);
-	if (ret)
-		goto done;
- 
-	ret = hb_launch_thread();
-	if (ret)
-		goto done;
- 
-done:
-	if (ret)
-		hb_teardown();
-	return ret;
 }
-#endif
 
-#if 0
 /*
- * hb_fill_node_bytemap()
- * 255 bytes... each byte set to 0 (not mounted) or 1 (mounted)
- *
+ * get a map of all nodes that are heartbeating in any regions
  */
-static int hb_fill_node_bytemap(struct inode *group, void *map, int size)
+void hb_fill_node_map(unsigned long *map, unsigned bytes)
 {
-	hb_disk_slot *slot;
-	int idx = 0;
-	nm_group_inode_private *priv;
-	u8 *bytemap = (u8 *)map;
-	
-	priv = group->u.generic_ip;
+	struct hb_region *reg = NULL;
+	struct hb_disk_slot *slot;
 
-	down(&group->i_sem);
+	BUG_ON(bytes < (BITS_TO_LONGS(NM_MAX_NODES) * sizeof(unsigned long)));
 
-	if (priv->disk.uuid[0]) {
-		while ((slot = nm_iterate_group_disk_slots(group, &idx))) {
-			if (idx >= size-1) {
-				hbprintk("map size (%d) too small for "
-					 "index (%d)\n", size, idx);
-				up(&group->i_sem);
-				return -EINVAL;
-			}
-			if (slot->state == HB_NODE_STATE_UP)
-				bytemap[idx] = 1;
-			idx++;
-		}
-	} else {
-		hbprintk("filling straight from slot bitmap for non-disk "
-			 "heartbeat group\n");
-		idx = 0;
-		while ((idx = find_next_bit(priv->slot_bitmap, NM_MAX_NODES,
-					    idx)) != -1) {
-			if (idx == NM_MAX_NODES)
-				break;
-			bytemap[idx] = 1;
-		}
-	}
+	memset(map, 0, bytes);
 
-	up(&group->i_sem);
+	/* callers want to serialize this map and callbacks so that they
+	 * can trust that they don't miss nodes coming to the party */
+	down_read(&hb_callback_sem);
 
-	return 0;
-}
-
-int hb_fill_node_map(struct inode *group, void *map, int size)
-{
-	hb_disk_slot *slot;
-	int idx = 0;
-	nm_group_inode_private *priv;
-	
-	priv = group->u.generic_ip;
-
-	memset(map, 0, size);
-	down(&group->i_sem);
-
-	if (priv->disk.uuid[0]) {
-		while ((slot = nm_iterate_group_disk_slots(group, &idx))) {
-			if (idx >= size-1) {
-				hbprintk("map size (%d) too small for "
-					 "index (%d)\n", size, idx);
-				up(&group->i_sem);
-				return -EINVAL;
-			}
-			if (slot->state == HB_NODE_STATE_UP)
-				set_bit(idx, map);
-			idx++;
-		}
-	} else {
-		hbprintk("filling straight from slot bitmap for non-disk "
-			 "heartbeat group\n");
-		memcpy(map, priv->slot_bitmap, size);
+	list_for_each_entry(reg, &hb_active_regions, hr_active_item) {
+		read_lock(&reg->hr_slot_list_lock);
+		list_for_each_entry(slot, &reg->hr_alive_list, ds_alive_item)
+			set_bit(slot->ds_node_num, map);
+		read_unlock(&reg->hr_slot_list_lock);
 	}
 
-	up(&group->i_sem);
-
-	return 0;
+	up_read(&hb_callback_sem);
 }
 EXPORT_SYMBOL(hb_fill_node_map);
-#endif
 
 /* 
  * heartbeat usysfs bits.  The heartbeat set is a default set under
@@ -818,15 +425,23 @@
 	return kobj ? container_of(kobj, struct hb_region, hr_kobj) : NULL;
 }
 
+/* drop_object only drops its ref after killing the thread, nothing should
+ * be using the region anymore.  this has to clean up any state that
+ * attributes might have built up. */
 static void hb_region_release(struct kobject *kobj)
 {
-	struct hr_region *reg = to_hr_region(kobj);
+	struct hb_region *reg = to_hb_region(kobj);
 	printk("releasing reg %p\n", reg);
+
+	if (reg->hr_bdev)
+		blkdev_put(reg->hr_bdev);
+	kfree(reg->hr_slots); /* might be null if never activated */
+	kfree(reg);
 }
 
 static ssize_t hb_region_block_bytes_read(struct hb_region *reg, char *page)
 {
-	return sprintf(page, "%d\n", node->nd_block_bytes);
+	return sprintf(page, "%lld\n", (long long)reg->hr_block_bytes);
 }
 
 static ssize_t hb_region_block_bytes_write(struct hb_region *reg,
@@ -840,14 +455,22 @@
 	if (!p || (*p && (*p != '\n')))
 		return -EINVAL;
 
+	/* XXX probably very stupid. */
+	if (tmp >= 65536) /* just so we can use hweight16 */
+		return -ERANGE;
+	if (hweight16(tmp) != 1)
+		return -EINVAL;
+
 	/* XXX compare blocks against dev later on commit? */
 	reg->hr_block_bytes = tmp;
+	/* XXX is this right? */
+	reg->hr_block_bits = ffs(reg->hr_block_bytes);
 
 	return count;
 }
 static ssize_t hb_region_start_block_read(struct hb_region *reg, char *page)
 {
-	return sprintf(page, "%d\n", node->nd_start_block);
+	return sprintf(page, "%lld\n", (long long)reg->hr_start_block);
 }
 
 static ssize_t hb_region_start_block_write(struct hb_region *reg,
@@ -868,7 +491,7 @@
 }
 static ssize_t hb_region_blocks_read(struct hb_region *reg, char *page)
 {
-	return sprintf(page, "%d\n", node->nd_blocks);
+	return sprintf(page, "%d\n", reg->hr_blocks);
 }
 
 static ssize_t hb_region_blocks_write(struct hb_region *reg,
@@ -876,17 +499,100 @@
 					   size_t count)
 {
 	unsigned long long tmp;
+	u8 i;
 	char *p = (char *)page;
+	struct hb_disk_slot *slot;
 
 	tmp = simple_strtoull(p, &p, 0);
 	if (!p || (*p && (*p != '\n')))
 		return -EINVAL;
 
-	/* XXX compare blocks against dev later on commit? */
+	if (tmp >= NM_MAX_NODES)
+		return -ERANGE;
+
+	reg->hr_slots = kcalloc(tmp, sizeof(struct hb_disk_slot), GFP_KERNEL);
+	if (reg->hr_slots == NULL)
+		return -ENOMEM;
+
+	/* XXX worry about start block being defined already.  do this
+	 * in commit? */
+	for(i = 0; i < reg->hr_blocks; i++) {
+		slot = &reg->hr_slots[i];
+		slot->ds_block = reg->hr_start_block + 1;
+		slot->ds_node_num = i;
+		slot->ds_margin = HB_INITIAL_DISK_MARGIN;
+		INIT_LIST_HEAD(&slot->ds_alive_item);
+		INIT_LIST_HEAD(&slot->ds_dead_item);
+	}
+
 	reg->hr_blocks = tmp;
 
 	return count;
 }
+
+static ssize_t hb_region_dev_read(struct hb_region *reg, char *page)
+{
+	const char *str = bdevname(reg->hr_bdev, page);
+	return strlen(str);
+}
+
+/* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */
+static ssize_t hb_region_dev_write(struct hb_region *reg, const char *page,
+				   size_t count)
+{
+	long fd;
+	char *p = (char *)page;
+	struct file *filp = NULL;
+	struct inode *inode = NULL;
+	ssize_t ret = -EINVAL;
+
+	fd = simple_strtol(p, &p, 0);
+	if (!p || (*p && (*p != '\n')))
+		goto out;
+
+	if (fd < 0 || fd >= INT_MAX)
+		goto out;
+
+	filp = fget(fd);
+	if (filp == NULL)
+		goto out;
+
+	inode = igrab(filp->f_mapping->host);
+	if (inode == NULL)
+		goto out;
+	reg->hr_bdev = I_BDEV(filp->f_mapping->host);
+
+	ret = blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ, 0);
+	if (ret) {
+		reg->hr_bdev = NULL;
+		goto out;
+	}
+	inode = NULL;
+
+	reg->hr_task = kthread_run(hb_thread, reg, "hb-%s", reg->hr_kobj.name);
+	if (IS_ERR(reg->hr_task)) {
+		reg->hr_task = NULL;
+		goto out;
+	}
+
+	down_write(&hb_callback_sem);
+	list_add_tail(&hb_active_regions, &reg->hr_active_item);
+	up_write(&hb_callback_sem);
+
+	ret = count;
+out:
+	if (filp)
+		fput(filp);
+	if (inode)
+		iput(inode);
+	if (ret < 0) {
+		if (reg->hr_bdev) {
+			blkdev_put(reg->hr_bdev);
+			reg->hr_bdev = NULL;
+		}
+	}
+	return ret;
+}
 struct hb_region_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct hb_region *, char *);
@@ -908,32 +614,37 @@
 	.show	= hb_region_blocks_read,
 	.store	= hb_region_blocks_write,
 };
+static struct hb_region_attribute hb_region_attr_dev = {
+	.attr	= { .name = "dev", .mode = S_IRUGO | S_IWUSR },
+	.show	= hb_region_dev_read,
+	.store	= hb_region_dev_write,
+};
 
 static struct attribute *hb_region_default_attrs[] = {
-	&hb_region_block_bytes.attr,
-	&hb_region_start_block.attr,
-	&hb_region_blocks.attr,
-//	&hb_region_dev.attr,  /* link to a real device?  hmm. */
+	&hb_region_attr_block_bytes.attr,
+	&hb_region_attr_start_block.attr,
+	&hb_region_attr_blocks.attr,
+	&hb_region_attr_dev.attr,
 	NULL,
 };
 
-static ssize_t hb_region_attr_show(struct kobject *kobj,
-			     struct attribute *attr,
-			     char *page)
+static ssize_t hb_region_show(struct kobject *kobj,
+			      struct attribute *attr,
+			      char *page)
 {
 	struct hb_region *reg = to_hb_region(kobj);
-	struct hb_region_attribute *nm_nodde_attr =
+	struct hb_region_attribute *hb_region_attr =
 		container_of(attr, struct hb_region_attribute, attr);
 	ssize_t ret = 0;
 
 	if (hb_region_attr->show)
-		ret = hb_region_attr->show(node, page);
+		ret = hb_region_attr->show(reg, page);
 	return ret;
 }
 
 static ssize_t hb_region_store(struct kobject *kobj,
-			      struct attribute *attr,
-			      const char *page, size_t count)
+			       struct attribute *attr,
+			       const char *page, size_t count)
 {
 	struct hb_region *reg = to_hb_region(kobj);
 	struct hb_region_attribute *hb_region_attr =
@@ -941,7 +652,7 @@
 	ssize_t ret = -EINVAL;
 
 	if (hb_region_attr->store)
-		ret = hb_region_attr->store(node, page, count);
+		ret = hb_region_attr->store(reg, page, count);
 	return ret;
 }
 
@@ -954,7 +665,7 @@
 	.ktype	= {
 		.release	= hb_region_release,
 		.sysfs_ops	= &hb_region_sysfs_ops,
-		.default_attrs	= hb_region_default_addrs,
+		.default_attrs	= hb_region_default_attrs,
 	},
 	.owner	= THIS_MODULE,
 };
@@ -974,22 +685,24 @@
 }
 
 static struct kobject *hb_heartbeat_set_make_object(struct kset *kset,
-					      const char *name)
+						    const char *name)
 {
 	struct hb_region *reg = NULL;
-	struct hb_cluster *cluster = to_hb_cluster(kset->kobj.parent);
-	struct kobj *ret = NULL;
+	struct kobject *ret = NULL;
 
-	printk("trying to make a heartbeat object under cluster %p\n", cluster);
+	printk("trying to make a heartbeat object\n");
 
 	reg = kcalloc(1, sizeof(struct hb_region), GFP_KERNEL);
 	if (reg == NULL)
 		goto out; /* ENOMEM */
 
-	strcpy(reg->hr_kobj.name, name);
-	reg->kobj.k_name = reg->kobj.name;
-	reg->kobj.ktype = &hb_region_type.ktype;
+	INIT_LIST_HEAD(&reg->hr_alive_list);
+	INIT_LIST_HEAD(&reg->hr_dead_list);
+
+	kobject_set_name(&reg->hr_kobj, name);
+	reg->hr_kobj.ktype = &hb_region_type.ktype;
 	kobject_init(&reg->hr_kobj);
+
 	ret = &reg->hr_kobj;
 
 out:
@@ -999,11 +712,24 @@
 	return ret;
 }
 
-static void hb_heartbeat_set_drop_object(struct kset *kset, struct kobject *kobj)
+static void hb_heartbeat_set_drop_object(struct kset *kset,
+				         struct kobject *kobj)
 {
-	struct hb_heartbeat_set *hs = to_hb_heartbeat_set(kset);
+	struct hb_region *reg = to_hb_region(kobj);
 
-	printk("dropping hb_heartbeat_set %p\n", hs);
+	printk("dropping hr_region %p\n", reg);
+
+	down_read(&hb_callback_sem);
+	if (!list_empty(&reg->hr_active_item))
+		list_del_init(&reg->hr_active_item);
+	up_read(&hb_callback_sem);
+
+	/* stop the thread when the user removes the region dir */
+	if (reg->hr_task) {
+		kthread_stop(reg->hr_task);
+		reg->hr_task = NULL;
+	}
+
 	kobject_put(kobj);
 }
 
@@ -1037,7 +763,7 @@
 	return ret;
 }
 
-void *hb_free_hb_set(struct kset *kset)
+void hb_free_hb_set(struct kset *kset)
 {
 	struct hb_heartbeat_set *hs = to_hb_heartbeat_set(kset);
 	kfree(hs);
@@ -1122,7 +848,7 @@
 }
 EXPORT_SYMBOL(hb_unregister_callback);
 
-static void hb_do_callbacks(int type, void *ptr1, void *ptr2, int idx)
+static void hb_do_callbacks(int type, struct nm_node *node, int idx)
 {
 	struct list_head *iter;
 	struct hb_callback_func *f;
@@ -1132,15 +858,19 @@
 	if (IS_ERR(hbcall))
 		return;
 
+	/* XXX not interruptible?  this is in the hb thread.. */
+	down_write(&hb_callback_sem);
+
 	if (down_interruptible(&hbcall->sem)) {
 		hbprintk("missed hb callback(%d) due to EINTR!\n", type);
-		return;
+		goto out;
 	}
 	
 	list_for_each(iter, &hbcall->list) {
 		f = list_entry(iter, struct hb_callback_func, hc_item);
-		(f->hc_func)(ptr1, ptr2, idx, f->hc_data);
+		(f->hc_func)(node, idx, f->hc_data);
 	}
-
 	up(&hbcall->sem);
+out:
+	up_write(&hb_callback_sem);
 }

Modified: branches/usysfsify/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/heartbeat.h	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/heartbeat.h	2005-03-16 19:14:57 UTC (rev 1984)
@@ -30,18 +30,10 @@
 
 #include "ocfs2_heartbeat.h"
 
-enum {
-	HB_NODE_STATE_INIT = 0,
-	HB_NODE_STATE_DOWN,
-	HB_NODE_STATE_UP
-};
-
 /* callback stuff */
-
 enum {
 	HB_NODE_DOWN_CB = 0,
 	HB_NODE_UP_CB,
-	HB_NODE_RESPONDED_CB,    // this one is very chatty
 	HB_NUM_CB
 };
 
@@ -56,20 +48,9 @@
 	int			hc_type;
 };
 
-enum {
-	HB_Root = 1,
-	HB_Disk,
-	HB_WriteOpArraySize
-};
-
-
-// number of initial allowed misses 
-#define HB_INITIAL_DISK_MARGIN     60
-#define HB_INITIAL_NET_MARGIN      60
-
 // number of allowed misses in steady state
+#define HB_INITIAL_DISK_MARGIN     60
 #define HB_DISK_MARGIN             30
-#define HB_NET_MARGIN              30
 
 struct kset *hb_alloc_hb_set(void);
 void hb_free_hb_set(struct kset *kset);
@@ -78,8 +59,7 @@
 		      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);
+void hb_fill_node_map(unsigned long *map, unsigned bytes);
+void hb_init(void);
 
-
-
 #endif /* CLUSTER_HEARTBEAT_H */

Modified: branches/usysfsify/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/nodemanager.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/nodemanager.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -21,7 +21,6 @@
 
 #include "cl_compat.h"
 #include "util.h"
-#include "clcommon.h"
 
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -629,6 +628,8 @@
 	int ret;
 	unsigned i;
 
+	hb_init();
+
 	for (i = 0; i <= ARRAY_SIZE(nm_callbacks); i++)
 		INIT_LIST_HEAD(&nm_callbacks[i]);
 

Modified: branches/usysfsify/fs/ocfs2/cluster/tcp.h
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/tcp.h	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/cluster/tcp.h	2005-03-16 19:14:57 UTC (rev 1984)
@@ -41,10 +41,9 @@
 #include <linux/in.h>
 
 /*
- * FIXME: no need for clcommon.h and nodemanager.h except for
+ * FIXME: no need for nodemanager.h except for
  * NM_MAX_NAME_LEN...shouldn't that be something or somewhere else?
  */
-#include "clcommon.h"
 #include "nodemanager.h"
 #include "ocfs2_tcp.h"
 

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmast.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmast.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmast.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -42,7 +42,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmconvert.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmconvert.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmconvert.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -42,7 +42,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmfs.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmfs.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmfs.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -40,7 +40,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
 #include "cluster/heartbeat.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmfs_compat.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmfs_compat.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmfs_compat.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -5,7 +5,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"
 

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmlock.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmlock.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmlock.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -42,7 +42,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmmaster.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmmaster.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmmaster.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -42,7 +42,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmmod.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmmod.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmmod.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -43,7 +43,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"
@@ -1091,7 +1090,7 @@
 	/* group sem locking should work for us here -- we're already
 	 * registered for heartbeat events so filling this should be
 	 * atomic wrt getting those handlers called. */
-	status = hb_fill_node_map(dlm->group, dlm->live_nodes_map,
+	status = hb_fill_node_map(dlm->live_nodes_map,
 				  sizeof(dlm->live_nodes_map));
 	if (status < 0) {
 		dlmprintk("I couldn't fill my node map!\n");

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmrecovery.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmrecovery.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmrecovery.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -41,7 +41,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmthread.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmthread.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmthread.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -44,7 +44,6 @@
 #include "util.h"
 
 #include "cluster/cl_compat.h"
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/dlmunlock.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/dlmunlock.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/dlmunlock.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -42,7 +42,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlm/userdlm.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlm/userdlm.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlm/userdlm.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -37,7 +37,6 @@
 
 #include "util.h"
 
-#include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
 #include "cluster/heartbeat.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/dlmglue.c
===================================================================
--- branches/usysfsify/fs/ocfs2/dlmglue.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/dlmglue.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -34,7 +34,6 @@
 #include <linux/kthread.h>
 
 #include <cluster/util.h>
-#include <cluster/clcommon.h>
 #include <cluster/heartbeat.h>
 #include <cluster/nodemanager.h>
 #include <cluster/tcp.h>

Modified: branches/usysfsify/fs/ocfs2/heartbeat.c
===================================================================
--- branches/usysfsify/fs/ocfs2/heartbeat.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/heartbeat.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -32,7 +32,6 @@
 #include <linux/highmem.h>
 
 #include <cluster/util.h>
-#include <cluster/clcommon.h>
 #include <cluster/heartbeat.h>
 #include <cluster/nodemanager.h>
 #include <dlm/dlmcommon.h>

Modified: branches/usysfsify/fs/ocfs2/ocfs.h
===================================================================
--- branches/usysfsify/fs/ocfs2/ocfs.h	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/ocfs.h	2005-03-16 19:14:57 UTC (rev 1984)
@@ -43,7 +43,6 @@
 #endif
 
 #include "cluster/util.h"
-#include "cluster/clcommon.h"
 #include "cluster/nodemanager.h"
 #include "cluster/heartbeat.h"
 #include "cluster/tcp.h"

Modified: branches/usysfsify/fs/ocfs2/super.c
===================================================================
--- branches/usysfsify/fs/ocfs2/super.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/super.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -43,7 +43,6 @@
 #include <linux/inet.h>
 
 #include <cluster/util.h>
-#include <cluster/clcommon.h>
 #include <cluster/nodemanager.h>
 #include <dlm/dlmcommon.h>
 

Modified: branches/usysfsify/fs/ocfs2/vote.c
===================================================================
--- branches/usysfsify/fs/ocfs2/vote.c	2005-03-16 05:53:39 UTC (rev 1983)
+++ branches/usysfsify/fs/ocfs2/vote.c	2005-03-16 19:14:57 UTC (rev 1984)
@@ -32,7 +32,6 @@
 #include <linux/kthread.h>
 
 #include <cluster/util.h>
-#include <cluster/clcommon.h>
 #include <cluster/heartbeat.h>
 #include <cluster/nodemanager.h>
 #include <cluster/tcp.h>



More information about the Ocfs2-commits mailing list