[Ocfs2-commits] mfasheh commits r2528 - branches/ocfs2-1.0/fs/ocfs2/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Aug 18 19:24:46 CDT 2005


Author: mfasheh
Signed-off-by: jlbec
Date: 2005-08-18 19:24:43 -0500 (Thu, 18 Aug 2005)
New Revision: 2528

Modified:
   branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c
   branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.h
   branches/ocfs2-1.0/fs/ocfs2/cluster/nodemanager.c
   branches/ocfs2-1.0/fs/ocfs2/cluster/tcp_internal.h
Log:
* backport r2527 from trunk:
   -Make heartbeat dead iterations tunable. This will help sites
    who are getting heartbeat timeouts on very busy systems.

Signed-off-by: jlbec



Modified: branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c	2005-08-19 00:21:47 UTC (rev 2527)
+++ branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c	2005-08-19 00:24:43 UTC (rev 2528)
@@ -32,6 +32,7 @@
 #include <linux/configfs.h>
 #include <linux/random.h>
 #include <linux/crc32.h>
+#include <linux/time.h>
 
 #include "heartbeat.h"
 #include "tcp.h"
@@ -69,6 +70,23 @@
 
 #define O2HB_DEFAULT_BLOCK_BITS       9
 
+unsigned int o2hb_dead_threshold = O2HB_DEFAULT_DEAD_THRESHOLD;
+
+/* Only sets a new threshold if there are no active regions. 
+ *
+ * No locking or otherwise interesting code is required for reading
+ * o2hb_dead_threshold as it can't change once regions are active and
+ * it's not interesting to anyone until then anyway. */
+void o2hb_dead_threshold_set(unsigned int threshold)
+{
+	if (threshold > O2HB_MIN_DEAD_THRESHOLD) {
+		spin_lock(&o2hb_live_lock);
+		if (list_empty(&o2hb_all_regions))
+			o2hb_dead_threshold = threshold;
+		spin_unlock(&o2hb_live_lock);
+	}
+}
+
 struct o2hb_node_event {
 	struct list_head        hn_item;
 	enum o2hb_callback_type hn_event_type;
@@ -118,7 +136,6 @@
 	char			hr_dev_name[BDEVNAME_SIZE];
 
 	unsigned int		hr_timeout_ms;
-	unsigned int		hr_dead_iter;
 
 	/* randomized as the region goes up and down so that a node
 	 * recognizes a node going up and down in one iteration */
@@ -713,7 +730,7 @@
 	/* live nodes only go dead after enough consequtive missed
 	 * samples..  reset the missed counter whenever we see
 	 * activity */
-	if (slot->ds_equal_samples >= reg->hr_dead_iter || gen_changed) {
+	if (slot->ds_equal_samples >= o2hb_dead_threshold || gen_changed) {
 		mlog(ML_HEARTBEAT, "Node %d left my region\n",
 		     slot->ds_node_num);
 
@@ -1086,15 +1103,14 @@
 static void o2hb_init_region_params(struct o2hb_region *reg)
 {
 	reg->hr_slots_per_page = PAGE_CACHE_SIZE >> reg->hr_block_bits;
-	reg->hr_dead_iter = O2HB_DEAD_THRESHOLD;
 	reg->hr_timeout_ms = O2HB_REGION_TIMEOUT_MS;
 
 	mlog(ML_HEARTBEAT, "hr_start_block = %llu, hr_blocks = %u\n",
 	     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);
+	mlog(ML_HEARTBEAT, "hr_timeout_ms = %u\n", reg->hr_timeout_ms);
+	mlog(ML_HEARTBEAT, "dead threshold = %u\n", o2hb_dead_threshold);
 }
 
 static int o2hb_map_slot_data(struct o2hb_region *reg)

Modified: branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.h	2005-08-19 00:21:47 UTC (rev 2527)
+++ branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.h	2005-08-19 00:24:43 UTC (rev 2528)
@@ -34,9 +34,14 @@
 /* number of changes to be seen as live */
 #define O2HB_LIVE_THRESHOLD	   2
 /* number of equal samples to be seen as dead */
-#define O2HB_DEAD_THRESHOLD	   7
+extern unsigned int o2hb_dead_threshold;
+#define O2HB_DEFAULT_DEAD_THRESHOLD	   7
+/* Otherwise MAX_WRITE_TIMEOUT will be zero... */
+#define O2HB_MIN_DEAD_THRESHOLD	  2
+#define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1))
 
-#define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (O2HB_DEAD_THRESHOLD - 1))
+/* Always use this to set o2hb_dead_threshold */
+void o2hb_dead_threshold_set(unsigned int threshold);
 
 #define O2HB_CB_MAGIC		0x51d1e4ec
 

Modified: branches/ocfs2-1.0/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/cluster/nodemanager.c	2005-08-19 00:21:47 UTC (rev 2527)
+++ branches/ocfs2-1.0/fs/ocfs2/cluster/nodemanager.c	2005-08-19 00:24:43 UTC (rev 2528)
@@ -732,10 +732,12 @@
 static struct proc_dir_entry *o2nm_proc;
 
 #define O2NM_VERSION_PROC_NAME "interface_revision"
+#define O2NM_HB_DEAD_THRESHOLD_NAME "hb_dead_threshold"
 
 static void o2nm_remove_proc(struct proc_dir_entry *parent)
 {
 	remove_proc_entry(O2NM_VERSION_PROC_NAME, parent);
+	remove_proc_entry(O2NM_HB_DEAD_THRESHOLD_NAME, parent);
 }
 
 static void __exit exit_o2nm(void)
@@ -754,12 +756,12 @@
 	o2net_exit();
 }
 
-static int o2nm_proc_version(char *page, char **start, off_t off,
-			     int count, int *eof, void *data)
+static int o2nm_proc_read_uint(char *page, char **start, off_t off,
+			       int count, int *eof, unsigned int data)
 {
 	int len;
 
-	len = sprintf(page, "%u\n", O2NM_API_VERSION);
+	len = sprintf(page, "%u\n", data);
 	if (len < 0)
 		return len;
 
@@ -779,6 +781,46 @@
 	return len;
 }
 
+static int o2nm_proc_version(char *page, char **start, off_t off,
+			     int count, int *eof, void *data)
+{
+	return o2nm_proc_read_uint(page, start, off, count, eof,
+				   O2NM_API_VERSION);
+}
+
+static int o2nm_proc_threshold(char *page, char **start, off_t off,
+			       int count, int *eof, void *data)
+{
+	return o2nm_proc_read_uint(page, start, off, count, eof,
+				   o2hb_dead_threshold);
+}
+
+static int o2nm_proc_write_threshold(struct file *file,
+				     const char __user *buffer,
+				     unsigned long count, void *data)
+{
+	char buf[32];
+	char *p = buf;
+	unsigned long tmp;
+
+	if (count > ARRAY_SIZE(buf) - 1)
+		count = ARRAY_SIZE(buf) - 1;
+
+	if (copy_from_user(buf, buffer, count))
+		return -EFAULT;
+
+	buf[ARRAY_SIZE(buf) - 1] = '\0';
+
+	tmp = simple_strtoul(p, &p, 10);
+	if (!p || (*p && (*p != '\n')))
+                return -EINVAL;
+
+	/* this will validate ranges for us. */
+	o2hb_dead_threshold_set((unsigned int) tmp);
+
+	return count;
+}
+
 static int o2nm_init_proc(struct proc_dir_entry *parent)
 {
 	struct proc_dir_entry *p;
@@ -790,6 +832,17 @@
 				   NULL);
 	if (!p)
 		return -ENOMEM;
+
+	p = create_proc_read_entry(O2NM_HB_DEAD_THRESHOLD_NAME,
+				   S_IFREG | S_IRUGO | S_IWUSR, parent,
+				   o2nm_proc_threshold,
+				   NULL);
+	if (!p) {
+		remove_proc_entry(O2NM_VERSION_PROC_NAME, parent);
+		return -ENOMEM;
+	}
+	p->write_proc = o2nm_proc_write_threshold;
+
 	return 0;
 }
 

Modified: branches/ocfs2-1.0/fs/ocfs2/cluster/tcp_internal.h
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/cluster/tcp_internal.h	2005-08-19 00:21:47 UTC (rev 2527)
+++ branches/ocfs2-1.0/fs/ocfs2/cluster/tcp_internal.h	2005-08-19 00:24:43 UTC (rev 2528)
@@ -35,7 +35,7 @@
 /* we're delaying our quorum decision so that heartbeat will have timed
  * out truly dead nodes by the time we come around to making decisions
  * on their number */
-#define O2NET_QUORUM_DELAY_MS	((O2HB_DEAD_THRESHOLD + 2) * O2HB_REGION_TIMEOUT_MS)
+#define O2NET_QUORUM_DELAY_MS	((o2hb_dead_threshold + 2) * O2HB_REGION_TIMEOUT_MS)
 
 #define O2NET_KEEPALIVE_DELAY_SECS	5
 #define O2NET_IDLE_TIMEOUT_SECS		10



More information about the Ocfs2-commits mailing list