Method for storing L2P table, system, device, and medium
View Patent ↗The present disclosure provides a method for storing an L2P table, including the following steps: detecting the L2P table, in response to detecting update of the L2P table, acquiring a logical block address (LBA) for which a mapping relation is updated in the L2P table; sending the LBA to a journal manager; reading a corresponding physical block address (PBA) in the L2P table according to the received LBA and assembling the LBA and the corresponding PBA into delta data in response to the journal manager receiving the LBA; and saving the delta data and several basic data currently to be saved in the L2P table as a snapshot in a non-volatile memory. The present disclosure further provides a system, a computer device, and a readable storage medium.
1. A method for storing a logical to physical (L2P) table, comprising:
detecting the L2P table, in response to detecting update of the L2P table, acquiring a logical block address (LBA) for which a mapping relation is updated in the L2P table;
sending the LBA to a journal manager;
reading a corresponding physical block address (PBA) in the L2P table according to the received LBA and assembling the LBA and the corresponding PBA into delta data in response to the journal manager receiving the LBA; and
saving the delta data and several basic data currently to be saved in the L2P table as a snapshot in a non-volatile memory.
2. The method according to claim 1 , further comprising:
creating a recover table; and
recording snapshot information about the snapshot into the recover table.
3. The method according to claim 2 , further comprising:
acquiring a plurality of snapshot data from the non-volatile memory according to the snapshot information recorded in the recover table in response to receiving an instruction to recover the L2P table; and
recovering, according to an order of the snapshot information in the recover table and an order of the plurality of delta data in each snapshot data, each delta data in each snapshot data into the L2P table.
4. The method according to claim 2 , wherein the recover table is a linear table with JM_LBA as an index and SLC NAND address for storing the snapshot as content.
5. The method according to claim 4 , wherein the snapshot information comprises the SLC NAND address.
6. The method according to claim 1 , wherein the sending the LBA to a journal manager further comprises:
storing the LBA in a LBA buffer; and
sending the LBAs in the LBA buffer to the journal manager in response to a count of the LBAs in the LBA buffer reaching a threshold.
7. The method according to claim 6 , wherein the reading a corresponding physical block address (PBA) in the L2P table according to the received LBA and assembling the LBA and the corresponding PBA into delta data in response to the journal manager receiving the LBA further comprises:
reading sequentially, by the journal manager, the LBAs in the LBA buffer, obtaining corresponding PBAs according to the L2P table, and obtaining a plurality of delta data, and storing the plurality of delta data into a write buffer in sequence.
8. The method according to claim 7 , wherein the saving the delta data and several basic data currently to be saved in the L2P table as a snapshot in a non-volatile memory further comprises:
acquiring several basic data currently to be saved in the L2P table and filling the several basic data currently to be saved in the L2P table into a second preset space of the write buffer in response to filling a first preset space in the write buffer with the delta data; and
saving the write buffer as a snapshot in the non-volatile memory in response to filling the buffer with header information about the write buffer.
9. The method according to claim 8 , wherein a count of the delta data stored in the first preset space of the write buffer is an integer multiple of the count of the LBAs stored in the LBA buffer.
10. The method according to claim 8 , wherein the snapshot is composed of 3 parts, that are formed in the form of write buffer, and comprises a header, a delta buffer and a base buffer.
11. The method according to claim 10 , wherein the L2P table is segmented according to a size of the base buffer, and each segment is one of the several basic data to be saved currently.
12. The method according to claim 11 , wherein the filling the several basic data currently to be saved in the L2P table into a second preset space of the write buffer comprises filling one segment of base data successively and cyclically into the base buffer of the current write buffer, and the delta data in the current write buffer corresponds to the base data of other segments or the base data in the current write buffer.
13. The method according to claim 7 , wherein the storing the plurality of delta data into a write buffer in sequence comprises: storing the delta data into the write buffer in sequence of reading the LBAs from the LBA buffer.
14. The method according to claim 13 , wherein the journal manager is configured with several 16k write buffers for storing the received L2P updated data.
15. The method according to claim 14 , wherein the count of delta data stored by a single write buffer is an integer multiple of the count of LBAs stored by a single LBA buffer.
16. The method according to claim 15 , wherein after storing the plurality of delta data into the write buffer, the LBA buffer is released by the journal manager.
17. The method according to claim 6 , wherein when the LBA buffer is full, the count of the LBAs stored in the LBA buffer and buffer address are sent to the journal manager via a message.
18. The method according to claim 1 , wherein the journal manager is a software module in an SSD firmware, and is responsible for management of L2P tables.
19. A non-volatile computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by a processor, cause the processor to perform operations of:
detecting a logical to physical (L2P) table, in response to detecting update of the L2P table, acquiring a logical block address (LBA) for which a mapping relation is updated in the L2P table;
sending the LBA to a journal manager;
reading a corresponding physical block address (PBA) in the L2P table according to the received LBA and assembling the LBA and the corresponding PBA into delta data in response to the journal manager receiving the LBA; and
saving the delta data and several basic data currently to be saved in the L2P table as a snapshot in a non-volatile memory.
20. A computer device, comprising:
at least one processor; and
a memory storing computer readable instructions executable on the processor, wherein the computer readable instructions, when executed by the processor, cause the processor to perform operations of:
detecting a logical to physical (L2P) table, in response to detecting update of the L2P table, acquiring a logical block address (LBA) for which a mapping relation is updated in the L2P table;
sending the LBA to a journal manager;
reading a corresponding physical block address (PBA) in the L2P table according to the received LBA and assembling the LBA and the corresponding PBA into delta data in response to the journal manager receiving the LBA; and
saving the delta data and several basic data currently to be saved in the L2P table as a snapshot in a non-volatile memory.