Data backtracking method and electronic equipment
By employing a dual mapping table mechanism and reserving temporary storage areas in solid-state storage devices, the problems of low data backtracking efficiency and resource consumption in solid-state storage devices are solved, achieving efficient data backtracking and performance maintenance.
Patent Information
- Application Number
- CN202511872912.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-01-16
AI Technical Summary
In existing technologies, solid-state storage devices are inefficient and consume a lot of storage resources when backtracking data, affecting write performance and failing to effectively manage historical data mapping relationships.
A dual mapping table mechanism is adopted. One mapping table maintains the current valid data, and the other mapping table records the mapping relationship of the data to be traced back. A temporary storage area is reserved in the solid-state storage device to store the old data. The combination of these two mapping tables enables fast data tracing.
It achieves efficient data backtracking, avoids excessive storage resource consumption and write performance loss, and reduces system complexity and storage overhead.
Smart Images

Figure CN121349773A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data backtracking method and electronic device. Background Technology
[0002] Currently, during the use of solid-state storage devices, the host frequently performs read and write operations on the stored data. In practical applications, the host may need to backtrack and read updated or invalid historical data due to operational errors, accidental data deletion, or data verification requirements. However, the mapping table of solid-state storage devices typically only maintains the mapping relationship between the logical address and physical address of currently valid data. The mapping information corresponding to older data is overwritten or deleted when data is updated, making it impossible for the host to directly obtain historical data through conventional read methods.
[0003] Data backtracking methods in related technologies, by reserving an independent backup area to perform a complete backup of all old data before the update, can achieve data backtracking, but they consume a lot of valuable storage resources, and the backup process will significantly reduce the write performance of solid-state storage devices. Another solution records the change history of the mapping table through logs. When backtracking, it is necessary to traverse the logs to reconstruct the historical mapping relationship. This method is not only inefficient in backtracking, but log management also increases system complexity and storage overhead. Summary of the Invention
[0004] This application provides a data backtracking method and electronic device to at least solve the problem that data backtracking methods in the related art are inefficient and reduce the write performance of solid-state storage devices.
[0005] Firstly, this application provides a data backtracking method, including:
[0006] Receive the target request sent by the host and determine the type of the target request;
[0007] When the type of the target request is a backtracking data read request, the target logical block address is matched in the first mapping table to obtain the target first entry corresponding to the target logical block address; wherein, the backtracking data read request includes the target logical block address corresponding to the data to be backtracked, and the first mapping table includes the mapping relationship between multiple logical block addresses and the first entry;
[0008] The type of the first target entry is determined. If the type of the first target entry is an associated target temporary table index, the target temporary table index is matched in the second mapping table to obtain the target second entry corresponding to the target temporary table index. The second mapping table includes multiple mapping relationships between temporary table indexes and second entries.
[0009] Extract the target physical block address corresponding to the data to be traced in the second target entry, obtain the data to be traced in the temporary storage area based on the target physical block address, and send the data to be traced to the host; wherein, the temporary storage area is a pre-divided area in the reserved storage space of the solid-state storage device.
[0010] Secondly, this application also provides a data backtracking device, comprising:
[0011] The request receiving module is used to receive target requests sent by the host and determine the type of the target request.
[0012] The first entry acquisition module is used to match the target logical block address in the first mapping table when the type of the target request is a backtracking data reading request, so as to obtain the target first entry corresponding to the target logical block address; wherein, the backtracking data reading request includes the target logical block address corresponding to the backtracking data, and the first mapping table includes the mapping relationship between multiple logical block addresses and the first entry;
[0013] The second entry acquisition module is used to determine the type of the target first entry, and when the type of the target first entry is an associated target temporary table index, it matches the target temporary table index in the second mapping table to obtain the target second entry corresponding to the target temporary table index; wherein, the second mapping table includes multiple mapping relationships between temporary table indexes and second entries;
[0014] The data sending module is used to extract the target physical block address corresponding to the data to be traced in the second target entry, obtain the data to be traced in the temporary storage area based on the target physical block address, and send the data to be traced to the host; wherein, the temporary storage area is a pre-divided area in the reserved storage space of the solid-state storage device.
[0015] Thirdly, this application also provides an electronic device, including:
[0016] Memory, used to store computer programs;
[0017] A processor is used to implement the steps of the method as described in the first aspect when executing a computer program.
[0018] Fourthly, this application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method as described in the first aspect.
[0019] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect.
[0020] This application provides a data backtracking method and electronic device. The method maintains the mapping of currently valid data through a first mapping table, records the mapping of old data to be backtracked through a second mapping table, and pre-allocates a temporary storage area in the reserved storage space of a solid-state storage device to store the old data. When the host initiates a backtracking request, it first locates the associated temporary storage table index through the first mapping table, then quickly obtains the physical address of the data to be backtracked through the second mapping table and reads the data from the temporary storage area. This eliminates the need for a complete backup of all old data, avoiding significant storage resource consumption and write performance degradation, thus improving backtracking efficiency and reducing system complexity and storage overhead. Attached Figure Description
[0021] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 An application scenario diagram corresponding to a data backtracking method provided in an embodiment of this application;
[0023] Figure 2 A flowchart illustrating a data backtracking method provided in an embodiment of this application;
[0024] Figure 3 A flowchart illustrating a data backtracking method provided in another embodiment of this application;
[0025] Figure 4 A flowchart illustrating a data backtracking method provided in another embodiment of this application;
[0026] Figure 5 A flowchart illustrating a data backtracking method provided in another embodiment of this application;
[0027] Figure 6 A flowchart illustrating a data backtracking method provided in another embodiment of this application;
[0028] Figure 7 A schematic diagram of the structure of a data backtracking device provided in an embodiment of this application;
[0029] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0031] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] Currently, in the use of solid-state storage devices (such as SSDs), the host frequently performs read and write operations on the stored data. Because solid-state storage devices rely on flash memory chips for data storage, they have an "erase-before-write" characteristic. When the host updates data corresponding to a logical address, the solid-state storage device typically writes the new data to a new physical storage area and updates the mapping between logical and physical addresses through a mapping table. Old data is marked as invalid, awaiting subsequent garbage collection. In practical applications, the host may need to backtrack and read updated or marked-invalid historical data due to operational errors, accidental data deletion, or data verification requirements. However, in existing technologies, the mapping table of solid-state storage devices typically only maintains the mapping between the logical and physical addresses of currently valid data. The mapping information corresponding to older data is overwritten or deleted with data updates, preventing the host from directly retrieving historical data through conventional reading methods.
[0033] The backtracking method in related technologies, by reserving an independent backup area, performs a complete backup of all old data before the update. Although this method can achieve data backtracking, it will consume a lot of valuable storage resources, and the backup process will significantly reduce the write performance of solid-state storage devices. Another solution is to record the change history of the mapping table through logs. When backtracking, it is necessary to traverse the logs to reconstruct the historical mapping relationship. This method is not only inefficient in backtracking, but log management will also increase system complexity and storage overhead.
[0034] Therefore, there is an urgent need for a data backtracking solution that balances storage resource consumption, backtracking efficiency, and system performance.
[0035] Therefore, when facing the problems in the aforementioned related technologies, a special mapping mechanism can be constructed. During the data update process, not only is the mapping relationship of the currently valid data recorded, but also the relevant mapping information of the old data is retained, so that the old data can be quickly located when backtracking is needed. Specifically, two mapping tables are pre-configured. The first mapping table is used to maintain the mapping relationship between the logical block address of the currently valid data and the first entry, which can meet the needs of normal read and write operations on the host side. The second mapping table is specifically used to store information related to the old data, which includes the mapping relationship between multiple temporary storage table indexes and the second entry. The second entry records the physical block address corresponding to the data to be backtracked. Through this physical block address, the data to be backtracked can be obtained from the pre-defined temporary storage area. The temporary storage area, as part of the reserved storage space of the solid-state storage device, is specifically used to store this old data that may need to be backtracked. It does not occupy a lot of storage resources like a full backup, and can effectively save the key information of the old data. Thus, by using the two mapping tables in conjunction with the reserved temporary storage area, efficient data backtracking can be achieved without significantly increasing storage overhead and system complexity.
[0036] Figure 1 This application provides an example of a data backtracking method according to one embodiment of the present application, and includes an application scenario diagram. Figure 1 As shown, this application scenario includes a host device 10 and a solid-state storage device 11. The host device 10 and the solid-state storage device 11 are communicatively connected. The cache layer of the solid-state storage device 11 pre-stores an FTL (Flash Translation Layer) mapping table and a temporary storage area mapping table. The FTL mapping table includes multiple mapping relationships between logical block addresses and first entries; the temporary storage area mapping table includes multiple mapping relationships between temporary storage table indexes and second entries. A temporary storage area is pre-defined in the reserved storage space of the solid-state storage device 11, and the temporary storage area is used to store old data.
[0037] Specifically, when data backtracking is required, the host device 10 sends a backtracking data retrieval request to the solid-state storage device 11. Upon receiving the backtracking data retrieval request, the solid-state storage device 11 first matches the logical block address in the FTL mapping table to obtain the first entry corresponding to the logical block address; wherein, the backtracking data retrieval request includes the logical block address corresponding to the data to be backtracked. Then, it determines the type of the first entry, and if the type of the first entry is an associated temporary storage table index, it matches the temporary storage area mapping table according to the temporary storage table index to obtain the second entry corresponding to the temporary storage table index. Finally, the solid-state storage device 11 extracts the physical block address corresponding to the data to be backtracked from the second entry, retrieves the data to be backtracked in the temporary storage area based on the physical block address, and sends the data to be backtracked to the host device 10.
[0038] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0039] Figure 2 This is a flowchart illustrating a data backtracking method provided in one embodiment of this application, as shown below. Figure 2 As shown, the execution subject of this embodiment is a data backtracking device. This device can be implemented through a computer program, or through a medium storing the relevant computer program, such as a USB flash drive and / or optical disc; alternatively, it can be implemented through a physical device that integrates or installs the relevant computer program, such as a chip or electronic device. The electronic device may be a computer or a server, etc. The data backtracking provided in this embodiment includes the following steps:
[0040] Optionally, the method of this embodiment can be applied to the controller of a solid-state storage device. The solid-state storage device includes a regular storage area for storing currently valid data and a temporary storage area for temporarily storing historical data to be traced back. The temporary storage area is an independent area pre-divided in the reserved storage space of the solid-state storage device.
[0041] S201. Receive the target request sent by the host and determine the type of the target request.
[0042] Optionally, the controller of the solid-state storage device can establish a data communication link with the host through a preset communication interface, and listen for and receive various requests sent by the host in real time.
[0043] Among them, the target request is the instruction sent by the host based on the data operation requirements. The types of target requests include at least data write requests, current data read requests, and backtracking data read requests.
[0044] Optionally, the controller of the solid-state storage device includes a request parsing module, which performs protocol parsing and type identification on the received target request. Optionally, by extracting the operation identifier field from the target request header, if the operation identifier field is a preset backtracking read identifier, the target request is determined to be a backtracking data read request; if it is a write identifier or a current read identifier, the corresponding regular write or regular read process is executed.
[0045] It should be noted that by pre-judging the type of the target request, request routing can be achieved, avoiding the triggering of invalid backtracking processes and improving system response efficiency.
[0046] S202. When the type of the target request is a backtracking data read request, the target logical block address is matched in the first mapping table to obtain the target first entry corresponding to the target logical block address; wherein, the backtracking data read request includes the target logical block address corresponding to the data to be backtracked, and the first mapping table includes the mapping relationship between multiple logical block addresses and the first entry.
[0047] Optionally, when the target request is determined to be a backtracking data read request, the request parsing module further extracts the target logical block address (LBA, Logical Block Address) corresponding to the data to be backtracked from the backtracking data read request. The target logical block address is the logical storage address allocated by the host for the data to be backtracked; the host identifies the historical data that needs to be backtracked through the logical storage address.
[0048] Optionally, the cache layer of the solid-state storage device has a pre-defined first mapping table. The first mapping table is a table that associates logical addresses with index information. The function of the first mapping table is to establish a bridge between the logical address of the data to be traced and the subsequent query link. The first mapping table stores multiple entries (i.e., first entries). Each first entry corresponds to a set of mapping relationships between "logical block address and index information". The types of index information include two types: one is a direct index pointing to the physical address of the currently valid data in the regular storage area, and the other is a temporary table index associated with the temporary storage area.
[0049] Optionally, after receiving the target logical block address, the controller of the solid-state storage device uses a hash lookup or binary search algorithm to match it in the first mapping table. Specifically, using the target logical block address as the key, the logical block address field in the first mapping table is traversed. When a completely matching logical block address is found, its corresponding entry is designated as the target first entry. If no matching logical block address is found, a response message indicating that the data does not exist can be returned to the host.
[0050] S203. Determine the type of the first target entry, and if the type of the first target entry is an associated target temporary table index, match it in the second mapping table according to the target temporary table index to obtain the target second entry corresponding to the target temporary table index; wherein, the second mapping table includes multiple mapping relationships between temporary table indexes and second entries.
[0051] Optionally, after obtaining the first target entry, the controller of the solid-state storage device determines the type of its index information by parsing the type identifier field of the first target entry. If the type identifier of the first target entry is a direct index, it means that the current valid data corresponding to the target logical block address is stored in the regular storage area, and there is no need to execute the backtracking process. The physical address can be obtained directly based on the direct index and the data can be read. If the type identifier of the first target entry is a temporary table index, it means that there is an old version of the data to be backtracked. The old version to be backtracked is stored in the temporary storage area, and the data needs to be further located through secondary mapping.
[0052] Specifically, the cache layer of the solid-state storage device has a pre-defined second mapping table. This second mapping table is a dedicated mapping table for the temporary storage area, used to establish the correspondence between the temporary storage table index and the physical address of the temporary storage area. Optionally, the second mapping table contains multiple entries (i.e., second entries). Each second entry records a set of mapping information between the temporary storage table index and the physical block address (PBA), where the physical block address precisely points to the specific storage unit within the temporary storage area.
[0053] Optionally, when the type of the first target entry is an associated target temporary table index, the controller of the solid-state storage device extracts the target temporary table index and performs a matching operation in the second mapping table using the target temporary table index as the key. Since the second mapping table is built for the temporary storage area and has far fewer entries than the first mapping table that covers the entire storage area, the matching process can be completed quickly, and the second target entry that uniquely corresponds to the target temporary table index is obtained through matching.
[0054] S204. Extract the target physical block address corresponding to the data to be traced back in the second entry of the target, obtain the data to be traced back in the temporary storage area based on the target physical block address, and send the data to be traced back to the host; wherein, the temporary storage area is a pre-divided area in the reserved storage space of the solid-state storage device.
[0055] Optionally, the controller extracts the target physical block address corresponding to the data to be traced from the second target entry. The target physical block address includes the partition identifier of the temporary storage area and the offset address within the area, which can directly locate the flash memory chip storage unit storing the historical data to be traced.
[0056] Optionally, the controller, based on the flash memory chip's control protocol, sends a read command to the storage unit corresponding to the target physical block address, and reads the data to be traced back stored in the temporary storage area through the flash memory interface module. After reading, the read data can be verified (e.g., by using CRC check to ensure data integrity). If the verification passes, the data to be traced back is encapsulated according to the communication protocol supported by the host and sent to the host through the communication interface, completing the entire data traceback process; if the data verification fails, a data read error response is returned to the host.
[0057] It should be noted that by dividing the reserved storage space of the solid-state storage device into an independent temporary storage area, which is specifically used to store historical data that needs to be retained (such as data marked as needing to be traced back on the host side, intermediate data of critical business, etc.), the temporary storage area is physically isolated from the main storage area that stores the currently valid data, to avoid historical data being overwritten by regular read and write operations or accidentally erased by the garbage collection mechanism, thus providing physical storage protection for data traceability.
[0058] This application provides a data backtracking method that maintains the mapping of currently valid data through a first mapping table and records the mapping of old data to be backtracked through a second mapping table. A temporary storage area is pre-allocated in the reserved storage space of a solid-state storage device to store the old data. When the host initiates a backtracking request, the first mapping table is used to locate the associated temporary storage table index, and then the second mapping table is used to quickly obtain the physical address of the data to be backtracked and read the data to be backtracked from the temporary storage area. This eliminates the need for a complete backup of all old data, avoiding significant storage resource consumption and write performance degradation, thus improving data backtracking efficiency and reducing system complexity and storage overhead.
[0059] Figure 3 A flowchart illustrating a data backtracking method provided in another embodiment of this application is shown below. Figure 3 As shown, as an optional implementation, based on any of the above embodiments, the following steps are also included:
[0060] S301. If the type of the target request is a data write request, match the logical block address of the data to be written in the first mapping table to determine whether the logical block address of the data to be written is the first creation write.
[0061] Optionally, when the type of the target request is determined to be a data write request, the controller's request parsing module first extracts the logical block address (i.e., the logical block address to be written) corresponding to the data to be written from the data write request. Then, based on the logical block address to be written, a matching operation is performed in the first mapping table. The matching method is the same as in S202, and a hash lookup or binary search algorithm can be used to quickly determine whether there is a first entry in the first mapping table corresponding to the logical block address to be written.
[0062] Optionally, if no entry corresponding to the logical block address to be written is found in the first mapping table, the logical block address is determined to be the first creation and write operation. The controller will perform the operation according to the normal write process, that is, write the data to be written to the normal storage area, and add the corresponding first entry in the first mapping table based on the physical block address after writing and the logical block address to be written (the entry type is direct index, and the index information points to the physical block address of the normal storage area).
[0063] The regular storage space, also known as the normal storage space of a solid-state storage device, is used to store currently valid data (non-temporary data to be recalled) and is physically isolated from the temporary storage area.
[0064] S302. If the logical block address of the data to be written is not the first time it has been created and written, determine whether the data write request is a fault recovery write from the upper layer.
[0065] Among them, upper-layer fault recovery write refers to the scenario in which, after an upper-layer system (such as a database transaction system) fails (such as a power outage, crash, or transaction failure), in order to restore data consistency, the final correct data is extracted from the backup node or historical records and rewritten to the solid-state storage device. For example, rebuilding the initial data after a transaction rollback.
[0066] Optionally, if the first entry corresponding to the logical block address to be written already exists in the first mapping table, it means that the logical block address is not being written for the first time. In this case, the request parsing module of the solid-state storage device controller needs to further determine whether the data write request is a write for upper-layer fault recovery.
[0067] Optionally, the request parsing module extracts the preset scenario identifier field from the data write request header. If the scenario identifier field is a fault recovery identifier set by the upper-layer system (such as the host operating system or database system) (e.g., 0xFFFF), then the data write request is determined to be an upper-layer fault recovery write. If it is a regular write identifier, then the regular old data migration, new data writing, and mapping table update process is executed.
[0068] S303. In the case of a data write request being an upper-layer fault recovery write, the data to be written is written to the regular storage space of the solid-state storage device, and the first mapping table is updated based on the physical block address and logical block address after the data to be written is completed.
[0069] Optionally, if the data write request is confirmed to be a write for recovery from an upper-layer failure, the controller of the solid-state storage device will prioritize the validity and immediate availability of the data write and directly write the data to be written to the regular storage space of the solid-state storage device.
[0070] Optionally, after the data write operation is completed, the flash interface module of the solid-state storage device sends a confirmation message of completion and the corresponding target physical block address (the physical address within the conventional storage space) to the mapping management module. Based on the target physical block address and the address of the logical block to be written, the mapping management module of the solid-state storage device updates the original first entry corresponding to the logical block address in the first mapping table, replacing the original index information with the new physical block address. This ensures that subsequent regular read requests from the host side to the logical block address can directly locate the data after fault recovery, guaranteeing the business continuity of the upper-layer system after fault recovery.
[0071] It should be noted that in this embodiment, the written data is divided into three categories: initial creation data, regular modification data, and fault recovery data. Initial creation data has no old data; the old data in regular modification data has backtracking value (and needs to be temporarily stored); and the old data in fault recovery data has no backtracking value (and does not need to be temporarily stored). For fault recovery data, the association between the target LBA and the new PBA in the FTL mapping table is directly updated, overwriting the original invalid mapping, ensuring that the correct data is directly obtained during subsequent reads and avoiding mapping confusion. The temporary storage area is used to store regular modification data with backtracking value, and does not store invalid old data in fault recovery scenarios, improving the utilization rate of the temporary storage area and avoiding resource waste.
[0072] S304. If the data write request is not an upper-layer fault recovery write and the write type identifier in the data write request is temporary write, extract the temporary table index in the data write request.
[0073] Optionally, if it is determined that the data write request is not an upper-layer fault recovery write, and the "write type identifier" field in the data write request header is a preset temporary write identifier (such as 0x0001), the old data temporary storage process will be triggered to retain historical data versions for subsequent backtracking. Among them, temporary storage write is a type of data write request, which is suitable for "routine business modification write" scenarios. The purpose of temporary storage write is to retain old data for subsequent backtracking.
[0074] Optionally, the request parsing module of the solid-state storage device controller extracts a preset temporary table index from the data write request. This temporary table index is a unique identifier (such as a 32-bit integer format) pre-negotiated between the solid-state storage device and the host, used to uniquely associate the historical data to be stored in the temporary storage area, avoiding backtracking errors caused by index conflicts.
[0075] S305. Based on the logical block address, determine the corresponding physical data block address in the first mapping table, and migrate the data corresponding to the physical data block address to the temporary storage area.
[0076] Optionally, using the logical block address of the data to be written as the key, an exact match is performed in the first mapping table to locate the first entry corresponding to the logical block address, and the physical block address of the old data is extracted from the first entry. Subsequently, the data migration module reads the old data corresponding to the physical block address through the flash memory interface, writes it completely into the storage unit of the temporary storage area, and records the current physical block address (physical address within the temporary storage area) after the old data is written to the temporary storage area, thus completing the migration and retention of the old data.
[0077] S306. Modify the first entry corresponding to the logical block address in the first mapping table to the associated temporary storage table index.
[0078] Optionally, after the old data migration is completed and the verification is correct, the original first entry corresponding to the logical block address in the first mapping table is modified, the type of the corresponding first entry is updated from "associated direct index" to "associated temporary table index", and the index information field is replaced with the temporary table index extracted in step S304, thereby establishing the association link between the logical block address and the temporary table index, providing a query entry point for subsequent backtracking requests.
[0079] S307. Write the second entry at the position corresponding to the temporary table index in the second mapping; wherein the second entry includes the logical block address, the current data physical block address, and the historical data physical block address.
[0080] Optionally, the second entry is constructed and written by locating the empty entry corresponding to the index of the temporary storage table in the second mapping table. Optionally, the second entry specifically includes the logical block address of the data to be written, the physical block address of the current data (i.e., the physical address of the new data in the regular storage area), and the physical block address of the historical data (i.e., the physical address of the old data in the temporary storage area, used to trace the data storage trajectory). By recording multiple fields, more granular backtracking scenario requirements can be supported.
[0081] Optionally, the controller writes the new data to be written to a free physical block in the regular storage area, and writes the physical block address after storage to the current data physical block address in the second mapping table, ensuring that subsequent read requests can accurately obtain the latest data, achieving a smooth transition between old and new data and reliable retention of historical data.
[0082] The data backtracking method provided in this application distinguishes between initial writes and update writes during data writing. For upper-layer fault recovery writes, the first mapping table is directly updated to ensure data reliability. For temporary writes, old data is migrated to the temporary storage area and the first and second mapping tables are updated. This method supports efficient data backtracking while avoiding the waste of resources from full backups, achieving a balance between write performance and backtracking capability.
[0083] As an optional implementation, based on any of the above embodiments, it includes:
[0084] The host performs a temporary write operation on the logical block address corresponding to the existing second entry again. The second entry needs to be updated to retain the latest data and ensure that historical data before the most recent update can be obtained during backtracking.
[0085] Specifically, before data is written, the first entry in the first mapping table corresponding to the logical block address is of type "association temporary table index". The index information can be the temporary table index index_x, indicating that the historical data of the logical block address has been associated with the second mapping table through this index. In the second mapping table, the second entry corresponding to the temporary table index index_x already exists. The fields recorded in this second entry can be the logical block address, the new physical block address after the last update, and the old physical block address that was previously temporary. Among them, the new physical block address after the last update is the valid data address of the current logical block address in the regular storage area (i.e., the second newest data address before this update), and the old physical block address that was previously temporary is the historical data address of the logical block address that was migrated to the temporary storage area during the previous round of updates.
[0086] Optionally, the host initiates a write request to modify the logical block address, carrying a temporary write flag, the latest data to be written, and a specified temporary table index, index_x. Optionally, using the temporary table index, index_x associated with the first mapping table, the "new data physical block address after the last update" is located in the second mapping table, the next newest data corresponding to the new data physical block address after the last update is read, the next newest data is written to the temporary area, and the physical block address of the next newest data in the temporary area is recorded.
[0087] Optionally, after data is written, the original second entry corresponding to the temporary storage table index_x in the second mapping table is overwritten. The updated entry fields are (original logical block address, physical block address after the new data is written to the regular storage area, and temporary storage address of the original slightly new data). The physical block address after the new data is written to the regular storage area is the final storage address of the new data to be written on the host in the regular storage area, and the temporary storage address of the original slightly new data is the address after the slightly new data is migrated to the temporary storage area. Optionally, the data corresponding to the "physical block address of the previously temporary data" recorded in the original second mapping table entry is marked as invalid, and the temporary storage area space occupied by this address is subsequently reclaimed by the garbage collection mechanism. The first entry type corresponding to the logical block address in the first mapping table remains "associative temporary storage table index," and the index information remains the temporary storage table index_x, ensuring that subsequent backtracking requests can locate the updated temporary storage table entry through this index.
[0088] As an optional implementation, based on any of the above embodiments, it includes:
[0089] In any scenario, the host needs to perform a temporary write operation on the logical block address LBAy. However, since the specified temporary table index index_x is already associated with a valid second entry of another logical block address LBAx, it is necessary to overwrite the original second entry corresponding to the temporary table index, while maintaining the valid data mapping relationship of the logical block address LBAx to avoid data loss.
[0090] Specifically, before the data is written, there are two sets of valid first entries in the first mapping table: the first entry corresponding to the logical block address LBAx, which is of type "associative temporary table index", and the index information is the temporary table index index_x, indicating that its historical data has been associated with the second mapping table; the first entry corresponding to the logical block address LBAy, which is of type "associative direct index", and the index information is the old data physical block address of the logical block address LBAy (i.e., the valid data address of this logical block address in the regular storage area before this update). In the second mapping table, the second entry corresponding to the temporary table index index_x is (logical block address LBAx, the current valid data physical block address of logical block address LBAx, and the temporary old data physical block address of logical block address LBAx); where "the current valid data physical block address of logical block address LBAx" is the current valid data address of this logical block address in the regular storage area, and "the temporary old data physical block address of logical block address LBAx" is the storage address of its historical data in the temporary storage area.
[0091] Optionally, the host initiates a modification write request for the logical block address LBAy. The modification write request carries a temporary write identifier, the new data to be written, and the specified temporary table index index_x (which must overwrite the original logical block address LBAx entry associated with the index).
[0092] Optionally, read the old data corresponding to the "old data physical block address of logical block address LBAy" in the first mapping table, write it into the temporary storage area, and record the physical block address of the old data in the temporary storage area (i.e., the temporary storage address of the old data of logical block address LBAy); then, read the next newest data corresponding to the "current valid data physical block address of logical block address LBAx" in the second mapping table, and write it into the regular storage area (this address will be used as the new valid data address of logical block address LBAx, replacing the original valid data address).
[0093] Optionally, after data is written, the type of the first entry at logical block address LBAx is changed from "associative temporary table index" to "associative direct index," and the index information is updated to "the address after the second newest data at logical block address LBAx is written to the regular storage area." Similarly, the type of the first entry at logical block address LBAy is changed from "associative direct index" to "associative temporary table index," and the index information is updated to the temporary table index index_x, establishing an association with the second mapping table. The original entry corresponding to the temporary table index index_x in the second mapping table is overwritten, and the updated entry fields are: logical block address LBAy, the physical block address after the new data at logical block address LBAy is written to the regular storage area, and the temporary storage address of the old data at logical block address LBAy. Historical data corresponding to "the physical block address of the old temporary data at logical block address LBAx" in the original second mapping table is marked as invalid data to reclaim temporary storage area space.
[0094] As an optional implementation, based on any of the above embodiments, it includes:
[0095] In any scenario, the host needs to perform a temporary write operation on the logical block address LBAy. The specified temporary table index index_x has been associated with a valid entry of the logical block address LBAx, and the logical block address LBAy itself has been associated with a second mapping table through another temporary table index index_y. The second entry needs to be overwritten twice and redundant mapping relationships need to be cleaned up to avoid index conflicts.
[0096] Specifically, before data is written, the first mapping table contains two sets of entries for the associated temporary storage table index: The first entry corresponds to the logical block address LBAx, is of type "associated temporary storage table index," and its index information is the temporary storage table index index_x. The corresponding entries in the second mapping table for this temporary storage table index are: logical block address LBAx, the current valid physical block address of logical block address LBAx, and the physical block address of the old temporary data at logical block address LBAx. The second entry corresponds to the logical block address LBAy, is of type "associated temporary storage table index," and its index information is the temporary storage table index index_y. The corresponding entries in the second mapping table for this index are: logical block address LBAy, the current valid physical block address of logical block address LBAy, and the physical block address of the old temporary data at logical block address LBAy.
[0097] Optionally, the host initiates a modification write request for the logical block address LBAy. The modification write request carries a temporary write identifier, the new data to be written, and the specified temporary table index index_x (which must overwrite the original logical block address LBAx entry associated with the index).
[0098] Optionally, by reading the temporary storage table index_y associated with the first mapping table, the "current valid physical block address of logical block address LBAy" (i.e., the second newest data address before this update) is located in the second mapping table. The second newest data is read and written to the temporary storage area, and its physical block address in the temporary storage area is recorded (i.e., the temporary storage address of the second newest data of logical block address LBAy). The temporary storage table index_x associated with the first mapping table is read, the "current valid physical block address of logical block address LBAx" (i.e., the second newest data address of logical block address LBAx) is located in the second mapping table. The second newest data is read and written to the regular storage area as the new valid data address of logical block address LBAx.
[0099] Specifically, after data is written, the first entry type of logical block address LBAx is changed from "associative temporary table index" to "associative direct index," and the index information is updated to "the address after the second newest data in logical block address LBAx is written to the regular storage area," ensuring that regular reads can locate valid data. The first entry type of logical block address LBAy remains "associative temporary table index," and the index information is updated from temporary table index index_y to temporary table index index_x. At the same time, the original index index_y is marked as invalid to avoid incorrect associations in subsequent requests.
[0100] Specifically, after data is written, the entry corresponding to the temporary storage table index_x is overwritten with: logical block address LBAy, the physical block address after the new data at logical block address LBAy is written to the regular storage area, and the temporary storage address of the next new data at logical block address LBAy. The entry corresponding to the temporary storage table index_y is set to the initial value state 0, the association with logical block address LBAy is removed, and it is marked as a free index for later use. The historical data corresponding to "physical block address of the old temporary data at logical block address LBAx" and "physical block address of the old temporary data at logical block address LBAy" in the original second mapping table are all invalidated to reclaim invalid data space in the temporary storage area.
[0101] Figure 4 A flowchart illustrating a data backtracking method provided in another embodiment of this application is shown below. Figure 4 As shown in the figure, as an optional implementation, based on any of the above embodiments, the following steps are also included:
[0102] S401. Determine whether the physical block address corresponding to the data to be written points to the cache area of the solid-state storage device.
[0103] The cache area is a high-speed cache partition in the DDR (Double Data Rate Synchronous Dynamic Random Access Memory) of solid-state storage devices. It is used to temporarily store data to be written / read in order to alleviate the write latency caused by the "erase before write" characteristic of flash memory and improve the data read and write response speed.
[0104] Optionally, the controller of the solid-state storage device extracts the physical block address corresponding to the data to be written from the data write request, and determines whether it points to the cache area of the solid-state storage device by parsing the physical block address prefix identifier. The address prefix identifier is a preset distinguishing field. For example, physical addresses starting with "0x01" point to the cache area, and those starting with "0x02" point to the regular storage area.
[0105] S402. If the physical block address corresponding to the data to be written points to the cache area, write the data to be written to the cache area.
[0106] Optionally, when it is determined that the physical block address corresponding to the data to be written points to the cache area, the controller of the solid-state storage device calls the cache write interface to write the data to be written to the free storage unit of the cache area in a page-aligned manner.
[0107] Optionally, during the process of writing data to the cache, a burst transmission mode is adopted to improve the data transmission rate, and the storage location (cache page address) and write timestamp of the data in the cache are recorded in real time to provide a basis for subsequent flushing and writing scheduling.
[0108] S403. Based on the wear leveling strategy of the solid-state storage device, determine the target flash physical page to be written to.
[0109] Wear leveling is an algorithm used within solid-state storage devices to balance the number of erases and writes to each physical block of flash memory, preventing some physical blocks from being overwritten and damaged prematurely, thus extending the overall lifespan of the solid-state storage device.
[0110] The target flash physical page is the smallest write unit in NAND (NOT AND Flash Memory) flash memory. Data must ultimately be written to this unit to complete persistent storage.
[0111] Optionally, the wear leveling module of the solid-state storage device's controller maintains a linked list of erase count statistics for each physical page of the flash memory chip in real time. This linked list is arranged in ascending order of erase count. When determining the target to be written, the wear leveling module selects the group of physical pages with the fewest erase counts from the linked list and determines the number and location of the target flash memory physical pages based on the size of the data to be written (e.g., 4KB, 8KB). If multiple physical pages with the same erase count exist, the physical pages located in free blocks are selected first to avoid performance loss caused by cross-block writing, ensure that the wear degree of each area of the flash memory tends to be consistent, and extend the overall lifespan of the device.
[0112] S404. Write the data to be written in the cache to the target flash physical page, and update the usage status of the physical block address corresponding to the data to be written to "written".
[0113] Optionally, direct memory access technology is used to quickly transfer the data to be written in the cache to the flash interface module, which then writes the data to the target flash physical page determined by S403 according to the flash protocol. After the data writing is completed, the flash controller returns a write success signal to the solid-state storage device controller. The solid-state storage device controller updates the usage status of the physical block address corresponding to the data from "pending write" to "written", and deletes the cache record of the data in the cache index table, releasing the corresponding cache space.
[0114] S405. If the physical block address corresponding to the data to be written does not point to the cache, determine whether there is unwritten data corresponding to the physical block address in the cache.
[0115] Optionally, when it is determined that the physical block address corresponding to the data to be written does not point to the cache area, the controller of the solid-state storage device uses the physical block address as the key to traverse the cache index table (which records the association between cached data and physical addresses) and determine whether there is any unwritten data (i.e. data that has been written to the cache but not yet written to the flash memory) corresponding to the physical block address in the cache area.
[0116] This operation avoids version conflicts between data at the same physical address in the cache and flash memory, ensuring data consistency.
[0117] S406. If there is unwritten data corresponding to a physical block address in the cache, merge the unwritten data with the data to be written.
[0118] Optionally, if there is unwritten data corresponding to the physical block address in the cache, the controller of the solid-state storage device extracts the unwritten data in the cache and compares and merges it with the data to be written according to the data offset address. For overlapping data segments, the data to be written is used as the basis for overwriting; for non-overlapping segments, they are spliced in offset order to form a complete data block (such as merging into a 16KB continuous data block).
[0119] Optionally, after data merging, CRC32 verification is used to ensure data integrity. If the verification fails, the data is extracted again and merged to avoid data corruption caused by merging errors.
[0120] S407: Write the data after merging the unwritten data and the data to be written into the target flash physical page.
[0121] Optionally, after data merging is complete, the wear leveling module of the solid-state storage device's controller uses the wear leveling strategy of S403 to determine the target flash physical page and writes the merged data to the target flash physical page without going through the cache. After writing is complete, the solid-state storage device's controller updates the first entry corresponding to the physical block address in the first mapping table, directly pointing the index to the new target physical page address, and deletes the corresponding unwritten data record in the cache, completing the entire write process. By merging the write operation, the number of flash memory erase / write cycles can be reduced, improving write efficiency and reducing wear.
[0122] This application provides a data backtracking method that reduces the number of direct flash writes by utilizing a cache buffer and extends flash memory lifespan by combining a wear leveling strategy. It also improves storage space utilization by merging unwritten data and avoiding resource waste caused by frequent small data writes, thereby achieving a balanced improvement in write performance, storage efficiency, and device lifespan.
[0123] Figure 5 A flowchart illustrating a data backtracking method provided in another embodiment of this application is shown below. Figure 5 As shown, as an optional implementation, based on any of the above embodiments, the following steps are also included:
[0124] S501. If the target request is a temporary write request, parse the temporary write request to obtain the temporary starting index and the number of temporary logical blocks to be deleted.
[0125] Optionally, when the target request is determined to be a temporary write request with a "temporary data management identifier" in S201, the controller of the solid-state storage device parses the temporary write request and extracts the temporary start index and the number of temporary logical blocks to be deleted from the preset fields of the temporary write request. Optionally, the temporary data management identifier can exist in combination with the temporary write identifier, such as the request header identifier being 0x0001+0x0002.
[0126] The temporary storage starting index is the starting position identifier of the entry to be deleted in the second mapping table; the number of temporary storage logical blocks to be deleted is the number of temporary storage entries to be deleted consecutively. The number of temporary storage logical blocks to be deleted is set by the host based on the remaining space in the temporary storage area and business needs, and shall not exceed the total number of valid entries in the second mapping table.
[0127] S502. Determine the range of temporary table entries to be deleted in the second mapping table based on the starting index of the temporary storage and the number of temporary logical blocks to be deleted.
[0128] Optionally, after receiving the starting index of the temporary storage and the number of temporary logical blocks to be deleted, the controller of the solid-state storage device calculates the ending index of the temporary table entry to be deleted. Optionally, the ending index = the starting index of the temporary storage + the number of temporary logical blocks to be deleted - 1.
[0129] Optionally, after obtaining the terminating index, the validity of the terminating index is verified. If the terminating index exceeds the maximum index value of the second mapping table, the terminating index is adjusted to the maximum index of the second mapping table, and a prompt message "Actual deletion quantity adjusted" is returned to the host.
[0130] Optionally, the final determined "starting index - ending index" range is the range of temporary table entries to be deleted in the second mapping table, ensuring that the deletion operation only applies to the second entry within the target range and avoiding accidental deletion of mapping information of other valid data.
[0131] S503. Obtain the physical block address corresponding to each second entry within the scope of the temporary table entry to generate a list of physical block addresses to be invalidated.
[0132] Optionally, the controller of the solid-state storage device traverses the range of entries in the temporary storage table determined by S502, reads the complete information of each second entry in the range one by one, and extracts the "physical block address" field (i.e., the physical address where historical data is stored in the temporary storage area).
[0133] Optionally, the physical addresses are arranged in the order of the entry index to generate a list of physical block addresses to be invalidated. Each record in the list of physical block addresses to be invalidated contains the physical block address, the corresponding temporary table index, and the data storage timestamp, which are used for the traceability and verification of subsequent deletion operations.
[0134] S504. Based on the list of physical block addresses to be invalidated, delete the data corresponding to each physical block address in the temporary storage area, and starting from the second entry corresponding to the temporary storage start index, mark the second entry in the temporary storage table entry range as invalid in turn.
[0135] Optionally, after obtaining the list of physical block addresses to be invalidated, the controller of the solid-state storage device sends data erase commands to the corresponding physical block addresses in the temporary storage area one by one in the order of the physical block addresses in the list. The erase operation uses a block-level erase method supported by the flash memory chip to ensure that the data is completely erased and cannot be recovered.
[0136] Optionally, the controller of the solid-state storage device starts from the second entry corresponding to the temporary storage start index, and sequentially sets the "validity identifier" field of the second entry in the range of entries to be deleted to "invalid" (e.g., changes the identifier from 0x01 to 0x00), and records the entry expiration time, providing a basis for subsequent garbage collection of the second mapping table.
[0137] Optionally, after all entries to be deleted are marked, the controller of the solid-state storage device updates the index management information of the second mapping table, marks the index position corresponding to the invalid entries as "free" for subsequent new temporary data to be written; and returns a "temporary data deletion completed" response to the host, including the actual number of deleted entries and the current remaining space size of the temporary storage area, to achieve closed-loop management of the temporary storage area.
[0138] The data backtracking method provided in this application embodiment avoids invalid data residue by directly deleting the mapping relationship between logical addresses and physical addresses, cleans up data in regular storage and temporary storage areas, reduces storage fragmentation, thereby ensuring data consistency and improving storage resource utilization.
[0139] Figure 6 A flowchart illustrating a data backtracking method provided in another embodiment of this application is shown below. Figure 6 As shown in the figure, as an optional implementation, based on any of the above embodiments, the following steps are also included:
[0140] S601. When the type of the target request is a trimming request, the trimming request includes the address range of the logical block to be trimmed.
[0141] Optionally, when the type of the target request is determined to be a trimming request (such as a TRIM request) in S201, it indicates that the host needs to mark and clean up invalid data within a specific logical address range. The controller of the solid-state storage device performs protocol parsing on the trimming request and extracts the logical block address range to be trimmed from the trimming request. This logical block address range to be trimmed is usually represented in the form of "starting logical block address + number of addresses" (for example, starting address 0x00002000, number of addresses 0x00000100, representing the logical block addresses to be trimmed from 0x00002000 to 0x000020FF).
[0142] Optionally, the controller of the solid-state storage device will also verify the validity of the address range of the logical block to be pruned. If the starting address exceeds the maximum logical address supported by the device or the number of addresses is 0, a "request parameter invalid" response will be returned to the host.
[0143] S602. Match each logical block address in the first mapping table according to the address range of the logical block to be trimmed, so as to obtain the first entry corresponding to each logical block address to be trimmed.
[0144] Optionally, after obtaining the range of logical block addresses to be pruned, the controller of the solid-state storage device generates a list of all logical block addresses within that range and matches each logical block address to be pruned one by one in the first mapping table.
[0145] Optionally, for a successfully matched logical block address to be pruned, its corresponding complete first entry (including entry type, index information, etc.) is extracted and added to the list of entries to be processed. Optionally, for addresses that fail to match (i.e., there is no corresponding entry in the first mapping table), they can be regarded as invalid addresses and no further processing is required.
[0146] S603. Mark each first entry as invalid and delete the mapping relationship between the logical block address to be pruned and the first entry in the first mapping table.
[0147] Optionally, invalidation processing is performed on each first entry in the list of entries to be processed. First, the "Validity Identifier" field of the entry is updated from "Valid" to "Invalid", and an invalidation timestamp is recorded to provide a basis for subsequent defragmentation of the first mapping table. Then, the association between the address of the logical block to be pruned and the corresponding first entry is deleted from the index structure of the first mapping table to ensure that subsequent requests will no longer locate these invalid entries.
[0148] Optionally, after deleting the mapping relationship, the storage space of the first mapping table is compacted, and the space occupied by invalid entries is reclaimed to avoid the query performance degradation caused by the expansion of the mapping table.
[0149] S604. If the type of the first entry is associated physical block address, the data corresponding to the physical block address is deleted in the regular storage area of the solid-state storage device.
[0150] Optionally, the type identifier of each first entry can be parsed by traversing the list of entries to be processed.
[0151] Optionally, if the entry type is "associated direct index" (i.e., the index information is a physical block address pointing to a regular storage area), then the physical block address is extracted and added to the list of physical addresses to be deleted.
[0152] Optionally, for each address in the list of physical addresses to be deleted, an erase command is sent to the corresponding physical block according to the block-level operation characteristics of the flash memory chip, deleting the data corresponding to that physical address in the regular storage area. After the data deletion is completed, the erase record of that physical block is fed back to the controller of the solid-state storage device, updating its wear statistics information.
[0153] Optionally, after the pruning request is processed, the controller of the solid-state storage device returns a "pruning successful" response to the host, which includes the number of logical block addresses actually processed and the size of the released storage space, providing a reference for the storage resource management of the upper-layer system.
[0154] S605. If the type of the first entry is an associated temporary table index, match it in the second mapping table according to the temporary table index to obtain the second entry corresponding to the temporary table index.
[0155] Optionally, when traversing the list of items to be processed, if the type identifier of the first item is detected as "associated temporary table index", the temporary table index recorded in the first item is extracted. Then, using the temporary table index as the key, a matching algorithm consistent with S203 (such as hash lookup) is used to perform an exact match in the second mapping table to locate the second item that uniquely corresponds to the temporary table index, ensuring that subsequent operations can accurately associate the target data in the temporary storage area.
[0156] Optionally, if a match fails (e.g., the second entry corresponding to the temporary table index in the second mapping table has been deleted), the exception information is recorded and subsequent steps are skipped to avoid invalid operations.
[0157] S606. Extract the physical block address of the historical data from the second entry and mark the second entry as invalid.
[0158] Optionally, from the second entry matched by S605, the "physical block address" field (i.e., the storage address of historical data in the temporary storage area) is extracted, and the physical block address of the historical data is stored in the list of temporary storage addresses to be cleaned. Subsequently, the "validity identifier" field of the second entry in the second mapping table is updated from "valid" to "invalid", and the entry marking time and the identifier of the corresponding pruning request are recorded to provide a basis for the subsequent defragmentation of the second mapping table.
[0159] S607. Based on the physical block address of the historical data in the second entry, delete the corresponding data in the temporary storage area.
[0160] Optionally, after obtaining the list of temporary storage addresses to be cleaned, a block-level erase operation is performed on each physical block address in the list of temporary storage addresses according to the storage management protocol of the temporary storage area. Optionally, after the erase operation is completed, a "data cleanup complete" signal is sent back to the controller of the solid-state storage device, and the free space statistics of the temporary storage area are updated, and the released space is included in the free resource pool for subsequent temporary storage writing.
[0161] Optionally, the controller of the solid-state storage device integrates the cleanup results of the regular storage area and the temporary storage area, and returns a detailed response to the host containing "the amount of regular storage cleaned, the amount of temporary storage cleaned, and the total space released", ensuring that the upper-layer system can accurately grasp the status of storage resources and improve the storage resource utilization and garbage collection efficiency of the device.
[0162] The data backtracking method provided in this application avoids the accumulation of invalid data by marking the second mapping table entry as invalid and deleting temporary data after backtracking or when data becomes invalid; during formatting, storage space fragmentation is reduced by invalidating logical addresses and clearing the first mapping table.
[0163] As an optional implementation, based on any of the above embodiments, the following steps are also included:
[0164] First, if the target request is a formatted request, modify the logical block address in each second entry in the second mapping table to an invalid temporary logical block address.
[0165] Optionally, when the type of the target request is determined to be a formatting request in S201, the formatting range identifier in the formatting request is extracted first. If the formatting range identifier is a formatting type involving a temporary storage area, all second entries in the second mapping table are traversed, and the "logical block address" field in each entry is uniformly modified to a preset "invalid temporary storage logical block address" (e.g., a 32-bit address of all 1s, 0xFFFFFFFF).
[0166] Optionally, invalid addresses are pre-defined by the system to avoid conflicting with any valid logical addresses, ensuring that subsequent requests cannot be associated with formatted historical data through these entries.
[0167] Optionally, after modification, the consistency of the second mapping table data is ensured through verification and comparison to avoid anomalies caused by failure to modify some entries.
[0168] Optionally, after all second entries in the second mapping table are invalidated, the metadata management module of the solid-state storage device's controller synchronously performs metadata cleanup. Specifically, the metadata management module locates the jm_l2p entry in the first table that is bound to the second mapping table. This jm_l2p entry records metadata such as the storage address, total number of entries, and current version of the second mapping table in the solid-state storage device's Double Data Rate Synchronous Dynamic Random Access Memory (DDR), and is the sole basis for the metadata management module to identify and manage the second mapping table. Optionally, all fields (storage address, version number, valid range, etc.) in the jm_l2p entry are reset to initial invalid values (such as 0x00000000), thus severing the association between the first table and the second mapping table.
[0169] Secondly, after the second mapping table is formatted, determine whether the first mapping table needs to be formatted.
[0170] Optionally, after confirming that all target entries in the second mapping table have been modified (i.e., returning a "format ready" signal), the first mapping table is formatted. Optionally, the judgment criteria include whether the formatting request carries a "full formatting flag" (set by the host according to requirements, such as a flag of 0x01 indicating full formatting), and whether the proportion of invalid entries in the first mapping table exceeds a preset threshold (e.g., 80%, which can be dynamically adjusted). Optionally, if either condition is met, the first mapping table is determined to need to be formatted; if neither condition is met, only the formatting of the second mapping table is completed, retaining the valid entries in the first mapping table to reduce unnecessary performance loss.
[0171] Finally, if the first mapping table needs to be formatted, the first mapping table is cleared.
[0172] Optionally, when it is determined that the first mapping table needs to be formatted, the controller of the solid-state storage device can call the secure zeroing interface to perform a full zeroing of the index structure and entry data of the first mapping table.
[0173] Optionally, the zeroing operation uses direct memory access to improve efficiency and avoid consuming CPU resources. Specifically, the storage area corresponding to the first mapping table is first marked as "inaccessible" to prevent it from being accessed by other modules during the formatting process; then, the data in this storage area is zeroed page by page using hardware instructions; finally, the status flag of the first mapping table is updated from "normal" to "uninitialized". After zeroing is completed, the access restriction on the storage area is lifted, and the formatting result, including the processing status of the first and second mapping tables, is returned to the host.
[0174] The data backtracking method provided in this application embodiment marks all logical block addresses of the second entries in the second mapping table as invalid temporary logical block addresses when a formatting request is triggered, thereby severing the association between historical data and logical addresses and avoiding backtracking residue; then, a conditional judgment is used to trigger a clearing operation of the first mapping table to completely clear the current valid data mapping relationship.
[0175] As an optional implementation, based on any of the above embodiments, the second mapping table, as one of the metadata of the solid-state storage device, is managed and restored throughout its entire lifecycle by the JM (Journal Manager). The storage mechanism, resource consumption assessment, and restoration strategy of the second mapping table are as follows:
[0176] Optionally, the second mapping table is saved using a delta+base snapshot method, with JM performing runtime dynamic saving and power-off triggered saving to ensure that metadata is not lost.
[0177] The base section is a complete baseline snapshot of the second mapping table, which is saved at a preset period or when a trigger condition is met (such as when the update volume of the second mapping table reaches a threshold). The delta section contains incremental update data after the baseline snapshot, with the format defined as temp_delta(temp_entry_index, LBA, PBAn, PBAo). A single delta entry occupies 16 bytes and records the index, logical block address, new physical block address (PBAn), and old physical block address (PBAo) of the second mapping table entry.
[0178] Optionally, when JM uses the delta+base method to save the second mapping table, it needs to occupy the SLC (Single-Level Cell) block resources of the solid-state storage device.
[0179] Optionally, during the power-down process, JM flushes a portion of the second mapping table's cache to ensure that incremental updates to the second mapping table are not lost. When flushing the second mapping table's cache, the update operation is first paused, and data integrity is verified on the cached portion. If the verification passes, the cached data is flushed to NAND according to a preset SLC block write strategy. After flushing, the second mapping table's status is marked as "saved," and the subsequent power-down process continues. If an anomaly occurs during the power-down process (such as a sudden power outage), since the second mapping table uses dual-backup storage, it can be restored using the backup data after power-up, ensuring data consistency.
[0180] Optionally, after power-on, JM first restores the first table, and then restores the second mapping table based on the metadata association information in the first table. Specifically, after power-on, JM first loads and parses the first table, extracting the base snapshot storage address, delta incremental data storage address, and version information of the second mapping table; it first reads the base snapshot data to initialize the second mapping table, and then applies delta incremental patches one by one in chronological order to update the entry information in the second mapping table; after the restoration is completed, the integrity of the second mapping table is verified. If the verification passes, the status of the second mapping table is marked as "available"; otherwise, the backup data restoration process is triggered.
[0181] Figure 7 This is a schematic diagram of the structure of a data backtracking device provided in an embodiment of this application, as shown below. Figure 7 As shown, the data backtracking device provided in this embodiment is located in an electronic device. The data backtracking device 70 provided in this embodiment includes: a request receiving module 71, a first entry acquisition module 72, a second entry acquisition module 73, and a data sending module 74.
[0182] Specifically, the request receiving module 71 is used to receive the target request sent by the host and determine the type of the target request; the first entry acquisition module 72 is used to match the target logical block address in the first mapping table when the type of the target request is a backtracking data read request, so as to obtain the target first entry corresponding to the target logical block address; wherein, the backtracking data read request includes the target logical block address corresponding to the data to be backtracked, and the first mapping table includes multiple mapping relationships between logical block addresses and the first entry; the second entry acquisition module 73 is used to determine the type of the target first entry, and when the type of the target first entry is an associated target temporary storage table index, it matches the target temporary storage table index in the second mapping table to obtain the target second entry corresponding to the target temporary storage table index; wherein, the second mapping table includes multiple mapping relationships between temporary storage table indexes and the second entry; the data sending module 74 is used to extract the target physical block address corresponding to the data to be backtracked in the target second entry, obtain the data to be backtracked in the temporary storage area based on the target physical block address, and send the data to be backtracked to the host; wherein, the temporary storage area is a pre-divided area in the reserved storage space of the solid-state storage device.
[0183] Optionally, a data backtracking device may also include a data writing module.
[0184] Optionally, the data writing module is used to, when the target request is a data writing request, match the logical block address of the data to be written in the first mapping table to determine whether the logical block address of the data to be written is the first creation write; when the logical block address of the data to be written is not the first creation write, determine whether the data writing request is an upper-layer fault recovery write; when the data writing request is an upper-layer fault recovery write, write the data to be written to the regular storage space of the solid-state storage device, and update the first mapping table based on the physical block address and logical block address after the data to be written is completed.
[0185] Optionally, the data writing module is further configured to: extract the temporary table index from the data writing request when the data writing request is not an upper-layer fault recovery write and the write type identifier in the data writing request is temporary write; determine the corresponding physical data block address in the first mapping table based on the logical block address; migrate the data corresponding to the physical data block address to the temporary storage area; modify the first entry corresponding to the logical block address in the first mapping table to associate with the temporary table index; and write a second entry at the position corresponding to the temporary table index in the second mapping; wherein the second entry includes the logical block address, the current physical data block address, and the historical physical data block address.
[0186] Optionally, the data writing module is further configured to determine whether the physical block address corresponding to the data to be written points to the cache of the solid-state storage device; if the physical block address corresponding to the data to be written points to the cache, write the data to be written to the cache; determine the target flash physical page to which the data to be written is written according to the wear leveling strategy of the solid-state storage device; write the data to be written in the cache to the target flash physical page, and update the usage status of the physical block address corresponding to the data to be written to "written".
[0187] Optionally, the data writing module is further configured to determine whether there is unwritten data corresponding to the physical block address in the cache if the physical block address corresponding to the data to be written does not point to the cache; if there is unwritten data corresponding to the physical block address in the cache, merge the unwritten data with the data to be written; and write the merged data to the target flash physical page.
[0188] Optionally, a data backtracking device may further include a temporary storage area writing module.
[0189] Optionally, the temporary storage area writing module is used to parse the temporary storage write request when the target request type is a temporary storage write request, to obtain the temporary storage starting index and the number of temporary storage logical blocks to be deleted; determine the range of temporary storage table entries to be deleted in the second mapping table based on the temporary storage starting index and the number of temporary storage logical blocks to be deleted; obtain the physical block address corresponding to each second entry in the range of temporary storage table entries to generate a list of physical block addresses to be invalidated; delete the data corresponding to each physical block address in the temporary storage area based on the list of physical block addresses to be invalidated, and mark the second entries in the range of temporary storage table entries as invalid, starting from the second entry corresponding to the temporary storage starting index.
[0190] Optionally, a data backtracking device may also include a trimming module.
[0191] Optionally, the pruning module is configured to: when the target request is a pruning request, wherein the pruning request includes a range of logical block addresses to be pruned; match each logical block address range to be pruned in a first mapping table to obtain a first entry corresponding to each logical block address to be pruned; mark each first entry as invalid and delete the mapping relationship between the logical block address to be pruned and the first entry in the first mapping table; and when the type of the first entry is an associated physical block address, delete the data corresponding to the physical block address in the regular storage area of the solid-state storage device.
[0192] Optionally, a data backtracking device may also include an invalidation module.
[0193] Optionally, the invalidation module is used to, when the type of the first entry is an associated temporary table index, match it in the second mapping table according to the temporary table index to obtain the second entry corresponding to the temporary table index; extract the historical data physical block address in the second entry and mark the second entry as invalid; and delete the corresponding data in the temporary area based on the historical data physical block address in the second entry.
[0194] Optionally, a data backtracking device may also include a formatting module.
[0195] Optionally, the formatting module is used to modify the logical block addresses in each second entry of the second mapping table to invalid temporary logical block addresses when the target request is a formatted request; when the second mapping table is formatted, it determines whether the first mapping table needs to be formatted; when the first mapping table needs to be formatted, it performs a zeroing operation on the first mapping table.
[0196] It should be noted that the technical effects of the data backtracking device in this embodiment have been explained in the above-described embodiment of the data backtracking method, and therefore will not be repeated in this embodiment.
[0197] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, as shown below. Figure 8 As shown, the electronic device 80 provided in the embodiments of this application includes: a memory 81 and a processor 82.
[0198] The memory 81 stores a computer program, and the processor 82 is configured to run the computer program to perform the steps in any of the above-described data backtracking method embodiments.
[0199] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above data backtracking embodiments when it is run.
[0200] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0201] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data backtracking method embodiments.
[0202] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data backtracking method embodiments.
[0203] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0204] The solution provided in this application has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A data rollback method, characterized by, The method comprises the following steps: receiving a target request sent by a host, and judging the type of the target request; in the case that the type of the target request is a backtracking data reading request, matching a target logical block address in a first mapping table to obtain a target first entry corresponding to the target logical block address; wherein the backtracking data reading request comprises the target logical block address corresponding to the data to be backtracked, and the first mapping table comprises a mapping relationship between a plurality of logical block addresses and first entries; judging the type of the target first entry, and in the case that the type of the target first entry is an associated target temporary table index, matching the target temporary table index in a second mapping table to obtain a target second entry corresponding to the target temporary table index; wherein the second mapping table comprises a mapping relationship between a plurality of temporary table indexes and second entries; extracting a target physical block address corresponding to the data to be backtracked in the target second entry, obtaining the data to be backtracked in a temporary area based on the target physical block address, and sending the data to be backtracked to the host; wherein the temporary area is a region pre-divided in a reserved storage space of a solid state storage device.
2. The method of claim 1, wherein, Further comprising: in the case that the type of the target request is a data writing request, matching a logical block address of data to be written in the first mapping table to determine whether the logical block address of the data to be written is a first-time created writing; in the case that the logical block address of the data to be written is not a first-time created writing, judging whether the data writing request is an upper-layer fault recovery writing; in the case that the data writing request is an upper-layer fault recovery writing, writing the data to be written into a regular storage space of the solid state storage device, and updating the first mapping table based on a physical block address and a logical block address after the writing of the data to be written is completed.
3. The method of claim 2, wherein, Further comprising: in the case that the data writing request is not an upper-layer fault recovery writing, and the writing type identifier in the data writing request is a temporary writing, extracting a temporary table index in the data writing request; determining a corresponding data physical block address of the logical block address in the first mapping table, migrating data corresponding to the data physical block address to the temporary area; modifying the first entry corresponding to the logical block address in the first mapping table to be associated with the temporary table index; writing a second entry corresponding to the temporary table index in the second mapping table; wherein the second entry comprises a logical block address, a current data physical block address and a historical data physical block address.
4. The method of claim 2, wherein, Further comprising: judging whether a physical block address corresponding to the data to be written points to a cache area of the solid state storage device; in the case that the physical block address corresponding to the data to be written points to the cache area, writing the data to be written into the cache area; determining a target flash physical page for writing the data to be written according to a wear leveling strategy of the solid state storage device; write the to-be-written data in the cache area into the target flash physical page, and update a use state of a physical block address corresponding to the to-be-written data to written.
5. The method of claim 4, wherein, Further comprising: in the case that the physical block address corresponding to the to-be-written data does not point to the cache area, judging whether there is unflushed data corresponding to the physical block address in the cache area; in the case that there is unflushed data corresponding to the physical block address in the cache area, merging the unflushed data with the to-be-written data; writing the data after merging the unflushed data with the to-be-written data into the target flash physical page.
6. The method of claim 1, wherein, Further comprising: in the case that the type of the target request is a staging write request, parsing the staging write request to obtain a staging start index and a to-be-deleted staging logical block quantity; determining a range of staging table entries to be deleted in the second mapping table according to the staging start index and the to-be-deleted staging logical block quantity; obtaining physical block addresses corresponding to each second entry in the range of staging table entries to generate a list of to-be-invalidated physical block addresses; based on the list of to-be-invalidated physical block addresses, deleting data corresponding to each of the physical block addresses in the staging area, and starting from the second entry corresponding to the staging start index, sequentially invalidating second entries in the range of staging table entries.
7. The method of claim 1, wherein, Further comprising: in the case that the type of the target request is a pruning request, wherein the pruning request includes a to-be-pruned logical block address range; matching each to-be-pruned logical block address in the first mapping table according to the to-be-pruned logical block address range to obtain a first entry corresponding to each to-be-pruned logical block address; invalidating each first entry and deleting a mapping relationship between a to-be-pruned logical block address and the first entry in the first mapping table; in the case that the type of the first entry is an associated physical block address, deleting data corresponding to the physical block address in a regular storage area of the solid state storage device.
8. The method of claim 7, wherein, Further comprising: in the case that the type of the first entry is an associated staging table index, matching the staging table index in the second mapping table to obtain a second entry corresponding to the staging table index; extracting a historical data physical block address in the second entry and invalidating the second entry; based on the historical data physical block address in the second entry, deleting corresponding data in the staging area.
9. The method according to any one of claims 1 to 8, characterized in that, Further comprising: in the case that the type of the target request is a formatting request, modifying a logical block address in each second entry in the second mapping table to an invalid staging logical block address; in the case that the second mapping table is formatted, judging whether the first mapping table needs to be formatted; in the case that the first mapping table needs to be formatted, performing a zero operation on the first mapping table.
10. An electronic device, comprising: comprising: a memory for storing a computer program; a processor for executing the computer program to implement the method steps of any one of claims 1-9.
Citation Information
Patent Citations
Data writing method and device, equipment and storage medium
CN115599302A
Data processing method and device, equipment and medium
CN119248197A
Mapping table reconstruction method and storage device
CN120832363A
System and methods for managing time-based events to support rewinding of a database
US20250348386A1
