From 585f52a5dfd8cb4301d29804e7e05ddff1f3fca1 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Sun, 11 Apr 2010 16:10:00 +0800 Subject: [PATCH 03/30] dx_dirs: mkfs.ocfs2 support 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 Signed-off-by: Coly Li --- 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