[Ocfs2-tools-devel] [PATCH 03/15] dx_dirs v11: mkfs.ocfs2 support

Coly Li coly.li at suse.de
Sun Apr 11 01:10:00 PDT 2010


This adds only basic support to mkfs.ocfs2 to write the seed fields used
in directory indexing. The feature string
'indexed-dirs' is already there from a previous patch, so it is possible
to create a new file system with the directory
indexing feature turned on.

Future improvements that are needed:

- mkfs.ocfs2 should create the root directory and orphan dirs as
  indexed.
- possibly also we want to do this for the system dir, but that might
  require some discussion.

[modified the patch for code rebase and cleanup -- Coly Li]

Signed-off-by: Mark Fasheh <mfasheh at suse.com>
---
 mkfs.ocfs2/mkfs.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 5d01e3e..b43a9ba 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -1004,6 +1004,8 @@ get_state(int argc, char **argv)
 	if ((optind == argc) && !show_version)
 		usage(progname);
 
+	srand48(time(NULL));
+
 	device_name = argv[optind];
 	optind++;
 
@@ -2240,11 +2242,9 @@ format_superblock(State *s, SystemFileDiskRecord *rec,
 	 */
 	s->feature_flags.opt_compat &= ~OCFS2_FEATURE_COMPAT_BACKUP_SB;
 
-	if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_XATTR) {
+	if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_XATTR)
 		di->id2.i_super.s_xattr_inline_size =
 						OCFS2_MIN_XATTR_INLINE_SIZE;
-		di->id2.i_super.s_uuid_hash = ocfs2_xattr_uuid_hash(s->uuid);
-	}
 
 	di->id2.i_super.s_feature_incompat = s->feature_flags.opt_incompat;
 	di->id2.i_super.s_feature_compat = s->feature_flags.opt_compat;
@@ -2253,6 +2253,17 @@ format_superblock(State *s, SystemFileDiskRecord *rec,
 	strcpy((char *)di->id2.i_super.s_label, s->vol_label);
 	memcpy(di->id2.i_super.s_uuid, s->uuid, 16);
 
+	/* s_uuid_hash is also used by Indexed Dirs */
+	if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_XATTR ||
+	    s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS)
+		di->id2.i_super.s_uuid_hash = ocfs2_xattr_uuid_hash(s->uuid);
+
+	if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS) {
+		di->id2.i_super.s_dx_seed[0] = mrand48();
+		di->id2.i_super.s_dx_seed[1] = mrand48();
+		di->id2.i_super.s_dx_seed[2] = mrand48();
+	}
+
 	mkfs_swap_inode_from_cpu(s, di);
 	mkfs_compute_meta_ecc(s, di, &di->i_check);
 	do_pwrite(s, di, s->blocksize, super_off);
-- 
1.7.0.2




More information about the Ocfs2-tools-devel mailing list