Transaction-Safe FAT File System: Difference between revisions

Content deleted Content added
Marked as unreferenced, but content looks good.
TexFAT: Fixed typo
Tags: Mobile edit Mobile web edit
 
(34 intermediate revisions by 21 users not shown)
Line 1:
'''Transaction-Safe FAT File System''' ('''TFAT''') and '''Transaction-Safe Extended FAT File System''' ('''TexFAT''') refer to two [[file system]]s used in [[Microsoft]] products to provide transaction-safety for data stored on a disk. The goal is to reduce the risk of data loss in cases of power loss or unexpected removal of the drive. The latter problem has become more common with the spread of [[USB]] drives.
{{unreferenced}}
 
== {{anchor|FAT0|FAT1|TFAT12|TFAT16|TFAT32}}TFAT ==
'''A transaction-safe FAT''' ([[TFAT]]) file system is a file system designed specifically to provide transaction-safety for data stored on a disk. TFAT requires a hardware-specific driver designed for the type of media on which the TFAT volume resides.
The ''Transaction-Safe FAT File System'' (TFAT) of the '''TFAT12''', '''TFAT16''' and '''TFAT32''' file systems is a driver layer modification to the original [[File Allocation Table|FAT]] file systems [[FAT12]], [[FAT16]] and [[FAT32]] maintaining two copies (FAT&nbsp;0 and FAT&nbsp;1) of the file allocation table instead of two identical ones. While performing a drive operation, changes would be made to FAT&nbsp;1. When the operation is complete, the FAT&nbsp;1 table would be copied to FAT&nbsp;0, updating the stable view of the file system.<ref name=MSTFAT>{{cite web
| url=https://msdn.microsoft.com/en-us/library/aa915463.aspx
| title=TFAT Overview
| date=2015-11-17
| publisher=[[Microsoft Developer Network]]
| access-date=2019-12-05}}</ref>
{{Details|Design of the FAT file system#CLUST 1}}
 
== TexFAT ==
In addition, TFAT only can be implemented in a system using the extended FAT ([[exFAT]]) file system. TFAT supported by an exFAT file system is also known as [[TexFAT]].
The ''Transaction-Safe Extended FAT File System'' (TexFAT), TexFAT provides similar functionality to TFAT using the [[exFAT]] file system as the base file system instead of FAT. Introduced with [[Windows Embedded CE 6.0]], it is sometimes referred to as ''TFAT'' as well, which can lead to confusion with the original TFAT described above.<ref name=MSTexFAT>{{cite web
| url=https://msdn.microsoft.com/en-us/library/cc907927.aspx
| title=Transaction-Safe Extended FAT File System
| date=2010-03-18
| publisher=Microsoft Developer Network
| access-date=2019-12-05}}</ref>
 
The use of exFAT as the underlying file system allows for larger files and larger partitions. TexFAT requires a hardware-specific driver designed for the type of media on which the TexFAT volume resides.<ref name=MSTexFAT /> TexFAT is not supported by desktop/server versions of Windows.
 
== Limitations ==
Due to the lack of support in desktop [[operating system]]s, neither TFAT nor TexFAT are recommended for removable media. While the desktop OS could still read the drive, it could not use the transaction-safe features, so unexpected removal or a power outage could lead to data loss. In addition, directories created under the desktop OS may not be transaction-safe even if the drive is later attached to a TFAT/TexFAT aware operating system.<ref name=MSTFAT />
 
== TFATSee Overviewalso ==
* [[Design of the FAT file system]]
* [[Novell Transaction Tracking System]]
 
== References ==
{{Reflist}}
 
== Further reading ==
The original file allocation table (FAT) file system enabled file modification operations to be interrupted before completion. In this way, actions such as sudden power loss or sudden removal of a storage card frequently resulted in data loss and file system corruption. By making file operations transaction-safe, TFAT stabilizes the file system and ensures that the file system is not corrupted when an interruption occurs.
* {{cite conference
| title=Design Methodologies of Transaction-Safe Cluster Allocations in TFAT File System for Embedded Storage Devices
| publisher=[[IEEE]]
| first1=Keshava
| last1=Munegowda
| first2=G.T.
| last2=Raju
| first3=Veera Manikandan
| last3=Raju
| first4=T.N.
| last4=Manjunath
| date=December 2014
| conference=2014 International Conference on Information Technology
| doi=10.1109/ICIT.2014.22}}
 
* {{cite conference
TFAT works with two copies of the FAT table, a FAT1 table in which current operations are being conducted and a FAT0 table that is a stable copy of the last known good FAT. Modifications to FAT0 are not committed until all elements in a transaction have completed successfully. If a transaction fails to complete properly, the disk is set in the same state as it was before the transaction began. After all transactions are successfully completed, the FAT1 table is copied to FAT0.
| title=Characterization of Transaction-Safe Cluster Allocation Strategies of TexFAT File System for Embedded Storage Devices
| first1=Keshava
| last1=Munegowda
| first2=G.T.
| last2=Raju
| first3=Veera Manikandan
| last3=Raju
| first4=T.N.
| last4=Manjunath
| date=2014-12-11
| conference=Computational Intelligence in Data Mining
| doi=10.1007/978-81-322-2205-7_47}}
 
{{File systems}}
The theoretical limit for TFAT is 2 TB, with 512 byte sectors. File systems up to about 500 GB have been tested.
 
By default, only modifications to a directory and the FAT are backed up during a transaction using TFAT. To back up modifications to the data of a file, you must set the TransactData registry key to 1. If you set this value and also set the ForceWriteThrough value to 1, all successful write operations are committed.
 
To modify existing files, TFAT allocates a new cluster for the modified bits and reroutes the FAT chain for a file to include the new cluster. This is to ensure that if the transaction fails to complete successfully, the original copy of the file is left untouched.
 
The TFAT file system is best suited for non-removable media, such as NAND and NOR flash memory. Removable media can also use TFAT, but there are potential issues when attempting to use a TFAT removable card on a Windows desktop OS. Because there is no implementation of TFAT on Windows desktop OSs, Windows handles the removable media as if it were a FAT file system. If the card is removed during a critical operation, the Windows desktop OS may not correctly recognize the volume. If a directory is created on the removable media using a Windows desktop OS, and then used with TFAT in Windows Embedded CE, operations on files in that directory may not be transaction-safe. In addition, TFAT directories cannot be deleted using a Windows desktop OS.
 
 
 
== TFAT Programming Considerations ==
 
 
The interfaces exposed by the transaction-safe FAT (TFAT) file system are equivalent to those associated with the FAT file system. The following enhancements are provided by TFAT to ensure transaction safety:
* TFAT-specific drivers
* TFAT atomic sector writes
* FILE_FLAG_WRITE_THROUGH attribute
* FAT volume operations
* Operations from other components
 
=== TFAT-specific Drivers ===
 
TFAT is an extension of the FAT file system. TFAT requires a hardware-specific driver designed for the type of media on which the volume resides. The driver abstracts the media storage and provides atomic block operations.
 
For flash storage, the block driver must provide a verification of atomicity on the block level to provide transaction-safety for data on a disk.
 
=== TFAT Atomic Sector Writes ===
 
TFAT requires the underlying block structure to support atomic sector writes. The flash driver and most CF card hardware provide atomic sector write operations. If the block driver is not atomic, TFAT cannot guarantee transaction-safety.
 
Use the following settings for hard drives and other media with non-atomic sector writes:
 
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\HDProfile\FATFS]
"TfatMarkAlways"=dword:1
"NonatomicSector"=dword:1
"DisableAutoScan"=dword:1
 
Use the following settings for storage media with atomic sector writes:
 
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<Profile Name>\FATFS]
"DisableAutoScan"=dword:1
FILE_FLAG_WRITE_THROUGH attribute
 
