Solid state disk garbage collection method, device and equipment and readable storage medium

By detecting and managing the status of free blocks and effective data distribution tables of solid-state drives, the garbage collection process is optimized, and the problem of low garbage collection efficiency of Dram-Less solid-state drives is solved, improving recycling efficiency and system performance.

CN119046178APending Publication Date: 2024-11-29WUHAN TAICUN TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410880143.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

Dram-Less type solid-state drives lack Dram cache during garbage collection, resulting in the reconstruction of effective data distribution tables taking time, affecting garbage collection efficiency, and the host write operation is in a waiting state, affecting performance and delay, especially when effective data is distributed. The impact is more significant.

Method used

By detecting the number of free blocks in the solid state drive and the status of the effective data distribution table, rebuilding the state machine, applying for continuous storage space, rebuilding the effective data distribution table of the target block, and adding it to the candidate list, selecting the optimal block as the garbage collection source Block, start the garbage collection process, increase the pre-reconstruction and granularity control of effective data distribution tables, and optimize the garbage collection process.

Benefits of technology

It greatly improves garbage collection efficiency, reduces waiting time during garbage collection, and improves write performance and system response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046178A_ABST
    Figure CN119046178A_ABST
Patent Text Reader

Abstract

The invention provides a solid state disk garbage collection method, device and equipment and a readable storage medium, and belongs to the technical field of solid state disks. The method comprises the steps of detecting whether the number of idle available blocks in the solid state disk is lower than a first threshold value or not, judging whether an effective data distribution table reconstruction state machine is in an idle state or not, applying for a section of first continuous storage space, obtaining an optimal block of a flash memory as a target block for effective data distribution table reconstruction, and reconstructing an effective data distribution table of the target block, storing the effective data distribution table into a first continuous storage space, adding the target block into a candidate list for garbage collection, selecting an optimal block from the candidate list as a source block for garbage collection, simultaneously obtaining a corresponding effective data distribution table, and starting a garbage collection process. By adding the pre-reconstruction of the valid data distribution table, the moving speed of valid data is improved, so that the garbage recycling efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of solid state drive garbage recovery, and in particular to a solid state drive garbage recovery method, device, equipment and readable storage medium. Background Art

[0002] With the popularity of solid-state drives, the demand for cheaper Dram-Less solid-state drives is also increasing. However, since Dram-Less solid-state drives do not have Dram cache, the overall memory that can be used when the firmware is running is severely limited. No space is allocated to store the valid data distribution table of each physical block. When garbage collection is performed, it is necessary to search for valid data while moving it, which takes a long time and seriously affects the efficiency of garbage collection. Due to the restriction of proportional scheduling, the host write is always in a waiting state before the garbage collection is completed, affecting the write performance and delay, especially when the valid data is relatively scattered, the impact is more significant. Summary of the invention

[0003] In order to solve the above technical problems, the embodiments of the present application provide a solid state drive garbage collection method, device, equipment and readable storage medium.

[0004] In a first aspect, an embodiment of the present application provides a solid state drive garbage collection method, wherein the solid state drive includes a flash memory and a controller, and the controller has a built-in storage space, and the method includes:

[0005] Detecting whether the number of free available blocks in the solid state drive is lower than a first threshold, and determining whether the valid data distribution table reconstruction state machine is in an idle state;

[0006] If the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, applying for a first continuous storage space from the storage space, where the first continuous storage space is used to store the valid data distribution table;

[0007] If the application for the first continuous storage space is successful, obtaining the optimal block of the flash memory as a target block for rebuilding the valid data distribution table;

[0008] Setting the valid data distribution table reconstruction state machine to a busy state, rebuilding the valid data distribution table of the target block, storing the valid data distribution table in the first continuous storage space, and adding the target block to a candidate list for garbage collection;

[0009] Detecting whether the number of free available blocks in the solid state drive is lower than a second threshold, and determining whether the candidate list where the target block is located is empty, wherein the first threshold is greater than the second threshold;

[0010] If the candidate list is not empty, an optimal block is selected from the candidate list as a garbage collection source block, a target valid data distribution table corresponding to the garbage collection source block is obtained, and a garbage collection process is started.

