BUG: NILFS error (device dm-0): nilfs_bmap_lookup_contig: broken bmap (inode number=4023271)
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)
Ryusuke Konishi
maintainerQuoted 35 lines · Tomas Hlavaty
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 andmesa_shader_cache_dbdir 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.
Quoted 6 lines
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,
Sorry for the inconvenience, and thank you for reporting the details of the problem.
The log suggests that the b-tree, which is the metadata of the file or directory with inode 4023271, is corrupted, making it impossible to read and, as a result, impossible to write.
The /root/.cache/... directory is not created by nilfs, so it is probably an application directory.
If the problem is only partial, first mount it read-only,
and then try copying it to another device while excluding the directory from access, for example, by specifying the option "--exclude /root/.cache" in rsync.
As for in-place repair, the conclusion is that there is currently no way to do it. The only thing we can do is mount the filesystem read-only and salvage as much data as possible (without touching the damage). If you have a backup, it may be quicker to retrieve important data from there (in any case, nilfs is powerless against block device corruption, so please make backups as frequently as necessary).
syzbot started reporting a large number of automatically detected bugs a few years ago, so we have been fixing a lot of serious bugs over the past few years, and have also strengthened the detection of abnormal file system states.
That is probably why the abnormal message from a few years ago (probably a message about dropping to read-only and discarding dirty data) has become a problem now.
If there were no messages with the old kernel and there were no problems, you could use it to rescue your data, but since there is a high possibility that there is some abnormality that was not detected in the past, this method is generally not recommended.
I hope this helps a little.
Regards,
Ryusuke Konishi
Quoted 21 lines
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)