Tqfs file system architecture description (another lightweight embedded file system most suitable for nandflash)

Source: Internet
Author: User


 

According to some features of nandflash, the speed of reading and writing is fast. There are more or less bad blocks in the production process. The minimum erasure unit is block, and the minimum read unit is byte. In addition, it cannot be erased frequently, the best support for nandflash is the yaffs file system, but the maximum page size supported by the yaffs file system is 512 bytes, yaffs2 supports a page size of 2048 bytes, but for large Linux operating systems, whether Rom or RAM overhead is really nothing, however, if we only apply it to a single-chip microcomputer with dozens of Kbyte in Ram, it can be cropped and then cropped. This requires the birth of a combination of the advantages of yaffs, in addition, the file system with low hardware requirements is the original intention of the tqfs file system.

 

Advantages of tqfs File System

Less Rom required:About one thousand five hundred lines of code

Less Ram required:The average global variables to be created are basically used to store information such as the offset location of the tab table and the offset location of the content storage area. The maximum overhead of other local variables will not exceed 80 bytes.

Good File System Stability:Even if the file system suffers a catastrophic fault, it can still read the complete individual files in the file system, which is not available in other types of file systems.

Small Damage to hardware:Write a file to a fully formatted nandflash file. If nandflash is not fully written, tqfs will not erase the file.

There is no limit on the file size:A file can store up to one file on a storage device, and the minimum number of files can be stored. Theoretically, a storage device removes a block occupied by a tab, one file can be stored on each page of the remaining block. If one page is not occupied, k9f2g08 can be used as an example to store a maximum of 2048 *-64 files, the size of each file is 2 kbyte.

High efficiency:You do not need the whole space to store a file. When you need to Append content to a file that was a long time ago, the system will look for blank pages to write new content and link it to the previous file through the address to form a file. You can also delete only the file header to delete the file, the intermediate page of the file can be organized during block recovery,

Diverse file types:The types of files that can be stored include some special types in addition to the folder file type, such as the link type and root directory type. You can create multiple root directories in the file system, it is equivalent to multiple partitions in the hard disk.

The following is the first byte mark of each storage page to identify the page content. The nandflash Erasure process is a process from non-1 to 1. To avoid re-erasure, the file type cannot be modified if it is determined, however, this page is part of the entire file and can be changed from the file header to the file press center or the end of the file. However, once changed to the end of the file, the size of the file is determined, you cannot append it.

Enumfiletype {

Ft_notused = 0xff, // The page is not used

Ft_readyroom = 0x7f, // undefined generic file storage area

Ft_file = 0x1f, // undefined length storage area of the file type

Ft_filehead = 0x1e, // File Header

Ft_filecenter = 0x1c, // File

Ft_fileend = 0x18, // end of the file

Ft_folde = 0x2f, // folder type undefined length Storage Area

Ft_folderhead = 0x2e, // folder header flag

Ft_foldercenter = 0x2c, // folder intermediate flag

Ft_folderend = 0x28, // folder tail flag

Ft_link = 0x3f, // link type undefined length Storage Area

Ft_linkhead = 0x3e, // link header flag

Ft_linkcenter = 0x3c, // link file intermediate flag

Ft_linkend = 0x38, // link file tail flag

Ft_rootdir = 0x4f, // path file flag

Ft_rootdirhead = 0x4e, // root file header flag

Ft_rootdircenter = 0x4c, // The middle mark of the root file

Ft_rootdirend = 0x48, // The End of the root file

Ft_delete = 0x08, // mark of File Deletion

Ft_tab = 0x6f, // The file page is used to store the tab table flag

Ft_bad = 0x00 // page corruption mark

};

File system scalability:The file system architecture is tested on k9f2g08. Theoretically, it is compatible with nandflash of all sizes. If the file tab table is damaged or lost, you can spend some time searching for the file storage area to reconstruct the file tab table.

Bad block management of files:The bad block management of files is better than the traditional bad block management by writing a page with a flag of 0x00, but not by checking whether the page is unavailable, if a block of a storage device is not all bad, but the partial location on a page is damaged, (the nandflash bad zone is defined as that the erased block is not all 1 and is damaged ), other pages of the block can be used as usual.

File erasure balance:Writing a file to the file system is to find the available pages and write them backward. When writing a file that cannot be written again, the system will automatically enable deletion block recycling, recycling is to find all erasable blocks in the order from the past to the future to erase them. This ensures that the system does not frequently erase a specific block. This achieves balanced erasure.

 

 

 

Underlying tqfs File System ArchitectureIncluding nandflash overall planning using area division, the file tab location is determined in the formatting nandflash process, usually, the tab location is set on the first non-Bad block, the tab occupies one storage block, and the remaining parts of the file are the file content storage area. The location of the file content storage area is the relative offset location, that is, it is considered that the location of a non-Bad block next to the block of the tab is the base address. Each byte of the data area (the region where the data content is stored) of each page of the tab corresponds to each page of the content storage area, it is consistent with the content of the first byte of spare on each page of the content storage area. The tab is actually set to speed up file search and statistics.

 

 

Generic file management layerThis layer defines the data structure of each page in the file content storage area. The spare area of each page is left aligned to store the file_infor structure type data, which describes the details of this page, the data content storage area of each page stores the file content data. The file content is determined by the filetype in the file_infor data structure. If it is a common file type, the file content data is stored in this area, this is the same as other file systems. If it is a folder type, the page stores links. The link length is usually 8 bytes aligned and each 8 bytes describes a link file, in the first section, the link points to the file type, followed by the file address to which the link points. The link can also point to all types, the links in the folder are basically the same as those in the linked file. However, the link addresses in the linked file can be non-header parts of the file, however, the link in the folder can only point to the file header.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.