[0011] In one embodiment, the garbage collection process includes: The garbage collection process includes:

[0012] Traversing the target valid data distribution table to perform garbage collection and removal;

[0013] When the garbage collection source block completes the garbage collection migration, the first continuous storage space corresponding to the target valid data distribution table is released.

[0014] In one implementation, the reconstructing the valid data distribution table corresponding to the target block includes:

[0015] If the data written to the target block reaches a predetermined data write amount, wherein the predetermined data write amount is composed of the amount of data written to the flash memory by the host and the garbage collection; then the task of rebuilding the valid data distribution table is divided into multiple subtasks, and the corresponding valid data distribution table is rebuilt for each subtask.

[0016] In one embodiment, the task of reconstructing the effective data distribution table is divided into a plurality of subtasks, and the corresponding effective data distribution table is reconstructed for each of the subtasks, including:

[0017] Evenly dividing the predetermined data writing amount to obtain a plurality of data unit subsets;

[0018] A corresponding valid data distribution table is reconstructed for each of the subtasks according to each data unit subset.

[0019] In one embodiment, the method further comprises:

[0020] If the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, a second continuous storage space is applied to the host's memory buffer, and the second continuous storage space is used to store the valid data distribution table.

[0021] In one embodiment, the method further comprises:

[0022] When the amount of the first continuous storage space exceeds a third threshold, the valid data distribution table temporarily stops being rebuilt.

[0023] In one embodiment, the method further comprises:

[0024] The amount of reconstructed valid data is counted, and if the amount of valid data reaches a fourth threshold, the reconstruction of the target block is directly completed, wherein the amount of valid data is all valid data of the target block.

[0025] In a second aspect, an embodiment of the present application provides a device for garbage collection of a solid state drive, the device comprising:

[0026] A first checking module is used to detect whether the number of free available blocks in the solid state drive is lower than a first threshold value, and to determine whether the valid data distribution table reconstruction state machine is in an idle state;

[0027] an application module, configured to apply for a first continuous storage space from the storage space if the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, wherein the first continuous storage space is used to store the valid data distribution table;

[0028] A reconstruction module, configured to, if the application for the first continuous storage space is successful, obtain the optimal block of the flash memory as the target block for reconstruction of the valid data distribution table; set the valid data distribution table reconstruction state machine to a busy state, rebuild the valid data distribution table of the target block, store the valid data distribution table in the first continuous storage space, and add the target block to a candidate list for garbage collection;

[0029] a second checking module, detecting whether the number of free available blocks in the solid state drive is lower than a second threshold, and determining whether the candidate list where the target block is located is empty, wherein the first threshold is greater than the second threshold;

[0030] The garbage collection module selects the best block from the candidate list as the garbage collection source block if the candidate list is not empty, obtains the target valid data distribution table corresponding to the garbage collection source block, and starts the garbage collection process.

[0031] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and when the processor is running, the computer program executes the solid-state hard disk garbage collection method provided in the first aspect.

[0032] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when running on a processor, executes the solid-state hard disk garbage collection method provided in the first aspect.

[0033] The solid-state hard disk garbage collection method provided by the present application detects whether the number of free available blocks in the solid-state hard disk is lower than a first threshold value, and determines whether the effective data distribution table reconstruction state machine is in an idle state, applies for a first continuous storage space, obtains the optimal block of the flash memory as the target block for reconstruction of the effective data distribution table, rebuilds the effective data distribution table of the target block, stores the effective data distribution table in the first continuous storage space, and adds the target block to the candidate list for garbage collection, selects the optimal block from the candidate list as the source block for garbage collection, and simultaneously obtains the corresponding effective data distribution table to start the garbage collection process. By increasing the pre-reconstruction of the effective data distribution table and controlling the reconstruction granularity, garbage collection only requires the effective data to be moved according to the reconstructed effective data distribution table, which greatly improves the efficiency of garbage collection. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present application and should not be regarded as limiting the scope of protection of the present application. In each of the drawings, similar components are numbered similarly.

[0035] Figure 1 A schematic diagram of a process of a solid state drive garbage collection method provided by an embodiment of the present application is shown;

[0036] Figure 2 Another schematic diagram of a solid state drive garbage collection method provided by an embodiment of the present application is shown;

