[Ocfs2-tools-devel] [PATCH 4/6] ocfs2: tunefs enable discontig la

Srinivas Eeda srinivas.eeda at oracle.com
Mon May 7 16:49:08 PDT 2012


enable discontiguous localalloc feature

Signed-off-by: Srinivas Eeda <srinivas.eeda at oracle.com>
---
 tunefs.ocfs2/Makefile               |    1 +
 tunefs.ocfs2/feature_discontig_la.c |  116 +++++++++++++++++++++++++++++++++++
 tunefs.ocfs2/op_features.c          |    2 +
 3 files changed, 119 insertions(+), 0 deletions(-)
 create mode 100644 tunefs.ocfs2/feature_discontig_la.c

diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile
index 585a68c..b57cb02 100644
--- a/tunefs.ocfs2/Makefile
+++ b/tunefs.ocfs2/Makefile
@@ -19,6 +19,7 @@ UNINST_LIBRARIES = libocfs2ne.a
 OCFS2NE_FEATURES =			\
 	feature_backup_super		\
 	feature_discontig_bg		\
+	feature_discontig_la		\
 	feature_extended_slotmap	\
 	feature_inline_data		\
 	feature_local			\
diff --git a/tunefs.ocfs2/feature_discontig_la.c b/tunefs.ocfs2/feature_discontig_la.c
new file mode 100644
index 0000000..102548d
--- /dev/null
+++ b/tunefs.ocfs2/feature_discontig_la.c
@@ -0,0 +1,116 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * feature_discontig_alloc.c
+ *
+ * ocfs2 tune utility for enabling and disabling the discontig_alloc feature.
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include "ocfs2/ocfs2.h"
+
+#include "libocfs2ne.h"
+
+static int enable_discontig_la(ocfs2_filesys *fs, int flags)
+{
+	errcode_t ret = 0;
+	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
+	struct tools_progress *prog;
+	struct ocfs2_dinode *di;
+	uint64_t blkno;
+	char *buf = NULL;
+	int slot;
+
+	if (ocfs2_supports_discontig_la(super)) {
+		verbosef(VL_APP,
+			 "Discontiguous local alloc feature is already enabled;"
+			 " nothing to enable\n");
+		goto out;
+	}
+
+	if (!tools_interact("Enable the discontiguous local alloc feature on "
+			    "device \"%s\"? ",
+			    fs->fs_devname))
+		goto out;
+
+	prog = tools_progress_start("Enable discontig local alloc",
+				    "discontig la", 1);
+	if (!prog) {
+		ret = TUNEFS_ET_NO_MEMORY;
+		tcom_err(ret, "while initializing the progress display");
+		goto out;
+	}
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		goto out;
+
+	di = (struct ocfs2_dinode *)buf;
+	/* iterate every inode_alloc first. */
+	for (slot = 0; slot < OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
+	     slot++) {
+		ret = ocfs2_lookup_system_inode(fs,
+						LOCAL_ALLOC_SYSTEM_INODE,
+						slot, &blkno);
+		if (ret) {
+			tcom_err(ret, "while finding local alloc %d", slot);
+			goto out;
+		}
+
+		ret = ocfs2_read_inode(fs, blkno, buf);
+		if (ret)
+			goto out;
+
+		if (di->id1.bitmap1.i_total) {
+			tcom_err(ret, "local alloc %d is not clean, run "
+				 "fsck.ocfs2 to clean the file system", slot);
+			goto out;
+		}
+		tools_progress_step(prog, 1);
+	}
+	OCFS2_SET_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_DISCONTIG_LA);
+	tunefs_block_signals();
+	ret = ocfs2_write_super(fs);
+	tunefs_unblock_signals();
+	if (ret)
+		tcom_err(ret, "while writing out the superblock");
+
+	tools_progress_step(prog, 1);
+	tools_progress_stop(prog);
+out:
+	if (buf)
+		ocfs2_free(&buf);
+	return ret;
+}
+
+DEFINE_TUNEFS_FEATURE_INCOMPAT(discontig_la,
+			       OCFS2_FEATURE_INCOMPAT_DISCONTIG_LA,
+			       TUNEFS_FLAG_RW | TUNEFS_FLAG_ALLOCATION |
+			       TUNEFS_FLAG_LARGECACHE,
+			       enable_discontig_la,
+			       disable_discontig_la);
+
+#ifdef DEBUG_EXE
+int main(int argc, char *argv[])
+{
+	return tunefs_feature_main(argc, argv, &discontig_la_feature);
+}
+#endif
diff --git a/tunefs.ocfs2/op_features.c b/tunefs.ocfs2/op_features.c
index 20b65a5..2d07df2 100644
--- a/tunefs.ocfs2/op_features.c
+++ b/tunefs.ocfs2/op_features.c
@@ -47,6 +47,7 @@ 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;
+extern struct tunefs_feature discontig_la_feature;
 
 /* List of features supported by ocfs2ne */
 static struct tunefs_feature *features[] = {
@@ -64,6 +65,7 @@ static struct tunefs_feature *features[] = {
 	&indexed_dirs_feature,
 	&discontig_bg_feature,
 	&clusterinfo_feature,
+	&discontig_la_feature,
 	NULL,
 };
 
-- 
1.5.4.3




More information about the Ocfs2-tools-devel mailing list