[Ocfs2-tools-devel] [PATCH 02/11] debugfs.ocfs2: Display cluster stack information.

Joel Becker joel.becker at oracle.com
Tue May 27 18:44:22 PDT 2008


debugfs.ocfs2 now recognizes OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK and
acts appropriately when dumping the superblock.  This includes
displaying the cluster stack name and cluster name.

Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 debugfs.ocfs2/dump.c  |    8 ++++++
 debugfs.ocfs2/utils.c |   62 +++++++++++++++++++++++++-----------------------
 2 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index f43bf6b..33770c3 100644
--- a/debugfs.ocfs2/dump.c
+++ b/debugfs.ocfs2/dump.c
@@ -91,6 +91,14 @@ void dump_super_block(FILE *out, struct ocfs2_super_block *sb)
 	for (i = 0; i < 16; i++)
 		fprintf(out, "%02X", sb->s_uuid[i]);
 	fprintf(out, "\n");
+	if (ocfs2_userspace_stack(sb))
+		fprintf(out,
+			"\tCluster stack: %s\n"
+			"\tCluster name: %s\n",
+			sb->s_cluster_info.ci_stack,
+			sb->s_cluster_info.ci_cluster);
+	else
+		fprintf(out, "\tCluster stack: classic o2cb\n");
 
 	g_string_free(compat, 1);
 	g_string_free(incompat, 1);
diff --git a/debugfs.ocfs2/utils.c b/debugfs.ocfs2/utils.c
index af323b0..eef0531 100644
--- a/debugfs.ocfs2/utils.c
+++ b/debugfs.ocfs2/utils.c
@@ -28,33 +28,35 @@
 
 extern dbgfs_gbls gbls;
 
+/*
+ * Tests features in a flag field and adds to a printable string.  Expects
+ * the flag field named 'flag' and the string named 'str'.  Primarily for
+ * readability.
+ */
+#define test_feature(_flag, _flagstr) do {		\
+	typeof(flag) _f = (_flag);			\
+	if (flag & _f) {				\
+		g_string_append(str, (_flagstr));	\
+		g_string_append_c(str, ' ');		\
+		flag &= ~_f;				\
+	}						\
+} while (0)
+
 void get_incompat_flag(uint32_t flag, GString *str)
 {
-	if (flag & OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV)
-		g_string_append(str, "Heartbeat ");
-
-	if (flag & OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG)
-		g_string_append(str, "AbortedResize ");
-
-	if (flag & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT)
-		g_string_append(str, "Local ");
-
-	if (flag & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC)
-		g_string_append(str, "Sparse ");
-
-	if (flag & OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
-		g_string_append(str, "ExtendedSlotMap ");
-
-	if (flag & OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG) {
-		g_string_append(str, "AbortedTunefs ");
-	}
 
-	if (flag & ~(OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV |
-		     OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG |
-		     OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT |
-		     OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
-		     OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP |
-		     OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG))
+	test_feature(OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV, "Heartbeat");
+	test_feature(OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG, "AbortedResize");
+	test_feature(OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT, "Local");
+	test_feature(OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC, "Sparse");
+	test_feature(OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP,
+		     "ExtendedSlotMap");
+	test_feature(OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK,
+		     "UserspaceClusterStack");
+	test_feature(OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG, "AbortedTunefs");
+
+        /* test_feature() clears out known flags */
+	if (flag)
 		g_string_append(str, "Unknown ");
 
 	if (!str->len)
@@ -81,10 +83,10 @@ void get_tunefs_flag(uint32_t incompat_flag, uint16_t flag, GString *str)
 
 void get_compat_flag(uint32_t flag, GString *str)
 {
-	if (flag & OCFS2_FEATURE_COMPAT_BACKUP_SB)
-		g_string_append(str, "BackupSuper ");
+	test_feature(OCFS2_FEATURE_COMPAT_BACKUP_SB, "BackupSuper");
 
-	if (flag & ~(OCFS2_FEATURE_COMPAT_BACKUP_SB))
+        /* test_feature() clears out known flags */
+        if (flag)
 		g_string_append(str, "Unknown ");
 
 	if (!str->len)
@@ -95,10 +97,10 @@ void get_compat_flag(uint32_t flag, GString *str)
 
 void get_rocompat_flag(uint32_t flag, GString *str)
 {
-	if (flag & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
-		g_string_append(str, "Unwritten ");
+	test_feature(OCFS2_FEATURE_RO_COMPAT_UNWRITTEN, "Unwritten");
 
-	if (flag & ~OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
+        /* test_feature() clears out known flags */
+        if (flag)
 		 g_string_append(str, "Unknown ");
 
 	if (!str->len)
-- 
1.5.4.5




More information about the Ocfs2-tools-devel mailing list