A reliability application method for embedded high-speed storage file system
By performing sector alignment and secondary table decomposition of embedded high-speed storage file system, combined with four-time loading mechanism, the complexity and automation problems of file system error repair in embedded devices are solved, achieving high reliability and maintenance-free Storage solution.
Patent Information
- Application Number
- CN202111529993.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-15
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-12-15
AI Technical Summary
Existing embedded high-speed storage file systems are prone to errors in abnormal power outages or hardware errors, and the repair process is complex and difficult to automate, resulting in data loss and error amplification, making it difficult to effectively repair in embedded devices.
By performing sector alignment of logical sectors, decomposing file system table entries, dividing them into basic FST tables and emergency FST tables, and loading up to four times when system errors are performed, combining NSFS file system for error items to refactor and merge, ensure that File system reliability and automation repair.
It improves the reliability and automated repair capabilities of the embedded storage file system, reduces the scope of error impact, achieves the purpose of successfully loading the file system in any error situation, and meets the maintenance-free needs of embedded devices.
Smart Images

Figure CN114356652B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of embedded device information security processing, and in particular, relates to a reliability application method of an embedded high-speed storage file system. Background Art
[0002] High-speed storage modules implemented by FPGA usually use standard general-purpose file systems or their own custom file systems. If these file systems encounter problems such as abnormal power outages and hard disk hardware errors during use, it is very easy to cause data loss and file system failures. Once the file system fails, the file system loading process will attempt to repair the file system. These repairs usually include failure reporting, interactive repair, simple automatic repair, and logging. Compared with embedded storage systems, these repair methods have the problems of complex repair processes, error amplification, and errors that cannot be repaired in the end.
[0003] The reliability and repair difficulty of the file system currently used in embedded storage systems can be summarized into two problems: one is that it is easy to make mistakes in extreme situations (such as abnormal power failure), and the other is that once an error occurs, it is difficult to repair. The specific explanation is as follows:
[0004] 1. The working parameter options of the general file system cannot completely cover the working parameter settings of the underlying hardware of the embedded system. For example, the sector size of the file system is set to 512 bytes, while the underlying hard disk read and write block granularity of the embedded storage system may be set to 1M bytes (based on the consideration of the read and write rate). If a block granularity at the bottom layer fails, the file system needs to repair multiple sectors, and these sectors often cover healthy sectors. This requires first reporting a failure on the covered healthy sector, and then rebuilding the failed healthy sector together with the erroneous sector. Because the scope of the failed sector is expanded, there will be two results in the end: one is that the erroneous sector data can be reconstructed, but the repair process becomes very complicated; the other is that the error is enlarged, the data cannot be reconstructed, and the data of the failed healthy sector and the erroneous sector are lost together;
[0005] 2. The general file system is suitable for various operating systems, host computers, and servers. Repairing file system errors is a professional process that requires computer administrators and file system experts to perform repairs on site. Applying this repair process to embedded systems will result in the following problems:
[0006] (1) Embedded devices generally require maintenance-free features, do not have a complete software management interface, and are not suitable for on-site maintenance;
[0007] (2) General file systems are used for embedded devices. Because data storage is not designed according to business logic and hardware design, there is a possibility of over-repair and accidental deletion of data. For example, if errors occur in the general storage data of an embedded storage system, the task of data reconstruction is often concentrated inside the electronic disk. The electronic disk is designed with redundant storage, balancing strategies, and hash table fast positioning and recovery strategies. This requires the file system recovery process to focus on the recovery of file system header data rather than the recovery of file content data. The repair process of most general file systems will focus most of its energy on the recovery of file content data.
[0008] 3. In the file system repair process that requires human participation, if the repair link is skipped due to lack of human participation, or if the repair is abandoned voluntarily by humans, the error will be amplified, making the subsequent repair cost even higher or causing the system to be unrepairable in the end. Summary of the invention
[0009] In view of the above-mentioned defects of the prior art, the present invention proposes a reliability application method of an embedded high-speed storage file system, which realizes physical isolation of healthy areas and error areas by aligning the logical sectors, and then divides the FST file system table into two levels, namely, a basic FST table and an emergency FST table, so as to cope with the data recovery problem in emergencies, and finally recovers the system by combining four loading operations. The present invention not only reduces the possibility of error and the scope of sectors affected by the error through the above-mentioned settings, but also improves the automation and ease of error recovery, and ensures that the file system can be successfully loaded under any error conditions.
[0010] The specific implementation contents of the present invention are as follows:
[0011] The present invention proposes a reliability application method of an embedded high-speed storage file system. An embedded high-speed storage file system is burned into an embedded device; the embedded high-speed storage file system includes an FST file system table and an NSFS file system for controlling the FST file system table; the application method includes the following steps:
[0012] Step 1: Align the table entries of the FST file system table by sectors; the sector alignment is to decompose the operation of the header of the file of the embedded high-speed storage file system in the batch data recording process into the read and write operations on the sectors covered by each header through logical partitioning;
[0013] Step 2: Divide the sector-aligned FST file system table into a secondary FST table; the secondary FST table includes a basic FST table area and an emergency FST table area;
[0014] The basic FST table area is used to store the basic FST table of the logical partition; the basic FST table is generated when the partition is loaded and / or formatted, and is updated during the file directory operation;
[0015] Use the emergency FST table area to store the emergency FST table;
[0016] Step 3: When an error occurs in the embedded high-speed storage file system, a maximum of four loads are performed; the emergency FST table is used to store the IO queues of the embedded high-speed storage file system that have not been submitted to the basic FST table at the time of power failure, and is used to merge the NSFS file system during the next loading process; during the loading process, an attempt is made to merge the FST file system table, and the error items are reconstructed and / or ignored; the four loading processes are performed in sequence, and when a loading process is successful, the subsequent loading is ignored.
[0017] In order to better implement the present invention, further, the basic FST table is located between the first address of the logical disk after the logical partition and the 16K LBA logical block addresses, and is used to store the file and directory indexes of the logical disk data area.
[0018] In order to better implement the present invention, further, the basic FST table includes three basic FST table items, namely, storage header SHeader, disk header DHeader and SNode file system table item;
[0019] The storage header SHeader is located in the first table entry of the basic FST table and is used to store the storage information when the basic FST table is updated. The storage information includes the version number of the NSFS file system and the number of subsequent nodes.
[0020] The disk header DHeader is located in the second table entry of the basic FST table and is used to store the disk information when the basic FST table is updated;
[0021] The SNode file system entry is used to store index information of a directory or a file;
[0022] The storage header SHeader is used to define the number of table items totalItemCount; the space from the end address of the disk header DHeader to the length of the number of table items totalItemCount minus 2 is all used to store the file system table items.
[0023] In order to better implement the present invention, further, a write operation is performed on the basic FST table, and the specific operations are as follows:
[0024] Call the API function to perform the following directory file operations and generate and / or update the basic FST table during the operation:
[0025] Operation 1: Call the API function to format the logical partition;
[0026] Operation 2: Call API functions to create, delete, read and write directory files on logical partitions;
[0027] Operation three: Call the API function to manually refresh the logical partition;
[0028] Operation 4: Call the API function to uninstall the logical partition; if the read and write data is cached before uninstallation, the buffered data needs to be submitted.
[0029] In order to better implement the present invention, further, when performing operation one, a minimum FST table is generated using the NSFS file system, wherein the minimum FST table only contains a root directory table entry in addition to the table header; the generated minimum FST table is written into the storage area of the basic FST table through the write function of the hard disk using the NSFS file system.
[0030] In order to better implement the present invention, further, when performing the second operation, the creation, deletion, reading and writing operations of the directory files of the logical partition are cached in an IO queue.
[0031] In order to better implement the present invention, further, when the following conditions are met, the content of the IO queue will be directly submitted to the basic FST table to generate an update operation on the basic FST table entry:
[0032] Case 1: The second operation submission of the same node appears in the IO queue;
[0033] Case 2: The number of IO queues reaches the upper limit of the NSFS file system macro definition;
[0034] Case 3: When the user manually calls the API function to modify and submit the embedded high-speed storage file system, all dirty nodes in the IO queue are forcibly submitted to the basic FST table;
[0035] Case 4: When the user manually calls the API function to unload the logical partition, all dirty nodes in the IO queue are forcibly submitted to the basic FST table.
[0036] In order to better implement the present invention, further, the four loading operations in step 3 are sequentially as follows:
[0037] Loading 1: "Error-sensitive" loading process of basic FST table + emergency FST table;
[0038] Loading 2: "Error repair" loading process of basic FST table + emergency FST table;
[0039] Load 3: "Error-sensitive" loading process of loading the basic FST table alone;
[0040] Load 4: "Error fix" loading process of loading the base FST table alone;
[0041] The “error-sensitive” means that once an error occurs during the loading process, the current loading process will be exited immediately;
[0042] The "error repair" means that once an error occurs during the loading process, the NSFS file system is used to try to repair the error and then continue the current loading process. In the "error repair" loading process, even if the FST file system table is successfully loaded by repairing the error, it will be marked in the NSFS file system to prompt the user to take action as soon as possible.
[0043] In order to better implement the present invention, further, in the loading process of the "error repair", the repair operation includes the following points:
[0044] Repair operation 1: If the storage header SHeader table entry is wrong, try to reconstruct a storage header SHeader table entry based on the current NSFS file system information;
[0045] Repair operation 2: If the disk header DHeader table entry is wrong, try to reconstruct a disk header DHeader table entry based on the current NSFS file system information;
[0046] Repair operation 3: If the SNode file system entry of the directory node is wrong; if the wrong SNode file system entry is a root directory entry, use the NSFS file system to try to reconstruct a root directory SNode file system entry to replace the wrong entry; if the error is not the root directory entry, use the NSFS file system to delete the wrong directory entry and hand over the corresponding child node to the root directory entry for hosting; the child node includes a subdirectory and the files under the subdirectory;
[0047] Repair operation 4: If the SNode file system entry of the file node is wrong; use the NSFS file system to delete the wrong SNode file system entry and continue to load subsequent entries.
[0048] In order to better implement the present invention, further, a write operation is performed on the basic FST table, and the specific operations are as follows:
[0049] Call the API function to perform the following directory file operations and generate and / or update the basic FST table during the operation:
[0050] Operation 1: Call the API function "nsfsFormat" to format the logical partition;
[0051] Operation 2: Call the API function "nsfsXXX" to create, delete, read and write directory files on the logical partition; the "XXX" in the API function "nsfsXXX" refers to a group of API functions;
[0052] Operation 3: Call the API function "nsfsSync" to manually refresh the logical partition;
[0053] Operation 4: Call the API function "nsfsUmount" to unmount the logical partition; if the read and write data are cached before unmounting, the buffered data needs to be submitted.
[0054] In order to better implement the present invention, further, the emergency FST table adopts a storage method in which the table header and the IO node are interlaced; when an abnormal power failure occurs, the NSFS file system stores the IO operation queue that has not been submitted to the basic FST table in the emergency FST table after receiving the interruption; in step 3, during the next loading of the disk partition by the embedded high-speed storage file system, the NSFS file system restores the IO queue from the emergency FST table, and then merges it into the basic FST table.
[0055] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0056] The application method of the present invention improves the reliability of the embedded storage file system, achieves the maintenance-free purpose of the embedded storage module, and can achieve maintenance-free within the life cycle of the entire storage hard disk. At the same time, it is also a universal design solution that can be widely used in various embedded storage products. It has good application versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 This is an example diagram of the distribution of basic FST table items;
[0058] Figure 2 This is a sample diagram of the distribution of emergency FST entries;
[0059] Figure 3 Generate IO dirty nodes and submit them to the basic FST;
[0060] Figure 4 This is a schematic diagram of the write operation of the emergency FST triggered by an abnormal power failure interrupt;
[0061] Figure 5 The figure is a flowchart of the four loading processes of the file system header. DETAILED DESCRIPTION
[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. It should be understood that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments, and therefore should not be regarded as limiting the scope of protection. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technical personnel in this field without making creative work are within the scope of protection of the present invention.
[0063] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "disposed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0064] Embodiment 1:
[0065] This embodiment proposes a reliability application method of an embedded high-speed storage file system. An embedded high-speed storage file system is burned into an embedded device; the embedded high-speed storage file system includes an FST file system table and an NSFS file system for controlling the FST file system table; the application method includes the following steps:
[0066] Step 1: Align the table entries of the FST file system table by sectors; the sector alignment is to decompose the operation of the header of the file of the embedded high-speed storage file system in the batch data recording process into the read and write operations on the sectors covered by each header through logical partitioning;
[0067] Step 2: Divide the sector-aligned FST file system table into a secondary FST table; the secondary FST table includes a basic FST table area and an emergency FST table area;
[0068] The basic FST table area is used to store the basic FST table of the logical partition; the basic FST table is generated when the partition is loaded and / or formatted, and is updated during the file directory operation;
[0069] Use the emergency FST table area to store the emergency FST table;
[0070] Step 3: When an error occurs in the embedded high-speed storage file system, a maximum of four loads are performed; the emergency FST table is used to store the IO queues of the embedded high-speed storage file system that have not been submitted to the basic FST table at the time of power failure, and is used to merge the NSFS file system during the next loading process; during the loading process, an attempt is made to merge the FST file system table, and the error items are reconstructed and / or ignored; the four loading processes are performed in sequence, and when a loading process is successful, the subsequent loading is ignored.
[0071] Embodiment 2:
[0072] Based on the above-mentioned embodiment 1, in order to better realize the present invention, this embodiment further comprises the following: the basic FST table is located between the first address of the logical disk after the logical partition and the 16K LBA logical block addresses, and is used to store the file and directory indexes of the logical disk data area.
[0073] In order to better implement the present invention, further, the basic FST table includes three basic FST table items, namely, storage header SHeader, disk header DHeader and SNode file system table item;
[0074] The storage header SHeader is located in the first table entry of the basic FST table and is used to store the storage information when the basic FST table is updated. The storage information includes the version number of the NSFS file system and the number of subsequent nodes.
[0075] The disk header DHeader is located in the second table entry of the basic FST table and is used to store the disk information when the basic FST table is updated;
[0076] The SNode file system entry is used to store index information of a directory or a file;
[0077] The storage header SHeader is used to define the number of table items totalItemCount; the space from the end address of the disk header DHeader to the length of the number of table items totalItemCount minus 2 is all used to store the file system table items.
[0078] In order to better implement the present invention, further, a write operation is performed on the basic FST table, and the specific operations are as follows:
[0079] Call the API function to perform the following directory file operations and generate and / or update the basic FST table during the operation:
[0080] Operation 1: Call the API function to format the logical partition;
[0081] Operation 2: Call API functions to create, delete, read and write directory files on logical partitions;
[0082] Operation three: Call the API function to manually refresh the logical partition;
[0083] Operation 4: Call the API function to uninstall the logical partition; if the read and write data is cached before uninstallation, the buffered data needs to be submitted.
[0084] In order to better implement the present invention, further, when performing operation one, a minimum FST table is generated using the NSFS file system, wherein the minimum FST table only contains a root directory table entry in addition to the table header; the generated minimum FST table is written into the storage area of the basic FST table through the write function of the hard disk using the NSFS file system.
[0085] In order to better implement the present invention, further, when performing the second operation, the creation, deletion, reading and writing operations of the directory files of the logical partition are cached in an IO queue.
[0086] In order to better implement the present invention, further, when the following conditions are met, the content of the IO queue will be directly submitted to the basic FST table to generate an update operation on the basic FST table entry:
[0087] Case 1: The second operation submission of the same node appears in the IO queue;
[0088] Case 2: The number of IO queues reaches the upper limit of the NSFS file system macro definition;
[0089] Case 3: When the user manually calls the API function to modify and submit the embedded high-speed storage file system, all dirty nodes in the IO queue are forcibly submitted to the basic FST table;
[0090] Case 4: When the user manually calls the API function to unload the logical partition, all dirty nodes in the IO queue are forcibly submitted to the basic FST table.
[0091] In order to better implement the present invention, further, the four loading operations in step 3 are sequentially as follows:
[0092] Loading 1: "Error-sensitive" loading process of basic FST table + emergency FST table;
[0093] Loading 2: "Error repair" loading process of basic FST table + emergency FST table;
[0094] Load 3: "Error-sensitive" loading process of loading the basic FST table alone;
[0095] Load 4: "Error fix" loading process of loading the base FST table alone;
[0096] The “error-sensitive” means that once an error occurs during the loading process, the current loading process will be exited immediately;
[0097] The "error repair" means that once an error occurs during the loading process, the NSFS file system is used to try to repair the error and then continue the current loading process. In the "error repair" loading process, even if the FST file system table is successfully loaded by repairing the error, it will be marked in the NSFS file system to prompt the user to take action as soon as possible.
[0098] In order to better implement the present invention, further, in the loading process of the "error repair", the repair operation includes the following points:
[0099] Repair operation 1: If the storage header SHeader table entry is wrong, try to reconstruct a storage header SHeader table entry based on the current NSFS file system information;
[0100] Repair operation 2: If the disk header DHeader table entry is wrong, try to reconstruct a disk header DHeader table entry based on the current NSFS file system information;
[0101] Repair operation 3: If the SNode file system entry of the directory node is wrong; if the wrong SNode file system entry is a root directory entry, use the NSFS file system to try to reconstruct a root directory SNode file system entry to replace the wrong entry; if the error is not the root directory entry, use the NSFS file system to delete the wrong directory entry and hand over the corresponding child node to the root directory entry for hosting; the child node includes a subdirectory and the files under the subdirectory;
[0102] Repair operation 4: If the SNode file system entry of the file node is wrong; use the NSFS file system to delete the wrong SNode file system entry and continue to load subsequent entries.
[0103] In order to better implement the present invention, further, a write operation is performed on the basic FST table, and the specific operations are as follows:
[0104] Call the API function to perform the following directory file operations and generate and / or update the basic FST table during the operation:
[0105] Operation 1: Call the API function "nsfsFormat" to format the logical partition;
[0106] Operation 2: Call the API function "nsfsXXX" to create, delete, read and write directory files on the logical partition; the "XXX" in the API function "nsfsXXX" refers to a group of API functions;
[0107] Operation 3: Call the API function "nsfsSync" to manually refresh the logical partition;
[0108] Operation 4: Call the API function "nsfsUmount" to unmount the logical partition; if the read and write data are cached before unmounting, the buffered data needs to be submitted.
[0109] In order to better implement the present invention, further, the emergency FST table adopts a storage method in which the table header and the IO node are interlaced; when an abnormal power failure occurs, the NSFS file system stores the IO operation queue that has not been submitted to the basic FST table in the emergency FST table after receiving the interruption; in step 3, during the next loading of the disk partition by the embedded high-speed storage file system, the NSFS file system restores the IO queue from the emergency FST table, and then merges it into the basic FST table.
[0110] The other parts of this embodiment are the same as those of the above-mentioned embodiment 1, and thus will not be described in detail.
[0111] Embodiment 3:
[0112] This embodiment provides a specific implementation example based on any one of the above embodiments 1-2:
[0113] This reliability solution includes the following three core contents:
[0114] 1) Sector alignment is performed on FST (File System Table) entries. The entire FST table is erased and written only when the logical sector is formatted. The update operation at any other time is to erase and read and write a specific FST table entry. The purpose of this design is to reduce the possibility of errors in the entire FST table, reduce possible errors to a certain FST table entry, and reduce the scope of abnormality;
[0115] 2) Redundant design of the secondary FST table. The IO queue generated by the system during normal operation is updated to the basic FST table, and the system operation at the moment of power failure is updated to the emergency FST table. The separate operation of the basic FST table and the emergency FST table avoids the possibility of damaging the basic FST table entries by updating the basic FST table entries at the moment of power failure. The design ensures that the system has a basic FST available at any time.
[0116] 3) During the four loading processes of the FST table, even if an FST table entry fails, the four loading processes of the FST table will attempt to reconstruct the failed FST table entry and restore a usable FST table as much as possible.
[0117] First, the FST table entries are sector-aligned, that is, the operations on the file system headers during batch data recording are decomposed into read and write operations on the sectors covered by each header. For sectors that have never been involved in the recording process (such as the sectors of the headers corresponding to the recorded directory files), the recording process will not perform any operations on them. In this way, even if errors occur in one or some sectors, the repair process will only repair and reconstruct the data content of these sectors, and will not have any impact on the adjacent healthy sectors. This method physically isolates the impact of bad sectors on the surrounding healthy sectors, minimizing the range of erroneous sectors and thus the impact range.
[0118] Secondly, the design of the secondary FST table refers to dividing the FST file system table (File System Table) into two FST tables: basic FST and emergency FST. The basic FST area is used to store the basic FST table of the logical partition. The basic FST table is generated when the partition is loaded or formatted, and updated during the file directory operation. The emergency FST table is used to store the IO queue that has not been submitted to the basic FST at the time of system power failure, and is used for NSFS to merge during the next loading process.
[0119] 1) Basic FST table
[0120] The basic FST (File System Table) table is located between the logical disk's first address and 16K (16*1024) LBAs, and is used to store file and directory indexes in the logical disk data area. The basic FST table is composed of basic FST table entries. Each basic FST table entry occupies one disk LBA, and a maximum of 16K table entries can be defined. There are three types of FST table entries, namely:
[0121] a) SHeader, Save Header, the "storage header" table item, is located in the first table item of the basic FST and is used to save the storage information when the FST is updated, including the NSFS version number and the number of subsequent nodes;
[0122] b) DHeader, Disk Header, "disk header" table entry, located in the second table entry of the basic FST table, used to save the disk information when the FST is updated;
[0123] c) SNode file system entries are used to store the index information of a directory or a file. SHeader defines the number of entries totalItemCount. From the end address of Dheader to the length of totalItemCount-2, this space stores all file system entries.
[0124] A complete FST table is attached. Figure 1 .
[0125] 2) Emergency FST table
[0126] The next storage area of the logical disk next to the basic FST (File System Table) table is the emergency FST table. The emergency FST table is used to store the IO operation queue that has not been submitted to the basic FST table in the case of abnormal power failure. It is assumed that the hardware design of the storage device supports the function of maintaining a power-on time of milliseconds in the case of abnormal power failure, and notifying NSFS of the abnormal power failure through an interrupt at the first time of power failure. After receiving the interrupt, NSFS saves the cached IO queue directly in the emergency FST area instead of submitting it to the basic FST table. During the next process of loading the disk partition, NSFS restores the IO queue from the emergency FST table and then merges it into the basic FST table. Therefore, the emergency FST table will only be used when the device is abnormally powered off, and the content in the emergency FST table can only be merged in the next power-on process after the abnormal power failure.
[0127] The emergency FST table uses a table header and an IO node interleaved storage method. The table entry storage layout is shown in the attached Figure 2 .
[0128] 3) Writing process of basic FST table
[0129] The basic FST table is generated and updated during the following directory file operations:
[0130] a) When the user calls the API function "nsfsFormat" to format the logical partition;
[0131] b) When the user calls the API function "nsfsXXX" (XXX refers to a group of API functions) to create, delete, read or write directory files on the logical partition;
[0132] c) When the user calls the API function "nsfsSync" to manually refresh the logical partition;
[0133] d) When the user calls the API function "nsfsUmount" to unmount the logical partition, the read and write data before the unmount may be cached, and the cached data will be submitted at this time.
[0134] When the user uses the API call "nsfsFormat" to format the logical partition, NSFS will generate a minimum FST table that contains only a root directory table entry in addition to the header. NSFS will write the generated minimum FST table to the storage area of the basic FST table through the hard disk's write function. During the use of the logical partition, the user creates, deletes, reads and writes directories and files through various "nfsXXX" APIs, and all these operations will be cached in an IO queue. When the following conditions are met, the contents of the IO queue will be submitted directly to the basic FST table to generate update operations on the FST table entries:
[0135] a) The second operation submission of the same node appears in the IO queue. For example, there is a node in the queue indicating that the write timestamp of a directory has changed. Now a new node is added to the queue to indicate that the size of the same directory has changed. Before the new node is added, the old node will be submitted, that is, the table entry corresponding to this directory in the basic FST will be updated;
[0136] b) The number of IO queues reaches the upper limit of the NSFS macro definition, that is, the IO queue already contains the default 32 dirty nodes that have not been submitted. At this time, submitting a new node will cause all 32 IO dirty nodes to be submitted to the basic FST, that is, the basic FST table entries corresponding to these 32 dirty nodes will be updated;
[0137] c) When the user manually calls "nfsSync" to submit the file system modification, all dirty nodes in the IO queue will be forcibly submitted to the basic FST table;
[0138] d) When the user manually calls "nsfsUmount" to unmount the logical partition, all dirty nodes in the IO queue will be forced to be submitted to the basic FST table.
[0139] The writing process of the basic FST table is attached. Figure 3 .
[0140] 4) Emergency FST table writing process
[0141] The writing of the emergency FST table is triggered by an abnormal power outage. In the case of an abnormal power outage, the device is often in an extreme situation where the voltage is unstable and the normal voltage is maintained for a very short time. In this case, the hard disk write operation often becomes very dangerous, which can easily cause the hard disk sector write operation to fail to complete normally (for example, power outage during erasing, power outage during writing after erasing). The design of the emergency FST table is independent of the basic FST table, which just separates this dangerous operation from the normal file table entry operation, physically isolates the two operation sequences, and prevents dangerous operations from destroying normal file system table entries. As for the merging of emergency FST table entries, it is handled by the four loading processes of the file system.
[0142] The writing process of the emergency FST table is shown in the attached Figure 4 .
[0143] Finally, the file system table is loaded in up to four load passes.
[0144] The loading process will try to merge the file system headers and reconstruct or ignore the erroneous items. When the user calls "nsfsMount" to load the logical partition, NSFS will try four loading processes in succession. If one of the loading processes is successful, the subsequent loading processes will be ignored. The four loading processes are in the following order:
[0145] a) “Error-sensitive” loading process of basic FST + emergency FST;
[0146] b) The “error repair” loading process of basic FST + emergency FST;
[0147] c) “Error-sensitive” loading process of loading base FST alone;
[0148] d) A "bug fix" loading process for loading the base FST alone.
[0149] The so-called "error sensitivity" means that once an error occurs during the loading process, the current loading process will be immediately exited. The so-called "error repair" means that once an error occurs during the loading process, NSFS will try to repair the error and then continue the current loading process. Even if the "error repair" loading process successfully loads the FST by repairing the error, it will be marked in NSFS to prompt the user to take action as soon as possible.
[0150] The repair actions during the "error repair" process during the file system loading process can be summarized as follows:
[0151] a) If the "Sheader" entry is wrong, try to reconstruct an Sheader entry using the current NSFS information;
[0152] b) If the "Dheader" entry is wrong, try to reconstruct a Dheader entry using the current NSFS information;
[0153] c) If the directory node "Snode" table entry is wrong. If this table entry is a root directory table entry, NSFS will try to reconstruct a root directory Snode table entry to replace the wrong table entry. If the error is not in the root directory table entry, NSFS will delete the wrong directory table entry and hand over its child nodes (subdirectories and files under the directory) to the root directory table entry for hosting;
[0154] d) If the file node "Snode" table entry is wrong, NSFS will delete this table entry and continue to load subsequent table entries, which will only cause the file data corresponding to the wrong file table entry to be lost.
[0155] The four loading processes of the file system are shown in the attached Figure 5 .
[0156] The other parts of this embodiment are the same as any of the above embodiments 1-2, so they are not repeated here.
[0157] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A reliability application method of an embedded high-speed storage file system, wherein an embedded high-speed storage file system is burned into an embedded device; the embedded high-speed storage file system comprises an FST file system table and an NSFS file system for controlling the FST file system table; characterized in that: The following steps are involved: Step 1: Align the table entries of the FST file system table by sectors; the sector alignment is to decompose the operation of the header of the file of the embedded high-speed storage file system in the batch data recording process into the read and write operations on the sectors covered by each header through logical partitioning; Step 2: Divide the sector-aligned FST file system table into a secondary FST table; the secondary FST table includes a basic FST table area and an emergency FST table area; The basic FST table area is used to store the basic FST table of the logical partition; the basic FST table is generated when the partition is loaded and / or formatted, and is updated during the file directory operation; Use the emergency FST table area to store the emergency FST table; Step 3: When an error occurs in the embedded high-speed storage file system, a maximum of four loads are performed; the emergency FST table is used to store the IO queues of the embedded high-speed storage file system that have not been submitted to the basic FST table at the time of power failure, and is used to merge the NSFS file system during the next loading process; during the loading process, an attempt is made to merge the FST file system table, and the error items are reconstructed and / or ignored; the four loading processes are performed in sequence, and when a loading process is successful, the subsequent loading is ignored.
2. The reliability application method of an embedded high-speed storage file system as claimed in claim 1, characterized in that: The basic FST table is located between the first address of the logical disk after the logical partition and the 16K LBA logical block addresses, and is used to store the file and directory indexes of the logical disk data area.
3. The reliability application method of an embedded high-speed storage file system as claimed in claim 2, characterized in that: The basic FST table includes three basic FST table entries, namely storage header SHeader, disk header DHeader and SNode file system table entry; The storage header SHeader is located in the first table entry of the basic FST table and is used to store the storage information when the basic FST table is updated. The storage information includes the version number of the NSFS file system and the number of subsequent nodes. The disk header DHeader is located in the second table entry of the basic FST table and is used to store the disk information when the basic FST table is updated; The SNode file system entry is used to store index information of a directory or a file; The storage header SHeader is used to define the number of table items totalItemCount; the space from the end address of the disk header DHeader to the length of the number of table items totalItemCount minus 2 is all used to store the file system table items.
4. The reliability application method of an embedded high-speed storage file system as claimed in claim 3, characterized in that: For writing to the basic FST table, the specific operations are as follows: Call the API function to perform the following directory file operations and generate and / or update the basic FST table during the operation: Operation 1: Call the API function to format the logical partition; Operation 2: Call API functions to create, delete, read and write directory files on logical partitions; Operation three: Call the API function to manually refresh the logical partition; Operation 4: Call the API function to uninstall the logical partition; if the read and write data is cached before uninstallation, the buffered data needs to be submitted.
5. The reliability application method of an embedded high-speed storage file system as claimed in claim 4, characterized in that: When performing operation one, a minimum FST table is generated using the NSFS file system. The minimum FST table contains only one root directory table entry in addition to the table header. The generated minimum FST table is written into the storage area of the basic FST table through the write function of the hard disk using the NSFS file system.
6. The reliability application method of an embedded high-speed storage file system as claimed in claim 4, characterized in that: When performing the second operation, the creation, deletion, reading and writing operations of the directory files of the logical partition are cached in an IO queue.
7. The reliability application method of an embedded high-speed storage file system as described in claim 1 or 2 or 3 or 4 or 5 or 6, characterized in that: When the following conditions are met, the contents of the IO queue are directly submitted to the basic FST table to generate update operations on the basic FST table entries: Case 1: The second operation submission of the same node appears in the IO queue; Case 2: The number of IO queues reaches the upper limit of the NSFS file system macro definition; Case 3: When the user manually calls the API function to modify and submit the embedded high-speed storage file system, all dirty nodes in the IO queue are forcibly submitted to the basic FST table; Case 4: When the user manually calls the API function to unload the logical partition, all dirty nodes in the IO queue are forcibly submitted to the basic FST table.
8. The reliability application method of an embedded high-speed storage file system as claimed in claim 3, characterized in that: The four loading operations in step 3 are as follows: Loading 1: "Error-sensitive" loading process of basic FST table + emergency FST table; Loading 2: "Error repair" loading process of basic FST table + emergency FST table; Load 3: "Error-sensitive" loading process of loading the basic FST table alone; Load 4: "Error repair" loading process of loading the basic FST table alone; The "error sensitivity" means that once an error occurs during the loading process, the current loading process will be exited immediately; The "error repair" means that once an error occurs during the loading process, the NSFS file system is used to try to repair the error and then continue the current loading process. In the "error repair" loading process, even if the FST file system table is successfully loaded by repairing the error, it will be marked in the NSFS file system to prompt the user to take action as soon as possible.
9. The reliability application method of an embedded high-speed storage file system as claimed in claim 8, characterized in that: During the loading process of the "error repair", the repair operation includes the following points: Repair operation 1: If the storage header SHeader table entry is wrong, try to reconstruct a storage header SHeader table entry based on the current NSFS file system information; Repair operation 2: If the disk header DHeader table entry is wrong, try to reconstruct a disk header DHeader table entry based on the current NSFS file system information; Repair operation 3: If the SNode file system entry of the directory node is wrong; if the wrong SNode file system entry is a root directory entry, use the NSFS file system to try to reconstruct a root directory SNode file system entry to replace the wrong entry; if the error is not the root directory entry, use the NSFS file system to delete the wrong directory entry and hand over the corresponding child node to the root directory entry for hosting; the child node includes a subdirectory and the files under the subdirectory; Repair operation 4: If the SNode file system entry of the file node is wrong; use the NSFS file system to delete the wrong SNode file system entry and continue to load subsequent entries.
10. The reliability application method of an embedded high-speed storage file system as claimed in claim 4, characterized in that: For writing to the basic FST table, the specific operations are as follows: Call the API function to perform the following directory file operations and generate and / or update the basic FST table during the operation: Operation 1: Call the API function "nsfsFormat" to format the logical partition; Operation 2: Call the API function "nsfsXXX" to create, delete, read and write directory files on the logical partition. The "XXX" in the API function "nsfsXXX" refers to a group of API functions. Operation 3: Call the API function "nsfsSync" to manually refresh the logical partition; Operation 4: Call the API function "nsfsUmount" to unmount the logical partition; if the read and write data are cached before unmounting, the buffered data needs to be submitted.
11. The reliability application method of an embedded high-speed storage file system as claimed in claim 1, characterized in that: The emergency FST table adopts a storage method in which the table header and the IO node are interleaved; when an abnormal power outage occurs, the NSFS file system stores the IO operation queue that has not been submitted to the basic FST table in the emergency FST table after receiving the interruption; in step 3, during the next loading of the disk partition by the embedded high-speed storage file system, the NSFS file system restores the IO queue from the emergency FST table and then merges it into the basic FST table.
