A method for avoiding the conflict between garbage collection writes and Host writes in a solid state drive

During the garbage collection process of solid-state drives, the validity judgment before DRAM writes and the mapping relationship update after Flash writes are performed, and the data coverage problem caused by garbage collection and Host write conflicts is solved, and data integrity and system stability are improved.

CN119002806BActive Publication Date: 2025-06-17国创芯科技(江苏)有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411024230.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2025-06-17
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

In the prior art, the garbage collection mechanism and the Host writing process of the solid state hard disk are independent of each other, which may lead to garbage collection and rewriting of the same flash address, resulting in new data being overwritten by old data.

Method used

During the garbage collection process, the validity judgment and mapping relationship update are performed separately before data is written to DRAM and after Flash are written to, the changes in the physical address in the mapping table are monitored and recorded, and the old data mapping relationship that is invalid due to Host rewriting is eliminated, ensuring the integrity and consistency of the data.

Benefits of technology

It effectively avoids the problem that new data is covered by old data caused by conflicts between garbage collection and Host rewrite, and improves the data integrity and system stability of the flash storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119002806B_ABST
    Figure CN119002806B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for avoiding the conflict between garbage collection writing and Host writing in the field of data storage technology, including: during the garbage collection process, before the data is written into DRAM, checking whether the mapping relationship corresponding to the data has changed, and accordingly deciding whether to perform the operation of writing into DRAM; when preparing to update the mapping table after the whole packet of target data in the garbage collection is written into Flash, performing a validity judgment on the mapping relationship to be updated, removing the mapping relationships that have changed, and only updating the mapping relationships that have not changed to the mapping table. By performing validity judgment and mapping relationship update respectively in two stages before the data is written into DRAM and after it is written into Flash, this method effectively avoids the problem that new data is overwritten by old data due to the conflict between garbage collection and Host rewriting, and improves the data integrity and system stability of the flash storage system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data storage, and particularly to a method for avoiding the conflict between garbage collection writing and Host writing in a solid state drive. Background Art

[0002] The traditional garbage collection mechanism and writing mechanism of a solid state drive are two independent processes. The garbage collection mechanism reads out the valid data blocks in a certain block, then rewrites them into a new block, and then erases the original block; the Host writing process means that the Host issues a piece of data with a logical address, the controller allocates the physical address corresponding to the logical address of this piece of data, and then the controller writes it into the corresponding physical address in the Flash.

[0003] When the old data in a certain flash block in the solid state drive needs to be rewritten, first, the Host issues a new piece of data again. The logical address of this piece of data already exists in the mapping table of the solid state drive. However, according to the characteristics of NAND Flash, the same flash block cannot be written without being erased. The controller needs to reallocate a physical address of the Flash corresponding to the logical address of this piece of data, then write this piece of data into the new physical address of the Flash, and then update the current latest mapping relationship into the mapping table. The data on the original old physical address waits to be recycled and erased by the garbage collection mechanism of the solid state drive.

[0004] However, due to the independence of the garbage collection mechanism and the writing process, garbage collection operations may also occur while rewriting in the solid state drive. At this time, it is possible that both operations operate on the same logical address. The new rewritten data is first loaded into the corresponding physical address of the Flash, and then the garbage collection mechanism loads the original old data into the corresponding physical address of the Flash. At this time, the new data written by the Host is overwritten by the old data written by the garbage collection mechanism, and the mapping table is updated with the mapping relationship of the old data written by the garbage collection mechanism. When the Host issues a command to read the rewritten logical address part again and reads the data in the corresponding Flash physical address, it will be found that this is the old data written by the original garbage collection mechanism. Summary of the Invention

[0005] The present application provides a method for avoiding the conflict between garbage collection writing and Host writing in a solid state drive, and solves the problem that the new data is overwritten by the old data caused by garbage collection and rewriting of the same flash address in the prior art.

