SlideShare a Scribd company logo
1 of 36
Download to read offline
Persistent log with UBI
Matthieu CASTET - www.parrot.com

25 September 2013

Persistent log with UBI
Persistent log with UBI

ulog
Goal

Log must be persistent on product : Nand flash
Can be used to trace system updates

Has to be independent/hidden of application filesystem
not on / filesystem

Has to be usable on shipped products
difficult to resize all partitions

Persistent log with UBI

ulog
Which interface to use ?

Raw flash (MTD)
UBI
Nand filesystem (UBIFS, ...)

Persistent log with UBI

ulog
Flash device vs block device 1/2

Block device
Consists of sectors
Sectors are small (512, 1024 B)
Maintains 2 main operations:

Flash device
Consists of eraseblocks
Eraseblocks are larger ( typically
128KB)
Maintains 3 main operations:

read sector

read from eraseblock

write sector

write to eraseblock
erase eraseblock

Persistent log with UBI

ulog
Flash device vs block device 2/2

Block device
Bad sectors are re-mapped and
hidden by hardware (at least in
modern LBA hard drives)
Sectors are devoid of the wear-out
property

Flash device
Bad eraseblocks are not hidden
and should be dealt with in software
Eraseblocks wear-out and become
bad and unusable after about 103
(for MLC NAND) - 105 (NOR, SLC
NAND) erase cycles

Flash device is more difficult to handle (ecc, bad block,
eraseblock, ...)

Persistent log with UBI

ulog
MTD

MTD stands for "Memory Technology Devices"
Provides an abstraction of flash devices
Hides many aspects specific to particular flash
technologies
Provides uniform API to access various types of flashes
E.g., MTD supports NAND, NOR, ECC-ed NOR,
DataFlash, OneNAND, etc
Provides partitioning capabilities

Persistent log with UBI

ulog
UBI

Stands for "Unsorted Block Images"
Provides an abstraction of "UBI volume"
Has kernel API and user space API (/dev/ubi0)
Provides wear-leveling
Hides bad eraseblocks
Allows run-time volume creation, deletion, and re-size
Is somewhat similar to LVM, but for MTD devices

Persistent log with UBI

ulog
UBI volume vs MTD device
MTD device
Consists of physical
(PEB), typically 128 KB
Has 3 main operations

eraseblocks

UBI device
Consists of logical eraseblocks (LEB),
slightly smaller than PEB (e.g 126/124
KB)
Has 3 main operations

read from PEB

read from LEB

write to PEB

write to LEB

erase PEB

erase LEB

May have bad PEBs
PEBs wear out
MTD devices are static

Persistent log with UBI

ulog

Does not have bad LEB (handle a certain amount of bad PEB)
LEBs do not wear out - UBI spread the
I/O load across the whole flash
UBI volumes are dynamic
Main idea behind UBI
Maps LEBs to PEBs
Any LEB may be mapped to any PEB
Eraseblock headers store mapping information and erase
count

Persistent log with UBI

ulog
Other
Handle bit-flips by moving data to a different PEB
Configurable wear-leveling threshold
Atomic LEB change
Volume update/rename operation
Suitable for MLC NAND
Performs operations in background
Works on NAND, NOR and other flash types
Tolerant to power cuts
Simple and robust design
easy support in bootloader

Persistent log with UBI

ulog
UBIFS

Filesystem on top of UBI (2.6.27 2008-10)
Needs a minimal number of LEBs to work : 17
http://www.linuxmtd.infradead.org/faq/ubifs.html#L_few_lebs

Complex filesystem : few (rare) corruptions seen on
products

Persistent log with UBI

ulog
log over UBI

we have a UBI device (for linux kernel) with free space
UBIFS has too much overhead

Persistent log with UBI

ulog
UBI user API
include/mtd/ubi-user.h
device attach
device detach
volume create
volume delete
volume resize
volume rename
volume update (static volume)
LEB erase
LEB atomic change
LEB map
LEB unmap
lseek
read
write

Persistent log with UBI

ulog
ulog

A log entry is much smaller than a page size (512B-4KB)
A cache is needed (in flash)
ulog uses a dynamic volume to have per LEB write

Persistent log with UBI

ulog
ulog

Persistent log with UBI

ulog
ulog : flush 1

Persistent log with UBI

ulog
ulog : flush 2

Persistent log with UBI

