From: Hongzhen Luo <hongzhen@linux.alibaba.com>
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>
---
fs/erofs/Kconfig | 9 +++++++++
fs/erofs/erofs_fs.h | 5 +++--
fs/erofs/internal.h | 2 ++
fs/erofs/super.c | 3 +++
fs/erofs/xattr.c | 13 +++++++++++++
5 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
index d81f3318417d..b71f2a8074fe 100644
--- a/fs/erofs/Kconfig
+++ b/fs/erofs/Kconfig
@@ -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.
diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index e24268acdd62..20515d2462af 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -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; /* indexes the ishare key in prefix xattres */
+ __u8 reserved[2];
__le32 build_time; /* seconds added to epoch for mkfs time */
__le64 rootnid_8b; /* (48BIT on) nid of root directory */
__le64 reserved2;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 98fe652aea33..99e2857173c3 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -134,6 +134,7 @@ struct erofs_sb_info {
u32 xattr_blkaddr;
u32 xattr_prefix_start;
u8 xattr_prefix_count;
+ u8 ishare_xattr_pfx;
struct erofs_xattr_prefix_item *xattr_prefixes;
unsigned int xattr_filter_reserved;
#endif
@@ -238,6 +239,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)
{
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 2a44c4e5af4f..68480f10e69d 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -298,6 +298,9 @@ static int erofs_read_superblock(struct super_block *sb)
if (ret)
goto out;
}
+ if (erofs_sb_has_ishare_xattrs(sbi))
+ sbi->ishare_xattr_pfx =
+ dsb->ishare_xattr_prefix_id & EROFS_XATTR_LONG_PREFIX_MASK;
ret = -EINVAL;
sbi->feature_incompat = le32_to_cpu(dsb->feature_incompat);
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index 396536d9a862..969e77efd038 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -519,6 +519,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_pfx;
+ 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);
--
2.22.0
Hi Hongbo,
kernel test robot noticed the following build errors:
[auto build test ERROR on xiang-erofs/dev-test]
[also build test ERROR on xiang-erofs/dev xiang-erofs/fixes brauner-vfs/vfs.all linus/master v6.19-rc2 next-20251219]
[cannot apply to mszeredi-fuse/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Hongbo-Li/iomap-stash-iomap-read-ctx-in-the-private-field-of-iomap_iter/20251224-122950
base: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
patch link: https://lore.kernel.org/r/20251224040932.496478-6-lihongbo22%40huawei.com
patch subject: [PATCH v11 05/10] erofs: support user-defined fingerprint name
config: powerpc-randconfig-001-20251225 (https://download.01.org/0day-ci/archive/20251225/202512251143.WPBiiQZA-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 4ef602d446057dabf5f61fb221669ecbeda49279)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251225/202512251143.WPBiiQZA-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512251143.WPBiiQZA-lkp@intel.com/
All errors (new ones prefixed by >>):
>> fs/erofs/super.c:302:8: error: no member named 'ishare_xattr_pfx' in 'struct erofs_sb_info'
302 | sbi->ishare_xattr_pfx =
| ~~~ ^
1 error generated.
vim +302 fs/erofs/super.c
263
264 static int erofs_read_superblock(struct super_block *sb)
265 {
266 struct erofs_sb_info *sbi = EROFS_SB(sb);
267 struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
268 struct erofs_super_block *dsb;
269 void *data;
270 int ret;
271
272 data = erofs_read_metabuf(&buf, sb, 0, false);
273 if (IS_ERR(data)) {
274 erofs_err(sb, "cannot read erofs superblock");
275 return PTR_ERR(data);
276 }
277
278 dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
279 ret = -EINVAL;
280 if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
281 erofs_err(sb, "cannot find valid erofs superblock");
282 goto out;
283 }
284
285 sbi->blkszbits = dsb->blkszbits;
286 if (sbi->blkszbits < 9 || sbi->blkszbits > PAGE_SHIFT) {
287 erofs_err(sb, "blkszbits %u isn't supported", sbi->blkszbits);
288 goto out;
289 }
290 if (dsb->dirblkbits) {
291 erofs_err(sb, "dirblkbits %u isn't supported", dsb->dirblkbits);
292 goto out;
293 }
294
295 sbi->feature_compat = le32_to_cpu(dsb->feature_compat);
296 if (erofs_sb_has_sb_chksum(sbi)) {
297 ret = erofs_superblock_csum_verify(sb, data);
298 if (ret)
299 goto out;
300 }
301 if (erofs_sb_has_ishare_xattrs(sbi))
> 302 sbi->ishare_xattr_pfx =
303 dsb->ishare_xattr_prefix_id & EROFS_XATTR_LONG_PREFIX_MASK;
304
305 ret = -EINVAL;
306 sbi->feature_incompat = le32_to_cpu(dsb->feature_incompat);
307 if (sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT) {
308 erofs_err(sb, "unidentified incompatible feature %x, please upgrade kernel",
309 sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT);
310 goto out;
311 }
312
313 sbi->sb_size = 128 + dsb->sb_extslots * EROFS_SB_EXTSLOT_SIZE;
314 if (sbi->sb_size > PAGE_SIZE - EROFS_SUPER_OFFSET) {
315 erofs_err(sb, "invalid sb_extslots %u (more than a fs block)",
316 sbi->sb_size);
317 goto out;
318 }
319 sbi->dif0.blocks = le32_to_cpu(dsb->blocks_lo);
320 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
321 #ifdef CONFIG_EROFS_FS_XATTR
322 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
323 sbi->xattr_prefix_start = le32_to_cpu(dsb->xattr_prefix_start);
324 sbi->xattr_prefix_count = dsb->xattr_prefix_count;
325 sbi->xattr_filter_reserved = dsb->xattr_filter_reserved;
326 #endif
327 sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
328 if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) {
329 sbi->root_nid = le64_to_cpu(dsb->rootnid_8b);
330 sbi->dif0.blocks = sbi->dif0.blocks |
331 ((u64)le16_to_cpu(dsb->rb.blocks_hi) << 32);
332 } else {
333 sbi->root_nid = le16_to_cpu(dsb->rb.rootnid_2b);
334 }
335 sbi->packed_nid = le64_to_cpu(dsb->packed_nid);
336 if (erofs_sb_has_metabox(sbi)) {
337 if (sbi->sb_size <= offsetof(struct erofs_super_block,
338 metabox_nid))
339 return -EFSCORRUPTED;
340 sbi->metabox_nid = le64_to_cpu(dsb->metabox_nid);
341 if (sbi->metabox_nid & BIT_ULL(EROFS_DIRENT_NID_METABOX_BIT))
342 return -EFSCORRUPTED; /* self-loop detection */
343 }
344 sbi->inos = le64_to_cpu(dsb->inos);
345
346 sbi->epoch = (s64)le64_to_cpu(dsb->epoch);
347 sbi->fixed_nsec = le32_to_cpu(dsb->fixed_nsec);
348 super_set_uuid(sb, (void *)dsb->uuid, sizeof(dsb->uuid));
349
350 if (dsb->volume_name[0]) {
351 sbi->volume_name = kstrndup(dsb->volume_name,
352 sizeof(dsb->volume_name), GFP_KERNEL);
353 if (!sbi->volume_name)
354 return -ENOMEM;
355 }
356
357 /* parse on-disk compression configurations */
358 ret = z_erofs_parse_cfgs(sb, dsb);
359 if (ret < 0)
360 goto out;
361
362 ret = erofs_scan_devices(sb, dsb);
363
364 if (erofs_sb_has_48bit(sbi))
365 erofs_info(sb, "EXPERIMENTAL 48-bit layout support in use. Use at your own risk!");
366 if (erofs_sb_has_metabox(sbi))
367 erofs_info(sb, "EXPERIMENTAL metadata compression support in use. Use at your own risk!");
368 if (erofs_is_fscache_mode(sb))
369 erofs_info(sb, "[deprecated] fscache-based on-demand read feature in use. Use at your own risk!");
370 out:
371 erofs_put_metabuf(&buf);
372 return ret;
373 }
374
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 2025/12/25 12:08, kernel test robot wrote:
> Hi Hongbo,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on xiang-erofs/dev-test]
> [also build test ERROR on xiang-erofs/dev xiang-erofs/fixes brauner-vfs/vfs.all linus/master v6.19-rc2 next-20251219]
> [cannot apply to mszeredi-fuse/for-next]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Hongbo-Li/iomap-stash-iomap-read-ctx-in-the-private-field-of-iomap_iter/20251224-122950
> base: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
> patch link: https://lore.kernel.org/r/20251224040932.496478-6-lihongbo22%40huawei.com
> patch subject: [PATCH v11 05/10] erofs: support user-defined fingerprint name
> config: powerpc-randconfig-001-20251225 (https://download.01.org/0day-ci/archive/20251225/202512251143.WPBiiQZA-lkp@intel.com/config)
> compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 4ef602d446057dabf5f61fb221669ecbeda49279)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251225/202512251143.WPBiiQZA-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202512251143.WPBiiQZA-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>>> fs/erofs/super.c:302:8: error: no member named 'ishare_xattr_pfx' in 'struct erofs_sb_info'
> 302 | sbi->ishare_xattr_pfx =
> | ~~~ ^
> 1 error generated.
>
>
> vim +302 fs/erofs/super.c
>
> 263
> 264 static int erofs_read_superblock(struct super_block *sb)
> 265 {
> 266 struct erofs_sb_info *sbi = EROFS_SB(sb);
> 267 struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
> 268 struct erofs_super_block *dsb;
> 269 void *data;
> 270 int ret;
> 271
> 272 data = erofs_read_metabuf(&buf, sb, 0, false);
> 273 if (IS_ERR(data)) {
> 274 erofs_err(sb, "cannot read erofs superblock");
> 275 return PTR_ERR(data);
> 276 }
> 277
> 278 dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
> 279 ret = -EINVAL;
> 280 if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
> 281 erofs_err(sb, "cannot find valid erofs superblock");
> 282 goto out;
> 283 }
> 284
> 285 sbi->blkszbits = dsb->blkszbits;
> 286 if (sbi->blkszbits < 9 || sbi->blkszbits > PAGE_SHIFT) {
> 287 erofs_err(sb, "blkszbits %u isn't supported", sbi->blkszbits);
> 288 goto out;
> 289 }
> 290 if (dsb->dirblkbits) {
> 291 erofs_err(sb, "dirblkbits %u isn't supported", dsb->dirblkbits);
> 292 goto out;
> 293 }
> 294
> 295 sbi->feature_compat = le32_to_cpu(dsb->feature_compat);
> 296 if (erofs_sb_has_sb_chksum(sbi)) {
> 297 ret = erofs_superblock_csum_verify(sb, data);
> 298 if (ret)
> 299 goto out;
> 300 }
> 301 if (erofs_sb_has_ishare_xattrs(sbi))
> > 302 sbi->ishare_xattr_pfx =
> 303 dsb->ishare_xattr_prefix_id & EROFS_XATTR_LONG_PREFIX_MASK;
> 304
> 305 ret = -EINVAL;
> 306 sbi->feature_incompat = le32_to_cpu(dsb->feature_incompat);
> 307 if (sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT) {
> 308 erofs_err(sb, "unidentified incompatible feature %x, please upgrade kernel",
> 309 sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT);
> 310 goto out;
> 311 }
> 312
> 313 sbi->sb_size = 128 + dsb->sb_extslots * EROFS_SB_EXTSLOT_SIZE;
> 314 if (sbi->sb_size > PAGE_SIZE - EROFS_SUPER_OFFSET) {
> 315 erofs_err(sb, "invalid sb_extslots %u (more than a fs block)",
> 316 sbi->sb_size);
> 317 goto out;
> 318 }
> 319 sbi->dif0.blocks = le32_to_cpu(dsb->blocks_lo);
> 320 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
> 321 #ifdef CONFIG_EROFS_FS_XATTR
The EROFS_FS_XATTR is disabled, so should put in here.. I will fix it in
next version.
Thanks,
Hongbo
> 322 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
> 323 sbi->xattr_prefix_start = le32_to_cpu(dsb->xattr_prefix_start);
> 324 sbi->xattr_prefix_count = dsb->xattr_prefix_count;
> 325 sbi->xattr_filter_reserved = dsb->xattr_filter_reserved;
> 326 #endif
> 327 sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
> 328 if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) {
> 329 sbi->root_nid = le64_to_cpu(dsb->rootnid_8b);
> 330 sbi->dif0.blocks = sbi->dif0.blocks |
> 331 ((u64)le16_to_cpu(dsb->rb.blocks_hi) << 32);
> 332 } else {
> 333 sbi->root_nid = le16_to_cpu(dsb->rb.rootnid_2b);
> 334 }
> 335 sbi->packed_nid = le64_to_cpu(dsb->packed_nid);
> 336 if (erofs_sb_has_metabox(sbi)) {
> 337 if (sbi->sb_size <= offsetof(struct erofs_super_block,
> 338 metabox_nid))
> 339 return -EFSCORRUPTED;
> 340 sbi->metabox_nid = le64_to_cpu(dsb->metabox_nid);
> 341 if (sbi->metabox_nid & BIT_ULL(EROFS_DIRENT_NID_METABOX_BIT))
> 342 return -EFSCORRUPTED; /* self-loop detection */
> 343 }
> 344 sbi->inos = le64_to_cpu(dsb->inos);
> 345
> 346 sbi->epoch = (s64)le64_to_cpu(dsb->epoch);
> 347 sbi->fixed_nsec = le32_to_cpu(dsb->fixed_nsec);
> 348 super_set_uuid(sb, (void *)dsb->uuid, sizeof(dsb->uuid));
> 349
> 350 if (dsb->volume_name[0]) {
> 351 sbi->volume_name = kstrndup(dsb->volume_name,
> 352 sizeof(dsb->volume_name), GFP_KERNEL);
> 353 if (!sbi->volume_name)
> 354 return -ENOMEM;
> 355 }
> 356
> 357 /* parse on-disk compression configurations */
> 358 ret = z_erofs_parse_cfgs(sb, dsb);
> 359 if (ret < 0)
> 360 goto out;
> 361
> 362 ret = erofs_scan_devices(sb, dsb);
> 363
> 364 if (erofs_sb_has_48bit(sbi))
> 365 erofs_info(sb, "EXPERIMENTAL 48-bit layout support in use. Use at your own risk!");
> 366 if (erofs_sb_has_metabox(sbi))
> 367 erofs_info(sb, "EXPERIMENTAL metadata compression support in use. Use at your own risk!");
> 368 if (erofs_is_fscache_mode(sb))
> 369 erofs_info(sb, "[deprecated] fscache-based on-demand read feature in use. Use at your own risk!");
> 370 out:
> 371 erofs_put_metabuf(&buf);
> 372 return ret;
> 373 }
> 374
>
Hi Hongbo,
kernel test robot noticed the following build errors:
[auto build test ERROR on xiang-erofs/dev-test]
[also build test ERROR on xiang-erofs/dev xiang-erofs/fixes brauner-vfs/vfs.all linus/master v6.19-rc2 next-20251219]
[cannot apply to mszeredi-fuse/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Hongbo-Li/iomap-stash-iomap-read-ctx-in-the-private-field-of-iomap_iter/20251224-122950
base: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
patch link: https://lore.kernel.org/r/20251224040932.496478-6-lihongbo22%40huawei.com
patch subject: [PATCH v11 05/10] erofs: support user-defined fingerprint name
config: nios2-randconfig-r071-20251225 (https://download.01.org/0day-ci/archive/20251225/202512251005.yZVSPUOm-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251225/202512251005.yZVSPUOm-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512251005.yZVSPUOm-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/erofs/super.c: In function 'erofs_read_superblock':
>> fs/erofs/super.c:302:20: error: 'struct erofs_sb_info' has no member named 'ishare_xattr_pfx'
302 | sbi->ishare_xattr_pfx =
| ^~
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for CAN_DEV
Depends on [n]: NETDEVICES [=n] && CAN [=m]
Selected by [m]:
- CAN [=m] && NET [=y]
vim +302 fs/erofs/super.c
263
264 static int erofs_read_superblock(struct super_block *sb)
265 {
266 struct erofs_sb_info *sbi = EROFS_SB(sb);
267 struct erofs_buf buf = __EROFS_BUF_INITIALIZER;
268 struct erofs_super_block *dsb;
269 void *data;
270 int ret;
271
272 data = erofs_read_metabuf(&buf, sb, 0, false);
273 if (IS_ERR(data)) {
274 erofs_err(sb, "cannot read erofs superblock");
275 return PTR_ERR(data);
276 }
277
278 dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
279 ret = -EINVAL;
280 if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
281 erofs_err(sb, "cannot find valid erofs superblock");
282 goto out;
283 }
284
285 sbi->blkszbits = dsb->blkszbits;
286 if (sbi->blkszbits < 9 || sbi->blkszbits > PAGE_SHIFT) {
287 erofs_err(sb, "blkszbits %u isn't supported", sbi->blkszbits);
288 goto out;
289 }
290 if (dsb->dirblkbits) {
291 erofs_err(sb, "dirblkbits %u isn't supported", dsb->dirblkbits);
292 goto out;
293 }
294
295 sbi->feature_compat = le32_to_cpu(dsb->feature_compat);
296 if (erofs_sb_has_sb_chksum(sbi)) {
297 ret = erofs_superblock_csum_verify(sb, data);
298 if (ret)
299 goto out;
300 }
301 if (erofs_sb_has_ishare_xattrs(sbi))
> 302 sbi->ishare_xattr_pfx =
303 dsb->ishare_xattr_prefix_id & EROFS_XATTR_LONG_PREFIX_MASK;
304
305 ret = -EINVAL;
306 sbi->feature_incompat = le32_to_cpu(dsb->feature_incompat);
307 if (sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT) {
308 erofs_err(sb, "unidentified incompatible feature %x, please upgrade kernel",
309 sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT);
310 goto out;
311 }
312
313 sbi->sb_size = 128 + dsb->sb_extslots * EROFS_SB_EXTSLOT_SIZE;
314 if (sbi->sb_size > PAGE_SIZE - EROFS_SUPER_OFFSET) {
315 erofs_err(sb, "invalid sb_extslots %u (more than a fs block)",
316 sbi->sb_size);
317 goto out;
318 }
319 sbi->dif0.blocks = le32_to_cpu(dsb->blocks_lo);
320 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
321 #ifdef CONFIG_EROFS_FS_XATTR
322 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
323 sbi->xattr_prefix_start = le32_to_cpu(dsb->xattr_prefix_start);
324 sbi->xattr_prefix_count = dsb->xattr_prefix_count;
325 sbi->xattr_filter_reserved = dsb->xattr_filter_reserved;
326 #endif
327 sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
328 if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) {
329 sbi->root_nid = le64_to_cpu(dsb->rootnid_8b);
330 sbi->dif0.blocks = sbi->dif0.blocks |
331 ((u64)le16_to_cpu(dsb->rb.blocks_hi) << 32);
332 } else {
333 sbi->root_nid = le16_to_cpu(dsb->rb.rootnid_2b);
334 }
335 sbi->packed_nid = le64_to_cpu(dsb->packed_nid);
336 if (erofs_sb_has_metabox(sbi)) {
337 if (sbi->sb_size <= offsetof(struct erofs_super_block,
338 metabox_nid))
339 return -EFSCORRUPTED;
340 sbi->metabox_nid = le64_to_cpu(dsb->metabox_nid);
341 if (sbi->metabox_nid & BIT_ULL(EROFS_DIRENT_NID_METABOX_BIT))
342 return -EFSCORRUPTED; /* self-loop detection */
343 }
344 sbi->inos = le64_to_cpu(dsb->inos);
345
346 sbi->epoch = (s64)le64_to_cpu(dsb->epoch);
347 sbi->fixed_nsec = le32_to_cpu(dsb->fixed_nsec);
348 super_set_uuid(sb, (void *)dsb->uuid, sizeof(dsb->uuid));
349
350 if (dsb->volume_name[0]) {
351 sbi->volume_name = kstrndup(dsb->volume_name,
352 sizeof(dsb->volume_name), GFP_KERNEL);
353 if (!sbi->volume_name)
354 return -ENOMEM;
355 }
356
357 /* parse on-disk compression configurations */
358 ret = z_erofs_parse_cfgs(sb, dsb);
359 if (ret < 0)
360 goto out;
361
362 ret = erofs_scan_devices(sb, dsb);
363
364 if (erofs_sb_has_48bit(sbi))
365 erofs_info(sb, "EXPERIMENTAL 48-bit layout support in use. Use at your own risk!");
366 if (erofs_sb_has_metabox(sbi))
367 erofs_info(sb, "EXPERIMENTAL metadata compression support in use. Use at your own risk!");
368 if (erofs_is_fscache_mode(sb))
369 erofs_info(sb, "[deprecated] fscache-based on-demand read feature in use. Use at your own risk!");
370 out:
371 erofs_put_metabuf(&buf);
372 return ret;
373 }
374
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 2025/12/24 12:09, Hongbo Li wrote:
> From: Hongzhen Luo <hongzhen@linux.alibaba.com>
>
> 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>
> ---
> fs/erofs/Kconfig | 9 +++++++++
> fs/erofs/erofs_fs.h | 5 +++--
> fs/erofs/internal.h | 2 ++
> fs/erofs/super.c | 3 +++
> fs/erofs/xattr.c | 13 +++++++++++++
> 5 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
> index d81f3318417d..b71f2a8074fe 100644
> --- a/fs/erofs/Kconfig
> +++ b/fs/erofs/Kconfig
> @@ -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.
> diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
> index e24268acdd62..20515d2462af 100644
> --- a/fs/erofs/erofs_fs.h
> +++ b/fs/erofs/erofs_fs.h
> @@ -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; /* indexes the ishare key in prefix xattres */
> + __u8 reserved[2];
> __le32 build_time; /* seconds added to epoch for mkfs time */
> __le64 rootnid_8b; /* (48BIT on) nid of root directory */
> __le64 reserved2;
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 98fe652aea33..99e2857173c3 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -134,6 +134,7 @@ struct erofs_sb_info {
> u32 xattr_blkaddr;
> u32 xattr_prefix_start;
> u8 xattr_prefix_count;
> + u8 ishare_xattr_pfx;
Could we use the same naming as `ishare_xattr_prefix_id`?
> struct erofs_xattr_prefix_item *xattr_prefixes;
> unsigned int xattr_filter_reserved;
> #endif
> @@ -238,6 +239,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)
> {
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index 2a44c4e5af4f..68480f10e69d 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -298,6 +298,9 @@ static int erofs_read_superblock(struct super_block *sb)
> if (ret)
> goto out;
> }
> + if (erofs_sb_has_ishare_xattrs(sbi))
> + sbi->ishare_xattr_pfx =
> + dsb->ishare_xattr_prefix_id & EROFS_XATTR_LONG_PREFIX_MASK;
It seems this part is still unmodified.
But after checking the code just now, I agree it may need more work
in order to pass dsb to erofs_xattr_prefixes_init(), so I can live
with the current status.
Thanks,
Gao Xiang
>
> ret = -EINVAL;
> sbi->feature_incompat = le32_to_cpu(dsb->feature_incompat);
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 396536d9a862..969e77efd038 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -519,6 +519,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_pfx;
> + 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);
© 2016 - 2026 Red Hat, Inc.