BUG: NILFS error (device dm-0): nilfs_bmap_lookup_contig: broken bmap (inode number=4023271)

From: Tomas Hlavaty
Date: Tue Jun 24 2025 - 16:34:32 EST


Hi Ryusuke,

I get the following error:

NILFS error (device dm-0): nilfs_bmap_lookup_contig:
broken bmap (inode number=4023271)

and the filesystem gets mounted read-only.

I can remount the filesystem read-write again manually, but after an
operation which touches the broken part of the filesystem, it gets
remounted read-only again.

I have identified the file of the inode:
sudo find / -inum 4023271
as
/root/.cache/mesa_shader_cache_db/index
but remounting rw and trying to
rm -r /root/.cache
puts the filesystem to ro mode again.
(not sure why there is .cache dir and mesa_shader_cache_db dir in the
/root dir, I never use root account for GUI)

I am in the process of upgrading the system from nixos24.11 to
nixos25.05 but this issue is preventing me from doing so. Is there a
way to fix the filesystem so that it stays read-write? Or do I have to
discard the whole filesystem?

Also I have noticed since long time ago, that reboot or shutdown says
something about nilfs discarding stuff, which seems strange and those
messages were not there a year or more ago. Not sure if this is
related, but it should not be discarding anything I guess. I see these
messages on many machines so it is not related to a particular hardware.

Log and stacktrace are bellow.
Please let me know if I can provide more info about the problem.

Any help would be appreciated.

Thank you,

Tomas

$ uname -a
Linux buta 6.6.87 #1-NixOS SMP PREEMPT_DYNAMIC Thu Apr 10 12:37:44 UTC 2025 x86_64 GNU/Linux

$ sudo dmesg | grep nilfs
[ 1.087780] stage-1-init: [Tue Jun 24 19:32:16 UTC 2025] loading module nilfs2...
[ 35.318251] NILFS error (device dm-0): nilfs_bmap_lookup_contig: broken bmap (inode number=4023271)
[ 35.319235] NILFS error (device dm-0): nilfs_bmap_lookup_contig: broken bmap (inode number=4023271)
[...]
[ 35.347872] NILFS error (device dm-0): nilfs_bmap_lookup_contig:
broken bmap (inode number=4023271)
[ 1733.401421] nilfs_segctor_do_construct+0xdd/0x2630 [nilfs2]
[ 1733.401747] ? nilfs_mdt_fetch_dirty+0x19/0x50 [nilfs2]
[ 1733.401899] ? nilfs_test_metadata_dirty.isra.0+0x50/0xb0 [nilfs2]
[ 1733.402059] nilfs_segctor_construct+0x170/0x2b0 [nilfs2]
[ 1733.402220] nilfs_segctor_thread+0x155/0x3f0 [nilfs2]
[ 1733.402385] ? __pfx_nilfs_segctor_thread+0x10/0x10 [nilfs2]
[ 1738.068626] NILFS error (device dm-0): nilfs_bmap_last_key: broken
bmap (inode number=4023271)