[Ocfs2-tools-devel] [PATCH 22/32] tools: Set and clear OCFS2_FEATURE_INCOMPAT_CLUSTERINFO

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


tunefs sets and clears OCFS2_FEATURE_INCOMPAT_CLUSTERINFO using
--fs-features=[no]clusterinfo.

tunefs --update-cluster-stack updates the cluster stack info for
o2cb stack if the above incompat it set.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 libocfs2/dlm.c                     |   13 +++-
 mkfs.ocfs2/mkfs.c                  |   10 ++-
 tunefs.ocfs2/Makefile              |    3 +-
 tunefs.ocfs2/feature_clusterinfo.c |  129 ++++++++++++++++++++++++++++++++++++
 tunefs.ocfs2/op_features.c         |    2 +
 5 files changed, 152 insertions(+), 5 deletions(-)
 create mode 100644 tunefs.ocfs2/feature_clusterinfo.c

diff --git a/libocfs2/dlm.c b/libocfs2/dlm.c
index 8751c07..848b795 100644
--- a/libocfs2/dlm.c
+++ b/libocfs2/dlm.c
@@ -151,8 +151,17 @@ errcode_t ocfs2_set_cluster_desc(ocfs2_filesys *fs,
 			if (ret)
 				goto out;
 		}
-		sb->s_feature_incompat |=
-			OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+
+		/*
+		 * if clusterinfo is not set and the stackname != o2cb,
+		 * then set the userspace flag
+		 */
+		if (!(sb->s_feature_incompat &
+		      OCFS2_FEATURE_INCOMPAT_CLUSTERINFO)) {
+			if (strcmp(desc->c_stack, OCFS2_CLASSIC_CLUSTER_STACK))
+				sb->s_feature_incompat |=
+					OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+		}
 		memcpy(sb->s_cluster_info.ci_stack, desc->c_stack,
 		       OCFS2_STACK_LABEL_LEN);
 		memcpy(sb->s_cluster_info.ci_cluster, desc->c_cluster,
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 3922638..012fbe6 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -2262,8 +2262,14 @@ format_superblock(State *s, SystemFileDiskRecord *rec,
 
 	if (s->cluster_stack) {
 		s->feature_flags.opt_incompat |=
-			(OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP|
-			 OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK);
+			OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP;
+
+		if (!(s->feature_flags.opt_incompat &
+		      OCFS2_FEATURE_INCOMPAT_CLUSTERINFO) &&
+		    (strcmp(s->cluster_stack, OCFS2_CLASSIC_CLUSTER_STACK))) {
+			s->feature_flags.opt_incompat |=
+				OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+		}
 		memcpy(di->id2.i_super.s_cluster_info.ci_stack,
 		       s->cluster_stack, OCFS2_STACK_LABEL_LEN);
 		memcpy(di->id2.i_super.s_cluster_info.ci_cluster,
diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile
index 1871136..3847d0f 100644
--- a/tunefs.ocfs2/Makefile
+++ b/tunefs.ocfs2/Makefile
@@ -28,7 +28,8 @@ OCFS2NE_FEATURES =			\
 	feature_unwritten_extents	\
 	feature_xattr			\
 	feature_indexed_dirs		\
-	feature_quota
+	feature_quota			\
+	feature_clusterinfo
 
 OCFS2NE_OPERATIONS =			\
 	op_cloned_volume		\
diff --git a/tunefs.ocfs2/feature_clusterinfo.c b/tunefs.ocfs2/feature_clusterinfo.c
new file mode 100644
index 0000000..2431362
--- /dev/null
+++ b/tunefs.ocfs2/feature_clusterinfo.c
@@ -0,0 +1,129 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * feature_clusterinfo.c
+ *
+ * ocfs2 tune utility to enable and disable the clusterinfo feature flag
+ *
+ * Copyright (C) 2010 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+#include "ocfs2/ocfs2.h"
+
+#include "libocfs2ne.h"
+
+static int enable_clusterinfo(ocfs2_filesys *fs, int flags)
+{
+	errcode_t err = 0;
+	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
+	struct tools_progress *prog;
+
+	if (OCFS2_HAS_INCOMPAT_FEATURE(super,
+				       OCFS2_FEATURE_INCOMPAT_CLUSTERINFO)) {
+		verbosef(VL_APP,
+			 "Clusterinfo feature is already enabled; "
+			 "nothing to enable\n");
+		goto out;
+	}
+
+	if (!tools_interact("Enable the clusterinfo feature on "
+			    "device \"%s\"? ", fs->fs_devname))
+		goto out;
+
+	prog = tools_progress_start("Enable clusterinfo", "clusterinfo", 1);
+	if (!prog) {
+		err = TUNEFS_ET_NO_MEMORY;
+		tcom_err(err, "while initializing the progress display");
+		goto out;
+	}
+
+	/* With clusterinfo set, userspace flag becomes superfluous */
+	OCFS2_SET_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_CLUSTERINFO);
+	OCFS2_CLEAR_INCOMPAT_FEATURE(super,
+				     OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK);
+	super->s_cluster_info.ci_stackflags = 0;
+
+	tunefs_block_signals();
+	err = ocfs2_write_super(fs);
+	if (err)
+		tcom_err(err, "while writing out the superblock");
+	tunefs_unblock_signals();
+
+	tools_progress_step(prog, 1);
+	tools_progress_stop(prog);
+
+out:
+	return err;
+}
+
+static int disable_clusterinfo(ocfs2_filesys *fs, int flags)
+{
+	errcode_t err = 0;
+	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
+	struct tools_progress *prog;
+
+	if (!OCFS2_HAS_INCOMPAT_FEATURE(super,
+					OCFS2_FEATURE_INCOMPAT_CLUSTERINFO)) {
+		verbosef(VL_APP,
+			 "Clusterinfo feature is already disabled; "
+			 "nothing to disable\n");
+		goto out;
+	}
+
+	if (!tools_interact("Disable the clusterinfo feature on "
+			    "device \"%s\"? ", fs->fs_devname))
+		goto out;
+
+	prog = tools_progress_start("Disable clusterinfo", "noclusterinfo", 1);
+	if (!prog) {
+		err = TUNEFS_ET_NO_MEMORY;
+		tcom_err(err, "while initializing the progress display");
+		goto out;
+	}
+
+	/* When clearing clusterinfo, set userspace if clusterstack != o2cb */
+	if (ocfs2_userspace_stack(super))
+		OCFS2_SET_INCOMPAT_FEATURE(super,
+					OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK);
+	OCFS2_CLEAR_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_CLUSTERINFO);
+
+	tunefs_block_signals();
+	err = ocfs2_write_super(fs);
+	if (err)
+		tcom_err(err, "while writing out the superblock");
+	tunefs_unblock_signals();
+
+	tools_progress_step(prog, 1);
+	tools_progress_stop(prog);
+
+out:
+	return err;
+
+}
+
+DEFINE_TUNEFS_FEATURE_INCOMPAT(clusterinfo,
+			       OCFS2_FEATURE_INCOMPAT_CLUSTERINFO,
+			       TUNEFS_FLAG_RW,
+			       enable_clusterinfo,
+			       disable_clusterinfo);
+
+#ifdef DEBUG_EXE
+int main(int argc, char *argv[])
+{
+	return tunefs_feature_main(argc, argv, &clusterinfo_feature);
+}
+#endif
diff --git a/tunefs.ocfs2/op_features.c b/tunefs.ocfs2/op_features.c
index 2ad0623..20b65a5 100644
--- a/tunefs.ocfs2/op_features.c
+++ b/tunefs.ocfs2/op_features.c
@@ -46,6 +46,7 @@ extern struct tunefs_feature grpquota_feature;
 extern struct tunefs_feature refcount_feature;
 extern struct tunefs_feature indexed_dirs_feature;
 extern struct tunefs_feature discontig_bg_feature;
+extern struct tunefs_feature clusterinfo_feature;
 
 /* List of features supported by ocfs2ne */
 static struct tunefs_feature *features[] = {
@@ -62,6 +63,7 @@ static struct tunefs_feature *features[] = {
 	&refcount_feature,
 	&indexed_dirs_feature,
 	&discontig_bg_feature,
+	&clusterinfo_feature,
 	NULL,
 };
 
-- 
1.7.0.4




More information about the Ocfs2-tools-devel mailing list