]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: fix long xattr name prefix placement
authorGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 11 Sep 2025 19:27:11 +0000 (03:27 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 11 Sep 2025 19:37:07 +0000 (03:37 +0800)
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: 414091322c63 ("erofs: implement metadata compression")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/erofs_fs.h
fs/erofs/internal.h
fs/erofs/xattr.c

index 377ee12b8b96677ea8b0a0bda3e3926302760096..3d5738f80072ee7b65e55a4d61514f4432a319e6 100644 (file)
 /* to allow for x86 boot sectors and other oddities. */
 #define EROFS_SUPER_OFFSET      1024
 
-#define EROFS_FEATURE_COMPAT_SB_CHKSUM          0x00000001
-#define EROFS_FEATURE_COMPAT_MTIME              0x00000002
-#define EROFS_FEATURE_COMPAT_XATTR_FILTER      0x00000004
+#define EROFS_FEATURE_COMPAT_SB_CHKSUM                 0x00000001
+#define EROFS_FEATURE_COMPAT_MTIME                     0x00000002
+#define EROFS_FEATURE_COMPAT_XATTR_FILTER              0x00000004
 #define EROFS_FEATURE_COMPAT_SHARED_EA_IN_METABOX      0x00000008
+#define EROFS_FEATURE_COMPAT_PLAIN_XATTR_PFX           0x00000010
+
 
 /*
  * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should
index 4ccc5f0ee8dfb99b31b36ab83a626c9f22aeacc9..9319c66e86c3c32bb9acd4cf9bf9c223f6a71bb7 100644 (file)
@@ -234,6 +234,7 @@ EROFS_FEATURE_FUNCS(metabox, incompat, INCOMPAT_METABOX)
 EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)
 EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER)
 EROFS_FEATURE_FUNCS(shared_ea_in_metabox, compat, COMPAT_SHARED_EA_IN_METABOX)
+EROFS_FEATURE_FUNCS(plain_xattr_pfx, compat, COMPAT_PLAIN_XATTR_PFX)
 
 static inline u64 erofs_nid_to_ino64(struct erofs_sb_info *sbi, erofs_nid_t nid)
 {
index eaa9efd766eea718b9cb1164014ac62ae62c89e1..396536d9a86216ee7f14904c5a53b69982905457 100644 (file)
@@ -482,6 +482,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
        erofs_off_t pos = (erofs_off_t)sbi->xattr_prefix_start << 2;
        struct erofs_xattr_prefix_item *pfs;
        int ret = 0, i, len;
+       bool plain = erofs_sb_has_plain_xattr_pfx(sbi);
 
        if (!sbi->xattr_prefix_count)
                return 0;
@@ -490,9 +491,15 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
        if (!pfs)
                return -ENOMEM;
 
-       if (sbi->packed_inode)
-               buf.mapping = sbi->packed_inode->i_mapping;
-       else
+       if (!plain) {
+               if (erofs_sb_has_metabox(sbi))
+                       (void)erofs_init_metabuf(&buf, sb, true);
+               else if (sbi->packed_inode)
+                       buf.mapping = sbi->packed_inode->i_mapping;
+               else
+                       plain = true;
+       }
+       if (plain)
                (void)erofs_init_metabuf(&buf, sb, false);
 
        for (i = 0; i < sbi->xattr_prefix_count; i++) {