ulog
ulog : flush 2

Persistent log with UBI

ulog
ulog : flush 3

Persistent log with UBI

ulog
ulog : flush 4

Persistent log with UBI

ulog
Data flush

Copy data from level N to level N+1
Merge pages to try to fill pages from level N+1
if level 0 has 64 entries of about 20 B, it can be merged in a
page of 2 KB.

Can be recursive !
flush of L0, but L1 is full
flush of L1 needed
...

Persistent log with UBI

ulog
ulog : rotate 1

Persistent log with UBI

ulog
ulog : rotate 2

Persistent log with UBI

ulog
ulog : rotate 3

Persistent log with UBI

ulog
ulog : rotate 4

Persistent log with UBI

ulog
ulog : rotate 5

Persistent log with UBI

ulog
Data rotate

Clean next LEB (if not empty)
Write data on it

Persistent log with UBI

ulog
Data format

Header (32 bits)
size (24 bits)
version (3 bits) (relevant for first page)

Log data

Persistent log with UBI

ulog
Scan

Parse header for all LEBs
LEB version
LEB index (which pages have data)

For last level (L2), find current LEB
All empty use first (L2) LEB
Use LEB version

Persistent log with UBI

ulog
Scan

Parse header for all LEBs
LEB version
LEB index (which pages have data)

For last level (L2), find current LEB
All empty use first (L2) LEB
Use LEB version

Persistent log with UBI

ulog
ulog API

ulog_init
ulog_destroy
ulog_read
ulog_printf
ulog_vprintf
ulog_flush

Persistent log with UBI

ulog
ulog demo

Persistent log with UBI

ulog
TODO

any remark?

Persistent log with UBI

ulog
TODO

any remark?
Need to correctly handle all power failure cases during a
flush
Can be complex in case of cascaded flush

Some data are currently duplicated

Persistent log with UBI

ulog
Questions ?

Merci pour votre attention !
Thanks for your attention!
Questions?

Persistent log with UBI

ulog

More Related Content

Viewers also liked

Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Anne Nicolas
 
Kernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutionsKernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutions
Anne Nicolas
 
Introduction to UBI
Introduction to UBIIntroduction to UBI
Introduction to UBI
Roy Lee
 

Viewers also liked (6)

Kernel Recipes 2013 - Automating source code evolutions using Coccinelle
Kernel Recipes 2013 - Automating source code evolutions using CoccinelleKernel Recipes 2013 - Automating source code evolutions using Coccinelle
Kernel Recipes 2013 - Automating source code evolutions using Coccinelle
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machines
 
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
Distro Recipes 2013 : Contribution of RDF metadata for traceability among pro...
 
Kernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutionsKernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutions
 
Introduction to UBI
Introduction to UBIIntroduction to UBI
Introduction to UBI
 
Linux I/O path_20070116
Linux I/O path_20070116Linux I/O path_20070116
Linux I/O path_20070116
 

Similar to Kernel Recipes 2013 - Persistent logs using UBI

TokuDB internals / Лесин Владислав (Percona)
TokuDB internals / Лесин Владислав (Percona)TokuDB internals / Лесин Владислав (Percona)
TokuDB internals / Лесин Владислав (Percona)
Ontico
 
Efficient logging in multithreaded C++ server
Efficient logging in multithreaded C++ serverEfficient logging in multithreaded C++ server
Efficient logging in multithreaded C++ server
Shuo Chen
 

Similar to Kernel Recipes 2013 - Persistent logs using UBI (12)

TokuDB internals / Лесин Владислав (Percona)
TokuDB internals / Лесин Владислав (Percona)TokuDB internals / Лесин Владислав (Percona)
TokuDB internals / Лесин Владислав (Percona)
 
logfs
logfslogfs
logfs
 
cPanelCon 2014: InnoDB Anatomy
cPanelCon 2014: InnoDB AnatomycPanelCon 2014: InnoDB Anatomy
cPanelCon 2014: InnoDB Anatomy
 
Burst Buffer: From Alpha to Omega
Burst Buffer: From Alpha to OmegaBurst Buffer: From Alpha to Omega
Burst Buffer: From Alpha to Omega
 
Ceph Day Berlin: Ceph on All Flash Storage - Breaking Performance Barriers
Ceph Day Berlin: Ceph on All Flash Storage - Breaking Performance BarriersCeph Day Berlin: Ceph on All Flash Storage - Breaking Performance Barriers
Ceph Day Berlin: Ceph on All Flash Storage - Breaking Performance Barriers
 
