UBIFS: is the corrupted file in a finite state when power cut ?

Zhihao Cheng chengzhihao1 at huawei.com
Fri May 6 19:55:17 PDT 2022


在 2022/4/24 17:32, 袁建鹏 写道:
> These questions puzzles me a lot, and not mentioned in ubifs documents.
> 
> Q1. Power cut while writting to a new file,  does the file is in the following finite state, not possible in other state, right ?
> 
> 	1. the file not exists.
> 	
> 	2. the file is empty.
> 	
> 	3. the file size is partial, but no tail hole.
> 	
> 	4. the file size is partial, but with tail hole.
> 	
> 	5. the file size is entire, but with tail hole.
> 	
> 	6. the file is right.
> 
A1. After looking through ubifs's writing/reading and size-recovery 
process, I think there are following states:
1. the file not exists.
2. the file is empty.
3. file size > data length, with tail hole. (See do_readpage())
4. the file is right.

BTW, what does 'file size is entire/partial' mean?
> Q2. Power cut while truncating old file then write
> 
> 	1. the file is not changed.
> 	
> 	other states are same as Q1 2/3/4/5/6
> 
> Q3. power cut only lost tailing writes ?
> 
> 	write 3 times: a b c, it's not possible that b is lost but a c written.
> 	
A3. Yes. UBIFS replays journal in order according to sqnum. (See 
apply_replay_list())
> Q4. power cut only lost whole min I/O unit size ?
> 
> 	with 2048 bytes min io unit size. write 100 bytes in one write() call.
> 	it's not possible that seen 20 bytes with 80 bytes lost.
A4. For DATA head, ubifs drops all nodes until a complete group(You may 
treat it as an atomic operation), see ubifs_recover_leb->drop_last_group.



More information about the linux-mtd mailing list