[0006] An embodiment of the present application provides a method for avoiding the conflict between garbage collection writing and Host writing in a solid state drive, and the method includes:

[0007] Step 1: During the garbage collection process, when data is read from Flash to DRAM and ready to be written, perform the following operations:

[0008] (a) Look up the physical address corresponding to the logical address of this data in the mapping table inside the controller;

[0009] (b) Determine whether the physical address corresponding to this logical address has changed to confirm whether this data is valid data;

[0010] Step 2: During the period from when the garbage collection data is written from DRAM to Flash until the mapping table is updated, perform the following operations:

[0011] (a) Monitor and record the parts of the physical addresses in the mapping table that have changed, that is, the parts rewritten by the Host;

[0012] (b) For the entire target data (Target data) written to Flash, search and eliminate the mapping relationships that match the physical addresses of each piece of data in the target data among the mapping relationships where the physical addresses in the mapping table have changed;

[0013] (c) Update the remaining target data mapping relationships to the mapping table to complete the garbage collection process.

[0014] The beneficial effects of the above embodiments are as follows: By performing validity judgment and mapping relationship update respectively in two stages before data is written to DRAM and after it is written to Flash, this method effectively avoids the problem of new data being overwritten by old data caused by the conflict between garbage collection and Host rewriting, and improves the data integrity and system stability of the flash storage system.

[0015] Based on the above embodiments, the present application can be further improved as follows:

[0016] In one embodiment of the present application, the lookup and judgment operations in Step 1 are used to confirm the validity of data before it is written to DRAM, to avoid incorrect processing of invalid data.

[0017] In one embodiment of the present application, the monitoring and recording operations in Step 2 are executed by the internal algorithm of the memory, and are used to count and record the modification actions of the mapping relationships, so as to eliminate the old data mapping relationships that become invalid due to Host rewriting when updating the mapping table.

[0018] In one embodiment of the present application, the rejection operation in the second step is specifically as follows: Compare the physical address of each piece of data in the Target data that has been written to the flash after garbage collection with the modification records recorded in the mapping table. If a hit occurs, it is regarded as old data and its mapping relationship is rejected; the unhit part is retained and updated to the mapping table.

[0019] An embodiment of the present application also provides a device using the above method, including: a mapping relationship monitoring module, a DRAM write control module, and a post-Flash write mapping update module, where:

[0020] The mapping relationship monitoring module is used to monitor in real time the change in the correspondence between the logical address and the physical address in the mapping table;

[0021] The DRAM write control module controls the write operation of data to the DRAM during the garbage collection process according to the result of the mapping relationship monitoring module;

[0022] After the garbage collection data is written to the Flash, the post-Flash write mapping update module determines whether to reject the changed mapping relationship according to the result of the mapping relationship monitoring module, and updates the mapping table.

[0023] An embodiment of the present application also provides a system using the above method, including a flash memory, a dynamic random access memory, a controller, and a mapping table. The controller uses the method as described above to avoid new data being overwritten by old data during the garbage collection process. Description of the Drawings

[0024] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts do not necessarily draw according to the actual scale.

[0025] Figure 1 It is a step flowchart of a method for avoiding write conflicts between solid-state drive garbage collection writes and Host writes in an embodiment of the present application;

[0026] Figure 2 It is a process example diagram of step S1 in an embodiment of the present application;

[0027] Figure 3 It is a process example diagram of step S2 in an embodiment of the present application. Detailed Embodiments

[0028] The present invention will be further clarified below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and not to limit the scope of the present invention. After reading the present invention, various equivalent modifications made by those skilled in the art to the present invention fall within the scope defined by the appended claims of this application.

[0029] It should be noted that like reference numerals and letters denote like items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0030] Embodiment 1:

[0031] As Figure 1 shown, a method for avoiding the conflict between garbage collection writes and Host writes in a solid-state drive, the method includes the following:

[0032] S1: Mapping relationship check before writing data to DRAM, including:

