ubifs: handling dirty data (writing back) + power cuts
Rafał Miłecki
zajec5 at gmail.com
Fri Feb 25 06:17:14 PST 2022
Hi,
my system is setup as follows:
# mount | grep ubifs
/dev/ubi0_1 on /mount/ubifs type ubifs (rw,noatime,assert=read-only,ubi=0,vol=1)
# cat /proc/sys/vm/dirty_writeback_centisecs
500
# cat /proc/sys/vm/dirty_expire_centisecs
3000
(5 s and 30 s respectively) and I'm currently debugging some data issues
related to power cuts.
My actual problem is related to ubifs behaviour for power cuts happening
between 5 and 35 seconds after saving a file:
date > /mount/ubifs/test.txt && sleep 15 && echo CUT POWER *NOW*
On the next boot test.txt exists but it's EMPTY (file size 0).
For newly created files above behaviour is not the worst one - however
I'd expect such file to not exist at all.
The biggest problem is when dealing with existing files. In such case
power cut means loosing it completely. I don't get *old* content nor
*new* content.
I noticed this behaviour with kernel 5.10 and also reproduced it with
5.4, 4.14 and 4.4.
Is this a bug or some quirky feature? Can I do anything to avoid such
situations except modifying all user space to call fsync() when needed?
More information about the openwrt-devel
mailing list