Skip to content

Commit 1fcf686

Browse files
committed
erofs: fix long xattr name prefix placement
Currently, xattr name prefixes are forcibly placed into the packed inode if the fragments feature is enabled, and users have no option to put them in plain form directly on disk. This is inflexible. First, as mentioned above, users should be able to store unwrapped long xattr name prefixes unconditionally (COMPAT_PLAIN_XATTR_PFX). Second, since we now have the new metabox inode to store metadata, it should be used when available instead of the packed inode. Fixes: 4140913 ("erofs: implement metadata compression") Signed-off-by: Gao Xiang <[email protected]>
1 parent 181993b commit 1fcf686

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

fs/erofs/erofs_fs.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
/* to allow for x86 boot sectors and other oddities. */
1313
#define EROFS_SUPER_OFFSET 1024
1414

15-
#define EROFS_FEATURE_COMPAT_SB_CHKSUM 0x00000001
16-
#define EROFS_FEATURE_COMPAT_MTIME 0x00000002
17-
#define EROFS_FEATURE_COMPAT_XATTR_FILTER 0x00000004
15+
#define EROFS_FEATURE_COMPAT_SB_CHKSUM 0x00000001
16+
#define EROFS_FEATURE_COMPAT_MTIME 0x00000002
17+
#define EROFS_FEATURE_COMPAT_XATTR_FILTER 0x00000004
1818
#define EROFS_FEATURE_COMPAT_SHARED_EA_IN_METABOX 0x00000008
19+
#define EROFS_FEATURE_COMPAT_PLAIN_XATTR_PFX 0x00000010
20+
1921

2022
/*
2123
* Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should

fs/erofs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ EROFS_FEATURE_FUNCS(metabox, incompat, INCOMPAT_METABOX)
234234
EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)
235235
EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER)
236236
EROFS_FEATURE_FUNCS(shared_ea_in_metabox, compat, COMPAT_SHARED_EA_IN_METABOX)
237+
EROFS_FEATURE_FUNCS(plain_xattr_pfx, compat, COMPAT_PLAIN_XATTR_PFX)
237238

238239
static inline u64 erofs_nid_to_ino64(struct erofs_sb_info *sbi, erofs_nid_t nid)
239240
{

fs/erofs/xattr.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
482482
erofs_off_t pos = (erofs_off_t)sbi->xattr_prefix_start << 2;
483483
struct erofs_xattr_prefix_item *pfs;
484484
int ret = 0, i, len;
485+
bool plain = erofs_sb_has_plain_xattr_pfx(sbi);
485486

486487
if (!sbi->xattr_prefix_count)
487488
return 0;
@@ -490,9 +491,15 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
490491
if (!pfs)
491492
return -ENOMEM;
492493

493-
if (sbi->packed_inode)
494-
buf.mapping = sbi->packed_inode->i_mapping;
495-
else
494+
if (!plain) {
495+
if (erofs_sb_has_metabox(sbi))
496+
(void)erofs_init_metabuf(&buf, sb, true);
497+
else if (sbi->packed_inode)
498+
buf.mapping = sbi->packed_inode->i_mapping;
499+
else
500+
plain = true;
501+
}
502+
if (plain)
496503
(void)erofs_init_metabuf(&buf, sb, false);
497504

498505
for (i = 0; i < sbi->xattr_prefix_count; i++) {

0 commit comments

Comments
 (0)