[0037] Figure 3 Another schematic diagram of a solid state drive garbage collection method provided in an embodiment of the present application is shown;

[0038] Figure 4 A structural schematic diagram of a solid state drive garbage collection device provided in an embodiment of the present application is shown.

[0039] Icons: 400 - solid state drive garbage collection device, 401 - first inspection module, 402 - application module, 403 - reconstruction module, 404 - second inspection module, 405 - garbage collection module. DETAILED DESCRIPTION

[0040] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0041] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0042] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present application, are intended only to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations of the foregoing items.

[0043] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0044] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.

[0045] Example 1

[0046] An embodiment of the present application provides a solid state drive garbage collection method.

[0047] See also Figure 1 , Figure 1 A schematic diagram of a solid state drive garbage collection method provided by an embodiment of the present application is shown, and specific steps may include:

[0048] S101: Detect whether the number of free available blocks in the solid state drive is lower than a first threshold, and determine whether a valid data distribution table reconstruction state machine is in an idle state.

[0049] In this embodiment, a solid state drive (SSD) is a hard disk that uses a flash memory chip as a storage medium, and is targeted at a specific Dram-Less solid state drive, which is a model that does not include a Dram cache in the SSD, wherein a free available block refers to a storage block that has not been allocated to any file on the Dram-Less solid state drive; a valid data distribution table is a data structure in the form of a bitmap, in which 1 usually indicates that valid data is stored in the corresponding storage block, and 0 indicates that no valid data is stored in the corresponding storage block, or the storage block is free and can be used to store new data; a reconstruction state machine refers to a state machine that manages the valid data distribution table, which is responsible for updating the valid data distribution table when necessary.

[0050] Optionally, before rebuilding the valid data distribution table, it is first necessary to detect whether the number of free available blocks is lower than a first threshold. If the number of free available blocks is lower than this threshold, some data that is no longer needed should be cleaned up in time to make room for new data. It is also necessary to determine whether the current valid data distribution table reconstruction state machine is in an idle state. If the reconstruction state machine is in a busy state, it means that there is a valid data distribution table being updated, and another valid data distribution table cannot be rebuilt at this time.

[0051] S102: If the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, apply for a first continuous storage space from the built-in storage, where the first continuous storage space is used to store the valid data distribution table.

[0052] In this embodiment, if the solid-state hard disk flash memory has 1000 storage blocks, each storage block has 400 pages (data pages), one page is 16k, and every 4k is a data unit, then the bits in the valid data distribution table required for a storage block are: 400*4=1600 bits, that is, 1600 / 8=200 bytes. In this embodiment, since there is no Dram cache in the Dram-Less solid-state hard disk, a continuous storage space is applied to the built-in storage of the solid-state hard disk controller, and a continuous physical address space is requested to be allocated. This continuous physical address space can store 200 bytes of the valid data distribution table of the storage block. The continuous storage space can ensure that the storage of the valid data distribution table is compact and efficient, reduce the addressing overhead, and improve the access speed during garbage collection.

[0053] In one embodiment, if the number of free available blocks in the solid-state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, a second continuous storage space is applied to the host's memory buffer, and the second continuous storage space is used to store the valid data distribution table.

[0054] In this embodiment, in addition to being stored in the controller cache of the solid-state drive, the valid data distribution table corresponding to the storage block can also be stored in the host memory buffer (Host Memory Buffer, HMB). By utilizing the host memory buffer, the host can provide currently unused memory resources to the solid-state drive through the NVMe (NVM Express) protocol, thereby storing the valid data distribution table corresponding to the storage block in the solid-state drive.

[0055] S103: If the application for the first continuous storage space is successful, an optimal block of the flash memory is obtained as a target block for rebuilding the valid data distribution table.

[0056] It should be noted that: in this embodiment, the optimal block is the storage block with the least valid data, which can improve the speed of rebuilding the valid data table. Selecting the optimal block includes: first, scanning the flash memory of the entire Dram-Less solid-state drive to obtain the valid data volume information of each storage block; comparing the valid data volume of each storage block to find the storage block with the least valid data volume; selecting the storage block with the least valid data volume as the target of rebuilding the current valid data distribution table.

