[Ocfs2-tools-devel] [PATCH 1/2] ocfs2-tools: Add extended attribute support in mkfs.ocfs2

Tao Ma tao.ma at oracle.com
Mon Aug 25 23:39:06 PDT 2008


my mistake. review the wrong patch. ;)

Regards,
Tao

Tao Ma wrote:
> 
> Tiger Yang wrote:
>> This patch add support for new feature xattr in mkfs.ocfs2.
>>
>> Signed-off-by: Tiger Yang <tiger.yang at oracle.com>
>> ---
>>  include/ocfs2-kernel/ocfs2_fs.h |   89 ++++++++++++++++++++++++++++++++++----
>>  include/ocfs2/ocfs2.h           |    2 +
>>  libocfs2/Makefile               |    3 +-
>>  libocfs2/feature_string.c       |    9 ++++-
>>  libocfs2/inode.c                |    7 +++
>>  libocfs2/xattr.c                |   37 ++++++++++++++++
>>  mkfs.ocfs2/mkfs.c               |    6 +++
>>  mkfs.ocfs2/mkfs.ocfs2.8.in      |    5 ++
>>  sizetest/sizetest.c             |   12 +++++-
>>  9 files changed, 157 insertions(+), 13 deletions(-)
>>  create mode 100644 libocfs2/xattr.c
>>
>> diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
>> index 0cfef2a..ade9ec1 100644
>> --- a/include/ocfs2-kernel/ocfs2_fs.h
>> +++ b/include/ocfs2-kernel/ocfs2_fs.h
>> @@ -64,6 +64,7 @@
>>  #define OCFS2_INODE_SIGNATURE		"INODE01"
>>  #define OCFS2_EXTENT_BLOCK_SIGNATURE	"EXBLK01"
>>  #define OCFS2_GROUP_DESC_SIGNATURE      "GROUP01"
>> +#define OCFS2_XATTR_BLOCK_SIGNATURE	"XATTR01"
>>  
>>  /* Compatibility flags */
>>  #define OCFS2_HAS_COMPAT_FEATURE(sb,mask)			\
>> @@ -89,8 +90,9 @@
>>  #define OCFS2_FEATURE_INCOMPAT_SUPP	(OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
>>  					 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
>>  					 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
>>  					 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
>> -					 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK)
>> +					 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
>> +					 | OCFS2_FEATURE_INCOMPAT_XATTR)
>>  #define OCFS2_FEATURE_RO_COMPAT_SUPP	OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
>>  
>>  /*
>> @@ -126,10 +128,6 @@
>>  /* Support for data packed into inode blocks */
>>  #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA	0x0040
>>  
>> -/* Support for the extended slot map */
>> -#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
>> -
>> -
>>  /*
>>   * Support for alternate, userspace cluster stacks.  If set, the superblock
>>   * field s_cluster_info contains a tag for the alternate stack in use as
>> @@ -141,6 +139,12 @@
>>   */
>>  #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK	0x0080
>>  
>> +/* Support for the extended slot map */
>> +#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
>> +
>> +/* Support for extended attributes */
>> +#define OCFS2_FEATURE_INCOMPAT_XATTR		0x0200
>> +
>>  /*
>>   * backup superblock flag is used to indicate that this volume
>>   * has backup superblocks.
>> @@ -554,7 +558,7 @@ struct ocfs2_super_block {
>>  /*40*/	__le16 s_max_slots;		/* Max number of simultaneous mounts
>>  					   before tunefs required */
>>  	__le16 s_tunefs_flag;
>> -	__le32 s_reserved1;
>> +	__le32 s_uuid_hash;
>>  	__le64 s_first_cluster_group;	/* Block offset of 1st cluster
>>  					 * group header */
>>  /*50*/	__u8  s_label[OCFS2_MAX_VOL_LABEL_LEN];	/* Label for mounting, etc. */
>> @@ -562,7 +566,11 @@ struct ocfs2_super_block {
>>  /*A0*/  struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
>>  						     stack.  Only valid
>>  						     with INCOMPAT flag. */
>> -/*B8*/  __le64 s_reserved2[17];		/* Fill out superblock */
>> +/*B8*/	__le16 s_xattr_inline_size;	/* extended attribute inline size
>> +					   for this fs*/
>> +	__le16 s_reserved0;
>> +	__le32 s_reserved1;
>> +/*C0*/  __le64 s_reserved2[16];		/* Fill out superblock */
>>  /*140*/
>>  
>>  	/*
>> @@ -612,7 +620,8 @@ struct ocfs2_dinode {
>>  					   belongs to */
>>  	__le16 i_suballoc_bit;		/* Bit offset in suballocator
>>  					   block group */
>> -/*10*/	__le32 i_reserved0;
>> +/*10*/	__le16 i_reserved0;
>> +	__le16 i_xattr_inline_size;
>>  	__le32 i_clusters;		/* Cluster count */
>>  	__le32 i_uid;			/* Owner UID */
>>  	__le32 i_gid;			/* Owning GID */
>> @@ -631,11 +640,12 @@ struct ocfs2_dinode {
>>  	__le32 i_atime_nsec;
>>  	__le32 i_ctime_nsec;
>>  	__le32 i_mtime_nsec;
>> -	__le32 i_attr;
>> +/*70*/	__le32 i_attr;
>>  	__le16 i_orphaned_slot;		/* Only valid when OCFS2_ORPHANED_FL
>>  					   was set in i_flags */
>>  	__le16 i_dyn_features;
>> -/*70*/	__le64 i_reserved2[8];
>> +	__le64 i_xattr_loc;
>> +/*80*/	__le64 i_reserved2[7];
>>  /*B8*/	union {
>>  		__le64 i_pad1;		/* Generic way to refer to this
>>  					   64bit union */
>> @@ -706,6 +716,65 @@ struct ocfs2_group_desc
>>  /*40*/	__u8    bg_bitmap[0];
>>  };
>>  
>> +/*
>> + * On disk extended attribute structure for OCFS2
>> + * Include ocfs2_xattr_entry, ocfs2_xattr_header, ocfs2_xattr_value_root
>> + * ocfs2_xattr_tree_root and ocfs2_xattr_block.
>> + */
>> +#define OCFS2_XATTR_INDEXED		0x1
>> +
>> +#define OCFS2_HASH_SHIFT		5
>> +
>> +/* Inline extended attribute size (in bytes) */
>> +#define OCFS2_MIN_XATTR_INLINE_SIZE     256
>> +
>> +struct ocfs2_xattr_entry {
>> +	__le32	xe_name_hash;
>> +	__le16	xe_name_offset;
>> +	__u8	xe_name_len;
>> +	__u8	xe_type : 7;
>> +	__u8	xe_local : 1;
>> +	__le64	xe_value_size;
>> +};
> the structure here has been changed.
>> +
>> +struct ocfs2_xattr_header {
>> +	__le16	xh_count;
>> +	__le16	xh_reserved1;
>> +	__le32	xh_csum;
>> +	__le64  xh_reserved2;
>> +	struct ocfs2_xattr_entry	xh_entries[0];
>> +};
> also here xh_csum is moved to the end. So please update the disk layout 
> so that we can use it.
> 
> Regards,
> Tao
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel



More information about the Ocfs2-tools-devel mailing list