Skip to content

Commit b3bfcb9

Browse files
lostjefflehsiangkao
authored andcommitted
erofs: introduce on-disk format for long xattr name prefixes
Besides the predefined xattr name prefixes, introduces long xattr name prefixes, which work similarly as the predefined name prefixes, except that they are user specified. It is especially useful for use cases together with overlayfs like Composefs model, which introduces diverse xattr values with only a few common xattr names (trusted.overlay.redirect, trusted.overlay.digest, and maybe more in the future). That makes the existing predefined prefixes ineffective in both image size and runtime performance. When a user specified long xattr name prefix is used, only the trailing part of the xattr name apart from the long xattr name prefix will be stored in erofs_xattr_entry.e_name. e_name is empty if the xattr name matches exactly as the long xattr name prefix. All long xattr prefixes are stored in the packed or meta inode, which depends if fragments feature is enabled or not. For each long xattr name prefix, the on-disk format is kept as the same as the unique metadata format: ALIGN({__le16 len, data}, 4), where len represents the total size of struct erofs_xattr_long_prefix, followed by data of struct erofs_xattr_long_prefix itself. Each erofs_xattr_long_prefix keeps predefined prefixes (base_index) and the remaining prefix string without the trailing '\0'. Two fields are introduced to the on-disk superblock, where xattr_prefix_count represents the total number of the long xattr name prefixes recorded, and xattr_prefix_start represents the start offset of recorded name prefixes in the packed/meta inode divided by 4. When referring to a long 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 long name prefix among all long xattr name prefixes. Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Acked-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20230407141710.113882-5-jefflexu@linux.alibaba.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent a97a218 commit b3bfcb9

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

fs/erofs/erofs_fs.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ struct erofs_super_block {
7676
__le16 extra_devices; /* # of devices besides the primary device */
7777
__le16 devt_slotoff; /* startoff = devt_slotoff * devt_slotsize */
7878
__u8 dirblkbits; /* directory block size in bit shift */
79-
__u8 reserved[5];
79+
__u8 xattr_prefix_count; /* # of long xattr name prefixes */
80+
__le32 xattr_prefix_start; /* start of long xattr prefixes */
8081
__le64 packed_nid; /* nid of the special packed inode */
8182
__u8 reserved2[24];
8283
};
@@ -211,6 +212,13 @@ struct erofs_xattr_ibody_header {
211212
#define EROFS_XATTR_INDEX_LUSTRE 5
212213
#define EROFS_XATTR_INDEX_SECURITY 6
213214

215+
/*
216+
* bit 7 of e_name_index is set when it refers to a long xattr name prefix,
217+
* while the remained lower bits represent the index of the prefix.
218+
*/
219+
#define EROFS_XATTR_LONG_PREFIX 0x80
220+
#define EROFS_XATTR_LONG_PREFIX_MASK 0x7f
221+
214222
/* xattr entry (for both inline & shared xattrs) */
215223
struct erofs_xattr_entry {
216224
__u8 e_name_len; /* length of name */
@@ -220,6 +228,12 @@ struct erofs_xattr_entry {
220228
char e_name[]; /* attribute name */
221229
};
222230

231+
/* long xattr name prefix */
232+
struct erofs_xattr_long_prefix {
233+
__u8 base_index; /* short xattr name prefix index */
234+
char infix[]; /* infix apart from short prefix */
235+
};
236+
223237
static inline unsigned int erofs_xattr_ibody_size(__le16 i_xattr_icount)
224238
{
225239
if (!i_xattr_icount)

0 commit comments

Comments
 (0)