Skip to contentSkip to conversation

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

DISCUSSION 袁建鹏 2 participants 3 messages Apr 24, 2022 – May 7, 2022 Memory technology devices (MTD)

lore
Share & tools
lore

袁建鹏

author
#0 lore raw

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.

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.

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.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#1 lore raw
Quoted 8 lines · 袁建鹏

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.

Quoted 8 lines

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?

Quoted 10 lines

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())

Quoted 4 lines

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.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw
Quoted 5 lines
Quoted 5 lines

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.

It is possible that seen 20 bytes with 80 bytes lost.

UBIFS writes data content in PAGE unit(We assume that page_size equals to 4096), for example (See ubifs_writepage() and generic_perform_write()):

        20B  80B
         ↓   ↓

| PAGE1 | PAGE2 |
↑
powercut!

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/