[Ocfs2-commits] mfasheh commits r2354 - trunk/fs/ocfs2/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Jun 1 20:03:59 CDT 2005


Author: mfasheh
Signed-off-by: zab
Date: 2005-06-01 20:03:54 -0500 (Wed, 01 Jun 2005)
New Revision: 2354

Modified:
   trunk/fs/ocfs2/cluster/heartbeat.c
   trunk/fs/ocfs2/cluster/heartbeat.h
   trunk/fs/ocfs2/cluster/ocfs2_heartbeat.h
   trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h
Log:
* make heartbeat timeout and node death threshold configurable. We want this
  for timeout tuning.

Signed-off-by: zab



Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c	2005-06-02 00:59:25 UTC (rev 2353)
+++ trunk/fs/ocfs2/cluster/heartbeat.c	2005-06-02 01:03:54 UTC (rev 2354)
@@ -52,8 +52,6 @@
 static struct list_head o2hb_live_slots[O2NM_MAX_NODES];
 static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
 static LIST_HEAD(o2hb_node_events);
-
-
 static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue);
 
 static struct o2hb_callback {
@@ -62,8 +60,12 @@
 
 static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type);
 
-#define O2HB_THREAD_MS                2000   // every 2 seconds
+#define O2HB_REGION_MIN_TIMEOUT_MS	500
+#define O2HB_REGION_MAX_TIMEOUT_MS	jiffies_to_msecs(MAX_JIFFY_OFFSET)
 
+/* number of changes to be seen as live */ 
+#define O2HB_LIVE_THRESHOLD	   2
+
 #define O2HB_DEFAULT_BLOCK_BITS       9
 
 struct o2hb_node_event {
@@ -109,6 +111,9 @@
 	atomic_t		hr_steady_iterations;
 
 	char			hr_dev_name[BDEVNAME_SIZE];
+
+	unsigned int		hr_timeout_ms;
+	unsigned int		hr_dead_iter;
 };
 
 struct o2hb_bio_wait_ctxt {
@@ -512,7 +517,8 @@
 	o2nm_node_put(node);
 }
 
-static int o2hb_check_slot(struct o2hb_disk_slot *slot)
+static int o2hb_check_slot(struct o2hb_region *reg,
+			   struct o2hb_disk_slot *slot)
 {
 	int changed = 0;
 	struct o2hb_node_event event = 
@@ -568,7 +574,7 @@
 	/* live nodes only go dead after enough consequtive missed
 	 * samples..  reset the missed counter whenever we see 
 	 * activity */
-	if (slot->ds_equal_samples >= O2HB_DEAD_THRESHOLD) {
+	if (slot->ds_equal_samples >= reg->hr_dead_iter) {
 		mlog(ML_HEARTBEAT, "Node %d left my region\n",
 		     slot->ds_node_num);
 
@@ -665,7 +671,7 @@
 	i = -1;
 	while((i = find_next_bit(configured_nodes, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) {
 
-		change |= o2hb_check_slot(&reg->hr_slots[i]);
+		change |= o2hb_check_slot(reg, &reg->hr_slots[i]);
 	}
 
 	/* let the person who launched us know when things are steady */
@@ -696,7 +702,7 @@
 
 		/* the kthread api has blocked signals for us so no
 		 * need to record the return value. */
-		msleep_interruptible(O2HB_THREAD_MS);
+		msleep_interruptible(reg->hr_timeout_ms);
 	}
 
 	for(i = 0; i < reg->hr_blocks; i++)
@@ -775,6 +781,63 @@
 	kfree(reg);
 }
 
+static ssize_t o2hb_region_dead_iter_read(struct o2hb_region *reg,
+					  char *page)
+{
+	return sprintf(page, "%u\n", reg->hr_dead_iter);
+}
+
+static ssize_t o2hb_region_dead_iter_write(struct o2hb_region *reg,
+					   const char *page,
+					   size_t count)
+{
+	unsigned long tmp;
+	char *p = (char *)page;
+
+	if (reg->hr_bdev)
+		return -EINVAL;
+
+	tmp = simple_strtoul(p, &p, 0);
+	if (!p || (*p && (*p != '\n')))
+		return -EINVAL;
+
+	if (!tmp)
+		return -ERANGE;
+
+	reg->hr_dead_iter = (unsigned int)tmp;
+
+	return count;
+}
+
+static ssize_t o2hb_region_timeout_ms_read(struct o2hb_region *reg,
+					   char *page)
+{
+	return sprintf(page, "%u\n", reg->hr_timeout_ms);
+}
+
+static ssize_t o2hb_region_timeout_ms_write(struct o2hb_region *reg,
+					    const char *page,
+					    size_t count)
+{
+	unsigned long tmp;
+	char *p = (char *)page;
+
+	if (reg->hr_bdev)
+		return -EINVAL;
+
+	tmp = simple_strtoul(p, &p, 0);
+	if (!p || (*p && (*p != '\n')))
+		return -EINVAL;
+
+	if (tmp > O2HB_REGION_MAX_TIMEOUT_MS ||
+	    tmp < O2HB_REGION_MIN_TIMEOUT_MS)
+		return -ERANGE;
+
+	reg->hr_timeout_ms = (unsigned int)tmp;
+
+	return count;
+}
+
 static int o2hb_read_block_input(struct o2hb_region *reg,
 				 const char *page,
 				 size_t count,
@@ -902,6 +965,8 @@
 	     reg->hr_start_block, reg->hr_blocks);
 	mlog(ML_HEARTBEAT, "hr_block_bytes = %u, hr_block_bits = %u\n",
 	     reg->hr_block_bytes, reg->hr_block_bits);
+	mlog(ML_HEARTBEAT, "hr_timeout_ms = %u, hr_dead_iter = %u\n",
+	     reg->hr_timeout_ms, reg->hr_dead_iter);
 }
 
 static int o2hb_map_slot_data(struct o2hb_region *reg)
@@ -993,7 +1058,8 @@
 		goto out;
 
 	if (reg->hr_blocks == 0 || reg->hr_start_block == 0 ||
-	    reg->hr_block_bytes == 0)
+	    reg->hr_block_bytes == 0 || reg->hr_dead_iter == 0 ||
+	    reg->hr_timeout_ms == 0)
 		goto out;
 
 	inode = igrab(filp->f_mapping->host);
@@ -1070,6 +1136,22 @@
 	ssize_t (*store)(struct o2hb_region *, const char *, size_t);
 };
 
