Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor10051721005172 Limitations Of Journaling Anchor10071511007151When properly used, the journaling system provides reliable protection for the file system metadata. To ensure proper operation, though, you should understand certain limitations, and follow the corresponding recommendations. A failure to observe these recommendations could spoil the benefits of using the journaling system and lead to file system corruption.anchor10136881013688

Journaling and cached FILE access mode

...

FS_FILE_ACCESS_MODE_CACHED should be avoided on a journaled volume. Using the FS_FILE_ACCESS_MODE_CACHED file access mode prevents the journaling module from effectively ensuring file meta data consistency since it might lead to a mismatch between the file’s size and its allocated storage space, resulting in a waste of storage space. Anchor10053451005345

Journaling and FAT16/32 removable media

...

1010142The journaling module recovery process is based on the assumption that the file system has not been modified since the failure occurred. Therefore, mounting a journaled volume on a host (including accesses through USB Mass Storage Class) should be avoided as much as possible. If it must be done, you must first make sure that the volume has been cleanly unmounted from the embedded host. Anchor10101431010143

Journaling and FAT12 removable media

Anchor10071581007158It is strongly discouraged to mount a FAT12 journaled volume on another host. It is important to note that, unlike the FAT16 and FAT32 cases, it is not enough to cleanly unmount the volume on the embedded host to ensure proper journaling module behavior. Anchor10184371018437

Journaling and cache

Anchor10184381018438Since they do not affect disk write operations, read cache (FS_VOL_CACHE_MODE_RD) and write-through cache (FS_VOL_CACHE_WR_THROUGH) can be safely used along with journaling. However, the combination of write-back cache (FS_VOL_CACHE_WR_BACK) and journaling should be avoided at all cost. Anchor10055531005553

Journaling and API level atomicity

...

1010618While the journaling system does provide top-level FAT layer operation atomicity, it does not necessarily provide API-level operation atomicity. Most of the time, one API-level file system operation will result in a single top-level FAT operation being performed (see Appendix 10, “How Journaling Works” on page 128 How Journaling Works). In that case, the API-level operation is guaranteed to be atomic. For instance, a call to FSEntry_Rename() will result in a single FAT rename operation being performed (assuming that renaming is not cross-volume). Therefore, the API-level rename operation is guaranteed to be atomic. On the other hand, a call to FSFile_Truncate() will likely result in many successive top-level FAT operations being performed. Therefore, the API-level truncate operation is not guaranteed to be atomic. Non-atomic API level operations, along with the possible interruption side effects, are listed in Table 10-1 Table - Non-atomic API level operations.
anchor

Panel

...

borderWidth

...

1010621
HTML Table
summary
classPlain_Table
Table Row (tr)
Table Cell (td)
Anchor
1010621
0

...

titleTable - Non-atomic API level operations


10106231010623

API level operation

Table Cell (td) Anchor

API level function

Table Cell (td) Anchor1010625

1010625

Possible interruption side effects

Table Row (tr) Table Cell (td)anchor1010627

1010627

Entry copy

Table Cell (td) Anchor10106291010629

FSEntry_Copy() or FSEntry_Rename() with the destination being on a different volume than source.

Table Cell (td) Anchor10106311010631

The destination file size could end up being less than the source file size.

Table Row (tr) Table Cell (td) Anchor10106331010633

File write

Anchor1018898

1018898

(data appending)

Table Cell (td) Anchor10106351010635

FSFile_

FileWr

Wr() with file buffers enabled.

Table Cell (td) Anchor10106371010637

The file size could be changed to any value between the original file size and the new file size.

Table Row (tr) Table Cell (td) Anchor10185601018560

File write

Anchor10189371018937

(data overwriting)

Table Cell (td)anchor1018562

1018562

FSFile_

FileWr

Wr() with or without file buffers.

Table Cell (td) Anchor10185641018564

If existing data contained in a file is overwritten with new data, data at overwritten locations could end up corrupted.

Table Row (tr) Table Cell (td) Anchor10106391010639

File extension

Table Cell (td)anchor1010641

1010641

FSFile_Truncate() or FSFile_PosSet() with position set beyond file size.

Table Cell (td) Anchor10106431010643

The file size could be changed to any value between the original file size and the new file size. Also, unwritten file space could contain uninitialized on-disk data.

...

...


...

Journaling and device drivers

...

Data can be lost in case of unexpected reset or power-failure in either the File System Layer or in the Device Driver Layer. Your entire system is fail-safe only if both layers are fail-safe. The journaling add-on makes the file system layer fail-safe. Some of µC/FS’s device drivers are guaranteed to provide fail-safe sector operations. It is the case of the NOR and NAND flash drivers. For other drivers, the fail-safety of the sector operations depends on the underlying hardware.