[Ocfs2-tools-devel] [PATCH 1/2] ocfs2-tools: Set hash seed when convert ocfs2 to support indexed-dirs
Tiger Yang
tiger.yang at oracle.com
Mon Feb 14 23:13:49 PST 2011
The hash seed should be set in super block when convert ocfs2
to support indexed-dirs with tunefs.ocfs2, and it should be clear
when disable indexed-dirs.
Signed-off-by: Tiger Yang <tiger.yang at oracle.com>
---
tunefs.ocfs2/feature_indexed_dirs.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/tunefs.ocfs2/feature_indexed_dirs.c b/tunefs.ocfs2/feature_indexed_dirs.c
index 7a918e7..5cdc86c 100644
--- a/tunefs.ocfs2/feature_indexed_dirs.c
+++ b/tunefs.ocfs2/feature_indexed_dirs.c
@@ -117,6 +117,12 @@ static int enable_indexed_dirs(ocfs2_filesys *fs, int flags)
goto out;
}
+ /* set seed for indexed dir hash */
+ srand48(time(NULL));
+ super->s_dx_seed[0] = mrand48();
+ super->s_dx_seed[1] = mrand48();
+ super->s_dx_seed[2] = mrand48();
+
OCFS2_SET_INCOMPAT_FEATURE(super,
OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS);
@@ -302,6 +308,9 @@ static int disable_indexed_dirs(ocfs2_filesys *fs, int flags)
* fsck.ocfs2 will handle the orphan indexed trees. */
OCFS2_CLEAR_INCOMPAT_FEATURE(super,
OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS);
+
+ super->s_dx_seed[0] = super->s_dx_seed[1] = super->s_dx_seed[2] = 0;
+
ret = ocfs2_write_super(fs);
tunefs_unblock_signals();
--
1.7.2.1
More information about the Ocfs2-tools-devel
mailing list