[0057] In one implementation, when the amount of the first continuous storage space exceeds a third threshold, the valid data distribution table temporarily stops being rebuilt.

[0058] In this embodiment, a counter needs to be initialized to record the number of storage blocks for which valid data distribution tables are rebuilt. When the number of continuous storage spaces requested from the solid-state hard disk controller exceeds a third threshold, the third threshold is usually 2 or more. When the threshold is exceeded, in order to avoid occupying too much storage space, the reconstruction of the valid data distribution table is suspended.

[0059] S104: Setting the valid data distribution table reconstruction state machine to a busy state, rebuilding the valid data distribution table of the target block, storing the valid data distribution table in a first continuous storage subspace, and adding the target block to a candidate list for garbage collection.

[0060] In this embodiment, when the effective data distribution table reconstruction state machine starts working, the following steps are included: Read the target block: First, read all physical addresses of all storage blocks from the solid-state hard disk flash memory, and these physical addresses can be provided by the solid-state hard disk controller; Analyze the physical address: For each physical address, parse its corresponding storage block and page information; Query the mapping table: This mapping table records the physical address of each storage block and the corresponding area in the controller cache. Through this mapping table, the controller can quickly find and access the data in the storage block and map it to the corresponding position in the cache; Update the effective data distribution table: Use a bitmap to represent the effective data distribution of each storage block, and map the effective data position of the physical address in the storage block to the corresponding position in the continuous storage subspace. After the reconstruction of the effective data distribution table of the target block is completed, the target block is placed in the garbage collection list and waits for the garbage collection operation.

[0061] Reference Figure 2 In one embodiment, the reconstructing the valid data distribution table corresponding to the target block further includes steps S201-S202:

[0062] S201: If the data written into the flash memory reaches a predetermined data writing amount, wherein the predetermined data writing amount is composed of the data amount written into the flash memory by the host and the garbage collection.

[0063] S202: dividing the task of reconstructing the effective data distribution table into a plurality of subtasks, and reconstructing the corresponding effective data distribution table for each of the subtasks.

[0064] In this embodiment, it is first necessary to calculate whether the data written to the flash memory reaches the predetermined data writing amount. A third-party tool (such as IntelSSDBox) can be used to view the writing amount, that is, the size of the data sent to the target block. A writing amount threshold is set. If the threshold reaches the predetermined data writing amount, the task of rebuilding the valid data distribution table is triggered, and the task is divided into multiple subtasks according to the writing amount, and then the corresponding valid data distribution table is rebuilt for each subtask.

[0065] Reference Figure 3 In one embodiment, the task of reconstructing the effective data distribution table is divided into a plurality of subtasks, and the corresponding effective data distribution table is reconstructed for each of the subtasks, including steps S301-S302:

[0066] Step S301: evenly divide the data writing amount to obtain a plurality of data writing sub-sets.

[0067] Step S302: Reconstructing a corresponding valid data distribution table for each of the subtasks according to each data writing subset.

[0068] In this embodiment, when the data written to the target block reaches a predetermined data writing amount, the data writing amount is evenly divided, which can improve the reconstruction speed of the effective data distribution table. In this embodiment, the data amount is evenly divided using data pages as storage units, and at the same time, an algorithm is used to balance the reconstruction data units and addressing efficiency of the data pages of the target block.

[0069] S105: Detect whether the number of free available blocks in the solid state drive is lower than a second threshold, and determine whether the candidate list where the target block is located is empty, wherein the first threshold is greater than the second threshold;

[0070] In this embodiment, the first threshold value for detecting the number of free blocks is greater than the second threshold value. This design can ensure that the reconstruction of the valid data table is earlier than the garbage collection and removal of the target block; and the candidate list contains at least two target blocks, one of which is the target block for which the valid data table has been reconstructed, and the other is the target block for which the valid data table is being reconstructed, which requires occupying two storage resources of the solid-state hard disk storage space.

[0071] S106: If the candidate list is not empty, select the best block from the candidate list as the garbage collection source block, obtain the target valid data distribution table corresponding to the garbage collection source block, and start the garbage collection process.

