linux loopback remount-ro, ext4_da_writepages: jbd2_start: 8192 pages, ino 130135; err -30

I have a loopback device formatted with ext4 (^has_journal, disabled journalling).

During shutdown, when I try to force remount as read-only, the loopback mounted filesystem. echo "u" > /proc/sysrq-trigger

I see these ext4 errors after remount ext4_da_writepages: jbd2_start: 8192 pages, ino 130135; err -30

(err 30 is -EROFS, error due to writeback to read-only filesystem). As part of remount, I see that linux calls invalidate_bdev() which I guess should not let any writeback to occur. Not sure why I see these errors.

I do not see any errors when I format the loopback device as vfat.

Any help is appreciated.

thanks


Solution 1:

It's because sysrq-trigger is emergency only, and does not have a lot (any) of intelligence.

Looking in kernel source, at fs/super.c:do_emergency_remount(), it seems it will remount readonly filesystems by its order in the list (which is the same as you see when you do "cat /proc/mounts" for example). That is unfortunate, as it will most probably remount readonly your parent filesystem first, and then it will try to umount loopback filesytem, which would trigger writting (of superblock and any remaining modified data/metadata) to parent filesystem, which is already readonly, and hence fails with -EROFS.

The solution is use regular tools to umount and remount R/O instead of sysrq-trigger, for example using:

umount -a

(which would umount all that it can, and remount rootfs R/O)

Or manually running in correct order:

mount -oremount,ro /dev/xxx

If you need to use /proc/sysrq-trigger (why?), then you can either try to make kernel see the ordering you want (if that is possible at all, I haven't looked that deep) or modify the kernel to do the ordering from last-to-first (instead of first-to-last). It is perhaps not perfect (maybe for some more complex setups it would be wrong too), but it would be in most (if not all) cases better than current solution. I'd hazard it might even get into mainline kernel if you try to push it, as walking that particular list at that particular place is not performance critical, so cache misses etc. from walking the list backwards are not an issue.

BTW, you don't see the errors for VFAT (if it has not been modified lately), because VFAT (due to its simplicity) does not need to write modified superblock on umount back to disk.