Necessity of measures against power outage
In recent years, with the increasing adoption of memory products in industrial equipment, data security measures for the system have become important. In particular, measures against power outages for embedded systems are essential.
Non-volatile memory is suitable for storing data, but when used for booting, if some problem occurs with the data inside the memory or the managed file system, links may be broken (the linked file does not exist), etc. There is a risk of causing damage.
In anticipation of such risks, in addition to memory hardware countermeasures, file system software countermeasures are also essential. A file system is one of the functions of an operating system (OS). By utilizing the functions necessary to manage and manipulate data stored on storage devices, you can organize and manage your data.
In this article, we will explain two ways to deal with power outages in file systems and introduce recommended file systems.
*For memory measures (e.MMC), please refer to this article.
Workaround using file system
Solution 1: Journaling file system
A journaling file system is generally used as a power outage countermeasure using a file system. A journaling file system means that the state of the file system is saved periodically. In the event of an unexpected power outage, the journal can be restored to its original state, allowing the file system to be restored to its previous normal state.
The standard journaling file systems for Linux systems are ext3 and ext4 file systems.
Figure 2 shows the protocol assuming an SD card MMC interface. This is an outline of the protocol for file creation, file open processing, and file writing.
Write is executed to the file ID that has been opened with FS_write, and is processed by multiple write (CMD25) and Stop CMD (CMD12) on the MMC interface, the file data is written inside the NAND flash, and then the journal is written. will be updated.
Even if the data update process is interrupted due to a power outage, the process can be resumed using the journal information the next time the machine is started. To avoid corruption in ext3 and ext4 file systems, you need to set the journaling mode. The journaling modes are shown below.
journaling mode |
Data protected |
explanation |
writeback |
Metadata*3 |
・Operation mode that protects only metadata by journaling ・Equivalent behavior to other journaling file systems such as XFS and JFS |
ordered |
metadata |
- Guaranteed processing order: File data change completed → metadata changed ・Ensure that metadata does not point to invalid data *However, since the data is not protected by journaling, it may be corrupted due to processing interruption. |
journal |
metadata, data |
・Operation mode that protects both metadata and data with journaling ・The input/output speed is the slowest because all data is written to the storage twice. |
*3 Metadata: Data containing link information related to data
As mentioned above, it is resistant to unexpected power outages, but file system corruption may occur.
Solution 2: Copy on Write
Unlike journaling, the method of creating a copy of the original data and updating the copy is called copy on write. If processing is interrupted at any phase to update the copy, the data remains in its original or modified state. Therefore, data corruption will not occur due to half-hearted rewriting.
Similar to journaling, we will consider the protocol below assuming an SD card MMC interface.
If the update process for file ①' is interrupted, file ①' will not be updated in terms of metadata, so the original file of normal file ① will be linked.
There is no concept of metadata corruption, and data integrity is maintained. Additionally, there is generally no recovery action that occurs after a power outage, so the mount time is kept constant.
Summary
I have summarized journaling and copy on write in a table.
Consistency |
writing speed |
Power interruption tolerance |
file check |
Mount time |
supported OS, file system |
|
journaling |
◎ |
△ Performance is slightly inferior because it takes twice the time to write the log. |
△ Possible metadata corruption |
〇 File check required |
△ There may be variations when a power outage occurs. |
Ext3、ext4、JFS、XFS |
Copy on Write (CoW) |
◎ |
◎ Good performance |
◎ No metadata corruption |
◎ File check unnecessary in principle |
◎ kept constant |
Reliance Nitro(Tuxera File System) |
Tuxera's highly reliable file system
When handling important data on the system or in memory, it is necessary to consider data integrity and mounting time delays due to power outages as concerns.
These concerns may be resolved by using a highly reliable file system for the MMC interface and external memory described in this article.
the Company recommend the Copy on Write Tuxera file system.
Please see the following page for more details.
Inquiry
If you have any questions or concerns, please contact us using the form below.
the Company product representative will reply.