]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
erofs: support user-defined fingerprint name
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Fri, 23 Jan 2026 01:31:25 +0000 (01:31 +0000)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Fri, 23 Jan 2026 12:01:13 +0000 (20:01 +0800)
When creating the EROFS image, users can specify the fingerprint name.
This is to prepare for the upcoming inode page cache share.

Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/Kconfig
fs/erofs/erofs_fs.h
fs/erofs/internal.h
fs/erofs/super.c
fs/erofs/xattr.c

index d81f3318417dff7c74fa65a526dbc075369afb5c..b71f2a8074feb90f90d6405df975f04ff8fdbda8 100644 (file)
@@ -194,3 +194,12 @@ config EROFS_FS_PCPU_KTHREAD_HIPRI
          at higher priority.
 
          If unsure, say N.
+
+config EROFS_FS_PAGE_CACHE_SHARE
+       bool "EROFS page cache share support (experimental)"
+       depends on EROFS_FS && EROFS_FS_XATTR && !EROFS_FS_ONDEMAND
+       help
+         This enables page cache sharing among inodes with identical
+         content fingerprints on the same machine.
+
+         If unsure, say N.
index e24268acdd627fc4d623271861baa1999bbdd962..b30a74d307c5f90f42730265bc6cc08d053355de 100644 (file)
@@ -17,7 +17,7 @@
 #define EROFS_FEATURE_COMPAT_XATTR_FILTER              0x00000004
 #define EROFS_FEATURE_COMPAT_SHARED_EA_IN_METABOX      0x00000008
 #define EROFS_FEATURE_COMPAT_PLAIN_XATTR_PFX           0x00000010
-
+#define EROFS_FEATURE_COMPAT_ISHARE_XATTRS             0x00000020
 
 /*
  * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should
@@ -83,7 +83,8 @@ struct erofs_super_block {
        __le32 xattr_prefix_start;      /* start of long xattr prefixes */
        __le64 packed_nid;      /* nid of the special packed inode */
        __u8 xattr_filter_reserved; /* reserved for xattr name filter */
-       __u8 reserved[3];
+       __u8 ishare_xattr_prefix_id;
+       __u8 reserved[2];
        __le32 build_time;      /* seconds added to epoch for mkfs time */
        __le64 rootnid_8b;      /* (48BIT on) nid of root directory */
        __le64 reserved2;
index c508c96ce1428055d054397d7cb36c4f8b96ff37..ae4ade00b5787d71cb974ed07486f637e15355d6 100644 (file)
@@ -131,6 +131,7 @@ struct erofs_sb_info {
        u32 xattr_blkaddr;
        u32 xattr_prefix_start;
        u8 xattr_prefix_count;
+       u8 ishare_xattr_prefix_id;
        struct erofs_xattr_prefix_item *xattr_prefixes;
        unsigned int xattr_filter_reserved;
 #endif
@@ -235,6 +236,7 @@ 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)
+EROFS_FEATURE_FUNCS(ishare_xattrs, compat, COMPAT_ISHARE_XATTRS)
 
 static inline u64 erofs_nid_to_ino64(struct erofs_sb_info *sbi, erofs_nid_t nid)
 {
index 8940e8ff158ac4f8c26f6c79138dcd9bea0910fb..c9ea70d600ad71c767c3a721b369fc4dc4475ed2 100644 (file)
@@ -320,6 +320,15 @@ static int erofs_read_superblock(struct super_block *sb)
        sbi->xattr_prefix_start = le32_to_cpu(dsb->xattr_prefix_start);
        sbi->xattr_prefix_count = dsb->xattr_prefix_count;
        sbi->xattr_filter_reserved = dsb->xattr_filter_reserved;
+       if (erofs_sb_has_ishare_xattrs(sbi)) {
+               if (dsb->ishare_xattr_prefix_id >= sbi->xattr_prefix_count) {
+                       erofs_err(sb, "invalid ishare xattr prefix id %u",
+                                 dsb->ishare_xattr_prefix_id);
+                       ret = -EFSCORRUPTED;
+                       goto out;
+               }
+               sbi->ishare_xattr_prefix_id = dsb->ishare_xattr_prefix_id;
+       }
 #endif
        sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
        if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) {
index 512b998bdfff3042ecb7557102a825aa715158d9..732e3b3379d50a2bc65996cc3822fe8107f25209 100644 (file)
@@ -530,6 +530,19 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
        }
 
        erofs_put_metabuf(&buf);
+       if (!ret && erofs_sb_has_ishare_xattrs(sbi)) {
+               struct erofs_xattr_prefix_item *pf = pfs + sbi->ishare_xattr_prefix_id;
+               struct erofs_xattr_long_prefix *newpfx;
+
+               newpfx = krealloc(pf->prefix,
+                       sizeof(*newpfx) + pf->infix_len + 1, GFP_KERNEL);
+               if (newpfx) {
+                       newpfx->infix[pf->infix_len] = '\0';
+                       pf->prefix = newpfx;
+               } else {
+                       ret = -ENOMEM;
+               }
+       }
        sbi->xattr_prefixes = pfs;
        if (ret)
                erofs_xattr_prefixes_cleanup(sb);