ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
From: Sunil Mushran <sunil.mushran@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 01/20] ocfs2/cluster: Add heartbeat mode configfs parameter
Date: Tue, 14 Sep 2010 15:50:37 -0700	[thread overview]
Message-ID: <1284504656-2434-2-git-send-email-sunil.mushran@oracle.com> (raw)
In-Reply-To: <1284504656-2434-1-git-send-email-sunil.mushran@oracle.com>

Add heartbeat mode parameter to the configfs tree. This will be used
to set/show the heartbeat mode. The user is free to toggle the mode
between local and global as long as there is no active heartbeat region.

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
---
 fs/ocfs2/cluster/heartbeat.c |   70 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 41d5f1f..57cc715 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -77,7 +77,19 @@ static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type);
 
 #define O2HB_DEFAULT_BLOCK_BITS       9
 
+enum o2hb_heartbeat_modes {
+	O2HB_HEARTBEAT_LOCAL		= 0,
+	O2HB_HEARTBEAT_GLOBAL,
+	O2HB_HEARTBEAT_NUM_MODES,
+};
+
+char *o2hb_heartbeat_mode_desc[O2HB_HEARTBEAT_NUM_MODES] = {
+		"local",	/* O2HB_HEARTBEAT_LOCAL */
+		"global",	/* O2HB_HEARTBEAT_GLOBAL */
+};
+
 unsigned int o2hb_dead_threshold = O2HB_DEFAULT_DEAD_THRESHOLD;
+unsigned int o2hb_heartbeat_mode = O2HB_HEARTBEAT_LOCAL;
 
 /* Only sets a new threshold if there are no active regions.
  *
@@ -94,6 +106,22 @@ static void o2hb_dead_threshold_set(unsigned int threshold)
 	}
 }
 
+static int o2hb_global_hearbeat_mode_set(unsigned int hb_mode)
+{
+	int ret = -1;
+
+	if (hb_mode < O2HB_HEARTBEAT_NUM_MODES) {
+		spin_lock(&o2hb_live_lock);
+		if (list_empty(&o2hb_all_regions)) {
+			o2hb_heartbeat_mode = hb_mode;
+			ret = 0;
+		}
+		spin_unlock(&o2hb_live_lock);
+	}
+
+	return ret;
+}
+
 struct o2hb_node_event {
 	struct list_head        hn_item;
 	enum o2hb_callback_type hn_event_type;
@@ -1688,6 +1716,39 @@ static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group
 	return count;
 }
 
+static
+ssize_t o2hb_heartbeat_group_mode_show(struct o2hb_heartbeat_group *group,
+				       char *page)
+{
+	return sprintf(page, "%s\n",
+		       o2hb_heartbeat_mode_desc[o2hb_heartbeat_mode]);
+}
+
+static
+ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group,
+					const char *page, size_t count)
+{
+	unsigned int i;
+	int ret;
+	size_t len;
+
+	len = (page[count - 1] == '\n') ? count - 1 : count;
+
+	for (i = 0; i < O2HB_HEARTBEAT_NUM_MODES; ++i) {
+		if (strnicmp(page, o2hb_heartbeat_mode_desc[i], len))
+			continue;
+
+		ret = o2hb_global_hearbeat_mode_set(i);
+		if (!ret)
+			printk(KERN_NOTICE "ocfs2: Heartbeat mode set to %s\n",
+			       o2hb_heartbeat_mode_desc[i]);
+		return count;
+	}
+
+	return -EINVAL;
+
+}
+
 static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = {
 	.attr	= { .ca_owner = THIS_MODULE,
 		    .ca_name = "dead_threshold",
@@ -1696,8 +1757,17 @@ static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold
 	.store	= o2hb_heartbeat_group_threshold_store,
 };
 
+static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_mode = {
+	.attr   = { .ca_owner = THIS_MODULE,
+		.ca_name = "mode",
+		.ca_mode = S_IRUGO | S_IWUSR },
+	.show   = o2hb_heartbeat_group_mode_show,
+	.store  = o2hb_heartbeat_group_mode_store,
+};
+
 static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = {
 	&o2hb_heartbeat_group_attr_threshold.attr,
+	&o2hb_heartbeat_group_attr_mode.attr,
 	NULL,
 };
 
-- 
1.7.0.4

  reply	other threads:[~2010-09-14 22:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-14 22:50 [Ocfs2-devel] Global Heartbeat - fs patches Sunil Mushran
2010-09-14 22:50 ` Sunil Mushran [this message]
2010-09-25  8:11   ` [Ocfs2-devel] [PATCH 01/20] ocfs2/cluster: Add heartbeat mode configfs parameter Wengang Wang
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 02/20] ocfs2: Add an incompat feature flag OCFS2_FEATURE_INCOMPAT_CLUSTERINFO Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 03/20] ocfs2: Add support for heartbeat=global mount option Sunil Mushran
2010-09-25  8:39   ` Wengang Wang
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 04/20] ocfs2/dlm: Expose dlm_protocol in dlm_state Sunil Mushran
2010-09-25  8:42   ` Wengang Wang
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 05/20] ocfs2/cluster: Get all heartbeat regions Sunil Mushran
2010-09-23 21:57   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 06/20] ocfs2/dlm: Add message DLM_QUERY_REGION Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 07/20] ocfs2: Print message if user mounts without starting global heartbeat Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 08/20] ocfs2/dlm: Add message DLM_QUERY_NODEINFO Sunil Mushran
2010-09-23 22:18   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 09/20] ocfs2/cluster: Print messages when adding/removing nodes and heartbeat regions Sunil Mushran
2010-09-23 22:25   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 10/20] ocfs2/cluster: Check slots for unconfigured live nodes Sunil Mushran
2010-09-23 22:31   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 11/20] ocfs2/cluster: Reorganize o2hb debugfs init Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 12/20] ocfs2/cluster: Maintain live node bitmap per heartbeat region Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 13/20] ocfs2/cluster: Track number of global heartbeat regions Sunil Mushran
2010-09-25  9:36   ` Wengang Wang
2010-09-25  9:44     ` Joel Becker
2010-09-25 10:09       ` Wengang Wang
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 14/20] ocfs2/cluster: Track bitmap of live " Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 15/20] ocfs2/cluster: Maintain bitmap of quorum regions Sunil Mushran
2010-09-23 22:34   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 16/20] ocfs2/cluster: Maintain bitmap of failed regions Sunil Mushran
2010-09-23 22:35   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 17/20] ocfs2/cluster: Create debugfs files for live, quorum and failed region bitmaps Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 18/20] ocfs2/cluster: Create debugfs dir/files for each region Sunil Mushran
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 19/20] ocfs2/cluster: Add printks to show heartbeat up/down events Sunil Mushran
2010-09-23 22:36   ` Joel Becker
2010-09-14 22:50 ` [Ocfs2-devel] [PATCH 20/20] ocfs2/cluster: Show per region heartbeat elapsed time Sunil Mushran
2010-09-23 22:37 ` [Ocfs2-devel] Global Heartbeat - fs patches Joel Becker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1284504656-2434-2-git-send-email-sunil.mushran@oracle.com \
    --to=sunil.mushran@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).