Most TFAT operations are triggered by the FILE_FLAG_WRITE_THROUGH file attribute, as follows:
* When the file attribute FILE_FLAG_WRITE_THROUGH is set to TRUE for any file, each WriteFile function call is committed to the disk in an individual transaction. This means that TFAT has written data to both the volume and the FAT tables. If this attribute is not set, the data written by the WriteFile function is not committed until the CloseHandle or the FlushFileBuffers function is called.
* When CreateFile creates a memory-mapped file, it automatically sets the FILE_FLAG_WRITE_THROUGH value to TRUE.
* All databases and memory-mapped files must commit every WriteFile operation to the FAT atomically and set the FILE_FLAG_WRITE_THROUGH value to TRUE.
 
===Operations from Other Component===
 
Other operations such as rename, createdir, and RemoveDirectory are all transaction-safe and committed when the CloseHandle, the FlushFileBuffers, the or WriteFile function is called.
 
 
==FAT File System Registry Settings==
 
 
The file allocation table (FAT) file system retrieves driver specific settings from the registry.
 
You can place settings for FAT, exFAT, and TFAT at
 
HKEY_LOCAL_MACHINE\System\StorageManager\FATFS
 
- or -
 
HKEY_LOCAL_MACHINE\System\StorageManager\Profile\<MyProfileName>\FATFS.
 
In addition to settings that can be made at these levels, you can set formatting options for FAT, TFAT, and exFAT at
 
HKEY_LOCAL_MACHINE\System\StorageManager\FATFS\FormatOptions
 
==See also==
* [[List of file systems]]
 
==External links==
* [http://msdn.microsoft.com/en-us/library/aa911939.aspx Transaction-Safe FAT File System]
 
[[Category:Windows disk file systems]]
[[Category:Flash file systems]]
[[Category:Windows CE]]