Memory Mapping Cache
Memory Mapping CacheMemory Mapping Cache
Memory Mapping Cache
 
Efficient logging in multithreaded C++ server
Efficient logging in multithreaded C++ serverEfficient logging in multithreaded C++ server
Efficient logging in multithreaded C++ server
 
Write behind logging
Write behind loggingWrite behind logging
Write behind logging
 
Life Of A Dirty Page Inno Db Disk Io
Life Of A Dirty Page Inno Db Disk IoLife Of A Dirty Page Inno Db Disk Io
Life Of A Dirty Page Inno Db Disk Io
 
8086 microprocessor
8086 microprocessor8086 microprocessor
8086 microprocessor
 
Block I/O Layer Tracing: blktrace
Block I/O Layer Tracing: blktraceBlock I/O Layer Tracing: blktrace
Block I/O Layer Tracing: blktrace
 
SAQIB ALI.pptx
SAQIB ALI.pptxSAQIB ALI.pptx
SAQIB ALI.pptx
 

More from Anne Nicolas

Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Anne Nicolas
 

More from Anne Nicolas (20)

Kernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream firstKernel Recipes 2019 - Driving the industry toward upstream first
Kernel Recipes 2019 - Driving the industry toward upstream first
 
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIKernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
 
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernelKernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money
 
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureKernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and future
 
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
 
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
 
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and BareboxEmbedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
Embedded Recipes 2019 - Remote update adventures with RAUC, Yocto and Barebox
 
Embedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less specialEmbedded Recipes 2019 - Making embedded graphics less special
Embedded Recipes 2019 - Making embedded graphics less special
 
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre SiliconEmbedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
Embedded Recipes 2019 - Linux on Open Source Hardware and Libre Silicon
 
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) pictureEmbedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
Embedded Recipes 2019 - From maintaining I2C to the big (embedded) picture
 
Embedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops wayEmbedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops way
 
Embedded Recipes 2019 - Herd your socs become a matchmaker
Embedded Recipes 2019 - Herd your socs become a matchmakerEmbedded Recipes 2019 - Herd your socs become a matchmaker
Embedded Recipes 2019 - Herd your socs become a matchmaker
 
Embedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integrationEmbedded Recipes 2019 - LLVM / Clang integration
Embedded Recipes 2019 - LLVM / Clang integration
 
Embedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debuggingEmbedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debugging
 
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimediaEmbedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
 
