Disclosure of Invention
The present invention provides a method for reconstructing a logical-to-physical mapping table after power-off and restart, and a solid state disk, aiming at the defect that the solid state disk in the prior art cannot reconstruct the logical-to-physical mapping table due to partial data loss of an unwritten storage block caused by unexpected power-off.
The technical scheme adopted by the invention for solving the technical problems is as follows: a method for rebuilding a logical-to-physical mapping table after power-off restart is constructed, and comprises the following steps:
s1: reading system information data stored before power failure;
s2: acquiring a logic-to-physical mapping table stored before power failure;
s3: acquiring a block list stored before power failure;
s4: acquiring a single-layer storage unit block used before power failure according to the block list, and updating a physical-to-physical mapping table of a physical pair to which written data is mapped;
s5: and updating the storage area which is used by the three-layer storage unit to complete the reconstruction of the physical mapping table by the logic.
Preferably, in the method for rebuilding a physical mapping table by using logic after power-off restart according to the present invention, the step S1 includes:
s11: and searching the system information data stored before power failure in a storage block storing the system information data, wherein the system information data comprises the position information of a logical-to-physical mapping table and the block list information.
Preferably, in the method for rebuilding a physical mapping table by using logic after power-off restart according to the present invention, the step S2 includes:
s21: and acquiring the logic-to-physical mapping table stored before power failure according to the logic-to-physical mapping table position information of the system information data.
Preferably, in the method for rebuilding a physical mapping table by using logic after power-off restart according to the present invention, step S3 includes:
s31: and scanning the block list and the record number of each storage block, and acquiring the block list stored before power failure according to the record number.
Preferably, in the method for rebuilding a physical mapping table by using logic after power-off restart according to the present invention, the step S4 further includes:
s41: the three-layer storage unit in use is used for garbage collection and is not updated to the logical-to-physical mapping table.
Preferably, in the method for rebuilding a physical mapping table by using logic after power-off restart according to the present invention, the step S5 includes:
s51: and forcibly replacing the storage block of the three-layer storage unit from the block list and writing back the system information data.
Further, the method for reconstructing the physical mapping table by the logic after the power-off restart further includes:
s6: and writing the host data into the single-layer storage unit.
Further, the method for reconstructing a physical mapping table by logic after power-off restart further includes:
s7: and after the single-layer storage units with preset quantity are fully written, starting a garbage collection program, and transferring the effective data of the single-layer storage units into the three-layer storage units.
Preferably, the method for reconstructing a logical-to-physical mapping table after power-off restart according to the present invention divides the storage blocks into an unused storage block group, a data storage block group, and a logical-to-physical mapping table storage block group, where each group includes a link chain and a storage block being written.
In addition, the invention also constructs a solid state disk, wherein the solid state disk uses a three-layer storage unit as a storage device, and the solid state disk uses the reconstruction method of the logic pair physical mapping table.
The method for reconstructing the physical mapping table by the logic after the power failure restart and the solid state disk have the following advantages that: the method comprises the following steps: s1: reading system information data stored before power failure; s2: acquiring a logic-to-physical mapping table stored before power failure; s3: acquiring a block list stored before power failure; s4: acquiring a single-layer storage unit block used before power failure according to the block list, and updating a physical-to-logical mapping mapped to the written data to a logical-to-physical mapping table; s5: and updating the storage area which is used by the three-layer storage unit to complete the reconstruction of the physical mapping table by the logic. By implementing the invention, under the condition of unexpected power failure, the loss of the data being written is avoided by utilizing the characteristics of the SLC, the reconstruction efficiency is increased, and the reconstruction time is shortened.
Detailed Description
For a more clear understanding of the technical features, objects and effects of the present invention, embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
FIG. 1 is a flowchart illustrating a method for rebuilding a physical mapping table by logic after a power-off restart according to the present invention.
The present invention provides several necessary tables for the logical-to-physical mapping table rebuild after an unexpected power outage: the Block List (Block List Table), system Information data (System Information Table), and Logical-to-Physical Table (L2P) will be described below.
a. The Block List Table (Block List Table) is used to record the status and link relationship of each storage Block. The storage blocks are divided into three groups: free, data, logical-to-physical mapping table, each group having its own link chain and currently being written to the storage block. For example, when the storage Block for writing data is full, the physical pair of logical Page (P2L Page), block List (Block List Table) and record label of the storage Block are written to the last Page of the storage Block, and the Block List (Block List Table) is updated before writing, so as to re-designate the new storage Block being written.
b. The System Information Table (System Information Table) records the latest Table storage location and Block List (Block List Table) after each logical-to-physical mapping Table update, so as to reduce the number of storage blocks required to be scanned for reconstruction.
c. The Logical-to-Physical Table (L2P) is updated to the NAND Flash whenever a certain number of storage blocks are fully written, and when the storage blocks are updated once, the more storage blocks are spaced, which represents that the performance impact caused by the update is reduced, but the time for reconstructing the Logical-to-Physical Table after power-on is also increased.
In addition, when processing host data, the present invention writes data into single-level cell block (SLC), and when a certain number of SLCs are full, it starts garbage collection procedure to transfer the valid data of SLC to three-level cell (TLC), so as to avoid the loss of written host data and increase high access speed performance by using high data stability security of SLC.
Specifically, the method for reconstructing the physical mapping table by the logic after the power-off restart includes:
s1: and reading the system information data stored before power failure.
S2: and acquiring the logic-to-physical mapping table saved before power failure.
S3: and acquiring a block list saved before power failure.
S4: and acquiring the single-layer storage unit block used before power failure according to the block list, and updating the physical-to-logical mapping mapped to the written data to a logical-to-physical mapping table.
S5: and updating the storage area in use by the three-layer storage unit to complete the reconstruction of the physical mapping table by the logic.
FIG. 2 is a flowchart illustrating a method for rebuilding a physical mapping table by logic after a power-off restart according to a first embodiment of the present invention.
This embodiment provides several necessary tables in order to rebuild the logical-to-physical mapping table after an unexpected power outage: the Block List (Block List Table), system Information data (System Information Table), and Logical-to-Physical Table (L2P) will be described below.
a. The Block List Table (Block List Table) is used to record the status and link relationship of each storage Block. The storage blocks are divided into three groups: free, data, logical-to-physical mapping table, each group having its own link chain and currently being written to the storage block. For example, when the storage Block for writing data is full, the physical pair of logical Page (P2L Page), block List (Block List Table) and record label of the storage Block are written to the last Page of the storage Block, and the Block List (Block List Table) is updated before writing, so as to re-designate the new storage Block being written.
b. The System Information Table records the latest Table storage location and the latest Block List Table (Block List Table) after each logical pair physical mapping Table update, so as to reduce the number of storage blocks required to be scanned for reconstruction.
c. The Logical-to-Physical Table (L2P) is updated to the NAND Flash whenever a certain number of storage blocks are fully written, and the more storage blocks spaced once updated represents a reduction in performance impact caused by updating, but also increases the time for rebuilding the Logical-to-Physical Table after power-on.
In addition, when the host data is processed, the data is written into the single level cell block (SLC), and when a certain number of SLCs are full, a garbage collection procedure is initiated to transfer valid data of the SLC to the Triple Level Cell (TLC), which aims to avoid the loss of the written host data and increase the performance of high access speed by using the high data stability security of the SLC.
Specifically, the method for reconstructing the physical mapping table by the logic after the power-off restart includes:
s11: and searching the system information data stored before power failure in the storage block storing the system information data, wherein the system information data comprises the position information of the logical-to-physical mapping table and the block list information.
S21: and according to the logical-to-physical mapping table position information of the system information data, obtaining the logical-to-physical mapping table stored before power failure.
S31: and scanning the block list and the record number of each storage block, and acquiring the block list stored before power failure according to the record number.
S41: the three-layer storage unit in use is used for garbage collection and is not updated to the logical-to-physical mapping table. The single-layer storage unit used before power-off is found out by using the block list, and the physical-to-logical mapping table corresponding to the written data is updated to the logical-degree physical mapping table.
S51: the storage blocks of the three-layer storage unit are forcibly replaced from the block list and written back to the system information data, so that the damage caused by the continuous use of the three-layer storage unit under the condition of unexpected power failure is avoided.
Further, the method for reconstructing the physical mapping table by the logic after the power failure restart of the invention further comprises the following steps:
s6: and writing the host data into the single-layer storage unit.
Further, the method for reconstructing the physical mapping table by the logic after the power failure restart of the invention further comprises the following steps:
s7: after the preset number of single-layer storage units are fully written, a garbage collection program is started, and effective data of the single-layer storage units are transferred into the three-layer storage units.
Preferably, the method for reconstructing a logical-to-physical mapping table after power-off restart of the present invention divides the storage blocks into an unused storage block group, a data storage block group, and a logical-to-physical mapping table storage block group, wherein each group includes a link chain and a storage block being written.
The invention uses the block list to find the single-layer storage unit used before power-off, and updates the physical-to-physical mapping table (P2L) mapped by the written data to the logical-to-physical mapping table. In addition, the three-tier storage units in use are garbage collected and need not be updated to the logical-to-physical mapping table. Therefore, the present application utilizes the characteristics of the single-layer storage unit to avoid the loss of the data being written and utilizes the block list and the system information data to increase the reconstruction efficiency, thereby reducing the reconstruction time. And, improve the situation that the same three-layer storage unit is reused and damaged under the condition of continuous unexpected power failure.
In addition, the invention also constructs a solid state disk, wherein the solid state disk uses the three-layer storage unit as a storage device, and the solid state disk uses the reconstruction method of the logic pair physical mapping table.
The above embodiments are merely illustrative of the technical ideas and features of the present invention, and are intended to enable those skilled in the art to understand the contents of the present invention and implement the present invention, and not to limit the scope of the present invention. All equivalent changes and modifications made within the scope of the claims of the present invention should be covered by the claims of the present invention.