[Ocfs2-tools-devel] [PATCH 1/1] ocfs2-toos: Set hash seed when converting ocfs2 to support indexed-dirs

Tiger Yang tiger.yang at oracle.com
Sat Feb 12 01:42:30 PST 2011


This patch fix a issue when enable indexed-dirs with
tunefs.ocfs2. We should set the hash seed in super block
when we convert ocfs2 to support indexed-dirs.

Signed-off-by: Tiger Yang <tiger.yang at oracle.com>
---
 include/ocfs2-kernel/ocfs2_fs.h     |    2 +-
 tunefs.ocfs2/feature_indexed_dirs.c |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index ffda634..e1fe24d 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -610,7 +610,7 @@ struct ocfs2_super_block {
 	__le16 s_reserved0;
 	__le32 s_dx_seed[3];		/* seed[0-2] for dx dir hash.
 					 * s_uuid_hash serves as seed[3]. */
-/*C0*/  __le64 s_reserved2[15];		/* Fill out superblock */
+/*C8*/  __le64 s_reserved2[15];		/* Fill out superblock */
 /*140*/
 
 	/*
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