Kernel Recipes 2019 - Suricata and XDP
Kernel Recipes 2019 - Suricata and XDPKernel Recipes 2019 - Suricata and XDP
Kernel Recipes 2019 - Suricata and XDP
 
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Kernel Recipes 2013 - Persistent logs using UBI

  • 1. Persistent log with UBI Matthieu CASTET - www.parrot.com 25 September 2013 Persistent log with UBI
  • 3. Goal Log must be persistent on product : Nand flash Can be used to trace system updates Has to be independent/hidden of application filesystem not on / filesystem Has to be usable on shipped products difficult to resize all partitions Persistent log with UBI ulog
  • 4. Which interface to use ? Raw flash (MTD) UBI Nand filesystem (UBIFS, ...) Persistent log with UBI ulog
  • 5. Flash device vs block device 1/2 Block device Consists of sectors Sectors are small (512, 1024 B) Maintains 2 main operations: Flash device Consists of eraseblocks Eraseblocks are larger ( typically 128KB) Maintains 3 main operations: read sector read from eraseblock write sector write to eraseblock erase eraseblock Persistent log with UBI ulog
  • 6. Flash device vs block device 2/2 Block device Bad sectors are re-mapped and hidden by hardware (at least in modern LBA hard drives) Sectors are devoid of the wear-out property Flash device Bad eraseblocks are not hidden and should be dealt with in software Eraseblocks wear-out and become bad and unusable after about 103 (for MLC NAND) - 105 (NOR, SLC NAND) erase cycles Flash device is more difficult to handle (ecc, bad block, eraseblock, ...) Persistent log with UBI ulog
  • 7. MTD MTD stands for "Memory Technology Devices" Provides an abstraction of flash devices Hides many aspects specific to particular flash technologies Provides uniform API to access various types of flashes E.g., MTD supports NAND, NOR, ECC-ed NOR, DataFlash, OneNAND, etc Provides partitioning capabilities Persistent log with UBI ulog
  • 8. UBI Stands for "Unsorted Block Images" Provides an abstraction of "UBI volume" Has kernel API and user space API (/dev/ubi0) Provides wear-leveling Hides bad eraseblocks Allows run-time volume creation, deletion, and re-size Is somewhat similar to LVM, but for MTD devices Persistent log with UBI ulog
  • 9. UBI volume vs MTD device MTD device Consists of physical (PEB), typically 128 KB Has 3 main operations eraseblocks UBI device Consists of logical eraseblocks (LEB), slightly smaller than PEB (e.g 126/124 KB) Has 3 main operations read from PEB read from LEB write to PEB write to LEB erase PEB erase LEB May have bad PEBs PEBs wear out MTD devices are static Persistent log with UBI ulog Does not have bad LEB (handle a certain amount of bad PEB) LEBs do not wear out - UBI spread the I/O load across the whole flash UBI volumes are dynamic
  • 10. Main idea behind UBI Maps LEBs to PEBs Any LEB may be mapped to any PEB Eraseblock headers store mapping information and erase count Persistent log with UBI ulog
  • 11. Other Handle bit-flips by moving data to a different PEB Configurable wear-leveling threshold Atomic LEB change Volume update/rename operation Suitable for MLC NAND Performs operations in background Works on NAND, NOR and other flash types Tolerant to power cuts Simple and robust design easy support in bootloader Persistent log with UBI ulog
  • 12. UBIFS Filesystem on top of UBI (2.6.27 2008-10) Needs a minimal number of LEBs to work : 17 http://www.linuxmtd.infradead.org/faq/ubifs.html#L_few_lebs Complex filesystem : few (rare) corruptions seen on products Persistent log with UBI ulog
  • 13. log over UBI we have a UBI device (for linux kernel) with free space UBIFS has too much overhead Persistent log with UBI ulog
  • 14. UBI user API include/mtd/ubi-user.h device attach device detach volume create volume delete volume resize volume rename volume update (static volume) LEB erase LEB atomic change LEB map LEB unmap lseek read write Persistent log with UBI ulog
  • 15. ulog A log entry is much smaller than a page size (512B-4KB) A cache is needed (in flash) ulog uses a dynamic volume to have per LEB write Persistent log with UBI ulog
  • 17. ulog : flush 1 Persistent log with UBI ulog
  • 18. ulog : flush 2 Persistent log with UBI ulog
  • 19. ulog : flush 2 Persistent log with UBI ulog
  • 20. ulog : flush 3 Persistent log with UBI ulog
  • 21. ulog : flush 4 Persistent log with UBI ulog
  • 22. Data flush Copy data from level N to level N+1 Merge pages to try to fill pages from level N+1 if level 0 has 64 entries of about 20 B, it can be merged in a page of 2 KB. Can be recursive ! flush of L0, but L1 is full flush of L1 needed ... Persistent log with UBI ulog
  • 23. ulog : rotate 1 Persistent log with UBI ulog
  • 24. ulog : rotate 2 Persistent log with UBI ulog
  • 25. ulog : rotate 3 Persistent log with UBI ulog
  • 26. ulog : rotate 4 Persistent log with UBI ulog
  • 27. ulog : rotate 5 Persistent log with UBI ulog
  • 28. Data rotate Clean next LEB (if not empty) Write data on it Persistent log with UBI ulog
  • 29. Data format Header (32 bits) size (24 bits) version (3 bits) (relevant for first page) Log data Persistent log with UBI ulog
  • 30. Scan Parse header for all LEBs LEB version LEB index (which pages have data) For last level (L2), find current LEB All empty use first (L2) LEB Use LEB version Persistent log with UBI ulog
  • 31. Scan Parse header for all LEBs LEB version LEB index (which pages have data) For last level (L2), find current LEB All empty use first (L2) LEB Use LEB version Persistent log with UBI ulog
  • 33. ulog demo Persistent log with UBI ulog
  • 35. TODO any remark? Need to correctly handle all power failure cases during a flush Can be complex in case of cascaded flush Some data are currently duplicated Persistent log with UBI ulog
  • 36. Questions ? Merci pour votre attention ! Thanks for your attention! Questions? Persistent log with UBI ulog