[Ocfs2-tools-devel] [PATCH 21/32] libocfs2: Add stackflags in superblock

Sunil Mushran sunil.mushran at oracle.com
Tue Sep 14 15:54:51 PDT 2010


This patch adds stackflags to sb->s_clusterinfo. It also introduces a
clusterinfo flag OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT to denote the enabled
global heartbeat mode.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 debugfs.ocfs2/dump.c            |    4 ++++
 debugfs.ocfs2/include/utils.h   |    2 ++
 debugfs.ocfs2/utils.c           |   14 ++++++++++++++
 include/ocfs2-kernel/ocfs2_fs.h |   19 ++++++++++++++++++-
 include/ocfs2/ocfs2.h           |   11 +++++++++++
 libocfs2/feature_string.c       |   17 +++++++++++++++++
 6 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index fcdee0c..d56121e 100644
--- a/debugfs.ocfs2/dump.c
+++ b/debugfs.ocfs2/dump.c
@@ -102,6 +102,10 @@ void dump_super_block(FILE *out, struct ocfs2_super_block *sb)
 	else
 		fprintf(out, "\tCluster stack: classic o2cb\n");
 
+	get_cluster_info_flag(sb, buf, sizeof(buf));
+	fprintf(out, "\tCluster flags: %u %s\n",
+		sb->s_cluster_info.ci_stackflags, buf);
+
 	return ;
 }
 
diff --git a/debugfs.ocfs2/include/utils.h b/debugfs.ocfs2/include/utils.h
index 96de0cf..8b5c90c 100644
--- a/debugfs.ocfs2/include/utils.h
+++ b/debugfs.ocfs2/include/utils.h
@@ -41,6 +41,8 @@ void get_incompat_flag(struct ocfs2_super_block *sb, char *buf, size_t count);
 void get_tunefs_flag(struct ocfs2_super_block *sb, char *buf, size_t count);
 void get_compat_flag(struct ocfs2_super_block *sb, char *buf, size_t count);
 void get_rocompat_flag(struct ocfs2_super_block *sb, char *buf, size_t count);
+void get_cluster_info_flag(struct ocfs2_super_block *sb, char *buf,
+			   size_t count);
 void get_journal_block_type (uint32_t jtype, GString *str);
 void get_tag_flag (uint32_t flags, GString *str);
 FILE *open_pager(int interactive);
diff --git a/debugfs.ocfs2/utils.c b/debugfs.ocfs2/utils.c
index 38b4f6d..d22ae8e 100644
--- a/debugfs.ocfs2/utils.c
+++ b/debugfs.ocfs2/utils.c
@@ -78,6 +78,20 @@ void get_rocompat_flag(struct ocfs2_super_block *sb, char *buf, size_t count)
 		com_err(gbls.cmd, err, "while processing ro compat flags");
 }
 
+void get_cluster_info_flag(struct ocfs2_super_block *sb, char *buf,
+			   size_t count)
+{
+	errcode_t err = 0;
+
+	*buf = '\0';
+	if (ocfs2_o2cb_stack(sb))
+		err = ocfs2_snprint_cluster_o2cb_flags(buf, count,
+					sb->s_cluster_info.ci_stackflags);
+
+	if (err)
+		com_err(gbls.cmd, err, "while processing clusterinfo flags");
+}
+
 /*
  * get_journal_block_type()
  *
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index 5d335ad..1ba2f41 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -311,6 +311,11 @@
  */
 #define OCFS2_MIN_XATTR_INLINE_SIZE     256
 
+/*
+ * Cluster info flags (ocfs2_cluster_info.ci_stackflags)
+ */
+#define OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT	(0x01)
+
 struct ocfs2_system_inode_info {
 	char	*si_name;
 	int	si_iflags;
@@ -571,9 +576,21 @@ struct ocfs2_slot_map_extended {
  */
 };
 
+/*
+ * ci_stackflags is only valid if the incompat bit
+ * OCFS2_FEATURE_INCOMPAT_CLUSTERINFO is set.
+ */
 struct ocfs2_cluster_info {
 /*00*/	__u8   ci_stack[OCFS2_STACK_LABEL_LEN];
-	__le32 ci_reserved;
+	union {
+		__le32 ci_reserved;
+		struct {
+			__u8 ci_reserved1;
+			__u8 ci_reserved2;
+			__u8 ci_reserved3;
+			__u8 ci_stackflags;
+		};
+	};
 /*08*/	__u8   ci_cluster[OCFS2_CLUSTER_NAME_LEN];
 /*18*/
 };
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index e9b43f2..fe4ebb1 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -968,6 +968,8 @@ errcode_t ocfs2_snprint_feature_flags(char *str, size_t size,
 errcode_t ocfs2_snprint_tunefs_flags(char *str, size_t size, uint16_t flags);
 errcode_t ocfs2_snprint_extent_flags(char *str, size_t size, uint8_t flags);
 errcode_t ocfs2_snprint_refcount_flags(char *str, size_t size, uint8_t flags);
+errcode_t ocfs2_snprint_cluster_o2cb_flags(char *str, size_t size,
+					   uint8_t flags);
 errcode_t ocfs2_parse_feature(const char *opts,
 			      ocfs2_fs_options *feature_flags,
 			      ocfs2_fs_options *reverse_flags);
@@ -1264,6 +1266,15 @@ static inline int ocfs2_o2cb_stack(struct ocfs2_super_block *osb)
 	return 0;
 }
 
+static inline int ocfs2_cluster_o2cb_global_heartbeat(struct ocfs2_super_block *osb)
+{
+	if (!ocfs2_o2cb_stack(osb))
+		return 0;
+
+	return osb->s_cluster_info.ci_stackflags &
+		OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT;
+}
+
 static inline int ocfs2_writes_unwritten_extents(struct ocfs2_super_block *osb)
 {
 	/*
diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
index 2a052e9..c265d49 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -341,6 +341,16 @@ static struct flag_name ocfs2_refcount_flag_names[] = {
 	},
 };
 
+static struct flag_name ocfs2_cluster_o2cb_flag_names[] = {
+	{
+		.fl_name = "Globalheartbeat",
+		.fl_flag = OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT,
+	},
+	{
+		.fl_name = NULL,
+	},
+};
+
 static inline void merge_features(ocfs2_fs_options *features,
 				  ocfs2_fs_options new_features)
 {
@@ -505,6 +515,13 @@ errcode_t ocfs2_snprint_refcount_flags(char *str, size_t size, uint8_t flags)
 					str, size, (uint32_t)flags);
 }
 
+errcode_t ocfs2_snprint_cluster_o2cb_flags(char *str, size_t size,
+					   uint8_t flags)
+{
+	return ocfs2_snprint_flag_names(ocfs2_cluster_o2cb_flag_names,
+					str, size, (uint32_t)flags);
+}
+
 /*
  * If we are asked to clear a feature, we also need to clear any other
  * features that depend on it.
-- 
1.7.0.4




More information about the Ocfs2-tools-devel mailing list