UBIFS: file data corruption during the power cut-off test
richard at nod.at
Fri Jun 7 09:02:16 PDT 2019
----- Ursprüngliche Mail -----
> Now, I' overwriting the content of the "test0" with "test2", without "test0"
> mnt/data1 # dd if=test2 of=test0 conv=notrunc
> 222+0 records in
> 222+0 records out
> 113664 bytes (111.0KB) copied, 0.859668 seconds, 129.1KB/s
> /mnt/data1 # md5sum *
> 23376319de62934c3859615e6244aae0 test0
> 23376319de62934c3859615e6244aae0 test1
> 87cd1d1a28896e63eb039d75efef43a3 test2
> /mnt/data1 #
> For this particular test pass, the content of test2 matches the content of the
> original file test0, so overwriting test0 with test2 doesn't change the data.
> However, upon retry of the very same test from the beginning (with the power
> cut-off in the middle) it's easily to have the content of test2 (exactly the
> last 512 bytes in my case) which doesn't match test0, so "dd if=test2 of=test0
> conv=notrunc" will result in test0 with a different checksum.
> To remind, the partition is mounted with the "sync" option.
Ahhh, now understand what you do. Sorry for being dense.
I fear your assumption is not correct because UBIFS is strictly copy-on-write.
So if you overwrite a file, it will always create new data blocks. A data block
has 4k. If you face a power-cut from this 4k block the last written page can be
lost. This is likely what you see.
Does my answer help?
More information about the linux-mtd