[Ocfs2-tools-devel] [PATCH 6/7] tunefs.ocfs2: Turn on and off the extended slot map

tao.ma tao.ma at oracle.com
Thu Jan 10 17:51:39 PST 2008


You patch does touch increasing slot.
Although current ocfs2_extend_slot is only 8 bytes and the minimum 
cluster size is 4K and 8 * 255 << 4k, do you think we have any future 
improvement in future which will exceed the limit? ;)
Maybe a call of ocfs2_format_slot_map is needed for increasing slot?

Joel Becker wrote:
> Support for the extended slot map.  It can be enabled or disabled.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> ---
>  tunefs.ocfs2/Makefile         |    9 +++++-
>  tunefs.ocfs2/features.c       |   14 +++++++--
>  tunefs.ocfs2/format_slotmap.c |   60 +++++++++++++++++++++++++++++++++++++++++
>  tunefs.ocfs2/tunefs.c         |    4 ++-
>  tunefs.ocfs2/tunefs.h         |    6 +++-
>  5 files changed, 87 insertions(+), 6 deletions(-)
>  create mode 100644 tunefs.ocfs2/format_slotmap.c
>
> diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile
> index e6b4427..df317bd 100644
> --- a/tunefs.ocfs2/Makefile
> +++ b/tunefs.ocfs2/Makefile
> @@ -31,7 +31,14 @@ DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES -
>  
>  MANS = tunefs.ocfs2.8
>  
> -CFILES = tunefs.c query.c remove_slot.c sparse_file.c features.c
> +CFILES =		\
> +      tunefs.c		\
> +	query.c		\
> +	remove_slot.c	\
> +	sparse_file.c	\
> +	features.c	\
> +	format_slotmap.c
> +
>  HFILES = tunefs.h
>  
>  OBJS = $(subst .c,.o,$(CFILES))
> diff --git a/tunefs.ocfs2/features.c b/tunefs.ocfs2/features.c
> index 856e833..23eb9be 100644
> --- a/tunefs.ocfs2/features.c
> +++ b/tunefs.ocfs2/features.c
> @@ -1,4 +1,6 @@
> -/*
> +/* -*- mode: c; c-basic-offset: 8; -*-
> + * vim: noexpandtab sw=8 ts=8 sts=0:
> + *
>   * features.c
>   *
>   * source file for adding or removing features for tunefs.
> @@ -33,8 +35,10 @@ extern ocfs2_tune_opts opts;
>  #define TUNEFS_COMPAT_CLEAR	0
>  #define TUNEFS_RO_COMPAT_SET	OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
>  #define TUNEFS_RO_COMPAT_CLEAR	OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
> -#define TUNEFS_INCOMPAT_SET	OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC
> -#define TUNEFS_INCOMPAT_CLEAR	OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC
> +#define TUNEFS_INCOMPAT_SET	(OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC | \
> +				 OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
> +#define TUNEFS_INCOMPAT_CLEAR	(OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC | \
> +				 OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
>  
>  /*
>   * Check whether we can add or remove a feature.
> @@ -141,6 +145,10 @@ errcode_t update_feature(ocfs2_filesys *fs)
>  	if (opts.set_feature.ro_compat & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
>  		set_unwritten_extents_flag(fs);
>  
> +	if ((opts.set_feature.incompat | opts.clear_feature.incompat) &
> +	    OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
> +		ret = reformat_slot_map(fs);
> +
>  bail:
>  	return ret;
>  }
> diff --git a/tunefs.ocfs2/format_slotmap.c b/tunefs.ocfs2/format_slotmap.c
> new file mode 100644
> index 0000000..822b5c1
> --- /dev/null
> +++ b/tunefs.ocfs2/format_slotmap.c
> @@ -0,0 +1,60 @@
> +/* -*- mode: c; c-basic-offset: 8; -*-
> + * vim: noexpandtab sw=8 ts=8 sts=0:
> + *
> + * format_slotmap.c
> + *
> + * Switch between slot map formats.
> + *
> + * Copyright (C) 2007 Oracle.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public
> + * License along with this program; if not, write to the
> + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> + * Boston, MA 021110-1307, USA.
> + *
> + */
> +#include <ocfs2.h>
> +
> +#include <assert.h>
> +
> +#include <tunefs.h>
> +
> +extern ocfs2_tune_opts opts;
> +
> +errcode_t reformat_slot_map(ocfs2_filesys *fs)
> +{
> +	errcode_t ret = 0;
> +	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
> +	int extended = ocfs2_uses_extended_slot_map(super);
> +
> +	if (opts.set_feature.incompat &
> +	    OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP) {
> +		if (extended) {
> +			printf("Feature \"extended-slotmap\" is already enabled, skipping\n");
> +			goto out;
> +		}
> +		OCFS2_SET_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP);
> +	} else if (opts.clear_feature.incompat &
> +		   OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP) {
> +		if (!extended) {
> +			printf("Feature \"extended-slotmap\" is not enabled, skipping\n");
> +			goto out;
> +		}
> +		OCFS2_CLEAR_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP);
> +	}
> +
> +	ret = ocfs2_format_slot_map(fs);
> +
> +out:
> +	return ret;
> +}
> diff --git a/tunefs.ocfs2/tunefs.c b/tunefs.ocfs2/tunefs.c
> index fbcee4a..400ae10 100644
> --- a/tunefs.ocfs2/tunefs.c
> +++ b/tunefs.ocfs2/tunefs.c
> @@ -1,4 +1,6 @@
> -/*
> +/* -*- mode: c; c-basic-offset: 8; -*-
> + * vim: noexpandtab sw=8 ts=8 sts=0:
> + *
>   * tune.c
>   *
>   * ocfs2 tune utility
> diff --git a/tunefs.ocfs2/tunefs.h b/tunefs.ocfs2/tunefs.h
> index 566d746..77eda30 100644
> --- a/tunefs.ocfs2/tunefs.h
> +++ b/tunefs.ocfs2/tunefs.h
> @@ -1,4 +1,6 @@
> -/*
> +/* -*- mode: c; c-basic-offset: 8; -*-
> + * vim: noexpandtab sw=8 ts=8 sts=0:
> + *
>   * tune.h
>   *
>   * ocfs2 tune utility
> @@ -111,6 +113,8 @@ errcode_t clear_sparse_file_flag(ocfs2_filesys *fs, char *progname);
>  void set_unwritten_extents_flag(ocfs2_filesys *fs);
>  void free_clear_ctxt(void);
>  
> +errcode_t reformat_slot_map(ocfs2_filesys *fs);
> +
>  errcode_t feature_check(ocfs2_filesys *fs);
>  errcode_t update_feature(ocfs2_filesys *fs);
>  #endif /* _TUNEFS_H */
>   




More information about the Ocfs2-tools-devel mailing list