[Ocfs2-tools-devel] [PATCH 5/9] ocfs2-tools: add xattr support in mkfs.ocfs2

Joel Becker Joel.Becker at oracle.com
Fri Dec 19 12:57:01 PST 2008


On Fri, Dec 19, 2008 at 05:41:23PM +0800, Tiger Yang wrote:
> This patch add support for new feature xattr in mkfs.ocfs2.
> Xattr is an incompatible feature, need option --fs-features=xattr
> or --fs-feature-level=max-features to enable it.
> 
> Signed-off-by: Tiger Yang <tiger.yang at oracle.com>

Signed-off-by: Joel Becker <joel.becker at oracle.com>

> ---
>  libocfs2/feature_string.c  |   12 +++++++++++-
>  mkfs.ocfs2/mkfs.c          |    6 ++++++
>  mkfs.ocfs2/mkfs.ocfs2.8.in |    5 +++++
>  3 files changed, 22 insertions(+), 1 deletions(-)
> 
> diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
> index 56618db..a83692d 100644
> --- a/libocfs2/feature_string.c
> +++ b/libocfs2/feature_string.c
> @@ -73,7 +73,8 @@ static ocfs2_fs_options feature_level_defaults[] = {
>  	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
>  	 OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP |
>  	 OCFS2_FEATURE_INCOMPAT_INLINE_DATA |
> -	 OCFS2_FEATURE_INCOMPAT_META_ECC,
> +	 OCFS2_FEATURE_INCOMPAT_META_ECC |
> +	 OCFS2_FEATURE_INCOMPAT_XATTR,
>  	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN}, /* OCFS2_FEATURE_LEVEL_MAX_FEATURES */
>  };
>  
> @@ -116,6 +117,11 @@ static struct fs_feature_flags ocfs2_supported_features[] = {
>  		{0, OCFS2_FEATURE_INCOMPAT_META_ECC, 0},
>  	},
>  	{
> +		"xattr",
> +		{0, OCFS2_FEATURE_INCOMPAT_XATTR, 0},
> +		{0, OCFS2_FEATURE_INCOMPAT_XATTR, 0},
> +	},
> +	{
>  		NULL,
>  		{0, 0, 0},
>  		{0, 0, 0}
> @@ -179,6 +185,10 @@ static struct feature_name ocfs2_feature_names[] = {
>  		.fn_flag = {0, OCFS2_FEATURE_INCOMPAT_META_ECC, 0},
>  	},
>  	{
> +		.fn_name = "Xattr",
> +		.fn_flag = {0, OCFS2_FEATURE_INCOMPAT_XATTR, 0},
> +	},
> +	{
>  		.fn_name = NULL,
>  	},
>  };
> diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
> index 033af88..161b065 100644
> --- a/mkfs.ocfs2/mkfs.c
> +++ b/mkfs.ocfs2/mkfs.c
> @@ -2005,6 +2005,12 @@ 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) {
> +		di->id2.i_super.s_xattr_inline_size =
> +						OCFS2_MIN_XATTR_INLINE_SIZE;
> +		di->id2.i_super.s_uuid_hash = 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;
>  	di->id2.i_super.s_feature_ro_compat = s->feature_flags.opt_ro_compat;
> diff --git a/mkfs.ocfs2/mkfs.ocfs2.8.in b/mkfs.ocfs2/mkfs.ocfs2.8.in
> index de43946..a2e6321 100644
> --- a/mkfs.ocfs2/mkfs.ocfs2.8.in
> +++ b/mkfs.ocfs2/mkfs.ocfs2.8.in
> @@ -126,6 +126,11 @@ Enable support for sparse files. With this, \fIOCFS2\fR can avoid allocating (an
>  \fBunwritten\fR
>  Enable unwritten extents support. With this turned on, an application can request that a range of clusters be pre-allocated within a file. \fIOCFS2\fR will mark those extents with a special flag so that expensive data zeroing doesn't have to be performed. Reads and writes to a pre-allocated region act as reads and writes to a hole, except a write will not fail due to lack of data allocation. This feature requires \fBsparse\fR file support to be turned on. Available with the file system bundled with Linux kernels 2.6.23 and later.
>  .RE
> +.RS 1.2i
> +.TP
> +\fBxattr\fR
> +Enable support for extended attribute.
> +.RE
>  
>  .TP
>  \fB\-\-fs\-feature\-level=\fR\fR\fIfeature\-level\fR
> -- 
> 1.5.4.1
> 

-- 

"Nearly all men can stand adversity, but if you really want to
 test a man's character, give him power."
	- Abraham Lincoln

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list