[PATCH v2 04/34] ext2: don't set SB_RDONLY after filesystem errors

Christian Brauner brauner at kernel.org
Thu Nov 12 05:20:58 PST 2026


On Thu, Nov 12, 2026 at 01:01:34PM +0100, Christian Brauner wrote:
> Fwiw, this leaks the inode's anonymous tlocks. They're from TxLock which
> is shared by all jfs mounts. txLock() also sets mp->lid and pinned the
> metapages with metapage_nohomeok().
>
> So the helper would have to tear all of that down like txAbort() does
> and drop the pins. Doable, I guess not sure if this belongs into the
> series.

So ok, I tried to do this in a vm. With jfs.nTxLock=256 three rounds of
error + umount leaked 163 tlocks and the next writer on a fresh jfs hung
in txBeginAnon().

I think txAbort() might be the wrong model. It only drops the pin when
mp->lsn is set and doesn't free linelocks. So this would need a helper
modelled on txUnlock().

Fwiw, the BUG_ON() also triggers without this series. The error sets
SB_RDONLY, sync_filesystem() bails at umount and nothing commits the
anonymous tlocks. This series fixes that as a side effect because
sync_filesystem() keeps running.

> All the check
> does is make syncfs() return without writing anything and make unmount
> drop whatever the flusher hasn't gotten to yet. Which might be the goal
> you're after?

I tried that too on fat and ext2. With the check and an umount right
after the error new files are gone on both. If the flusher ran first
nothing is lost. That's exactly what happens without this series. If
writeback is allowed to finish nothing is lost either way.

Skipping these superblocks in the flusher is no better. ext4
effectively does that in its emergency state (ext4_writepages() bails)
and the stuck dirty pages throttle everyone else from testing. with 1.4G
stuck on ext4 a dd to ext2 on another disk crawled at ~1MB/s until ext4
was unmounted (cf. [1]).

[1]: https://lore.kernel.org/r/ZEnb7KuOWmu5P+V9@ovpn-8-24.pek2.redhat.com



More information about the linux-mtd mailing list