[Ocfs2-commits] smushran commits r2995 -
branches/ocfs2-1.2/fs/ocfs2/cluster
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Mar 26 13:26:50 PDT 2007
Author: smushran
Date: 2007-03-26 13:26:49 -0700 (Mon, 26 Mar 2007)
New Revision: 2995
Modified:
branches/ocfs2-1.2/fs/ocfs2/cluster/nodemanager.c
branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.c
branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.h
Log:
ocfs2: Make fence method a sysctl option
This patch is related to the one that changed the default fencing
call from panic to machine_restart. This patch allows one to go
back to panic by echoing 1 to /proc/fs/ocfs2_nodemanager/fence_method.
Signed-off-by: mfasheh
Modified: branches/ocfs2-1.2/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/cluster/nodemanager.c 2007-03-26 20:24:37 UTC (rev 2994)
+++ branches/ocfs2-1.2/fs/ocfs2/cluster/nodemanager.c 2007-03-26 20:26:49 UTC (rev 2995)
@@ -29,6 +29,7 @@
#include "tcp.h"
#include "nodemanager.h"
#include "heartbeat.h"
+#include "quorum.h"
#include "masklog.h"
#include "ver.h"
@@ -37,6 +38,8 @@
* cluster references throughout where nodes are looked up */
struct o2nm_cluster *o2nm_single_cluster = NULL;
+unsigned int o2nm_api_version = O2NM_API_VERSION;
+
#define OCFS2_MAX_HB_CTL_PATH 256
static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
@@ -903,11 +906,13 @@
#define O2NM_VERSION_PROC_NAME "interface_revision"
#define O2NM_HB_DEAD_THRESHOLD_NAME "hb_dead_threshold"
+#define O2NM_FENCE_OPTION_NAME "fence_method"
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);
+ remove_proc_entry(O2NM_FENCE_OPTION_NAME, parent);
}
static void __exit exit_o2nm(void)
@@ -926,12 +931,37 @@
o2net_exit();
}
+static int o2nm_proc_write_uint(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;
+
+ *(unsigned int *)data = tmp;
+
+ return count;
+}
+
static int o2nm_proc_read_uint(char *page, char **start, off_t off,
- int count, int *eof, unsigned int data)
+ int count, int *eof, void *data)
{
int len;
+ unsigned int val = *(unsigned int *)data;
- len = sprintf(page, "%u\n", data);
+ len = sprintf(page, "%u\n", val);
if (len < 0)
return len;
@@ -951,20 +981,6 @@
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)
@@ -995,25 +1011,37 @@
{
struct proc_dir_entry *p;
- p = create_proc_read_entry(O2NM_VERSION_PROC_NAME,
- S_IFREG | S_IRUGO,
- parent,
- o2nm_proc_version,
- NULL);
+ p = create_proc_entry(O2NM_VERSION_PROC_NAME,
+ S_IFREG | S_IRUGO, parent);
if (!p)
- return -ENOMEM;
+ goto bail1;
+ p->read_proc = o2nm_proc_read_uint;
+ p->data = (void *)&o2nm_api_version;
- 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 = create_proc_entry(O2NM_HB_DEAD_THRESHOLD_NAME,
+ S_IFREG | S_IRUGO | S_IWUSR, parent);
+ if (!p)
+ goto bail2;
p->write_proc = o2nm_proc_write_threshold;
+ p->read_proc = o2nm_proc_read_uint;
+ p->data = (void *)&o2hb_dead_threshold;
+ p = create_proc_entry(O2NM_FENCE_OPTION_NAME,
+ S_IFREG | S_IRUGO | S_IWUSR, parent);
+ if (!p)
+ goto bail3;
+ p->write_proc = o2nm_proc_write_uint;
+ p->read_proc = o2nm_proc_read_uint;
+ p->data = (void *)&o2quo_fence_option;
+
return 0;
+
+bail3:
+ remove_proc_entry(O2NM_HB_DEAD_THRESHOLD_NAME, parent);
+bail2:
+ remove_proc_entry(O2NM_VERSION_PROC_NAME, parent);
+bail1:
+ return -ENOMEM;
}
static int __init init_o2nm(void)
Modified: branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.c 2007-03-26 20:24:37 UTC (rev 2994)
+++ branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.c 2007-03-26 20:26:49 UTC (rev 2995)
@@ -66,16 +66,23 @@
unsigned long qs_hold_bm[BITS_TO_LONGS(O2NM_MAX_NODES)];
} o2quo_state;
+unsigned int o2quo_fence_option = 0;
+#define FENCE_PANIC_OPTION 1
+
/* this is horribly heavy-handed. It should instead flip the file
* system RO and call some userspace script. */
static void o2quo_fence_self(void)
{
- /* panic spins with interrupts enabled. with preempt
- * threads can still schedule, etc, etc */
- o2hb_stop_all_regions();
-
- printk("ocfs2 is very sorry to be fencing this system by restarting\n");
- machine_restart(NULL);
+ switch (o2quo_fence_option) {
+ case FENCE_PANIC_OPTION:
+ /* panic spins with interrupts enabled. with preempt
+ * threads can still schedule, etc, etc */
+ o2hb_stop_all_regions();
+ panic("*** ocfs2 is very sorry to be fencing this system by panicing ***\n");
+ default:
+ printk("*** ocfs2 is very sorry to be fencing this system by restarting ***\n");
+ machine_restart(NULL);
+ }
}
/* Indicate that a timeout occured on a hearbeat region write. The
Modified: branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.h
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.h 2007-03-26 20:24:37 UTC (rev 2994)
+++ branches/ocfs2-1.2/fs/ocfs2/cluster/quorum.h 2007-03-26 20:26:49 UTC (rev 2995)
@@ -23,6 +23,8 @@
#ifndef O2CLUSTER_QUORUM_H
#define O2CLUSTER_QUORUM_H
+extern unsigned int o2quo_fence_option;
+
void o2quo_init(void);
void o2quo_exit(void);
More information about the Ocfs2-commits
mailing list