forked from pool/ocfs2-tools
c8700c5230
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/ocfs2-tools?expand=0&rev=8
138 lines
3.5 KiB
Diff
138 lines
3.5 KiB
Diff
From 88d139c22a91b17ff451a50e37d002d8714748f3 Mon Sep 17 00:00:00 2001
|
|
From: Mark Fasheh <mfasheh@suse.com>
|
|
Date: Mon, 19 Apr 2010 22:26:47 -0700
|
|
Subject: [PATCH 18/30] mkfs.ocfs2: create root and orphan directories as indexed
|
|
|
|
If the indexed dirs feature is enabled but the inline directories feature is
|
|
for some reason disabled, we'll create sub-optimal (non-indexed) root and
|
|
orphan directories. It's easy however at the end of mkfs.ocfs2 to simply
|
|
index these.
|
|
|
|
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
|
|
---
|
|
mkfs.ocfs2/mkfs.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++----
|
|
mkfs.ocfs2/mkfs.h | 1 +
|
|
2 files changed, 62 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
|
|
index b43a9ba..5507872 100644
|
|
--- a/mkfs.ocfs2/mkfs.c
|
|
+++ b/mkfs.ocfs2/mkfs.c
|
|
@@ -82,6 +82,7 @@ static AllocGroup * initialize_alloc_group(State *s, const char *name,
|
|
uint64_t blkno,
|
|
uint16_t chain, uint16_t cpg,
|
|
uint16_t bpc);
|
|
+static void index_system_dirs(State *s, ocfs2_filesys *fs);
|
|
static void create_lost_found_dir(State *s, ocfs2_filesys *fs);
|
|
static void format_journals(State *s, ocfs2_filesys *fs);
|
|
static void format_slotmap(State *s, ocfs2_filesys *fs);
|
|
@@ -436,12 +437,6 @@ static void finish_normal_format(State *s)
|
|
printf("done\n");
|
|
|
|
if (!s->quiet)
|
|
- printf("Writing lost+found: ");
|
|
- create_lost_found_dir(s, fs);
|
|
- if (!s->quiet)
|
|
- printf("done\n");
|
|
-
|
|
- if (!s->quiet)
|
|
printf("Formatting quota files: ");
|
|
|
|
format_quota_files(s, fs);
|
|
@@ -449,6 +444,24 @@ static void finish_normal_format(State *s)
|
|
if (!s->quiet)
|
|
printf("done\n");
|
|
|
|
+ if (s->dx_dirs && !s->inline_data) {
|
|
+ /*
|
|
+ * We want to do this after quota, but before adding
|
|
+ * any new entries to directories.
|
|
+ */
|
|
+ if (!s->quiet)
|
|
+ printf("Indexing system directories: ");
|
|
+ index_system_dirs(s, fs);
|
|
+ if (!s->quiet)
|
|
+ printf("done\n");
|
|
+ }
|
|
+
|
|
+ if (!s->quiet)
|
|
+ printf("Writing lost+found: ");
|
|
+ create_lost_found_dir(s, fs);
|
|
+ if (!s->quiet)
|
|
+ printf("done\n");
|
|
+
|
|
ocfs2_close(fs);
|
|
}
|
|
|
|
@@ -1085,6 +1098,10 @@ get_state(int argc, char **argv)
|
|
s->no_backup_super = 0;
|
|
else
|
|
s->no_backup_super = 1;
|
|
+ if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS)
|
|
+ s->dx_dirs = 1;
|
|
+ else
|
|
+ s->dx_dirs = 0;
|
|
|
|
|
|
/* Here if the user set these flags explicitly, we will use them and
|
|
@@ -2751,6 +2768,44 @@ clear_both_ends(State *s)
|
|
return ;
|
|
}
|
|
|
|
+static void index_system_dirs(State *s, ocfs2_filesys *fs)
|
|
+{
|
|
+ errcode_t ret;
|
|
+ int i, num_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
|
|
+ uint64_t orphan_dir_blkno;
|
|
+
|
|
+
|
|
+ /* Start with the root directory */
|
|
+ ret = ocfs2_dx_dir_build(fs, fs->fs_root_blkno);
|
|
+ if (ret) {
|
|
+ com_err(s->progname, ret, "while indexing root directory");
|
|
+ goto bail;
|
|
+ }
|
|
+
|
|
+ for (i = 0; i < num_slots; i++) {
|
|
+ ret = ocfs2_lookup_system_inode(fs, ORPHAN_DIR_SYSTEM_INODE,
|
|
+ i, &orphan_dir_blkno);
|
|
+ if (ret) {
|
|
+ com_err(s->progname, ret,
|
|
+ "while looking up orphan dir %d for indexing",
|
|
+ i);
|
|
+ goto bail;
|
|
+ }
|
|
+
|
|
+ ret = ocfs2_dx_dir_build(fs, orphan_dir_blkno);
|
|
+ if (ret) {
|
|
+ com_err(s->progname, ret, "while indexing root directory");
|
|
+ goto bail;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return;
|
|
+
|
|
+bail:
|
|
+ clear_both_ends(s);
|
|
+ exit(1);
|
|
+}
|
|
+
|
|
static void create_lost_found_dir(State *s, ocfs2_filesys *fs)
|
|
{
|
|
errcode_t ret;
|
|
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
|
|
index b702f00..c3aecd6 100644
|
|
--- a/mkfs.ocfs2/mkfs.h
|
|
+++ b/mkfs.ocfs2/mkfs.h
|
|
@@ -188,6 +188,7 @@ struct _State {
|
|
int mount;
|
|
int no_backup_super;
|
|
int inline_data;
|
|
+ int dx_dirs;
|
|
int dry_run;
|
|
|
|
uint32_t blocksize;
|
|
--
|
|
1.7.0.2
|
|
|