Re: ext4: spurious "orphan cleanup on readonly fs" due to remount,ro failing to reset orphan_file structures

Bagas Sanjaya <[email protected]> Mon, 3 Aug 2026 07:28:30 +0700
Newsgroups org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
--3QVTYZfKyLSL06hz
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

[Cc'ing ext4 folks with full reply context]

On Sun, Aug 02, 2026 at 11:18:39PM +0100, Tigran Aivazian wrote:
> Hello,
>=20
> I have been experimenting with optimising rootfs for custom builds of
> Ubuntu 26 with various options like fast_commit, sparse_super2,
> orphan_file, inline_data, metadata_csum_seed, etc. And I noticed
> something strange: if my root filesystem is made with "orphan_file"
> feature then on every reboot I get this message:
>=20
> EXT4-fs (sda): orphan cleanup on readonly fs
>=20
> (tested with SSD, NVMe and even old HDD -- because initially I thought
> that maybe it was NVMe controller failing to flush its volatile DRAM
> cache to the NAND flash, but no, it wasn't the reason)
>=20
> I think what happens here is that when a filesystem with the
> "orphan_file" feature is fully unmounted, ext4_put_super()
> successfully clears the "orphan_present" superblock flag AND properly
> collapses/resets the physical orphan file headers. However, during a
> read-only remount (which systemd must do for / in order to halt the
> system) ext4_reconfigure() clears the "orphan_present" superblock flag
> but skips resetting the physical orphan file structures. Consequently,
> on the next boot (which starts with a read-only mount of /),
> ext4_fill_super() observes that while the superblock flag is clear,
> the orphan file itself appears non-empty. This unconditionally
> triggers ext4_orphan_cleanup(), which prints the spurious warning,
> scans the file, finds 0 orphans, and completes silently.
>=20
> Let's test this theory on the kernel 7.0.0-28-generic of Ubuntu 26:

Can you also confirm this on latest mainline (7.2-rc6)?

>=20
> # 1. Create a filesystem with the orphan_file feature
> mkfs.ext4 -O orphan_file /dev/sda
>=20
> # 2. Mount read-write
> mount -o rw /dev/sda /mnt
>=20
> # 3. Remount read-only (Simulating systemd shutdown)
> # This clears the orphan_present flag in the superblock, but leaves
> the orphan file structures intact.
> mount -o remount,ro /mnt
>=20
> # 4. Unmount and mount read-only (Simulating the next boot)
> umount /mnt
> mount -o ro /dev/sda /mnt
>=20
> Expected result in dmesg: nothing (well, except the usual
> mount/remount messages about ordered data mode, etc).
>=20
> Actual result in dmesg:
>=20
> EXT4-fs (sda): orphan cleanup on readonly fs
>=20
> Since this affects the default shutdown path for any modern Linux
> distribution using systemd and ext4 with the "orphan_file" feature, it
> would be great to get the remount,ro teardown path aligned with the
> full unmount teardown path in this aspect.
>=20

Thanks.

--=20
An old man doll... just what I always wanted! - Clara

--3QVTYZfKyLSL06hz
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQRwG4Bv3KXTpY/7j318J2xkpeRKHQUCam/gpgAKCRB8J2xkpeRK
HSjJAQCrTKPJqmqDsTmmKuuhPdXQqQvie8vEnTlFEPH0aYG+6QEAsM46SzZSFQS7
KZ+FYthoqCrwK657LOkMj/2Ive8VtgI=
=X71E
-----END PGP SIGNATURE-----

--3QVTYZfKyLSL06hz--