A File System Transaction Management Method Based on PINGPONG Logs
The PINGPONG log-based transaction management system addresses metadata inconsistency by maintaining dual bitmaps and logs, ensuring file system reliability and minimal data loss during power failures.
Patent Information
- Application Number
- CN202111592058.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-12-23
AI Technical Summary
The prior art is difficult to ensure the consistency of the file system and the integrity of user data in abnormal situations, especially in the case of power failure, the file system is prone to crash and the data is difficult to fully recover.
The PINGPONG logging mechanism is adopted to maintain the two-level bitmap of the file system and two transaction point log records, and the user data is backed up with the node log to ensure that the file system rolls back to the consistency state under abnormal conditions, and the user data is restored through the node log.
In abnormal situations such as power failure, ensure the consistency of the file system status, reduce data loss, and realize reliable recovery of user data.
Smart Images

Figure CN114356656B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer system software, and specifically provides a file system transaction management method based on PINGPONG logs. Background Art
[0002] Transaction management technology is to solve the problem of inconsistent metadata of the local file system under various abnormal conditions. However, for users, the reliability of local file access and storage not only means that the entire file system does not crash under abnormal power-off and other conditions, but also means that the files and data of the user's last operation can be restored as much as possible, and the less data is lost, the better. Considering that the log processing technology is relatively simple during data recovery and requires additional storage space, while the transaction processing technology has small space overhead, easy state control, and complex management, it is necessary to consider comprehensively. Use transaction management technology to ensure that the entire file system does not crash under abnormal conditions, and use traditional log management technology to ensure that the user's data can be restored as much as possible. Therefore, this project proposes a transaction consistency guarantee technology based on PING-PONG logs. Summary of the Invention
[0003] This application provides a file system transaction management method based on PINGPONG logs, which can solve the consistency problem of the file system state under abnormal power-off conditions, ensure that the entire file system does not crash under abnormal conditions, and the user's data can be restored as much as possible.
[0004] Technical Solution: This application provides a file system transaction management method based on PINGPONG logs, and the method includes the following steps:
[0005] Step 1: Preset a first-level bitmap and a second-level bitmap for the file system regarding space and node allocation. Among them, the first-level bitmap includes a transaction bitmap 0 and a transaction bit Figure 1 , and the second-level bitmap includes a free space bitmap 0, a free space bit Figure 1 , a free node bitmap 0 and a free node bit Figure 1 ;
[0006] Step 2: Preset a transaction point 0 log record and a transaction point 1 log record for the file system;
[0007] Step 3: Preset a node log for the file system, and the node log is used to back up the nodes to be modified by the user in the node table;
[0008] Step 4: When the file system has an abnormal power-off and is remounted after power-on, compare the sequence numbers of the transaction point 0 log record and the transaction point 1 log record to identify the current valid transaction point, and the other transaction point is the current working transaction;
[0009] Step 5: Obtain the corresponding valid transaction bitmap according to the current valid transaction point;
[0010] Step 6: Combine the valid transaction bitmap to obtain the space and node allocation of valid transactions;
[0011] Step 7: Obtain the secondary bitmap of the file system according to the space and node allocation of valid transactions;
[0012] Step 8: Allocate and modify the secondary bitmap in the obtained secondary bitmap of the file system.
[0013] Specifically, both the transaction point 0 log record and the transaction point 1 log record include the serial number of the belonging transaction point, free data blocks, the number of free nodes, and the nodes to be deleted.
[0014] Specifically, Step 4 specifically includes:
[0015] If the serial number of the transaction point 0 log record is greater than the serial number of the transaction point 1 log record, the transaction point 0 log record is the current valid transaction point, and the transaction point 1 log record is the current working transaction;
[0016] If the serial number of the transaction point 0 log record is less than the serial number of the transaction point 1 log record, the transaction point 1 log record is the current valid transaction point, and the transaction point 0 log record is the current working transaction.
[0017] Specifically, Step 5 specifically includes:
[0018] If the current valid transaction point is the transaction point 0 log record, the corresponding valid transaction bitmap is the transaction bitmap 0;
[0019] If the current valid transaction point is the transaction point 1 log record, the corresponding valid transaction bitmap is the transaction bit Figure 1 .
[0020] Specifically, Step 6 specifically includes:
[0021] If the valid transaction bitmap is the transaction bitmap 0, the space and node allocation of valid transactions correspond to the free space transaction bitmap 0 and the free node transaction bitmap 0;
[0022] If the valid transaction bitmap is the transaction bit Figure 1 , the space and node allocation of valid transactions correspond to the free space transaction bit Figure 1 and the free node transaction bit Figure 1 .
[0023] Specifically, Step 7 specifically includes:
[0024] The 0 in the free space transaction bitmap 0 corresponds to the free space bitmap 0 in the secondary bitmap of the file system;
[0025] The 1 in the free space transaction bitmap 0 corresponds to the free space bit in the secondary bitmap of the file system Figure 1 ;
[0026] The 0 in the free node transaction bitmap 0 corresponds to the free node bitmap 0 in the secondary bitmap of the file system;
[0027] The 1 in the free node transaction bitmap 0 corresponds to the free node bit in the secondary bitmap of the file system Figure 1 。
[0028] Specifically, after step 4, the method further includes:
[0029] If the transaction number in the node log is inconsistent with the current valid transaction number of the system, the data content of the modified node is restored through the node log;
[0030] If the transaction number in the node log is consistent with the current valid transaction number of the system, the node log data is discarded, and the data content of the modified node is restored through the data in the node table.
[0031] Specifically, the node table contains all node information of the file system. The information contained in each node includes file type, file size, number of file blocks, file creation time, file modification time, file access time, and the index blocks at all levels corresponding to the file data. The node log includes a transaction number, a node number, and the node information corresponding to the node to be modified.
[0032] The advantages and effects of the present invention: By designing the PINGPONG log, two state records (transaction point log record, transaction bitmap, free space bitmap, free node bitmap) are maintained for the file system. In the case of power failure, the consistency of the file system state is ensured by rolling back the system to the previous valid state, and the reliability problem of the file system under abnormal power failure is solved. By designing the node log to back up and store the user data to be modified, the recovery of the user data in the case of power failure is realized, the consistency of the user data state is ensured, and only a small part of the content is allowed to be lost. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a schematic diagram of the transaction organizational structure applied to the file system transaction management method based on the PINGPONG log provided by the embodiment of the present application;
[0034] Figure 2 It is a schematic diagram of a node log provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0035] Such as Figure 1As shown in the figure, the technical solution of the present invention: A file system transaction management method based on PINGPONG logs, comprising the following steps:
[0036] Step 1: Preset a first-level bitmap and a second-level bitmap for the file system regarding space and node allocation. Among them, the first-level bitmap includes a transaction bitmap 0 and a transaction bit Figure 1 , and the second-level bitmap includes a free space bitmap 0, a free space bit Figure 1 , a free node bitmap 0 and a free node bit Figure 1 ;
[0037] It should be noted that the space and node allocation of the file system are maintained by using two-level bitmaps. Each bit of the first-level bitmap represents which one of the second-level bitmaps to use.
[0038] Specifically, the transaction bitmap is divided into a free space transaction bitmap and a free node transaction bitmap. The principles of the free space transaction bitmap and the free node transaction bitmap are the same. Each position of the free space transaction bitmap represents a certain block of the corresponding free space bitmap. Its value of 0 means that the transaction point should use the data block of the free space bitmap 0, and 1 means that the transaction point should use the data block of the free space bit Figure 1 . Each position of the free node transaction bitmap represents a certain node of the corresponding free node bitmap. Its value of 0 means that the transaction point should use this node of the free node bitmap 0, and 1 means that the transaction point should use this node of the free node bit Figure 1 of this node.
[0039] Step 2. Preset the transaction point 0 log record and the transaction point 1 log record of the file system;
[0040] It should be noted that the file system maintains two copies of transaction information, namely the transaction point 0 log record and the transaction point 1 log record. The two logs are submitted alternately and are mutually PING-PONG. At any time, there is a committed transaction point and a transaction point being committed. Until the next submission, their states are swapped.
[0041] Specifically, both the transaction point 0 log record and the transaction point 1 log record include the serial number of the transaction point to which they belong, free data blocks, the number of free nodes, and the nodes to be deleted.
[0042] Step 3. Preset the node log of the file system, and the node log is used to back up the nodes to be modified by users in the node table;
[0043] Specifically, the node table contains all node information of the file system. The information contained in each node includes file type, file size, number of file blocks, file creation time, file modification time, file access time, and the index blocks at all levels corresponding to the file data. The node log includes the transaction number, node number, and the node information corresponding to the node to be modified.
[0044] It should be noted that for user file data, setting up a node log to maintain information about the nodes modified by the user improves data reliability.
[0045] Step 4: When the file system experiences an abnormal power failure and is remounted after power-on, compare the sequence numbers of the log records at transaction point 0 and transaction point 1 to identify the current valid transaction point, and the other transaction point is the current working transaction.
[0046] Specifically, if the sequence number of the log record at transaction point 0 is greater than the sequence number of the log record at transaction point 1, then the log record at transaction point 0 is the current valid transaction point, and the log record at transaction point 1 is the current working transaction.
[0047] If the sequence number of the log record at transaction point 0 is less than the sequence number of the log record at transaction point 1, then the log record at transaction point 1 is the current valid transaction point, and the log record at transaction point 0 is the current working transaction.
[0048] Step 5: According to the current valid transaction point, obtain the corresponding valid transaction bitmap.
[0049] Specifically, if the current valid transaction point is the log record at transaction point 0, then the corresponding valid transaction bitmap is transaction bitmap 0; if the current valid transaction point is the log record at transaction point 1, then the corresponding valid transaction bitmap is the transaction bit Figure 1 .
[0050] Step 6: Combining the valid transaction bitmap, the space and node allocation situation of the valid transactions can be obtained.
[0051] Specifically, if the valid transaction bitmap is transaction bitmap 0, then the space and node allocation situation of the valid transactions correspond to free space transaction bitmap 0 and free node transaction bitmap 0; if the valid transaction bitmap is the transaction bit Figure 1 , then the space and node allocation situation of the valid transactions correspond to free space transaction bit Figure 1 and free node transaction bit Figure 1 .
[0052] Step 7: According to the space and node allocation situation of the valid transactions, obtain the secondary bitmap of the file system.
[0053] Specifically, the 0 in free space transaction bitmap 0 corresponds to free space bitmap 0 in the secondary bitmap of the file system.
[0054] A 1 in the free space transaction bitmap 0 corresponds to a free space bit in the secondary bitmap of the file system. Figure 1 ;
[0055] A 0 in the free node transaction bitmap 0 corresponds to the free node bitmap 0 in the secondary bitmap of the file system;
[0056] A 1 in the free node transaction bitmap 0 corresponds to a free node bit in the secondary bitmap of the file system. Figure 1 .
[0057] It should be noted that the free space transaction bitmap 0 and the free node transaction bitmap 0 will be updated according to the allocation of free nodes and free space.
[0058] In this way, two states are maintained in the system. In case of abnormal situations such as power failure, the system can be rolled back to the latest and consistent file system state submitted through the transaction log, ensuring the reliability of the file system.
[0059] Step 8: In the secondary bitmap of the obtained file system, allocate and modify the secondary bitmap.
[0060] In summary, two states are maintained inside the file system, a modified state and an in-use valid state. Data is updated remotely to ensure the reliability of the file system.
[0061] After step 4, the method further includes: if the transaction number of the node log is inconsistent with the current valid transaction number of the system, then recover the data content of the modified node through the node log; if the transaction number of the node log is consistent with the current valid transaction number of the system, then discard the node log data and recover the data content of the modified node through the data in the node table.
[0062] It should be noted that when the transaction number of the node log is inconsistent with the current valid transaction number of the system, it indicates that a power failure occurred during the update of the node table. Then, the data content of the modified node can be recovered through the node log.
[0063] As Figure 2 shown, when changing the user file, the node log maintains an original backup of the file node, and the modification of the file is finally reflected in the update of the node table. The information recorded in the node log includes the current working transaction number, node number, and node data. The node data is remotely saved through the node log. When the transaction number of the node log is inconsistent with the current valid transaction number of the system, it indicates that a power failure occurred during the update of the node table. Then, the data content of the modified node can be recovered through the node log.
[0064] The specific working steps of using a file system transaction management method based on PINGPONG log according to the present invention:
[0065] 1. The space and node allocation of the file system are maintained using a two-level bitmap;
[0066] 2. The system maintains two transaction point log records, representing the two transaction states of the file system respectively;
[0067] 3. For user file data, a node log is designed to maintain information about the nodes modified by users.
[0068] 4. When mounting, the file system is reliably mounted according to the file system transaction operation process.
[0069] 5. When mounting, the file content is restored according to the user file data restoration process.
[0070] The effects achieved by the invention can be realized.
Claims
1. A file system transaction management method based on PINGPONG logs, characterized in that, The method includes the following steps: Step 1: Preset a first-level bitmap and a second-level bitmap for the file system regarding space and node allocation. Among them, the first-level bitmap includes a transaction bitmap 0 and a transaction bitmap 1, and the second-level bitmap includes a free space bitmap 0, a free space bitmap 1, a free node bitmap 0, and a free node bitmap 1; Step 2: Preset a transaction point 0 log record and a transaction point 1 log record of the file system; Step 3: Preset a node log of the file system, and the node log is used to back up the nodes to be modified by users in the node table; Step 4: When the file system loses power abnormally and is remounted after power-on, compare the sequence numbers of the transaction point 0 log record and the transaction point 1 log record to identify the current valid transaction point, and the other transaction point is the current working transaction; including: if the sequence number of the transaction point 0 log record is greater than the sequence number of the transaction point 1 log record, then the transaction point 0 log record is the current valid transaction point, and the transaction point 1 log record is the current working transaction; if the sequence number of the transaction point 0 log record is less than the sequence number of the transaction point 1 log record, then the transaction point 1 log record is the current valid transaction point, and the transaction point 0 log record is the current working transaction; After Step 4, the method further includes: if the transaction number of the node log is inconsistent with the current valid transaction number of the system, then recover the data content of the modified node through the node log; if the transaction number of the node log is consistent with the current valid transaction number of the system, then discard the node log data and recover the data content of the modified node through the data in the node table; Step 5: Obtain the corresponding valid transaction bitmap according to the current valid transaction point; Step 6: Combine the valid transaction bitmap to obtain the space and node allocation situation of the valid transaction; Step 7: Obtain the second-level bitmap of the file system according to the space and node allocation situation of the valid transaction; Step 8: In the obtained second-level bitmap of the file system, allocate and modify the second-level bitmap.
2. The file system transaction management method according to claim 1, wherein Both the transaction point 0 log record and the transaction point 1 log record include the serial number of the belonging transaction point, free data blocks, the number of free nodes, and the nodes to be deleted.
3. The file system transaction management method according to claim 1, characterized in that Step 5 specifically includes: If the current valid transaction point is the transaction point 0 log record, the corresponding valid transaction bitmap is the transaction bitmap 0; If the current valid transaction point is the transaction point 1 log record, the corresponding valid transaction bitmap is the transaction bitmap 1.
4. The file system transaction management method according to claim 1, characterized in that Step 6 specifically includes: If the valid transaction bitmap is the transaction bitmap 0, the space and node allocation situation of the valid transaction corresponds to the free space transaction bitmap 0 and the free node transaction bitmap 0; If the valid transaction bitmap is the transaction bitmap 1, the space and node allocation situation of the valid transaction corresponds to the free space transaction bitmap 1 and the free node transaction bitmap 1.
5. The file system transaction management method according to claim 1, wherein Step 7 specifically includes: 0 in the free space transaction bitmap 0 corresponds to the free space bitmap 0 in the second-level bitmap of the file system; 1 in the free space transaction bitmap 0 corresponds to the free space bitmap 1 in the second-level bitmap of the file system; 0 in the free node transaction bitmap 0 corresponds to the free node bitmap 0 in the second-level bitmap of the file system; The 1s in the idle node transaction bitmap 0 correspond to the idle node bitmap 1 in the secondary bitmap of the file system.
6. The file system transaction management method according to claim 1, characterized in that, The node log includes the transaction number, the node number, and the node information corresponding to the node to be modified.
Citation Information
Patent Citations
Method and apparatus for allocating storage addresses
US20100211755A1
Transaction log acceleration
US20160344834A1