[0072] In this embodiment, the optimal block is the target block with the least amount of valid data. The target block requires less time and resources to rebuild the valid data distribution table, which can improve the reconstruction efficiency. This is used as the source block for garbage collection. The target valid data distribution table corresponding to the source block is selected from the built-in storage of the controller, and the garbage collection process is started. It should be noted that during the garbage collection process, it is necessary to ensure that all access to the selected garbage collection source block is stopped to avoid data corruption or inconsistency.

[0073] In one embodiment, the garbage collection process includes: traversing the target valid data distribution table to perform garbage collection migration; when the garbage collection source block completes the garbage collection migration, releasing the first continuous storage subspace corresponding to the target valid data distribution table.

[0074] In this embodiment, it is first necessary to scan the valid data distribution table from beginning to end, record all positions marked as 1 (i.e., valid data), construct a garbage collection read command and send it to the solid-state drive controller. After the garbage collection read command is completed, check again whether the corresponding position in the valid data table is 1, add the valid data to the garbage collection write list, and when the data amount of a write unit is reached, construct a garbage collection write command and send it to the solid-state drive controller, and allocate a new storage block in the flash memory to store this data; after traversing all valid data distribution tables of the storage block until all data are moved, the continuous storage space where the target data distribution table is located can be released.

[0075] In one implementation, the amount of reconstructed valid data is counted, and if the amount of valid data reaches a fourth threshold, the reconstruction of the target block is directly completed, wherein the amount of valid data is all valid data of the target block.

[0076] In this embodiment, the valid data of each storage block is known, and the fourth threshold is set to the known amount of data of the target block. When the amount of reconstructed valid data reaches the fourth threshold, the reconstruction of the target block is completed, and there is no need to search for other data in the target block and mark the valid bitmap.

[0077] The solid-state hard disk garbage collection method provided in the present embodiment detects whether the number of free available blocks in the solid-state hard disk is lower than a first threshold value, and determines whether the valid data distribution table reconstruction state machine is in an idle state; if the number of free available blocks in the solid-state hard disk is lower than the first threshold value and the valid data distribution table reconstruction state machine is in an idle state, then apply for a first continuous storage space from the storage space, and the first continuous storage space is used to store the valid data distribution table; if the first continuous storage space application is successful, obtain the optimal block of the flash memory as the target block for reconstruction of the valid data distribution table; set the valid data distribution table reconstruction state machine to a busy state, rebuild the valid data distribution table of the target block, store the valid data distribution table in the first continuous storage space, and add the target block to a candidate list for garbage collection; detect whether the number of free available blocks in the solid-state hard disk is lower than a second threshold value, and determine whether the candidate list where the target block is located is empty, wherein the first threshold value is greater than the second threshold value; if the candidate list is not empty, select the optimal block from the candidate list as the garbage collection source block, obtain the target valid data distribution table corresponding to the garbage collection source block, and start the garbage collection process. By adding pre-reconstruction of the effective data distribution table and controlling the reconstruction granularity, garbage collection only needs to complete the effective data migration according to the reconstructed effective data distribution table, which greatly improves the garbage collection efficiency.

[0078] Example 2

[0079] In addition, an embodiment of the present application provides a solid state drive garbage collection device, which is applied to electronic equipment.

[0080] like Figure 4 As shown, the solid state drive garbage collection device 400 includes:

[0081] The first checking module 401 is used to detect whether the number of free available blocks in the solid state drive is lower than a first threshold, and to determine whether the valid data distribution table reconstruction state machine is in an idle state.

[0082] The application module 402 is used to apply for a first continuous storage space from the storage space if the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state. The first continuous storage space is used to store the valid data distribution table.

[0083] The reconstruction module 403 is used to obtain the optimal block of the flash memory as the target block for reconstruction of the valid data distribution table if the application for the first continuous storage space is successful; set the valid data distribution table reconstruction state machine to a busy state, rebuild the valid data distribution table of the target block, store the valid data distribution table in the first continuous storage space, and add the target block to a candidate list for garbage collection.

[0084] The second checking module 404 is used to detect whether the number of free available blocks in the solid state drive is lower than a second threshold, and to determine whether the candidate list where the target block is located is empty, wherein the first threshold is greater than the second threshold.

