Data garbage collection method, electronic equipment and storage medium
By performing feature processing and matching feature value tables on valid data in the storage device, invalid data is directly erased, which solves the write amplification problem caused by data relocation, and improves the write speed and service life of the storage device.
Patent Information
- Application Number
- CN202310702726.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2024-12-13
AI Technical Summary
During the garbage collection process, the storage device cannot erase invalid data separately, resulting in data relocation of valid data, resulting in write amplification and affecting the host's write speed.
By performing feature processing on valid data, generating feature values, and determining whether there is a matching feature value in the feature value table. If it exists, determine that the data is erasable data, directly erase without data relocation, and update the feature value table to reduce writing enlarge.
It realizes the normal reading and writing speed of effective data, reduces write amplification, and extends the service life of the storage device.
Smart Images

Figure CN119127059A_ABST
Abstract
Description
Technical Field
[0001] The present application is applied to the technical field of data processing, in particular to a data garbage collection method, an electronic device and a storage medium. Background Art
[0002] Storage devices will become fragmented after being used for a period of time, and garbage collection is needed to organize data and free up space.
[0003] In the current garbage collection process, due to the working characteristics of storage devices, when there is both valid data and invalid data on the source block, it is impossible to erase the invalid data alone. The only way is to erase the entire data on the source block and relocate the valid data to ensure normal reading of the valid data.
[0004] However, data migration of valid data will cause write amplification, thereby affecting the host write speed. Summary of the invention
[0005] The present application provides a data garbage collection method, an electronic device, and a storage medium to solve the problem that garbage collection of a storage device may lead to increased write amplification.
[0006] To solve the above technical problems, the present application provides a data garbage collection method, including: in response to the target data on the source block of the storage device including valid data and invalid data, feature processing is performed on the valid data to obtain a feature value of the valid data; judging whether there is a feature value in a feature value table that is the same as the feature value of the valid data; wherein the feature value table stores feature values of multiple preset data; if there is a feature value in the feature value table that is the same as the feature value of the valid data, determining that the target data on the source block is erasable data.
[0007] Among them, the step of performing feature processing on the valid data to obtain the feature value of the valid data includes: dividing the valid data into a plurality of valid sub-data of unit length in turn; performing preset encryption processing on each valid sub-data respectively to obtain the feature value of each valid sub-data; the step of judging whether there is a feature value identical to the feature value of the valid data in the feature value table includes: judging whether there is a feature value identical to the feature value of each valid sub-data in the feature value table; if there is a feature value identical to the feature value of all the valid sub-data in the feature value table, then it is determined that there is a feature value identical to the feature value of the valid data in the feature value table.
[0008] Among them, the steps of performing preset encryption processing on each valid sub-data respectively to obtain the characteristic value of each valid sub-data include: encrypting each valid sub-data respectively through the SM3 cryptographic hash algorithm to obtain the hash characteristic value of each valid sub-data; wherein the hash characteristic values of multiple preset data are stored in the characteristic value table.
[0009] Among them, the step of judging whether there is a characteristic value in the characteristic value table that is the same as the characteristic value corresponding to the characteristic value of each valid sub-data also includes: if there is no characteristic value in the characteristic value table that is the same as the characteristic value corresponding to the characteristic value of all valid sub-data, writing the valid data to other target blocks, determining that the target data on the source block is erasable data, and updating the characteristic value that does not exist in the characteristic value table into the characteristic value table.
[0010] Among them, the characteristic value table is stored in the private space of the storage device; the step of updating the characteristic values that do not exist in the characteristic value table into the characteristic value table also includes: in response to the private space storage of the storage device being full, deleting the characteristic value with the least number of hits in the characteristic value table, and updating the characteristic values that do not exist in the characteristic value table into the characteristic value table.
[0011] Among them, the step of responding to the target data on the target block including valid data and invalid data includes: performing preset encryption processing on multiple preset data of unit length to obtain the characteristic value of each preset data; establishing a corresponding relationship between each preset data and the characteristic value of each preset data, and generating a characteristic value table based on the characteristic value of each preset data.
[0012] Among them, the step of establishing a corresponding relationship between each preset data and the characteristic value of each preset data, and generating a characteristic value table based on the characteristic value of each preset data also includes: storing each preset data on a preset target block, and constructing a logical-physical mapping table based on the physical address of each preset data and the mapping address. The step of updating the characteristic value that does not exist in the characteristic value table into the characteristic value table also includes: establishing a mapping relationship between the physical address of the valid data located on other target blocks and the logical address of the valid data, and updating the mapping relationship to the logical-physical mapping table.
[0013] The data garbage collection method further includes: in response to reading the valid data, determining the physical address of the valid data from a logical-physical mapping table based on the logical address of the valid data; and acquiring the valid data from the physical address.
[0014] To solve the above technical problems, the present invention further provides an electronic device, comprising a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement any of the data garbage collection methods described above.
[0015] In order to solve the above technical problems, the present invention also provides a computer-readable storage medium on which program instructions are stored. When the program instructions are executed by a processor, a data garbage collection method as described in any one of the above items is implemented.
[0016] To solve the above technical problems, the present application provides a data garbage collection method by establishing a characteristic value table storing characteristic values of multiple preset data. When the target data on the source block includes valid data and invalid data, characteristic processing is performed on the valid data to obtain the characteristic value of the valid data. When there is a characteristic value identical to the characteristic value of the valid data in the characteristic value table, it is determined that the valid data is identical to the preset data corresponding to the characteristic value in the characteristic value table. Therefore, when the valid data is subsequently read, the preset data corresponding to the characteristic value in the characteristic value table can be directly used to call the valid data, thereby directly erasing the target data on the source block without the need to relocate the valid data. This ensures the normal reading of the valid data and reduces the process of writing the valid data into the target block for storage again, reduces the occurrence of write amplification, improves the host write speed and access speed of the storage device, improves the garbage collection performance of the data, and increases the service life of the storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flow chart of an embodiment of a method for garbage collection of data of the present application;
[0018] Figure 2 It is a flowchart of another embodiment of the method for garbage collection of data of the present application;
[0019] Figure 3 It is a schematic diagram of an implementation method of creating a characteristic value table;
[0020] Figure 4 is a schematic diagram of an implementation method for obtaining characteristic values of effective sub-data;
[0021] Figure 5 is a schematic diagram of an implementation method of updating a characteristic value table;
[0022] Figure 6 It is a schematic diagram of the framework of an embodiment of the electronic device of the present application;
[0023] Figure 7 A schematic diagram of a framework of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0025] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0026] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0027] See also Figure 1 , Figure 1 It is a flow chart of an embodiment of a method for garbage collection of data of the present application.
[0028] Step S11: In response to the target data on the source block of the storage device including valid data and invalid data, feature processing is performed on the valid data to obtain feature values of the valid data.
[0029] The data garbage collection method of this embodiment is applied to data recovery of storage devices. After a period of use, the storage device will be fragmented and it is necessary to sort out the data through garbage collection to free up space. The storage device may include but is not limited to a solid state drive or other storage device with Nand Flash (non-volatile memory) as the storage medium.
[0030] The source block is the data source and can be read. The target block is the data receiver and can be written. Invalid data is the data that needs to be erased on the source block of the storage device, while valid data is the data that needs to be retained on the source block of the storage device. Due to the working characteristics of the storage device, it is impossible to erase invalid data alone, and the data of the entire source block can only be erased at the same time.
[0031] When the target data on the source block includes both valid data and invalid data, this step first performs feature processing on the valid data to obtain feature values of the valid data.
[0032] Feature processing can be performed on valid data by feature filtering, feature wrapping, feature embedding, various data encryption methods, etc. to obtain feature values of valid data. The specific method of feature processing is not limited here.
[0033] Step S12: Determine whether there is an eigenvalue in the eigenvalue table that is the same as the eigenvalue of the valid data.
[0034] The characteristic value table stores characteristic values of various preset data, wherein the characteristic value of each preset data is obtained by performing the same characteristic processing method on the preset data as that of the valid data.
[0035] The various preset data are any data that may be stored in the storage device, for example: binary data all 0 data, binary data all 1 data, binary data 10101010b, binary data 01010101b, etc., which are not limited here.
[0036] Determine whether there is a eigenvalue in the eigenvalue table that is the same as the eigenvalue of the valid data. When there is a eigenvalue in the eigenvalue table that is the same as the eigenvalue of the valid data, it means that the valid data is the same as the preset data corresponding to the eigenvalue in the eigenvalue table; when there is no eigenvalue in the eigenvalue table that is the same as the eigenvalue of the valid data, it means that the valid data is different from multiple preset data corresponding to the eigenvalue table.
[0037] Step S13: If there is a characteristic value in the characteristic value table that is the same as the characteristic value of the valid data, it is determined that the target data on the source block is erasable data.
[0038] If there is an eigenvalue in the eigenvalue table that is the same as the eigenvalue of the valid data, it means that the valid data is the same as the preset data corresponding to the eigenvalue in the eigenvalue table. When the valid data is subsequently read, the preset data corresponding to the eigenvalue in the eigenvalue table can be directly used to call the valid data.
[0039] The valid data on the source block can be erased together with the invalid data, and there is no need to relocate the valid data. The target data on the source block is determined to be erasable data, thereby ensuring the normal reading of the valid data and reducing the process of writing the valid data again to the target block for storage, thereby reducing the occurrence of write amplification.
[0040] When the target data is determined to be erasable data, the erasable data can be erased during the idle time of the storage device, or all erasable data can be erased at a preset frequency, or the erasable data can be erased immediately when it is determined to be erasable data. The specific erasing timing is set based on actual needs.
[0041] When erasing target data, the target data can be directly erased to obtain a blank source block, or new data can be written into the source block to overwrite the target data to complete the erasure.
[0042] Through the above steps, the data garbage collection method of this embodiment establishes a characteristic value table storing characteristic values of multiple preset data, and when the target data on the source block includes valid data and invalid data, the valid data is subjected to characteristic processing to obtain the characteristic value of the valid data; and when there is a characteristic value identical to the characteristic value of the valid data in the characteristic value table, it is determined that the valid data is identical to the preset data corresponding to the characteristic value in the characteristic value table, so that when the valid data is subsequently read, the preset data corresponding to the characteristic value in the characteristic value table can be directly used to call the valid data, and the target data on the source block can be erasable without the need to relocate the valid data, thereby ensuring the normal reading of the valid data and reducing the process of writing the valid data again into the target block for storage, reducing the occurrence of write amplification, improving the host write speed and access speed of the storage device, improving the garbage collection performance of the data, and improving the service life of the storage device.
[0043] See also Figure 2 , Figure 2 It is a flowchart of another embodiment of the garbage collection method of data of the present application.
[0044] Step S21: In response to the target data on the source block of the storage device including valid data and invalid data, the valid data is divided into a plurality of valid sub-data of unit length in sequence.
[0045] Before garbage collection of data is performed, a characteristic value table is first established. Specifically, a plurality of preset data of unit length are encrypted to obtain characteristic values of each preset data; a corresponding relationship between each preset data and its characteristic value is established, and a characteristic value table is generated based on the characteristic value of each preset data.
[0046] The preset encryption process may include but is not limited to any data encryption process, such as: SM3 cryptographic hash algorithm, symmetric encryption algorithm, asymmetric encryption algorithm, identification encryption algorithm, hash function algorithm, etc. Preferably, the preset encryption process is SM3 cryptographic hash algorithm, which can reduce the similarity rate between the characteristic values of different preset data, thereby ensuring that the characteristic values of different preset data are different to a certain extent, thereby improving the accuracy of the correspondence between the characteristic values and each preset data.
[0047] The unit length can be any data length, for example: 4KB, 8KB, 10KB or 20KB, etc. Preferably, the unit length is 4KB, because 4KB is the minimum management unit of the storage device. By establishing a characteristic value table for the characteristic values corresponding to the various preset data of the minimum management unit, the comprehensiveness of the characteristic value table corresponding to various valid data in the storage device can be improved as much as possible, the number of hits between the valid data and the characteristic value table can be increased, and the occurrence of data migration can be reduced. The same is true for the subsequent division of valid sub-data.
[0048] The various preset data are any data that may be stored in the storage device, for example: binary data all 0 data, binary data all 1 data, binary data 10101010b, binary data 01010101b, etc., which are not limited here.
[0049] In a specific application scenario, when creating a characteristic value table, 4KB of multiple preset data can be encrypted using the SM3 cryptographic hash algorithm to obtain a 32-Byte hash characteristic value of each preset data; a corresponding relationship between each preset data and the hash characteristic value of each preset data is established, and finally a characteristic value table is generated based on the hash characteristic value of each preset data, wherein the hash characteristic values of multiple preset data are stored in the characteristic value table.
[0050] See also Figure 3 , Figure 3 It is a schematic diagram of an implementation method of creating a characteristic value table.
[0051] The various preset data include binary data all 0 data, binary data all 1 data, binary data 10101010b, binary data 01010101b, and the like. The preset data are encrypted respectively to obtain corresponding characteristic values. Specifically, the all 0 data can be encrypted by the SM3 cryptographic hash algorithm to obtain a hash characteristic value a; the all 1 data can be encrypted by the SM3 cryptographic hash algorithm to obtain a hash characteristic value b; the binary data 10101010b can be encrypted by the SM3 cryptographic hash algorithm to obtain a hash characteristic value c; the binary data 01010101b can be encrypted by the SM3 cryptographic hash algorithm to obtain a hash characteristic value d, and so on. Finally, all the hash characteristic values are combined to obtain the characteristic value table 30.
[0052] After the characteristic value tables of multiple preset data are established, each preset data is stored in a preset target block, and a logical-physical mapping table is constructed based on the physical address of each preset data and the mapping address, so that subsequent reading of valid data can use the logical-physical mapping table to search for physical addresses.
[0053] Before garbage collection begins, the source block and target block are selected and valid data is confirmed. After garbage collection begins, the source block data is read. In response to the target data on the source block including valid data and invalid data, it means that the invalid data on the source block needs to be erased, but the valid data needs to be retained. Then, the valid data is divided into multiple valid sub-data of unit length in turn. The length of the valid sub-data is the same as the length of the preset data corresponding to the characteristic value table.
[0054] In a specific application scenario, the valid data may be divided into a plurality of 4KB valid sub-data in sequence. In other application scenarios, the valid data may also be divided into valid sub-data of other gear lengths in sequence.
[0055] Step S22: performing preset encryption processing on each valid sub-data respectively to obtain a characteristic value of each valid sub-data.
[0056] After being divided into multiple valid sub-data of unit length, each valid sub-data is subjected to preset encryption processing to obtain the characteristic value of each valid sub-data. The preset encryption processing in this step is the same as the preset encryption processing corresponding to the characteristic value table, so as to ensure that the same valid sub-data and the preset data can obtain the same characteristic value after the same preset encryption processing, which is convenient for accurate comparison and judgment.
[0057] In a specific application scenario, when creating a characteristic value table, 4KB of various preset data can be encrypted by the SM3 cryptographic hash algorithm to obtain a 32-byte hash characteristic value of each preset data; a corresponding relationship between each preset data and the hash characteristic value of each preset data is established, and finally a characteristic value table is generated based on the hash characteristic value of each preset data, wherein the hash characteristic values of various preset data are stored in the characteristic value table. In this step, the 4KB of valid sub-data can also be encrypted by the SM3 cryptographic hash algorithm to obtain a 32-byte hash characteristic value of each valid sub-data.
[0058] In other application scenarios, when the unit length of the preset data corresponding to the eigenvalue table and the preset encryption algorithm are other, the method for constructing the eigenvalue table and the method for obtaining the eigenvalues of the valid sub-data are similar to the above application scenarios and will not be repeated.
[0059] See also Figure 4 , Figure 4 It is a schematic diagram of an implementation method for obtaining characteristic values of valid sub-data.
[0060] The source block H includes valid data H1 and invalid data H2 , wherein the valid data H1 is divided into a plurality of valid sub-data H11 .
[0061] Each valid sub-data H11 is encrypted by the SM3 cryptographic hash algorithm to obtain a hash characteristic value of each valid sub-data H11, namely, hash characteristic value A, hash characteristic value B, hash characteristic value C, and so on.
[0062] Step S23: Determine whether there is a feature value in the feature value table that is the same as the feature value of each valid sub-data.
[0063] Determine whether there is a feature value in the feature value table that is the same as the feature value of the valid sub-data. When there is a feature in the feature value table that is the same as the feature value of the valid sub-data, it means that the valid sub-data is the same as the preset data corresponding to the feature value in the feature value table; when there is no feature in the feature value table that is the same as the feature value of the valid sub-data, it means that the valid sub-data and multiple preset data corresponding to the feature value table are not the same.
[0064] Step S24: If there is a characteristic value in the characteristic value table that is the same as the characteristic values corresponding to all the valid sub-data, it is determined that the target data on the source block is erasable data.
[0065] If there is an eigenvalue in the eigenvalue table that corresponds to the eigenvalues of all valid sub-data, it means that the entire valid data corresponds to the eigenvalue in the eigenvalue table, that is, the preset data corresponding to the eigenvalue table can be spliced and restored to obtain the corresponding entire valid data.
[0066] In a specific application scenario, multiple preset data are already stored in the preset target block, that is, when valid data needs to be read, the valid data can be obtained by splicing the multiple preset data already stored in the target block. Therefore, the valid data on the source block can be directly erased, that is, the target data on the source block is determined to be erasable data, thereby removing the unnecessary invalid data.
[0067] In another specific application scenario, when valid data needs to be read, the characteristic values corresponding to multiple valid sub-data of the valid data in the characteristic value table can be reversely decrypted to obtain multiple valid sub-data, which are then spliced together to obtain valid data. Therefore, this step can determine that the target data on the source block is erasable data to remove unnecessary invalid data.
[0068] Step S25: If there is no eigenvalue in the eigenvalue table that corresponds to the eigenvalues of all valid sub-data, write the valid data into other target blocks, determine that the target data on the source block is erasable data, and update the eigenvalue that does not exist in the eigenvalue table into the eigenvalue table.
[0069] If there is no eigenvalue in the eigenvalue table that corresponds to the eigenvalues of all valid sub-data, it means that the entire valid data cannot be restored by splicing only the preset data or eigenvalues corresponding to the eigenvalue table. Then write the valid data to other target blocks, or write the valid sub-data that does not correspond to the eigenvalue in the eigenvalue table to other target blocks separately, so that the subsequent steps can read the valid data from other target blocks.
[0070] After writing the valid data, a mapping relationship is established between the physical address of the valid data on other target blocks and the logical address of the valid data, and the mapping relationship is updated in the logical-physical mapping table. When reading the valid data, the physical address of the valid data is determined from the logical-physical mapping table based on the logical address of the valid data; the valid data is obtained from the physical address to complete the reading of the valid data.
[0071] The target data on the source block is determined to be erasable data to remove unnecessary invalid data. Finally, the eigenvalues that do not exist in the eigenvalue table are updated into the eigenvalue table to expand the comprehensiveness of the eigenvalue table so that it can subsequently hit the same data as the current valid data.
[0072] In this embodiment, a logical-physical mapping table and a characteristic value table of preset data are pre-constructed, and valid sub-data that does not correspond to the characteristic values in the characteristic value table are written and the logical-physical mapping table and the characteristic value table are updated accordingly, so that any subsequent data that can correspond to the characteristic values in the characteristic value table can be read using the logical-physical mapping table, thereby improving the reading performance of the storage device.
[0073] See also Figure 5 , Figure 5 is a schematic diagram of an implementation method of updating the characteristic value table. Figure 3 , Figure 4 The eigenvalue of is used as an example to illustrate.
[0074] When the hash feature value A, the hash feature value B, and the hash feature value C are not the same as the hash feature values in the feature value table 30 , the hash feature value A, the hash feature value B, and the hash feature value C are added and updated to the feature value table 30 .
[0075] The characteristic value table can be stored in the private space of the storage device, and the number of storage bits in the characteristic value table is determined by the storage size of the private space. Among them, the private space refers to the non-user space in the storage device, which is used to store various types of data required to realize various functions of the storage device. In the process of updating the characteristic value table, if the private space storage of the storage device is full, delete the characteristic value with the least number of hits in the characteristic value table to release part of the private space, and then update the characteristic value that does not exist in the characteristic value table into the characteristic value table.
[0076] The hit count of the eigenvalue in the eigenvalue table is obtained by comparing the eigenvalues of previous valid sub-data. Specifically, when it is determined that there is an eigenvalue in the initial eigenvalue table that is the same as the eigenvalue of the valid sub-data, the eigenvalue in the eigenvalue table is a hit, and the hit count is increased by one.
[0077] When the storage device is idle, the characteristic values with zero hit times can be deleted to release some private space and improve the hit rate of the characteristic value table.
[0078] Through the above steps, the data garbage collection method of the present embodiment establishes a characteristic value table storing characteristic values of multiple preset data. When the target data on the source block includes valid data and invalid data, the valid data is divided into a plurality of valid sub-data of unit length in sequence, and each valid sub-data is respectively subjected to preset encryption processing to obtain the characteristic value of each valid sub-data, and it is judged whether there is a characteristic value that is the same as the characteristic value corresponding to the characteristic value of each valid sub-data in the characteristic value table. If there is a characteristic value that is the same as the characteristic value corresponding to the characteristic value of all the valid sub-data in the characteristic value table, it is determined that the target data on the source block is erasable data; if there is no characteristic value that is the same as the characteristic value corresponding to the characteristic value of all the valid sub-data in the characteristic value table, it is determined that the target data on the source block is erasable data; The target data on the source block is determined to be erasable data, and the eigenvalues that do not exist in the eigenvalue table are updated into the eigenvalue table, so that when the valid data is subsequently read, the preset data corresponding to the eigenvalue in the eigenvalue table can be directly used to call the valid data, and the target data on the source block can be directly erased without the need to relocate the valid data, thereby ensuring the normal reading of the valid data and reducing the process of writing the valid data to the target block again for storage, reducing the occurrence of write amplification, improving the host write speed and access speed of the storage device, improving the garbage collection performance of the data, and increasing the service life of the storage device. The above scheme has good scalability and can be applied to a variety of storage devices or other storage devices with Nand Flash (non-volatile memory) as storage media.
[0079] See also Figure 6 , Figure 6 6 is a schematic diagram of a framework of an embodiment of an electronic device of the present application. The electronic device 60 includes a memory 61 and a processor 62 coupled to each other, and the processor 62 is used to execute program instructions stored in the memory 61 to implement the steps of the above method embodiment. In a specific implementation scenario, the electronic device 60 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 60 may also include a laptop, a tablet computer, Nand Flash, etc., which are not limited here.
[0080] Specifically, the processor 62 is used to control itself and the memory 61 to implement the steps of any of the above method embodiments. The processor 62 can also be called a CPU (Central Processing Unit). The processor 62 may be an integrated circuit chip with signal processing capabilities. The processor 62 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 62 can be implemented by an integrated circuit chip.
[0081] The above solution can reduce the occurrence of write amplification and improve the host write speed and access speed of the storage device.
[0082] See also Figure 7 , Figure 7 The computer-readable storage medium 70 stores program instructions 701 that can be executed by a processor, and the program instructions 701 are used to implement the steps of any of the above method embodiments.
[0083] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0084] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0085] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0086] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0087] The above are only implementation methods of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A data garbage collection method, characterized in that: The data garbage collection method comprises: In response to the target data on the source block of the storage device including valid data and invalid data, performing feature processing on the valid data to obtain a feature value of the valid data; Determine whether there is a characteristic value in the characteristic value table that is the same as the characteristic value of the valid data; wherein the characteristic value table stores characteristic values of multiple preset data; If the characteristic value table contains a characteristic value that is the same as the characteristic value of the valid data, it is determined that the target data on the source block is erasable data.
2. The data garbage collection method according to claim 1, characterized in that: The step of performing feature processing on the valid data to obtain feature values of the valid data comprises: Sequentially dividing the valid data into a plurality of valid sub-data of unit length; Performing preset encryption processing on each of the valid sub-data respectively to obtain a characteristic value of each of the valid sub-data; The step of determining whether there is a characteristic value in the characteristic value table that is the same as the characteristic value of the valid data comprises: Determine whether there is a characteristic value in the characteristic value table that is the same as the characteristic value of each of the valid sub-data; If the eigenvalue table contains the same eigenvalue as the eigenvalues of all valid sub-data, it is determined that the eigenvalue table contains the same eigenvalue as the eigenvalue of the valid data.
3. The data garbage collection method according to claim 2, characterized in that: The step of performing preset encryption processing on each of the valid sub-data to obtain the characteristic value of each of the valid sub-data comprises: Encrypting each valid sub-data by using the SM3 cryptographic hash algorithm to obtain a hash characteristic value of each valid sub-data; The characteristic value table stores hash characteristic values of various preset data.
4. The data garbage collection method according to claim 2, characterized in that: The step of judging whether there is a characteristic value in the characteristic value table that is the same as the characteristic value of each valid sub-data further includes: If the characteristic value table does not contain the same characteristic value corresponding to the characteristic value of all valid sub-data, the valid data is written into other target blocks, the target data on the source block is determined to be erasable data, and the characteristic value that does not exist in the characteristic value table is updated into the characteristic value table.
5. The data garbage collection method according to claim 4, characterized in that: The characteristic value table is stored in the private space of the storage device; The step of updating the eigenvalues not existing in the eigenvalue table into the eigenvalue table further comprises: In response to the private space of the storage device being full, the feature value with the least hit times in the feature value table is deleted, and the feature value not existing in the feature value table is updated into the feature value table.
6. The data garbage collection method according to claim 4, characterized in that: The step of responding to the target data on the target block including valid data and invalid data includes: Performing the preset encryption process on the plurality of preset data of the unit length to obtain a characteristic value of each of the preset data; A corresponding relationship between each of the preset data and a characteristic value of each of the preset data is established, and the characteristic value table is generated based on the characteristic value of each of the preset data.
7. The data garbage collection method according to claim 6, characterized in that: The step of establishing a corresponding relationship between each of the preset data and a characteristic value of each of the preset data, and generating the characteristic value table based on the characteristic value of each of the preset data further includes: The preset data are stored in a preset target block, and a logical-physical mapping table is constructed based on a mapping relationship between a physical address of each preset data and a mapping address; The step of updating the eigenvalues not existing in the eigenvalue table into the eigenvalue table further comprises: A mapping relationship is established between the physical address of the valid data located on other target blocks and the logical address of the valid data, and the mapping relationship is updated in a logical-physical mapping table.
8. The data garbage collection method according to claim 7, characterized in that: The data garbage collection method further includes: In response to reading the valid data, determining a physical address of the valid data from the logical-physical mapping table based on the logical address of the valid data; The valid data is obtained from the physical address.
9. An electronic device, characterized in that: It comprises a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement the data garbage collection method as described in any one of claims 1 to 8.
10. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the data garbage collection method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
SSD user data management method and device, computer equipment and storage medium
CN120723160A
