forked from pool/ocfs2-tools
c8700c5230
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/ocfs2-tools?expand=0&rev=8
150 lines
4.2 KiB
Diff
150 lines
4.2 KiB
Diff
From 0afd7bae3557bd443eac4e388c0c3cbf47690e5d Mon Sep 17 00:00:00 2001
|
|
From: Mark Fasheh <mfasheh@suse.com>
|
|
Date: Sun, 11 Apr 2010 16:10:01 +0800
|
|
Subject: [PATCH 04/30] dx_dirs: Add tunefs.ocfs2 feature for indexed directories
|
|
|
|
This only enables them for now. Disabling is a bit more involved, and
|
|
will come later.
|
|
|
|
[modified the patch for code rebase and cleanup -- Coly Li]
|
|
|
|
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
|
|
Signed-off-by: Coly Li <coly.li@suse.de>
|
|
---
|
|
tunefs.ocfs2/Makefile | 1 +
|
|
tunefs.ocfs2/feature_indexed_dirs.c | 89 +++++++++++++++++++++++++++++++++++
|
|
tunefs.ocfs2/op_features.c | 2 +
|
|
3 files changed, 92 insertions(+), 0 deletions(-)
|
|
create mode 100644 tunefs.ocfs2/feature_indexed_dirs.c
|
|
|
|
diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile
|
|
index dad7034..6219af6 100644
|
|
--- a/tunefs.ocfs2/Makefile
|
|
+++ b/tunefs.ocfs2/Makefile
|
|
@@ -26,6 +26,7 @@ OCFS2NE_FEATURES = \
|
|
feature_sparse_files \
|
|
feature_unwritten_extents \
|
|
feature_xattr \
|
|
+ feature_indexed_dirs \
|
|
feature_quota
|
|
|
|
OCFS2NE_OPERATIONS = \
|
|
diff --git a/tunefs.ocfs2/feature_indexed_dirs.c b/tunefs.ocfs2/feature_indexed_dirs.c
|
|
new file mode 100644
|
|
index 0000000..368eb87
|
|
--- /dev/null
|
|
+++ b/tunefs.ocfs2/feature_indexed_dirs.c
|
|
@@ -0,0 +1,89 @@
|
|
+/* -*- mode: c; c-basic-offset: 8; -*-
|
|
+ * vim: noexpandtab sw=8 ts=8 sts=0:
|
|
+ *
|
|
+ * feature_indexed_dirs.c
|
|
+ *
|
|
+ * ocfs2 tune utility for enabling and disabling the directory indexing
|
|
+ * feature.
|
|
+ *
|
|
+ * Copyright (C) 2009 Novell. 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_indexed_dirs(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_indexed_dirs(super)) {
|
|
+ verbosef(VL_APP,
|
|
+ "Directory indexing feature is already enabled; "
|
|
+ "nothing to enable\n");
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+
|
|
+ if (!tools_interact("Enable the directory indexing feature on "
|
|
+ "device \"%s\"? ",
|
|
+ fs->fs_devname))
|
|
+ goto out;
|
|
+
|
|
+ prog = tools_progress_start("Enable directory indexing", "dir idx", 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_INDEXED_DIRS);
|
|
+ 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;
|
|
+}
|
|
+
|
|
+/*
|
|
+ * TUNEFS_FLAG_ALLOCATION because disabling will want to dealloc
|
|
+ * blocks.
|
|
+ */
|
|
+DEFINE_TUNEFS_FEATURE_INCOMPAT(indexed_dirs,
|
|
+ OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS,
|
|
+ TUNEFS_FLAG_RW | TUNEFS_FLAG_ALLOCATION,
|
|
+ enable_indexed_dirs,
|
|
+ NULL);
|
|
+
|
|
+#ifdef DEBUG_EXE
|
|
+int main(int argc, char *argv[])
|
|
+{
|
|
+ return tunefs_feature_main(argc, argv, &indexed_dirs_feature);
|
|
+}
|
|
+#endif
|
|
diff --git a/tunefs.ocfs2/op_features.c b/tunefs.ocfs2/op_features.c
|
|
index 91abca1..613ea7e 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 indexed_dirs_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,
|
|
+ &indexed_dirs_feature,
|
|
NULL,
|
|
};
|
|
|
|
--
|
|
1.7.0.2
|
|
|