[0085] The garbage collection module 405 is used to select the best block from the candidate list as the garbage collection source block if the candidate list is not empty, obtain the target valid data distribution table corresponding to the garbage collection source block, and start the garbage collection process.

[0086] Optionally, the garbage collection module 405 is further used to traverse the target valid data distribution table and perform garbage collection migration; when the garbage collection source block completes the garbage collection migration, the first continuous storage space corresponding to the target valid data distribution table is released.

[0087] Optionally, the reconstruction module 403 is also used to divide the reconstruction task of the valid data distribution table into multiple subtasks if the data written into the target block reaches a predetermined data write amount, wherein the predetermined data write amount is composed of the amount of data written into the flash memory by the host and the garbage collection; and reconstruct the corresponding valid data distribution table for each subtask.

[0088] Optionally, the reconstruction module 403 is further used to evenly divide the predetermined data writing amount to obtain a plurality of data unit subsets; and reconstruct a corresponding valid data distribution table for each of the subtasks according to each data unit subset.

[0089] Optionally, the application module 402 is also used to apply for a second continuous storage space from the host's memory buffer if the number of free available blocks in the solid-state hard disk is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, and the second continuous storage space is used to store the valid data distribution table.

[0090] Optionally, the reconstruction module 403 is further used to determine whether to temporarily stop rebuilding the valid data distribution table when the amount of the first continuous storage space exceeds a third threshold.

[0091] Optionally, the garbage collection module 405 is further used to count the amount of valid data that has been reconstructed, and if the amount of valid data reaches a fourth threshold, directly complete the reconstruction of the target block, wherein the amount of valid data is all valid data of the target block.

[0092] The solid state drive garbage collection device 400 provided in this embodiment can implement the solid state drive garbage collection method provided in Embodiment 1, and will not be described again here to avoid repetition.

[0093] The device for garbage collection of a solid-state hard disk provided in the present embodiment detects whether the number of free available blocks in the solid-state hard disk is lower than a first threshold value, and determines whether a valid data distribution table reconstruction state machine is in an idle state; if the number of free available blocks in the solid-state hard disk is lower than the first threshold value and the valid data distribution table reconstruction state machine is in an idle state, then a first continuous storage space is applied to the storage space, and the first continuous storage space is used to store a valid data distribution table; if the application for the first continuous storage space is successful, the optimal block of the flash memory is obtained as a target block for reconstruction of the valid data distribution table; the valid data distribution table reconstruction state machine is set to a busy state, the valid data distribution table of the target block is reconstructed, the valid data distribution table is stored in the first continuous storage space, and the target block is added to a candidate list for garbage collection; detects whether the number of free available blocks in the solid-state hard disk is lower than a second threshold value, and determines whether the candidate list where the target block is located is empty, wherein the first threshold value is greater than the second threshold value; if the candidate list is not empty, the optimal block is selected from the candidate list as a garbage collection source block, the target valid data distribution table corresponding to the garbage collection source block is obtained, and the garbage collection process is started. By adding pre-reconstruction of the effective data distribution table and controlling the reconstruction granularity, garbage collection only needs to complete the effective data migration according to the reconstructed effective data distribution table, which greatly improves the garbage collection efficiency.

[0094] Example 3

[0095] In addition, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program runs on the processor, the solid-state hard disk garbage collection method provided in Example 1 is executed.

[0096] The electronic device provided in the embodiment of the present invention can execute the steps of the solid state drive garbage collection method provided in the above method embodiment 1, which will not be described again here to avoid repetition.

[0097] Example 4

[0098] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the solid-state hard disk garbage collection method provided in Example 1 is implemented.

[0099] In this embodiment, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0100] The computer-readable storage medium provided in this embodiment can implement the solid-state hard disk garbage collection method provided in Example 1, and will not be described again here to avoid repetition.

[0101] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.

