Skip to content

Commit 6a318cc

Browse files
lostjefflehsiangkao
authored andcommitted
erofs: enable long extended attribute name prefixes
Let's enable long xattr name prefix feature. Old kernels will just ignore / skip such extended attributes. In addition, in case you don't want to mount such images, add another incompatible feature as an option for this. 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/20230407222808.19670-1-jefflexu@linux.alibaba.com [ Gao Xiang: minor commit message fix. ] Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 82bc1ef commit 6a318cc

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

fs/erofs/erofs_fs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define EROFS_FEATURE_INCOMPAT_ZTAILPACKING 0x00000010
2828
#define EROFS_FEATURE_INCOMPAT_FRAGMENTS 0x00000020
2929
#define EROFS_FEATURE_INCOMPAT_DEDUPE 0x00000020
30+
#define EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES 0x00000040
3031
#define EROFS_ALL_FEATURE_INCOMPAT \
3132
(EROFS_FEATURE_INCOMPAT_ZERO_PADDING | \
3233
EROFS_FEATURE_INCOMPAT_COMPR_CFGS | \
@@ -36,7 +37,8 @@
3637
EROFS_FEATURE_INCOMPAT_COMPR_HEAD2 | \
3738
EROFS_FEATURE_INCOMPAT_ZTAILPACKING | \
3839
EROFS_FEATURE_INCOMPAT_FRAGMENTS | \
39-
EROFS_FEATURE_INCOMPAT_DEDUPE)
40+
EROFS_FEATURE_INCOMPAT_DEDUPE | \
41+
EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES)
4042

4143
#define EROFS_SB_EXTSLOT_SIZE 16
4244

fs/erofs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ EROFS_FEATURE_FUNCS(compr_head2, incompat, INCOMPAT_COMPR_HEAD2)
285285
EROFS_FEATURE_FUNCS(ztailpacking, incompat, INCOMPAT_ZTAILPACKING)
286286
EROFS_FEATURE_FUNCS(fragments, incompat, INCOMPAT_FRAGMENTS)
287287
EROFS_FEATURE_FUNCS(dedupe, incompat, INCOMPAT_DEDUPE)
288+
EROFS_FEATURE_FUNCS(xattr_prefixes, incompat, INCOMPAT_XATTR_PREFIXES)
288289
EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)
289290

290291
/* atomic flag definitions */

fs/erofs/super.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ static int erofs_read_superblock(struct super_block *sb)
385385
sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
386386
#ifdef CONFIG_EROFS_FS_XATTR
387387
sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
388+
sbi->xattr_prefix_start = le32_to_cpu(dsb->xattr_prefix_start);
389+
sbi->xattr_prefix_count = dsb->xattr_prefix_count;
388390
#endif
389391
sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
390392
sbi->root_nid = le16_to_cpu(dsb->root_nid);
@@ -820,6 +822,10 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
820822
if (err)
821823
return err;
822824

825+
err = erofs_xattr_prefixes_init(sb);
826+
if (err)
827+
return err;
828+
823829
err = erofs_register_sysfs(sb);
824830
if (err)
825831
return err;
@@ -979,6 +985,7 @@ static void erofs_put_super(struct super_block *sb)
979985

980986
erofs_unregister_sysfs(sb);
981987
erofs_shrinker_unregister(sb);
988+
erofs_xattr_prefixes_cleanup(sb);
982989
#ifdef CONFIG_EROFS_FS_ZIP
983990
iput(sbi->managed_cache);
984991
sbi->managed_cache = NULL;

0 commit comments

Comments
 (0)