+static struct o2hb_region_attribute o2hb_region_attr_dead_iter = {
+	.attr	= { .ca_owner = THIS_MODULE,
+		    .ca_name = "dead_iter",
+		    .ca_mode = S_IRUGO | S_IWUSR },
+	.show	= o2hb_region_dead_iter_read,
+	.store	= o2hb_region_dead_iter_write,
+};
+
+static struct o2hb_region_attribute o2hb_region_attr_timeout_ms = {
+	.attr	= { .ca_owner = THIS_MODULE,
+		    .ca_name = "timeout_ms",
+		    .ca_mode = S_IRUGO | S_IWUSR },
+	.show	= o2hb_region_timeout_ms_read,
+	.store	= o2hb_region_timeout_ms_write,
+};
+
 static struct o2hb_region_attribute o2hb_region_attr_block_bytes = {
 	.attr	= { .ca_owner = THIS_MODULE,
 		    .ca_name = "block_bytes",
@@ -1103,6 +1185,8 @@
 };
 
 static struct configfs_attribute *o2hb_region_attrs[] = {
+	&o2hb_region_attr_dead_iter.attr,
+	&o2hb_region_attr_timeout_ms.attr,
 	&o2hb_region_attr_block_bytes.attr,
 	&o2hb_region_attr_start_block.attr,
 	&o2hb_region_attr_blocks.attr,

Modified: trunk/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.h	2005-06-02 00:59:25 UTC (rev 2353)
+++ trunk/fs/ocfs2/cluster/heartbeat.h	2005-06-02 01:03:54 UTC (rev 2354)
@@ -50,11 +50,6 @@
 	enum o2hb_callback_type hc_type;
 };
 
-/* number of changes to be seen as live */ 
-#define O2HB_LIVE_THRESHOLD	   2
-/* number of missed changes to be seen as dead */ 
-#define O2HB_DEAD_THRESHOLD	   30
-
 struct config_group *o2hb_alloc_hb_set(void);
 void o2hb_free_hb_set(struct config_group *group);
 

Modified: trunk/fs/ocfs2/cluster/ocfs2_heartbeat.h
===================================================================
--- trunk/fs/ocfs2/cluster/ocfs2_heartbeat.h	2005-06-02 00:59:25 UTC (rev 2353)
+++ trunk/fs/ocfs2/cluster/ocfs2_heartbeat.h	2005-06-02 01:03:54 UTC (rev 2354)
@@ -33,4 +33,7 @@
 	__u32 hb_cksum;
 };
 
+#define O2HB_DEFAULT_TIMEOUT_MS		2000
+#define O2HB_DEFAULT_NODE_DOWN_MISSES	10
+
 #endif /* _OCFS2_HEARTBEAT_H */

Modified: trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h
===================================================================
--- trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h	2005-06-02 00:59:25 UTC (rev 2353)
+++ trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h	2005-06-02 01:03:54 UTC (rev 2354)
@@ -28,7 +28,7 @@
 #ifndef _OCFS2_NODEMANAGER_H
 #define _OCFS2_NODEMANAGER_H
 
-#define O2NM_API_VERSION	2
+#define O2NM_API_VERSION	3
 
 #define O2NM_MAX_NODES		255
 #define O2NM_INVALID_NODE_NUM	255



More information about the Ocfs2-commits mailing list