[PATCH 3/6] erofs-utils: introduce on-disk format for extra xattr name prefix

Jingbo Xu jefflexu at linux.alibaba.com
Tue Apr 4 18:02:20 AEST 2023


Besides the predefined xattr name prefixes, introduces extra xattr name
prefixes, which works similarly as the predefined xattr name prefixees,
except that they are user specified.

When matched with a user specified extra xattr name prefix, only the
trailing part of the xattr name except the xattr name prefix will be
stored in erofs_xattr_entry.e_name.  e_name is empty if the xattr name
matches exactly as the extra xattr name prefix.

All extra xattr name prefixes are stored in the packed file.  For each
extra xattr name prefix, the on-disk format in packed file can be shown
as (u8 prefix_len, prefix string), where the first u8 represents the
length of the prefix string (excluding '\0'), followed by the content of
the prefix string (including '\0').

Two fields are introduced to the on-disk superblock, where
ea_prefix_count represents the total number of the extra xattr name
prefixes recorded in the packed file, and ea_prefix_off represents the
start offset of recorded name prefixes in the packed file.

When referring to an extra xattr name prefix, the highest bit (bit 7) of
erofs_xattr_entry.e_name_index is set, while the lower bits (bit 0-6)
as a whole represents the index of the referred name prefix among all
extra xattr name prefixes in the packed file.

Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
---
 include/erofs_fs.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/erofs_fs.h b/include/erofs_fs.h
index 8835a76..3d8eb5f 100644
--- a/include/erofs_fs.h
+++ b/include/erofs_fs.h
@@ -77,7 +77,9 @@ struct erofs_super_block {
 	} __packed u1;
 	__le16 extra_devices;	/* # of devices besides the primary device */
 	__le16 devt_slotoff;	/* startoff = devt_slotoff * devt_slotsize */
-	__u8 reserved[6];
+	__u8 reserved;
+	__u8 ea_prefix_count;	/* # of extra xattr name prefix */
+	__le32 ea_prefix_off;	/* start offset of extra prefixes in packed inode */
 	__le64 packed_nid;	/* nid of the special packed inode */
 	__u8 reserved2[24];
 };
@@ -228,6 +230,9 @@ struct erofs_xattr_ibody_header {
 #define EROFS_XATTR_INDEX_LUSTRE            5
 #define EROFS_XATTR_INDEX_SECURITY          6
 
+#define EROFS_XATTR_EA_FLAG	(1 << 7)
+#define EROFS_XATTR_EA_MASK	(EROFS_XATTR_EINDEX_FLAG - 1)
+
 /* xattr entry (for both inline & shared xattrs) */
 struct erofs_xattr_entry {
 	__u8   e_name_len;      /* length of name */
-- 
2.19.1.6.gb485710b



More information about the Linux-erofs mailing list