[Ocfs2-tools-devel] [PATCH 03/12] dx_dirs v7: mkfs.ocfs2 support

Coly Li coly.li at suse.de
Fri Jan 29 10:17:39 PST 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.

Signed-off-by: Mark Fasheh <mfasheh at suse.com>
Signed-off-by: Coly Li <coly.li at suse.de>
---
 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 19f5411..61cc556 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -965,6 +965,8 @@ get_state(int argc, char **argv)
 	if ((optind == argc) && !show_version)
 		usage(progname);

+	srand48(time(NULL));
+
 	device_name = argv[optind];
 	optind++;

@@ -2148,11 +2150,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;
@@ -2161,6 +2161,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 |
+	    di->id2.i_super.s_feature_incompat & OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS)
+		di->id2.i_super.s_uuid_hash = ocfs2_xattr_uuid_hash(s->uuid);
+
+	if (di->id2.i_super.s_feature_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);
-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list