[0102] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0103] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A solid state hard disk garbage collection method, characterized in that: The solid state drive includes a flash memory and a controller, wherein the controller has a built-in storage space, and the method includes: Detecting whether the number of free available blocks in the solid state drive is lower than a first threshold, and determining whether the valid data distribution table reconstruction state machine is in an idle state; If the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, applying for a first continuous storage space from the storage space, where the first continuous storage space is used to store the valid data distribution table; If the application for the first continuous storage space is successful, obtaining the optimal block of the flash memory as a target block for rebuilding the valid data distribution table; Setting the valid data distribution table reconstruction state machine to a busy state, rebuilding the valid data distribution table of the target block, storing the valid data distribution table in the first continuous storage space, and adding the target block to a candidate list for garbage collection; Detecting whether the number of free available blocks in the solid state drive is lower than a second threshold, and determining whether the candidate list where the target block is located is empty, wherein the first threshold is greater than the second threshold; If the candidate list is not empty, an optimal block is selected from the candidate list as a garbage collection source block, a target valid data distribution table corresponding to the garbage collection source block is obtained, and a garbage collection process is started.

2. The solid state drive garbage collection method according to claim 1, characterized in that: The garbage collection process includes: Traversing the target valid data distribution table to perform garbage collection and removal; When the garbage collection source block completes the garbage collection migration, the first continuous storage space corresponding to the target valid data distribution table is released.

3. The solid state drive garbage collection method according to claim 1, characterized in that: The reconstructing the valid data distribution table corresponding to the target block includes: If the data written to the target block reaches a predetermined data write amount, wherein the predetermined data write amount is composed of the amount of data written to the flash memory by the host and the garbage collection; then the task of rebuilding the valid data distribution table is divided into multiple subtasks, and the corresponding valid data distribution table is rebuilt for each subtask.

4. The solid state drive garbage collection method according to claim 3, characterized in that: The task of reconstructing the effective data distribution table is divided into a plurality of subtasks, and the corresponding effective data distribution table is reconstructed for each of the subtasks, including: Evenly dividing the predetermined data writing amount to obtain a plurality of data unit subsets; A corresponding valid data distribution table is reconstructed for each of the subtasks according to each data unit subset.

5. The solid state drive garbage collection method according to claim 1, characterized in that: The method further comprises: If the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, a second continuous storage space is applied to the host's memory buffer, and the second continuous storage space is used to store the valid data distribution table.

6. The solid state hard disk garbage collection method according to claim 1, characterized in that: The method further comprises: When the amount of the first continuous storage space exceeds a third threshold, the valid data distribution table temporarily stops being rebuilt.

7. The solid state hard disk garbage collection method according to claim 1, characterized in that: The method further comprises: The amount of reconstructed valid data is counted, and if the amount of valid data reaches a fourth threshold, the reconstruction of the target block is directly completed, wherein the amount of valid data is all valid data of the target block.

8. A solid state hard disk garbage collection device, characterized in that: The solid state drive includes a flash memory and a controller, wherein the controller has a built-in storage space, and the device includes: A first checking module is used to detect whether the number of free available blocks in the solid state drive is lower than a first threshold value, and to determine whether the valid data distribution table reconstruction state machine is in an idle state; an application module, configured to apply for a first continuous storage space from the storage space if the number of free available blocks in the solid state drive is lower than a first threshold and the valid data distribution table reconstruction state machine is in an idle state, wherein the first continuous storage space is used to store the valid data distribution table; A reconstruction module, configured to, if the application for the first continuous storage space is successful, obtain the optimal block of the flash memory as the target block for reconstruction of the valid data distribution table; set the valid data distribution table reconstruction state machine to a busy state, rebuild the valid data distribution table of the target block, store the valid data distribution table in the first continuous storage space, and add the target block to a candidate list for garbage collection; A second checking module is used to detect whether the number of free available blocks in the solid state drive is lower than a second threshold, and to determine whether the candidate list where the target block is located is empty, wherein the first threshold is greater than the second threshold; The garbage collection module is used to select the best block from the candidate list as the garbage collection source block if the candidate list is not empty, obtain the target valid data distribution table corresponding to the garbage collection source block, and start the garbage collection process.

9. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is run by the processor, the solid state drive garbage collection method according to any one of claims 1 to 7 is executed.

10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when running on a processor, executes the solid state hard disk garbage collection method described in any one of claims 1 to 7.

Citation Information

Cited By

  • Garbage recycling method, device and equipment suitable for FDP and medium

    CN120123259A

  • Hard disk garbage collection method and device, electronic equipment and storage medium

    CN120144067A