[0033] During the garbage collection process, when preparing to write a piece of data to DRAM, check whether the physical address corresponding to the logical address of this piece of data has changed in the mapping table;

[0034] If it is found that the physical address has changed, cancel the write operation of this piece of data to DRAM;

[0035] If the physical address has not changed, normally execute the operation of writing to DRAM.

[0036] S2: Validity judgment of mapping relationship update after Flash writing, including:

[0037] When all the target data in a whole package of garbage collection has been written to Flash and is ready to update the mapping table, perform the following operations:

[0038] Monitor and record the change situation of the physical address corresponding to the logical address in the mapping table;

[0039] Traverse the mapping relationship to be updated. For each mapping relationship, check whether the physical address corresponding to its logical address has changed;

[0040] If it is found that the physical address has changed, exclude the update of this mapping relationship;

[0041] Update the mapping relationships that have not changed to the mapping table.

[0042] The problem to be solved by step S1 is as follows: When the Host write command has changed the physical address corresponding to the logical address, the data of this garbage collection mechanism has not been written into the DRAM yet. This means that if, at this moment, according to the original mapping relationship, the data of this garbage collection is written into the DRAM and then from the DRAM into the Flash, the result is that the old data of the garbage collection overwrites the new data written by the Host. Subsequently, when reading the logical address of this data, the old data written by the original garbage collection is still obtained. To avoid the conflict between the old and new data caused by this situation, step S1 determines whether the mapping relationship of each piece of data prepared to be written into the DRAM by the garbage collection mechanism has changed when writing. The judgment condition is whether the physical address of the data currently written by the garbage collection has changed in the mapping table.

[0043] An example of step S1 is as follows Figure 2 As shown: When garbage collection writes LCA 1, a traversal is performed in the mapping table, and it is found that the physical address PCA 1 corresponding to LCA1 has changed, from PCA 1 -> PCA 1024. Therefore, the writing of this piece of garbage collection data LCA1 to the DRAM is cancelled. Then, LCA2 is prepared for writing. Using the same mechanism, but it is checked that the PCA corresponding to LCA2 has not changed, and this piece of garbage collection data LCA2 is normally written to the DRAM.

[0044] The problem to be solved by step S2 is as follows: When all the entire Target data of this garbage collection mechanism has been written into the Flash and is about to update the new mapping relationship into the mapping table, it is found that after the Host write command is issued, some mapping relationships in the mapping table have been changed. To avoid the conflict between the old and new data caused by this situation, step S2 judges the validity of the entire package of Target data after the garbage collection has been written into the Flash.

[0045] An example of step S2 is as follows Figure 3 As shown: That is, when the garbage collection data has written LCA 0 to LCA 1023 into the Flash and is about to come back to update the mapping relationship into the mapping table, the memory algorithm monitors and records that the physical address of LCA 1 has changed, that is, PCA 1 -> PCA 1024. At this time, the firmware algorithm is triggered to perform a pursuit of each pair of mapping relationships in the Target data prepared to update the mapping table inside the memory. It is found that LCA 1 is hit, and it is determined that it is the mapping relationship of the old data. Therefore, the update of the mapping relationship corresponding to LCA 1 in the Target data is excluded. Finally, the remaining new unhit mapping relationships of the data written by the garbage collection into the Flash are updated into the mapping table, and this process ends.

[0046] The technical solutions in the embodiments of the present application described above have at least the following technical effects or advantages:

[0047] 1. A mechanism designed within the controller of the present invention determines the validity of each piece of data written during garbage collection writing when it is written to the cache, and determines the validity of each piece of data before updating the mapping table after updating to Flash.

[0048] 2. The present invention effectively avoids the problem that new data is overwritten by old data inside the SSD.

[0049] Embodiment 2:

[0050] A device for avoiding conflicts between garbage collection writing and Host writing in a solid-state drive, adopting the method shown in Embodiment 1, further includes: a mapping relationship monitoring module, a DRAM writing control module, and a mapping update module after Flash writing, where:

