[Ocfs2-tools-devel] [PATCH 13/22] tunefs.ocfs2: Add enable discontig-bg operations.
Tao Ma
tao.ma at oracle.com
Wed Mar 31 21:41:17 PDT 2010
This patch just adds the support for enable discontig-bg
in tunefs.ocfs2 so that we can test it easily.
XXX:
Do we need to change the bg_size for all the suballocator
group so that it is consistent when new group is allocated?
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
tunefs.ocfs2/Makefile | 1 +
tunefs.ocfs2/feature_discontig_bg.c | 83 +++++++++++++++++++++++++++++++++++
tunefs.ocfs2/op_features.c | 2 +
3 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 tunefs.ocfs2/feature_discontig_bg.c
diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile
index dad7034..4682e38 100644
--- a/tunefs.ocfs2/Makefile
+++ b/tunefs.ocfs2/Makefile
@@ -18,6 +18,7 @@ UNINST_LIBRARIES = libocfs2ne.a
OCFS2NE_FEATURES = \
feature_backup_super \
+ feature_discontig_bg \
feature_extended_slotmap \
feature_inline_data \
feature_local \
diff --git a/tunefs.ocfs2/feature_discontig_bg.c b/tunefs.ocfs2/feature_discontig_bg.c
new file mode 100644
index 0000000..caba0d9
--- /dev/null
+++ b/tunefs.ocfs2/feature_discontig_bg.c
@@ -0,0 +1,83 @@
+/* -*- 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_bg(ocfs2_filesys *fs, int flags)
+{
+ errcode_t ret = 0;
+ struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
+ struct tools_progress *prog;
+
+ if (ocfs2_supports_discontig_bg(super)) {
+ verbosef(VL_APP,
+ "Discontiguous block group feature is already enabled;"
+ " nothing to enable\n");
+ goto out;
+ }
+
+ if (!tools_interact("Enable the discontiguous block group feature on "
+ "device \"%s\"? ",
+ fs->fs_devname))
+ goto out;
+
+ prog = tools_progress_start("Enable discontig block group",
+ "discontig bg", 1);
+ if (!prog) {
+ ret = TUNEFS_ET_NO_MEMORY;
+ tcom_err(ret, "while initializing the progress display");
+ goto out;
+ }
+
+ OCFS2_SET_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG);
+ 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:
+ return ret;
+}
+
+DEFINE_TUNEFS_FEATURE_INCOMPAT(discontig_bg,
+ OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG,
+ TUNEFS_FLAG_RW | TUNEFS_FLAG_ALLOCATION |
+ TUNEFS_FLAG_LARGECACHE,
+ enable_discontig_bg,
+ NULL);
+
+#ifdef DEBUG_EXE
+int main(int argc, char *argv[])
+{
+ return tunefs_feature_main(argc, argv, &discontig_bg_feature);
+}
+#endif
diff --git a/tunefs.ocfs2/op_features.c b/tunefs.ocfs2/op_features.c
index 91abca1..2758c45 100644
--- a/tunefs.ocfs2/op_features.c
+++ b/tunefs.ocfs2/op_features.c
@@ -44,6 +44,7 @@ extern struct tunefs_feature xattr_feature;
extern struct tunefs_feature usrquota_feature;
extern struct tunefs_feature grpquota_feature;
extern struct tunefs_feature refcount_feature;
+extern struct tunefs_feature discontig_bg_feature;
/* List of features supported by ocfs2ne */
static struct tunefs_feature *features[] = {
@@ -58,6 +59,7 @@ static struct tunefs_feature *features[] = {
&usrquota_feature,
&grpquota_feature,
&refcount_feature,
+ &discontig_bg_feature,
NULL,
};
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list