On Tue, Jun 24, 2025 at 04:53:46PM +0200, Anton Khirnov wrote:
> Package: e2fsprogs
> Version: 1.47.2-1+b1
> Severity: normal
> 
> Dear Maintainer,
> as a part of my backup system, I create read-only LVM snapshots of ext4
> partitions. On my newest machine, mounting these snapshots sometimes
> fails with
>   fsconfig() failed: Structure needs cleaning.
> accompanied by
>   ext4_mark_recovery_complete:6264: comm mount: Orphan file not empty on 
> read-only fs.
> in dmesg. Upon investigating, I found out that the orphan_file fs
> feature, which recently became enabled by default, is the culprit.
> 
> This behaviour seems suboptimal to me. Would it be possible to make such
> filesystems mountable? If not, perhaps this feature should not be on by
> default, or at least there should be a warning about this.

Hi Anton,

When you say read-only snapshots, do you mean that you created with
some command like this:

# lvcreate --size 100M --name snap --snapshot --permission r /dev/vg/source

This results in creating a read-only block device, and if there are
orphaned inodes, whether this is using the old traditional, single
linked list, or using a parallel set of orphaned inodes (which is what
orphan_file is all about), even when you do a read-only mount, we need
replay the journal and process the orphaned inodes before we can allow
the mount to proceed.

For example:

root@kvm-xfstests:~# losetup /dev/loop0 /tmp/foo.img
root@kvm-xfstests:~# mount -o ro /tmp/foo.img /mnt
[   38.970783] EXT4-fs (loop0): INFO: recovery required on readonly filesystem
[   38.971399] EXT4-fs (loop0): write access will be enabled during recovery
[   38.972917] EXT4-fs (loop0): orphan cleanup on readonly fs
[   38.973485] EXT4-fs (loop0): 1 orphan inode deleted
[   38.973929] EXT4-fs (loop0): recovery complete
[   38.974558] EXT4-fs (loop0): mounted filesystem 
b23e158e-a088-454a-8e18-91ed278538a0 ro with ordered data mode. Quota mode: 
none.

versus:

root@kvm-xfstests:~# losetup -r /dev/loop0 /tmp/foo.img
[  146.467117] loop0: detected capacity change from 0 to 65536
root@kvm-xfstests:~# mount -o ro /dev/loop0 /mnt
[  154.304952] EXT4-fs (loop0): INFO: recovery required on readonly filesystem
[  154.305579] EXT4-fs (loop0): write access unavailable, cannot proceed (try mo
unting with noload)
mount: /mnt: cannot mount /dev/loop0 read-only.
       dmesg(1) may have more information after failed mount system call.

I'd need to see your kernel messages to be certain, but this
requirement of needing to be able to write to the snapshot device is
there regardless of whether the orphan file feature is enabled or not.
So I'm not sure how you came to the conclusion that the orphan_file
feature is "at fault", but I'm pretty sure that's not the case.

I have been doing regular regression testing with the orphan_file
feature for years, and I haven't seen any problems with it.

Finally, why are you creating read-only LVM snapshots?  The whole
point of snapshots is that you can allow read-write snapshots, and
they won't affect the original source volume.  Just create the
snapshots without the "--permissions r" option, and then you can mount
the file system with -o ro, and things will work fine.  Yes, we may
need to replay the journal before continuing but that doesn't take a
lot of disk space.  Using --size 100M should be *more* than enough for
pretty much any file system.

Cheers,

                                                - Ted

Reply via email to