A quick recovery method for file system error caused by abnormal power-off
By introducing a dual-TAB master-slave mechanism and a fast verification and recovery mechanism, the performance loss problem after abnormal power failure of the file system is solved, and the fast recovery and high availability of the lightweight embedded storage system are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- MIANYANG WEIGU DEFENSE TECHNOLOGY CO LTD
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-05
AI Technical Summary
Existing file systems generally suffer from system performance degradation when handling errors caused by abnormal power outages, especially in lightweight embedded computing and storage systems where frequent access to or modification of a large number of files affects system performance.
A dual-TAB master-slave mechanism is adopted to achieve rapid file system recovery by quickly verifying TAB files or local entries. This includes creating TAB_A and TAB_B files when the file system is powered on and booting up, and performing rapid verification and recovery in abnormal situations, clearing faulty user file entries.
This greatly improves the availability and user experience of embedded storage systems, avoids time-consuming full-disk scans, and ensures that the file system can quickly recover to normal after an abnormal power outage.
Smart Images

Figure CN122152593A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data storage technology, and more specifically, relates to a method for rapid recovery of file system errors caused by abnormal power loss. Background Technology
[0002] With the rapid development of information technology and the advent of the big data era, the volume of data is exploding. From scientific research to business intelligence and various applications in daily life, massive amounts of data are ubiquitous. However, storing large amounts of files inevitably leads to file anomalies. To address this challenge, it is crucial not only to achieve effective storage of this data but also to ensure the accuracy of data storage and the normal operation of the storage system. This is especially true for high-performance computing environments, such as big data storage systems for radar equipment, which not only need to store large amounts of raw radar waveform data but also process massive amounts of resulting image files.
[0003] While many file systems currently offer various methods for anomaly recovery, most of these methods aim to shorten recovery time, which often comes at the cost of performance. For example, journaling file systems can quickly locate abnormal operations by querying log records after an abnormal power outage and restart; however, the process of collecting and recording log information itself incurs performance overhead, and when the number of files reaches a certain scale, it generates a large amount of redundant data. Similarly, file system anomaly recovery methods based on checkpointing technology also aim to shorten file system anomaly recovery time, but the checkpointing operation itself incurs a significant performance overhead.
[0004] The aforementioned methods for shortening file system exception recovery time at the expense of system performance may not have a significant drawback when applied to high-performance computing and storage systems. However, when applied to lightweight embedded computing and storage systems, where file systems have stringent performance requirements, using these methods would essentially sacrifice overall system performance for occasional, infrequently used functions, which is clearly undesirable. These methods not only consume substantial computing resources but also significantly impact the user experience, especially in embedded computing and storage systems that require frequent access to or modification of numerous files, severely affecting system performance.
[0005] Based on the above, a common problem with existing file systems when dealing with abnormal power loss recovery is that the operation of collecting, checking and recording relevant information during system operation affects system performance. In order to solve the above problems, there is an urgent need for a new method for lightweight embedded file systems that can achieve rapid recovery from abnormal power loss with minimal impact on system performance. Summary of the Invention
[0006] In view of this, the present invention provides a method for rapid recovery of file system errors caused by abnormal power loss, the method comprising the following steps: The power-on startup process is executed to determine if any file system errors have occurred. If an error occurs, the exception recovery process is initiated. In response to the instruction to enter the anomaly recovery process, the system checks if the TAB file is abnormal. If the TAB file is abnormal, it further determines whether the checksum verification error is in the TAB_A file or the TAB_B file. If the TAB_A file checksum verification error is incorrect, the system deletes the TAB_A file, recreates the TAB_A file, copies the TAB_B file to the TAB_A file, and ends the current anomaly recovery process. If the TAB_B file checksum verification error is incorrect, the system deletes the TAB_B file, recreates the TAB_B file, copies the TAB_A file to the TAB_B file, and ends the current anomaly recovery process. If the TAB file is normal, it is marked as a user file error, and the system enters the process of clearing faulty user files. After completing this process, the system deletes the corresponding entries in the TAB_A and TAB_B files and ends the anomaly recovery process.
[0007] Optionally, the power-on startup process includes: After the hardware is powered on and the software starts up, check whether partitioning and formatting are required. If partition formatting is required, perform the following operations in sequence: partition formatting, mounting the file system, creating new TAB_A and TAB_B files, and mounting the TAB_A file. If partitioning and formatting are not required, then mount the file system and verify and validate the file system entries. If the file system entry information passes the checksum verification, then mount the TAB_A file. If the file system entry information fails the checksum verification, the file system is considered to have encountered an error.
[0008] Optionally, the process for clearing faulty user files includes: In response to the instruction to enter the process of clearing faulty user files, determine whether all four attribute directory entries corresponding to the faulty user file are located in the current cache sector. If so, delete the four attribute directory entries and end the process of clearing faulty user files. If none of the four attribute directory entries are located in the current cache sector, determine whether attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4 are all located in the current cache sector. If so, delete attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4, read the data from the previous cache sector on the disk, delete attribute directory entry 1, and end the process of clearing faulty user files. If attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4 are not all located in the current cache sector, then determine whether attribute directory entry 3 and attribute directory entry 4 are both located in the current cache sector. If so, delete attribute directory entry 3 and attribute directory entry 4, read the data from the previous cache sector on the disk, delete attribute directory entry 1 and attribute directory entry 2, and end the process of clearing faulty user files. If attribute directory entry 3 and attribute directory entry 4 are not both located in the current cache sector, then delete attribute directory entry 4, read the data from the previous cache sector on the disk, and delete attribute directory entry 1, attribute directory entry 2, and attribute directory entry 3.
[0009] Optionally, the rapid recovery method further includes the following steps: During normal file system operation, whenever a new file is created, a brief information about that file is automatically extracted and written to both the TAB_A and TAB_B files.
[0010] The beneficial effects of this invention are as follows: This invention provides a rapid recovery method for file system errors caused by abnormal power outages, constructing a complete "dual-TAB primary / backup + entry-level precise repair" mechanism. This mechanism eliminates the need for a time-consuming full-disk scan of the entire file system after an abnormal power outage. Instead, it quickly verifies TAB files or local entries to locate and recover from errors, significantly improving the availability and user experience of embedded storage systems.
[0011] Other features and advantages of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0012] The present invention can be better understood by referring to the following description taken in conjunction with the accompanying drawings, in which the same or similar reference numerals are used throughout the drawings to denote the same or similar parts.
[0013] Figure 1 A schematic diagram of the file system power-on startup process according to an embodiment of the present invention is shown; Figure 2 A schematic diagram of the anomaly recovery process according to an embodiment of the present invention is shown; Figure 3 A schematic diagram of the process for clearing faulty user files according to an embodiment of the present invention is shown. Detailed Implementation
[0014] To enable those skilled in the art to more fully understand the technical solutions of the present invention, exemplary embodiments of the present invention will be described more comprehensively and in detail below with reference to the accompanying drawings. Obviously, the one or more embodiments of the present invention described below are merely one or more specific ways to implement the technical solutions of the present invention, and are not exhaustive. It should be understood that other ways belonging to a general inventive concept can be used to implement the technical solutions of the present invention, and should not be limited to the embodiments described exemplary. Based on one or more embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0015] Example: Figure 1 This diagram illustrates the power-on startup process of a file system according to an embodiment of the present invention. Figure 2 A schematic diagram of the anomaly recovery process according to an embodiment of the present invention is shown. Figure 3 A schematic diagram of the process for clearing faulty user files according to an embodiment of the present invention is shown.
[0016] Reference Figures 1-3 The rapid recovery method for file system errors caused by abnormal power loss according to embodiments of the present invention includes the following steps: The power-on startup process is executed to determine if any file system errors have occurred. If an error occurs, the exception recovery process is initiated. In response to the instruction to enter the anomaly recovery process, the system checks if the TAB file is abnormal. If the TAB file is abnormal, it further determines whether the checksum verification error is in the TAB_A file or the TAB_B file. If the TAB_A file checksum verification error is incorrect, the system deletes the TAB_A file, recreates the TAB_A file, copies the TAB_B file to the TAB_A file, and ends the current anomaly recovery process. If the TAB_B file checksum verification error is incorrect, the system deletes the TAB_B file, recreates the TAB_B file, copies the TAB_A file to the TAB_B file, and ends the current anomaly recovery process. If the TAB file is normal, it is marked as a user file error, and the system enters the process of clearing faulty user files. After completing this process, the system deletes the corresponding entries in the TAB_A and TAB_B files and ends the anomaly recovery process.
[0017] Furthermore, in this embodiment of the invention, the power-on startup process includes: After the hardware is powered on and the software starts up, check whether partitioning and formatting are required. If partition formatting is required, perform the following operations in sequence: partition formatting, mounting the file system, creating new TAB_A and TAB_B files, and mounting the TAB_A file. If partitioning and formatting are not required, then mount the file system and verify and validate the file system entries. If the file system entry information passes the checksum verification, then mount the TAB_A file. If the file system entry information fails the checksum verification, the file system is considered to have encountered an error.
[0018] Furthermore, in this embodiment of the invention, the process of clearing faulty user files includes: In response to the instruction to enter the process of clearing faulty user files, determine whether all four attribute directory entries corresponding to the faulty user file are located in the current cache sector. If so, delete the four attribute directory entries and end the process of clearing faulty user files. If none of the four attribute directory entries are located in the current cache sector, determine whether attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4 are all located in the current cache sector. If so, delete attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4, read the data from the previous cache sector on the disk, delete attribute directory entry 1, and end the process of clearing faulty user files. If attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4 are not all located in the current cache sector, then determine whether attribute directory entry 3 and attribute directory entry 4 are both located in the current cache sector. If so, delete attribute directory entry 3 and attribute directory entry 4, read the data from the previous cache sector on the disk, delete attribute directory entry 1 and attribute directory entry 2, and end the process of clearing faulty user files. If attribute directory entry 3 and attribute directory entry 4 are not both located in the current cache sector, then delete attribute directory entry 4, read the data from the previous cache sector on the disk, and delete attribute directory entry 1, attribute directory entry 2, and attribute directory entry 3.
[0019] Furthermore, the rapid recovery method for file system errors caused by abnormal power loss in this embodiment of the invention also includes the following steps: During normal file system operation, whenever a new file is created, a brief information about that file is automatically extracted and written to both the TAB_A and TAB_B files.
[0020] Specifically, the rapid recovery method for file system errors caused by abnormal power loss according to embodiments of the present invention includes the following parts: I. Power-on startup section: This invention provides a rapid recovery method for file system errors caused by abnormal power outages, applicable to a self-developed file system. The main body of this invention focuses on file system error recovery. Here, the power-on startup process is described to illustrate where the error recovery process falls within the power-on startup process. First, the hardware powers on, the software starts, and a check is performed to determine if partition formatting is required. If so, it indicates the absence of relevant partition information, necessitating partition formatting for first-time use. Then, the file system is mounted, and finally, TAB_A and TAB_B are created (TAB files are unique to the self-developed file system and serve as primary backup files recording basic file information). Finally, TAB_A is mounted. If not, it indicates the presence of corresponding drive letter partition information, and the file system is directly mounted. Then, the file system entry information is scanned and verified for correctness. If correct, TAB_A is mounted directly. If incorrect, it indicates a file system error, requiring an error recovery process. After error recovery is complete, TAB_A is mounted, completing the power-on startup process. The self-developed file system is a high-speed recording optimized FAT-compatible file system, facilitating the separation of data and instruction systems for lightweight, high-speed real-time data recording. A TAB file is a file that stores brief information about files in a file system.
[0021] II. Anomaly Recovery Process: According to the process in Part 1, when a file system checksum verification error is detected, the exception recovery process subroutine is entered. First, it checks if there is an error with a TAB file. If so, it further determines whether the error is with TAB_A or TAB_B. If it's with TAB_A, TAB_A is deleted, recreated, and TAB_B is copied to it, ending the current exception recovery process. If it's with TAB_B, TAB_B is deleted, recreated, and TAB_A is copied to it. Then, it checks if there is an error with a TAB file. If not, it marks it as a user file checksum verification error and enters the subroutine to delete the corresponding entry in the file system. After completing this subroutine, the corresponding entries in both TAB_A and TAB_B are deleted, finally ending the exception recovery process.
[0022] III. Clear the corresponding entries in the faulty user files: Each user file has at least three attribute directory entries: attribute directory entry 1, attribute directory entry 2, and attribute directory entry 3. Depending on the filename length, attribute directory entry 4 may also appear. Each directory entry is 32 bytes. In our self-developed file system, attribute directory entry 4 happens to exist. Our self-developed file system operates on a sector (1024 bytes) as the smallest unit of disk data. However, in actual testing, we found that a single user file entry might span two sectors, so appropriate handling is required during deletion. The following is the specific process for deleting user file entries in the file system. First, the process enters the sub-process for deleting the corresponding file system entry. It checks if there is complete user file entry information for the file with the verification error in the cache. If there is, the entry information for the corresponding file is deleted directly, and the exception handling ends. If the entry information is incomplete, it continues to check if attribute directory entries 2, 3, and 4 are in the current cache sector. If they are, attribute directory entries 2, 3, and 4 are deleted, the previous sector data is read from the disk, attribute directory entry 1 is deleted, and the exception handling ends. If not, it continues to check if attribute directory entries 3 and 4 are in the current cache sector. If they are, attribute directory entries 3 and 4 are deleted, the previous sector data is read from the disk, attribute directory entries 1 and 2 are deleted, and the exception handling ends. If not, attribute directory 4 is deleted, the previous sector data is read from the disk, attribute directory entries 1, 2, and 3 are deleted, and the exception handling ends.
[0023] IV. User File Information Collection Section: This part is crucial. The self-developed file system's unique TAB file collects simplified attribute information of user files and inherent file system user attribute entry information. First, the file is created. It checks if any existing user files have the same name as the newly created file. If not, it is created directly, and the new file information is added to TAB_A and TAB_B. The file information is also added to the file system entry information, completing the file creation and collection of user file information.
[0024] This invention provides a method for rapid recovery from file system errors caused by abnormal power outages, based on improvements to existing file systems. Specific improvements include introducing a pair of master-slave TAB files (TAB_A and TAB_B) and adding corresponding verification and recovery mechanisms to the file system's startup and file operation processes. The following are the specific steps for modifying the original file system: (1) System power-on and startup phase: After the hardware powers on and the software starts up, the system first checks whether the storage partition is being used for the first time. If it is being used for the first time (i.e., there is no valid partition information), the system performs a partition formatting operation and creates two files, TAB_A and TAB_B, after mounting the file system. These two files serve as primary and backup files for each other, recording brief information about all user files under this partition. Subsequently, the system mounts the TAB_A file as the currently active primary file. If it is not being used for the first time, the system directly mounts the existing file system and immediately scans and verifies the checksum of the file system entries.
[0025] (2) Normal startup and abnormal judgment: If the checksum verification passes, it means that the file system is in normal condition, and the system directly mounts the TAB_A file and enters normal working state. If the checksum verification fails, it is determined that there is an abnormality in the file system, and the abnormal recovery process is immediately initiated.
[0026] (3) Execution of the abnormal recovery process: 1) The system first determines whether the TAB file itself is corrupted or the user file entry information is corrupted.
[0027] 2) If the TAB_A checksum is incorrect, delete the corrupted TAB_A, recreate an empty TAB_A, and copy the complete contents of the intact TAB_B to TAB_A to restore master-slave consistency.
[0028] 3) If the TAB_B checksum is incorrect, delete the corrupted TAB_B, recreate an empty TAB_B, and copy the complete contents of the intact TAB_A to TAB_B.
[0029] 4) If the user file entry information checksum is determined to be incorrect (i.e. the TAB file itself is intact), then proceed to the "Clear the corresponding entry of the faulty user file" sub-process.
[0030] (4) Procedure for clearing faulty user file entries: Because the self-developed file system uses a sector (1024 bytes) as the smallest unit of operation, and the directory entry information of a single user file (usually containing attribute directory entries 1 to 4, each 32 bytes) may span two adjacent sectors, deletion operations need to be handled on a case-by-case basis: 1) If the cache already contains the complete directory entry information of the faulty file, mark it as invalid in the cache and write it back to complete the deletion.
[0031] 2) If the directory entry information is incomplete, check whether the attribute directory entries 2, 3, and 4 are located in the current cache sector in turn: if yes, delete the directory entries 2, 3, and 4 in the current sector first, then read the data from the previous sector from the disk and delete the directory entry 1 therein; if no, continue to check whether the directory entries 3 and 4 are in the current sector, and so on; finally, ensure that all directory entries that cross sectors are cleared correctly.
[0032] After deleting the user file entry, the corresponding brief file information entries are simultaneously deleted in TAB_A and TAB_B to ensure metadata consistency.
[0033] (5) User file information collection and maintenance: During normal system operation, whenever a new file is created, the system will automatically extract the file's brief information (including file name, size, timestamp, start and end sector numbers, etc.) and write it to TAB_A and TAB_B simultaneously to ensure real-time synchronization of the primary and backup file contents. This process is automatically triggered after the file creation or modification operation is completed, without user intervention.
[0034] Through the steps (1) to (5) above, this embodiment of the invention constructs a complete "dual-TAB primary / backup + entry-level precise repair" mechanism. This mechanism enables the system to perform a time-consuming full-disk scan of the entire file system after an abnormal power outage, instead of quickly verifying TAB files or local entries to complete error location and recovery, greatly improving the availability and user experience of the embedded storage system. The rapid recovery method for file system errors caused by abnormal power outages in this embodiment of the invention is closely related to file system management and optimization, ensuring that the storage file system can start working normally after an abnormal power outage, and is especially suitable for efficient data storage solutions in self-developed file systems. Using the rapid recovery method for file system errors caused by abnormal power outages in this embodiment of the invention, the cause of the abnormal file system caused by the abnormal power outage can be quickly and accurately located, and the file system can be quickly and accurately restored to a normal state, which is suitable for large-scale file collection file systems and fast-response, low-latency storage systems.
[0035] While one or more embodiments of the present invention have been described above, those skilled in the art will recognize that the present invention can be implemented in any other form without departing from its spirit and scope. Therefore, the embodiments described above are illustrative and not restrictive, and many modifications and substitutions will be apparent to those skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.
Claims
1. A method for rapid recovery of file system errors caused by abnormal power loss, characterized in that, include: The power-on startup process is executed to determine if any file system errors have occurred. If an error occurs, the exception recovery process is initiated. In response to the instruction to enter the exception recovery process, determine whether the TAB file is abnormal. If the TAB file is abnormal, continue to determine whether the TAB_A file checksum verification error or the TAB_B file checksum verification error is the case. If the TAB_A file checksum verification error is the case, delete the TAB_A file, recreate the TAB_A file, copy the TAB_B file to the TAB_A file, and end the current exception recovery process. If the TAB_B file checksum verification fails, delete the TAB_B file, recreate the TAB_B file, copy the TAB_A file to the TAB_B file, and end the current exception recovery process. If the TAB file is normal, it is marked as a user file error, and the process of clearing faulty user files is initiated. After the process is completed, the corresponding entry information in the TAB_A and TAB_B files is deleted, and the abnormal recovery process ends.
2. The method for rapid recovery of file system errors caused by abnormal power loss according to claim 1, characterized in that, The power-on startup process includes: After the hardware is powered on and the software starts up, check whether partitioning and formatting are required. If partition formatting is required, perform the following operations in sequence: partition formatting, mounting the file system, creating new TAB_A and TAB_B files, and mounting the TAB_A file. If partitioning and formatting are not required, then mount the file system and verify and validate the file system entries. If the file system entry information passes the checksum verification, then mount the TAB_A file. If the file system entry information fails the checksum verification, an error is determined to have occurred in the file system.
3. The method for rapid recovery of file system errors caused by abnormal power loss according to claim 2, characterized in that, The process for clearing faulty user files includes: In response to the instruction to enter the process of clearing faulty user files, determine whether all four attribute directory entries corresponding to the faulty user file are located in the current cache sector. If so, delete the four attribute directory entries and end the process of clearing faulty user files. If none of the four attribute directory entries are located in the current cache sector, determine whether attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4 are all located in the current cache sector. If so, delete attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4, read the data from the previous cache sector on the disk, delete attribute directory entry 1, and end the process of clearing faulty user files. If attribute directory entry 2, attribute directory entry 3, and attribute directory entry 4 are not all located in the current cache sector, then determine whether attribute directory entry 3 and attribute directory entry 4 are both located in the current cache sector. If so, delete attribute directory entry 3 and attribute directory entry 4, read the data from the previous cache sector on the disk, delete attribute directory entry 1 and attribute directory entry 2, and end the process of clearing faulty user files. If attribute directory entry 3 and attribute directory entry 4 are not both located in the current cache sector, then delete attribute directory entry 4, read the data from the previous cache sector on the disk, and delete attribute directory entry 1, attribute directory entry 2, and attribute directory entry 3.
4. The method for rapid recovery of file system errors caused by abnormal power loss according to claim 3, characterized in that, Also includes: During normal file system operation, whenever a new file is created, a brief information about that file is automatically extracted and written to both the TAB_A and TAB_B files.