linux/fs/erofs
Gao Xiang 7893cc1225 erofs: fix file-backed mounts no longer working on EROFS partitions
Sheng Yong reported [1] that Android APEX images didn't work with commit
072a7c7cdb ("erofs: don't bother with s_stack_depth increasing for
now") because "EROFS-formatted APEX file images can be stored within an
EROFS-formatted Android system partition."

In response, I sent a quick fat-fingered [PATCH v3] to address the
report.  Unfortunately, the updated condition was incorrect:

         if (erofs_is_fileio_mode(sbi)) {
-            sb->s_stack_depth =
-                file_inode(sbi->dif0.file)->i_sb->s_stack_depth + 1;
-            if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
-                erofs_err(sb, "maximum fs stacking depth exceeded");
+            inode = file_inode(sbi->dif0.file);
+            if ((inode->i_sb->s_op == &erofs_sops && !sb->s_bdev) ||
+                inode->i_sb->s_stack_depth) {

The condition `!sb->s_bdev` is always true for all file-backed EROFS
mounts, making the check effectively a no-op.

The real fix tested and confirmed by Sheng Yong [2] at that time was
[PATCH v3 RESEND], which correctly ensures the following EROFS^2 setup
works:
    EROFS (on a block device) + EROFS (file-backed mount)

But sadly I screwed it up again by upstreaming the outdated [PATCH v3].

This patch applies the same logic as the delta between the upstream
[PATCH v3] and the real fix [PATCH v3 RESEND].

Reported-by: Sheng Yong <shengyong1@xiaomi.com>
Closes: https://lore.kernel.org/r/3acec686-4020-4609-aee4-5dae7b9b0093@gmail.com [1]
Fixes: 072a7c7cdb ("erofs: don't bother with s_stack_depth increasing for now")
Link: https://lore.kernel.org/r/243f57b8-246f-47e7-9fb1-27a771e8e9e8@gmail.com [2]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-01-10 06:39:20 -10:00
..
compress.h erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
data.c iomap: add caller-provided callbacks for read and readahead 2025-11-05 12:57:23 +01:00
decompressor.c erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
decompressor_crypto.c erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
decompressor_deflate.c erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
decompressor_lzma.c erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
decompressor_zstd.c erofs: enable error reporting for z_erofs_fixup_insize() 2025-11-30 23:49:32 +08:00
dir.c erofs: Add support for FS_IOC_GETFSLABEL 2025-09-25 11:26:20 +08:00
erofs_fs.h erofs: switch on-disk header erofs_fs.h to MIT license 2025-12-01 15:25:43 +08:00
fileio.c Changes since last update: 2025-12-03 20:14:44 -08:00
fscache.c erofs: get rid of raw bi_end_io() usage 2025-11-30 23:55:13 +08:00
inode.c Coccinelle-based conversion to use ->i_state accessors 2025-10-20 20:22:26 +02:00
internal.h erofs: Add support for FS_IOC_GETFSLABEL 2025-09-25 11:26:20 +08:00
Kconfig erofs: Do not select tristate symbols from bool symbols 2025-08-11 06:02:20 +08:00
Makefile erofs: support DEFLATE decompression by using Intel QAT 2025-05-25 15:27:40 +08:00
namei.c erofs: get rid of erofs_kmap_type 2025-03-17 01:21:24 +08:00
super.c erofs: fix file-backed mounts no longer working on EROFS partitions 2026-01-10 06:39:20 -10:00
sysfs.c erofs: support to readahead dirent blocks in erofs_readdir() 2025-07-24 19:44:08 +08:00
xattr.c erofs: fix long xattr name prefix placement 2025-09-12 03:37:07 +08:00
xattr.h erofs: remove ENOATTR definition 2025-07-24 19:42:07 +08:00
zdata.c erofs: fix unexpected EIO under memory pressure 2025-12-22 00:18:53 +08:00
zmap.c erofs: consolidate z_erofs_extent_lookback() 2025-10-22 07:54:31 +08:00
zutil.c The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00