[Ocfs2-tools-devel] [RFC 3/9] dx_dirs v5: mkfs.ocfs2 support
Coly Li
coly.li at suse.de
Wed Jan 27 12:13:29 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.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
Index: ocfs2-tools/mkfs.ocfs2/mkfs.c
===================================================================
--- ocfs2-tools.orig/mkfs.ocfs2/mkfs.c
+++ ocfs2-tools/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, SystemFileDi
*/
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, SystemFileDi
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