UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded...
Transcript of UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded...
![Page 1: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/1.jpg)
UBI Fastmap
Thomas Gleixner - linutronix GmbH
Embedded Linux Conference Europe 2012, Barcelona
Thomas Gleixner - linutronix GmbH 1
![Page 2: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/2.jpg)
UBI
Overview
Thomas Gleixner - linutronix GmbH 2
![Page 3: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/3.jpg)
UBI
Provides
I Volume manager for FLASH
I Full device wear leveling
I Bad block handling
I Data integrity mechanisms
Thomas Gleixner - linutronix GmbH 3
![Page 4: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/4.jpg)
UBI
Volume management
Thomas Gleixner - linutronix GmbH 4
![Page 5: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/5.jpg)
UBI
Metadata storage
Thomas Gleixner - linutronix GmbH 5
![Page 6: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/6.jpg)
UBI
Metadata
I Erasecount header
I Volume information header
Thomas Gleixner - linutronix GmbH 6
![Page 7: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/7.jpg)
UBI
Volume information header
I Volume id
I Logical eraseblock number in volume
I Version counter
Thomas Gleixner - linutronix GmbH 7
![Page 8: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/8.jpg)
UBI
Metadata retrieval
Thomas Gleixner - linutronix GmbH 8
![Page 9: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/9.jpg)
UBI
Attach time
I O(N)
I Grows linear with FLASH size
Thomas Gleixner - linutronix GmbH 9
![Page 10: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/10.jpg)
UBI
Attach time
N = number of eraseblocksTp = time to read a single flash pageHp = number of header pages
Ta = N * Tp * Hp
Thomas Gleixner - linutronix GmbH 10
![Page 11: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/11.jpg)
UBI attach time
Example I: NAND 64MB 1024PEBs 512B pagesize
N = 1024Tp = 50usHp = 1
Ta = 1024 * 50us * 1 = 51.2ms
Thomas Gleixner - linutronix GmbH 11
![Page 12: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/12.jpg)
UBI attach time
Example II: NAND 4GB 8192PEBs 4K pagesize
N = 8192Tp = 100usHp = 2
Ta = 8192 * 100us * 2 = 1.6384s
Thomas Gleixner - linutronix GmbH 12
![Page 13: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/13.jpg)
UBI attach time
Can we be smarter?
I Store metadata in a special volume
I but ...
Thomas Gleixner - linutronix GmbH 13
![Page 14: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/14.jpg)
UBI metadata
Where to store metadata?
I No static storage space on NAND
I Metadata update needs to be rare
I No violation of UBI robustness
Thomas Gleixner - linutronix GmbH 14
![Page 15: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/15.jpg)
UBI metadata volume
How to find it?
I Split into two volumesI Reference volumeI Data volume
Thomas Gleixner - linutronix GmbH 15
![Page 16: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/16.jpg)
UBI metadata volumes
Reference volume
I contains information about the metadata volume location
I is located within the first N physical erase blocks
I has to be found by scanning
Thomas Gleixner - linutronix GmbH 16
![Page 17: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/17.jpg)
UBI metadata volumes
Data volume
I contains information about all physical eraseblocks
I condenses UBI header data
Thomas Gleixner - linutronix GmbH 17
![Page 18: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/18.jpg)
UBI metadata volumes
Avoid fast updates
I by storing a pool list
I by scanning the erase blocks in the pool list
I by rewriting metadata only when pool list changes
Thomas Gleixner - linutronix GmbH 18
![Page 19: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/19.jpg)
UBI metadata volumes
Pool list
I Configurable number of erase blocks
I Used for current write operations
Thomas Gleixner - linutronix GmbH 19
![Page 20: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/20.jpg)
UBI metadata volumes
Pool list changes
I due to wear leveling
I due to client (e.g. UBIFS) requirements
Thomas Gleixner - linutronix GmbH 20
![Page 21: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/21.jpg)
UBI metadata volumes
Preserve robustness
I by preserving the UBI header semantics
I by fallback to full scanning mode
Thomas Gleixner - linutronix GmbH 21
![Page 22: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/22.jpg)
UBI fastmap
Attach mode scheme
Thomas Gleixner - linutronix GmbH 22
![Page 23: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/23.jpg)
UBI
Attach mode scheme
Thomas Gleixner - linutronix GmbH 23
![Page 24: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/24.jpg)
UBI fastmap
Attach mode scheme
Thomas Gleixner - linutronix GmbH 24
![Page 25: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/25.jpg)
UBI fastmap
Attach time
Nb = number of eraseblocksNs = number of blocks to scan for reference volumeNp = number of pool eraseblocks to scanHp = number of header pagesSb = size of an eraseblockSp = size of a pageSd = size of metadata per eraseblockTp = time to read a single flash page
Ntotp = (Ns + Np) * Hp + Sb / Sp + Sp / SdTa = Ntotp * Tp
Thomas Gleixner - linutronix GmbH 25
![Page 26: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/26.jpg)
UBI fastmap attach time
Example I: NAND 64MB 1024PEBs 512B pagesize
Nb = 1024Ns = 16Np = 16Hp = 1
Sb = 65536Sp = 512Sd = 128Tp = 50us
Ntotp = (16+16)*1+65536/512+1024*96/512 = 352Ta = 352 * 50us = 17.6ms (UBI: 51.2ms)
Thomas Gleixner - linutronix GmbH 26
![Page 27: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/27.jpg)
UBI fastmap attach time
Example II: NAND 4GB 8192PEBs 4K pagesize
Nb = 8192Ns = 64Np = 256Hp = 2
Sb = 512*1024Sp = 4096Sd = 128Tp = 100us
Ntotp = (64+256)*2+512*1024/4096+8192*96/4096 = 960Ta = 960 * 100us = 96ms (UBI: 1.6384s)
Thomas Gleixner - linutronix GmbH 27
![Page 28: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/28.jpg)
UBI fastmap
Summary
I Fastmap provides significant speedup
I Speedup grows with flash size
Thomas Gleixner - linutronix GmbH 28
![Page 29: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/29.jpg)
UBI fastmap
Further possible optimizations
I Compressed fastmap storage
I Let the bootloader hand the scan table to the kernel
I Implement supplementary NVRAM support
Thomas Gleixner - linutronix GmbH 29
![Page 30: UBI Fastmap - eLinux · 2016. 7. 6. · UBI Fastmap Thomas Gleixner - linutronix GmbH Embedded Linux Conference Europe 2012, Barcelona Thomas Gleixner - linutronix GmbH 1. UBI Overview](https://reader035.fdocuments.us/reader035/viewer/2022063013/5fcd75dee07fe073a45d98da/html5/thumbnails/30.jpg)
UBI fastmap
Code
I Merged in Linux 3.7
I Sponsored by CELF
I Designed and implemented by linutronix
Thomas Gleixner - linutronix GmbH 30