[Ocfs2-tools-devel] [PATCH 1/1] ocfs2-toos: Set hash seed when converting ocfs2 to support indexed-dirs
Mark Fasheh
mfasheh at suse.com
Mon Feb 14 15:02:52 PST 2011
Hi Tiger,
On Sat, Feb 12, 2011 at 05:42:30PM +0800, Tiger Yang wrote:
> 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();
> +
We also want to be populating s_uuid_hash in the case that extended
attributes are not enabled.
> 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;
... and likewise, we should probably clear s_uuid_hash when
extended attributes are not enabled.
--Mark
--
Mark Fasheh
More information about the Ocfs2-tools-devel
mailing list