[Ocfs2-commits] zab commits r1998 - branches/usysfsify/fs/ocfs2/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Mar 17 17:24:30 CST 2005


Author: zab
Date: 2005-03-17 17:24:28 -0600 (Thu, 17 Mar 2005)
New Revision: 1998

Modified:
   branches/usysfsify/fs/ocfs2/cluster/heartbeat.c
Log:
o fix typical misuse of the horribly fragile list_head api
o block_bits off by one
o make sure we initialize the slots at the right time
o don't allow dev writing if slots haven't been allocated


Modified: branches/usysfsify/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/usysfsify/fs/ocfs2/cluster/heartbeat.c	2005-03-17 22:22:07 UTC (rev 1997)
+++ branches/usysfsify/fs/ocfs2/cluster/heartbeat.c	2005-03-17 23:24:28 UTC (rev 1998)
@@ -246,8 +246,7 @@
 	LIST_HEAD(newborn);
 	LIST_HEAD(deceased);
 	u64 cputime;
-	u8 i;
-	int rw;
+	int i, rw;
 
 	/* first we clear uptodate on other nodes slots and write our slot */
 	for(i = 0; i < reg->hr_blocks; i++) {
@@ -301,7 +300,7 @@
 				list_del_init(&slot->ds_dead_item);
 
 			if (list_empty(&slot->ds_alive_item))
-				list_add_tail(&newborn, &slot->ds_alive_item);
+				list_add_tail(&slot->ds_alive_item, &newborn);
 
 			slot->ds_last_time = cputime;
 			slot->ds_margin = HB_DISK_MARGIN;
@@ -322,7 +321,7 @@
 		/* 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);
+			list_add_tail(&slot->ds_dead_item, &deceased);
 		}
 	}
 
@@ -464,7 +463,7 @@
 	/* 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);
+	reg->hr_block_bits = ffs(reg->hr_block_bytes) - 1;
 
 	return count;
 }
@@ -499,9 +498,7 @@
 					   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')))
@@ -514,17 +511,6 @@
 	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;
@@ -545,6 +531,8 @@
 	struct file *filp = NULL;
 	struct inode *inode = NULL;
 	ssize_t ret = -EINVAL;
+	struct hb_disk_slot *slot;
+	int i;
 
 	fd = simple_strtol(p, &p, 0);
 	if (!p || (*p && (*p != '\n')))
@@ -557,6 +545,9 @@
 	if (filp == NULL)
 		goto out;
 
+	if (reg->hr_blocks == 0 || reg->hr_slots == NULL)
+		goto out;
+
 	inode = igrab(filp->f_mapping->host);
 	if (inode == NULL)
 		goto out;
@@ -569,14 +560,24 @@
 	}
 	inode = NULL;
 
-	reg->hr_task = kthread_run(hb_thread, reg, "hb-%s", reg->hr_kobj.name);
+	for(i = 0; i < reg->hr_blocks; i++) {
+		slot = &reg->hr_slots[i];
+		slot->ds_block = reg->hr_start_block + i;
+		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_task = kthread_run(hb_thread, reg, "hb-%s",
+				   reg->hr_kobj.k_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);
+	list_add_tail(&reg->hr_active_item, &hb_active_regions);
 	up_write(&hb_callback_sem);
 
 	ret = count;



More information about the Ocfs2-commits mailing list