[0051] The mapping relationship monitoring module is used to monitor in real time the change in the correspondence between the logical address and the physical address in the mapping table;

[0052] The DRAM writing control module controls the writing operation of data to the DRAM during the garbage collection process according to the result of the mapping relationship monitoring module;

[0053] The mapping update module after Flash writing determines to eliminate the changed mapping relationship according to the result of the mapping relationship monitoring module and updates the mapping table after the garbage collection data is written to Flash.

[0054] The working processes and functions of the modules in Embodiment 2 are the same as the corresponding descriptions in the method embodiment of Embodiment 1, and will not be elaborated here.

[0055] Embodiment 3:

[0056] A system for avoiding conflicts between garbage collection writing and Host writing in a solid-state drive, adopting the method shown in Embodiment 1, further includes a flash memory, a dynamic random access memory, a controller, and a mapping table. The controller adopts the method as described above to avoid new data being overwritten by old data during the garbage collection process.

[0057] The working processes and functions of the components in Embodiment 3 are the same as the corresponding descriptions in the method embodiment of Embodiment 1, and will not be elaborated here.

[0058] Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for avoiding conflicts between garbage collection writing of a solid state drive and writing of a host, characterized in that: include: During the garbage collection process, when data is read from the flash memory to the DRAM for writing, the following operations are performed: Check whether the physical address corresponding to the logical address of the data has changed in the mapping table; If it is found that the physical address has changed, the writing operation of the data to the DRAM is cancelled; if the physical address has not changed, the writing operation to the DRAM is performed normally; After the entire package of target data collected by garbage collection is written into the Flash, when the mapping table is to be updated, the validity of the mapping relationship to be updated is judged, the mapping relationship that has changed is eliminated, and only the mapping relationship that has not changed is updated to the mapping table; Among them, the validity judgment step of updating the mapping relationship after the entire package of target data is written to the Flash includes: monitoring and recording the changes of the physical addresses corresponding to the logical addresses in the mapping table, traversing the mapping relationships to be updated, and for each mapping relationship, checking whether the physical addresses corresponding to its logical addresses have changed, and eliminating the updates of the mapping relationships that have changed accordingly; the update operation of eliminating the mapping relationships that have changed is specifically: comparing the physical addresses of each data in the entire package of target data written to the flash memory after garbage collection with the modification records recorded in the mapping table, if there is a hit, it is regarded as old data and its mapping relationship is eliminated; the part that does not hit is retained and updated to the mapping table.

2. The method according to claim 1, characterized in that The operation of monitoring and recording changes in the physical addresses corresponding to the logical addresses in the mapping table is performed by an algorithm inside the memory, and is used to count and record modification actions of the mapping relationship.

3. A device for avoiding conflicts between garbage collection writing of a solid state drive and writing of a host, characterized in that: The method according to any one of claims 1 to 2 further comprises: a mapping relationship monitoring module, a DRAM write control module and a Flash post-write mapping update module, wherein: The mapping relationship monitoring module is used to monitor the changes in the corresponding relationship between the logical address and the physical address in the mapping table in real time; The DRAM write control module is used to control the writing operation of data to DRAM during the garbage collection process according to the result of the mapping relationship monitoring module; After the garbage collection data is written into the Flash, the Flash post-write mapping update module determines to remove the changed mapping relationship according to the result of the mapping relationship monitoring module, and updates the mapping table.

4. A system for avoiding conflicts between garbage collection writing of a solid state drive and writing of a host, characterized in that: The method according to any one of claims 1-2 is adopted, and also includes a flash memory, a dynamic random access memory, a controller and a mapping table. The controller adopts the method according to any one of claims 1-2 to avoid new data being overwritten by old data during garbage collection.

Citation Information

Patent Citations

  • Garbage collection method, device and medium applied to solid-state hard disk

    CN109144428A