RE:(2) [PATCH] erofs: apply the stacked fs check to extra file-backed devices

From: Daejun Park

Date: Tue Nov 03 2026 - 01:06:36 EST


> > - Lockdep warns about devs->rwsem vs i_rwsem for a device= path inside
> > an EROFS mount, with or without this patch.
>
> What does that mean? Can you explain more about this lockdep issue?

In the test, an EROFS image is mounted at /mnt/n1, and another EROFS
image is mounted at /mnt/n2 with device=/mnt/n1/blob2:

1. A cold directory lookup on an EROFS mount holds the directory's
i_rwsem in lookup_open() and reads the directory block through
erofs_lookup() -> erofs_bread() -> erofs_map_dev(), which takes
down_read(&devs->rwsem). Lockdep records i_rwsem -> devs->rwsem.

2. Mounting the second EROFS at /mnt/n2 calls erofs_scan_devices(),
which takes down_read(&sbi->devs->rwsem) on the new superblock and
then calls erofs_init_device() -> filp_open("/mnt/n1/blob2"). When
blob2 is not in the dcache, lookup_open() takes the directory's
i_rwsem on /mnt/n1.

Because both mounts share the lockdep classes &sbi->devs->rwsem and
&type->i_mutex_dir_key, lockdep reports a cycle:

WARNING: possible circular locking dependency detected
python3/1138 is trying to acquire lock:
(&type->i_mutex_dir_key#8){.+.+}-{4:4}, at: lookup_open+0x182/0x1650
but task is already holding lock:
(&sbi->devs->rwsem){++++}-{4:4}, at: erofs_fc_fill_super+0x2008/0x35c0

-> #1 (&sbi->devs->rwsem){++++}-{4:4}:
down_read+0x8f/0x4b0
erofs_map_dev+0x2f5/0xb20
...
erofs_bread+0x15c/0x5b0
erofs_find_target_block.constprop.0+0x22e/0xa40
erofs_namei+0x1d4/0x7c0
erofs_lookup+0x246/0x300
lookup_open+0x83b/0x1650

-> #0 (&type->i_mutex_dir_key#8){.+.+}-{4:4}:
down_read+0x8f/0x4b0
lookup_open+0x182/0x1650
...
filp_open+0x28/0x40
erofs_init_device+0x151/0x880
erofs_fc_fill_super+0x20e6/0x35c0

The second superblock is still in erofs_fc_fill_super(), and
down_write(&sbi->devs->rwsem) only runs in erofs_fc_parse_param() before
get_tree, so the two mounts cannot actually deadlock.

Also, Sashiko found that inode_share can nest file-backed reads through
a block-backed EROFS mount. I will send a v2 series with this patch
first, followed by a patch for inode_share and the bio_set patch.