WO2023082252A1 - Garbage collection method, and memory and memory management apparatus - Google Patents

Garbage collection method, and memory and memory management apparatus Download PDF

Info

Publication number
WO2023082252A1
WO2023082252A1 PCT/CN2021/130653 CN2021130653W WO2023082252A1 WO 2023082252 A1 WO2023082252 A1 WO 2023082252A1 CN 2021130653 W CN2021130653 W CN 2021130653W WO 2023082252 A1 WO2023082252 A1 WO 2023082252A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage area
physical storage
logical
physical
memory controller
Prior art date
Application number
PCT/CN2021/130653
Other languages
French (fr)
Chinese (zh)
Inventor
黄恩走
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2021/130653 priority Critical patent/WO2023082252A1/en
Publication of WO2023082252A1 publication Critical patent/WO2023082252A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation

Definitions

  • the present application relates to the technical field of storage, and in particular to a garbage collection method, a memory and a memory management device.
  • the memory is mainly composed of a memory controller and a storage unit that provides physical storage space.
  • the physical storage space is generally mapped to the virtual storage space.
  • the physical storage space can be divided into multiple physical blocks (physical block), and the virtual storage space can also be divided into many logical blocks (logical block).
  • the following uses a solid state disk (SSD) as an example for illustration.
  • the memory controller in the SSD can perform space management on the physical storage space in the storage unit.
  • the memory controller can not only use the flash translation layer (flash translation layer, FTL) to perform logical block address (logical block address, LBA) in the logical storage space and physical block address (physical block address, PBA) in the physical storage space
  • flash translation layer flash translation layer
  • LBA logical block address
  • PBA physical block address
  • the mapping and conversion between them can also perform garbage collection GC (garbage collection, GC) operations.
  • DSS distributed storage system
  • a distributed storage system can write data to SSD through append write mode, so as to realize the purposes of snapshot and exception handling, and also improve the performance of SSD.
  • DSS can also use FTL technology or other technologies similar to FTL technology to map and convert between DSS effective storage space and SSD LBA.
  • the DSS is also designed with a GC function for the logical storage space of the SSD, which is executed by the storage management device.
  • the basic unit of GC operation is a storage block.
  • SSD When SSD performs GC operation, it will move valid data in one physical block to other physical blocks, that is, every time GC operation is performed, SSD will transfer valid data in the physical storage area corresponding to GC operation to other physical blocks in the Flash medium. Re-persistent writing on the physical storage area consumes the P/E times in the Flash medium, thereby reducing the write performance presented by the SSD to the storage management device.
  • WAF write amplification factor
  • the industry uses the write amplification factor (WAF) to measure the impact of the same valid data being persistently stored multiple times on the Flash medium.
  • WAF is a numerical value, which is a ratio obtained by dividing the amount of data written into the Flash medium by the memory controller in the SSD by the amount of data written into the SSD by the memory management device.
  • the more times valid data is persistently stored on the Flash medium the greater the WAF of the SSD; that is, the greater the amount of valid data moved by GC operations inside the SSD, the greater the WAF of the SSD, and the lower the efficiency of SSD GC operations.
  • the performance presented by SSD to DSS especially the write performance, is also lower.
  • the DSS when the DSS performs GC operations, the DSS itself also has a WAF value; the WAF value of the DSS will reduce the write performance presented to the upper-layer application.
  • the WAF values of the SSD and the DSS when both the DSS and the SSD perform GC operations, the WAF values of the SSD and the DSS will reduce the write performance presented by the SSD to the storage management device.
  • the present application provides a garbage collection method, a memory and a memory management device, which are used to improve the efficiency of the memory controller to perform GC operations to ensure the performance of the memory when the memory management device and the GC function of the memory are superimposed.
  • a garbage collection method which is applied to a memory controller, and the method includes:
  • the logical storage The space is obtained by mapping the physical storage space managed by the memory controller; then, mapping the first logical storage area to at least one first physical storage area in the physical storage space; in the physical storage space, determining A plurality of second physical storage areas that need to perform a second GC operation; when it is determined that there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas, from the plurality of second physical storage areas Determine at least one second physical storage area to be selected; there is no intersection between the at least one second physical storage area to be selected and the at least one first physical storage area; and in the at least one second physical storage area to be selected Determine the first target physical storage area where the memory controller performs the second GC operation.
  • the memory controller After the memory controller receives the first GC information, it determines the first logical storage area where the processor needs to perform the first GC operation according to the received first GC information; then, the memory controller sets the first The logical storage area is mapped to at least one first physical storage area, wherein the first valid data located in the first logical storage area is stored in the at least one first physical storage area in the physical storage space. After determining the plurality of second physical storage areas, the memory controller determines whether the second physical storage area stores the second physical storage area by judging whether there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas. A valid data, and then it can be determined whether the second physical storage area is affected by the processor's first GC operation.
  • At least one first physical storage area intersects with multiple second physical storage areas, it means that the second GC operation of the memory controller is affected by the first GC operation.
  • Select at least one candidate second physical storage area that does not overlap with the first physical storage area in the area and determine the first target physical storage area for the memory controller to perform the second GC operation from the at least one candidate second physical storage area Storage area, to reduce the impact of the first GC operation on the second GC operation performed by the memory controller; and, when the processor performs the first GC operation on the first logical storage area, the processor moves the first valid data so that the physical The storage area of the corresponding first valid data stored in the storage space changes, so as to reduce the first valid data stored in the second physical storage area, and reduce the number of valid data that is invalidly moved by the memory controller in subsequent second GC operations. workload, improving the efficiency with which the memory controller performs the second GC operation.
  • the memory controller selects from the plurality of second physical storage areas to affect the At least one candidate second physical storage area whose factor is smaller than the set threshold; wherein, the impact factor of each second physical storage area is used to characterize the first valid data and the second valid data in the second physical storage area The storage space occupied by the intersection of in the second physical storage area.
  • the impact factor represents the influence of the processor executing the first GC operation on the memory controller executing the second GC operation on the second physical storage area.
  • the memory controller determines the impact factor of the processor performing the first GC operation on the first logical storage area on each second physical storage area according to the first valid data and the second valid data, and the memory controller can Determine the degree of influence of the first GC operation on the second physical storage area according to the determined impact factor; the memory controller selects at least one candidate second physical storage area whose impact factor is less than the set threshold from the plurality of second physical storage areas ; Then, the memory controller is made to select the first target physical storage area from at least one second physical storage area to be selected, and at the same time, the second physical storage area whose impact factor is greater than or equal to the set threshold is put behind for processing, On the basis of minimizing the workload of invalidly moving valid data when the memory controller performs the second GC operation, the workload of the memory controller for subsequently executing the second GC operation for invalidly moving valid data can be reduced, thereby improving the subsequent performance of the memory controller. The efficiency of the second GC operation.
  • the memory controller determines at least one third physical storage area that needs to perform the third GC operation in the physical storage space, and maps at least one third physical storage area to the logical storage space at least one second logical storage area; then, sending second GC information to the processor through an information management interface, wherein the second GC information is used to indicate at least one logical storage area that needs to perform a third GC operation.
  • the memory controller sends the second GC information to the processor, so that the processor can determine at least one second logical storage area where the memory controller needs to perform the third GC operation according to the received second GC information, and Applying the determined at least one second logical storage area to the process of the processor determining the first target logical storage area for performing the fourth GC operation, so that when the processor performs the fourth GC operation on the first target logical storage area, it can Reduce the valid data stored in the third physical storage area by processing the valid data located in the first target logical storage area, and reduce the workload of invalidly moving valid data when the memory controller performs the third GC operation on the third physical storage area , improving the efficiency of the subsequent third GC operation on the third physical storage area, so as to achieve the purpose of ensuring memory performance.
  • a garbage collection method which is applied to a processor, and the method includes:
  • the logical storage space determine the first logical storage area that needs to perform the first GC operation; wherein, the logical storage space is obtained by mapping the physical storage space managed by the memory controller; then, report to the memory controller through the information management interface Sending first GC information; wherein, the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation.
  • the memory controller makes the first GC information from the memory controller according to the received first GC information.
  • the second physical storage area where there is no intersection of the first logical storage area, determine the first target physical storage area for performing the second GC operation, so as to reduce the memory control of the processor when performing the first GC operation on the first logical storage area
  • the impact of the memory controller performing the second GC operation on the first target physical storage area, and reducing the workload of invalidly moving valid data when the memory controller performs the second GC operation on the first target physical storage area, and improving the memory controller's execution of the second GC operation The efficiency of GC operation, so as to achieve the purpose of guaranteeing memory performance.
  • the processor receives the second GC information sent by the memory controller through the information management interface; where the second GC information is used to indicate that the memory controller needs to perform the first GC on the physical storage space At least one second logical storage area obtained by mapping the third physical storage area of the three GC operations in the logical storage space; and, in the logical storage space, the processor determines that a plurality of second logical storage areas that need to perform the fourth GC operation Three logical storage areas; then, when there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, the third logical storage area to be selected from at least one of the plurality of third logical storage areas In the storage area, select the first target logical storage area where the processor performs the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
  • the processor determines at least one second logical storage area mapped in the logical storage space by the third physical storage area where the memory controller performs the third GC operation, and determines that it needs to execute A plurality of third logical storage areas operated by the fourth GC, and by judging whether there is an intersection between at least one second logical storage area and a plurality of third logical storage areas, it is determined whether the processor performs a fourth GC operation on the third logical storage area It will affect the execution of the third GC operation on the third physical storage area by the memory controller.
  • the selection processor executes a fourth GC
  • the first target logical storage area of the operation can enable the processor to reduce the amount stored in the third physical storage area by processing the valid data in the first target logical storage area when performing the fourth GC operation on the first target logical storage area. valid data, thereby reducing the workload of the memory controller for invalidly moving valid data when performing the third GC operation on the third physical storage area, improving the execution efficiency of the memory controller performing the third GC operation, and achieving the purpose of ensuring memory performance.
  • the processor selects the first target logical storage area with the largest invalid ratio among the at least one third logical storage area to be selected; wherein, each third logical storage area to be selected
  • the invalid ratio is a ratio of invalid data in the third logical storage area to be selected to the storage space of the third logical storage area to be selected.
  • the processor selects the first target logical storage area with the largest invalid ratio among at least one third logical storage area to be selected, which can ensure the execution efficiency of the processor when executing the fourth GC operation.
  • a memory in a third aspect, includes: a memory controller and a storage unit; the memory controller is used for:
  • the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • At least one candidate second physical storage area is determined from the plurality of second physical storage areas; the at least one There is no intersection between the second physical storage area to be selected and the at least one first physical storage area;
  • a first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one second physical storage area to be selected.
  • the memory controller is also used for:
  • a memory management device in a fourth aspect, includes: a processor and an information management interface; the processor is used for:
  • the logical storage space determine the first logical storage area that needs to perform the first GC operation; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • first GC information is used to indicate a first logical storage area where the processor needs to perform a first GC operation.
  • the processor is also used for:
  • the processor executes the first target logical storage area of the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
  • a garbage collection device is provided, and the garbage collection device is applied to a memory controller in a memory; the device includes:
  • the transmission module is configured to receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first logic of the first GC operation on the logical storage space storage area; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • mapping module configured to map the first logical storage area to at least one first physical storage area in the physical storage space
  • a determining module configured to determine a plurality of second physical storage areas that need to perform a second GC operation in the physical storage space; when there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas , determining at least one second physical storage area to be selected from the plurality of second physical storage areas; there is no intersection between the at least one second physical storage area to be selected and the at least one first physical storage area; Determine the first target physical storage area where the memory controller executes the second GC operation in the at least one second physical storage area to be selected.
  • the determining module is specifically configured to: in the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
  • the mapping module is specifically configured to: map the at least one third physical storage area to at least one second logical storage area in the logical storage space;
  • the transmission module is specifically configured to: send second GC information to the processor through the information management interface; wherein the second GC information is used to indicate the at least one first GC that needs to perform the third GC operation.
  • a garbage collection device is provided, the garbage collection device is applied to a processor; the device includes:
  • the processing module is configured to determine the first logical storage area that needs to perform the first GC operation in the logical storage space; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • a transmission module configured to send first GC information to the memory controller through the information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation .
  • the transmission module is specifically configured to: receive second GC information from the memory controller through the information management interface; where the second GC information is used to indicate that the memory controller At least one second logical storage area obtained by mapping the third physical storage area in the logical storage space where the controller needs to perform the third GC operation on the physical storage space;
  • the processing module is specifically configured to: in the logical storage space, determine a plurality of third logical storage areas that need to perform the fourth GC operation; when the at least one second logical storage area and the plurality of third logical storage areas When there is an intersection of the storage areas, selecting the first target logical storage area for the processor to perform the fourth GC operation from at least one candidate third logical storage area among the plurality of third logical storage areas; wherein , there is an intersection between the at least one candidate third logical storage area and the at least one second logical storage area.
  • the present application provides a computer-readable storage medium, on which a computer program or instruction is stored, and when the computer program or instruction is executed, the computer can execute any one of the above-mentioned first aspect or the first aspect.
  • the present application provides a computer program product.
  • the computer executes the computer program product, the computer is made to execute the method in the above-mentioned first aspect or any possible implementation manner of the first aspect, or the computer is made to execute the above-mentioned first aspect.
  • beneficial effects of the third aspect and the fifth aspect please refer to the description of the above-mentioned beneficial effects of the first aspect
  • beneficial effects of the fourth and sixth aspects please refer to the description of the above-mentioned beneficial effects of the second aspect. Repeat it again.
  • FIG. 1 is a schematic structural diagram of a possible storage system of the solution provided by the embodiment of the present application;
  • FIG. 2 is a schematic structural diagram of another possible storage system of the solution provided by the embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of another possible storage system of the solution provided by the embodiment of the present application.
  • FIG. 4 is a schematic diagram of a possible garbage collection method of the solution provided by the embodiment of the present application.
  • FIG. 5 is a schematic diagram of a possible garbage collection method of the solution provided by the embodiment of the present application.
  • FIG. 6 is a schematic diagram of a possible memory controller management queue of the solution provided by the embodiment of the present application.
  • FIG. 7 is a schematic diagram of a possible storage space of the solution provided by the embodiment of the present application.
  • FIG. 8 is a schematic diagram of another possible storage space of the solution provided by the embodiment of the present application.
  • FIG. 9 is a schematic flowchart of a possible garbage collection method of the solution provided by the embodiment of the present application.
  • FIG. 10 is a schematic diagram of another possible management queue of the solution provided by the embodiment of the present application.
  • FIG. 11 is a schematic flowchart of another possible garbage collection method of the solution provided by the embodiment of the present application.
  • FIG. 12 is a schematic diagram of an interaction process of a possible garbage collection method of the solution provided by the embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of a memory management device according to the solution provided by the embodiment of the present application.
  • Fig. 14 is a schematic structural diagram of a garbage collection device according to the solution provided by the embodiment of the present application.
  • Fig. 15 is a schematic structural diagram of another garbage collection device according to the solution provided by the embodiment of the present application.
  • Embodiments of the present application provide a garbage collection method, a memory, and a memory management device.
  • the method, the memory, and the memory management device are based on the same idea. Since the method, the memory, and the memory management device have similar problem-solving principles, the implementation of the memory, the memory management device, and the method can be referred to each other, and repeated descriptions will not be repeated.
  • the memory is composed of a memory controller and a storage unit of non-volatile medium particles such as Flash.
  • the storage unit provides physical storage space for the memory, and the storage unit includes many storage blocks (block), and the block includes many storage pages (page).
  • the current storage includes: SSD, shingled magnetic recording hard disk drive (SMR HDD) and other storage devices with GC functions similar to SSD.
  • SSD is a hard disk made of solid-state electronic memory chip arrays, also known as solid-state drives.
  • An SSD generally includes at least two parts, a memory controller and a storage array, and the memory controller can be used to control the storage array.
  • the storage array is composed of storage units that provide physical storage space, and are used to provide the storage area of the SSD and can store data.
  • a storage unit consists of multiple blocks. Wherein, the block may be a flash memory (flash), and the following uses a flash memory as an example for description.
  • the storage array usually includes dozens, hundreds or even thousands of flash memories, each flash memory can include hundreds to thousands of flash memory blocks, and each flash memory block can include thousands of flash memory pages .
  • Flash memory has three basic operations: read, write, and erase. Among them, the operation granularity of read operation and write operation is a flash memory page, and the operation granularity of erase operation is a flash memory block. Therefore, flash memory has remote update and asymmetric read/write erase. Latency characteristics.
  • the memory controller in the SSD can perform space management on the physical storage space in the storage unit.
  • the memory controller can not only use the FTL mapping table in the FTL to map and convert between the LBA in the logical storage space and the PBA in the physical storage space, but also perform GC operations to ensure the performance of the SSD.
  • the FTL mapping table is an address translation table, which is used to indicate the mapping relationship between the LBA in the logical storage space and the PBA in the physical storage space.
  • LBA is the logical block address generated by the system for data before writing to the block
  • PBA is the physical block address after writing to the block.
  • the data processing request is a read request (for requesting a read operation), the data of the corresponding PBA in the block is read out; if the data processing request is a write request (for requesting to perform a write operation), and the write operation If it is the first time to write a certain data, then write the data into the blank PBA in the storage block; The PBA corresponding to the data in the storage block is invalid, and the updated data corresponding to the data is written into the blank PBA in the storage block, and then the corresponding address mapping relationship in the FTL mapping table is updated to complete the operation. If the data processing request is an erase request (for requesting to perform an erase operation), delete the data of the corresponding physical address in the storage block, and delete the corresponding address mapping relationship in the FTL mapping table.
  • an erase request for requesting to perform an erase operation
  • GC operation is the operation of reclaiming the used space when the available storage space (blank storage space or free storage space) in the storage space is small, and its specific operation includes: reading the valid data in the selected storage block to be reclaimed And migrate it into the target storage block in the available storage space, and then erase all the data in the storage block to be reclaimed, so as to reclaim the storage space corresponding to the storage block through GC operation.
  • the storage system is mainly composed of a memory and a processor, wherein the number of the memory and the processor is not limited.
  • the storage system is a detachable storage system, for example, DSS.
  • the DSS consists of a management device and multiple storage servers; the storage server is used to store data, and the management device is used to manage the storage servers.
  • the management device in the DSS is equivalent to the processor in the storage system, and any storage server is equivalent to the memory.
  • IO input/output
  • IO request refers to other devices (such as processors) issued to the memory to instruct the memory controller to perform data processing Action request.
  • the IO request may include at least one of a read request, a write request, and an erase request.
  • the IO operation refers to the process in which the SSD executes the corresponding operation according to the received IO request, which is the operation performed by the SSD when responding to the IO request.
  • the IO operation may include at least one of a read operation, a write operation, and an erase operation.
  • the information management interface refers to the interface located in the memory and the processor, and is used to transmit GC information. Wherein, the information management interface may be an interface in a physical sense, or an interface in a logical sense.
  • the I/O interface refers to the interface located in the memory and the processor, and is used to transmit IO requests.
  • the storage space is divided into physical storage space and logical storage space.
  • the physical storage space refers to the space in which the data provided by the storage unit in the memory is actually stored.
  • the logical storage space refers to the storage space mapped to the outside of the physical storage space, which is controlled by the processor.
  • the processor can manage the physical storage space by managing the logical storage space.
  • the storage area refers to the basic unit for performing GC operations in the storage space, that is, the storage block.
  • the invalid ratio refers to the ratio of invalid data in the storage area to the storage space of the storage area.
  • the storage space is divided into physical storage space and logical storage space, for the convenience of distinction, in the embodiment of the present application, the storage blocks in the physical storage space may be called physical blocks, and the storage blocks in the logical storage space may be called logical blocks .
  • the valid data in the storage block corresponding to the GC operation will be moved to other storage blocks.
  • description will be made by taking the storage as an SSD and the storage management device as a DSS as an example.
  • an SSD performs a GC operation, it moves the valid data in the physical storage area corresponding to the GC operation to other physical storage areas.
  • the WAF of the SSD is larger, and the efficiency of the SSD to perform GC operations is higher. If the value is low, the write performance presented by the SSD is poor; and, when the DSS also performs GC operations, the WAF value of the DSS itself will reduce the write performance presented by the SSD to the upper-layer application.
  • the performance of the memory may be affected.
  • an embodiment of the present application provides a garbage collection method, which is applied to a memory management device and a memory, and the memory is capable of performing GC operations and IO operations.
  • the processor in the memory management device and the first device in the memory can transmit GC information to the second device through an information management interface, wherein the GC information is used to indicate the storage area where the first device performs GC operations; the second The second device determines the storage area for the next GC operation according to the received GC information, thereby reducing the amount of invalid data transfer when the memory controller performs GC operations, thereby improving the efficiency of the memory controller to perform GC operations, and finally ensuring that the memory performance.
  • FIG. 1 is a schematic structural diagram of a possible storage system to which the solution provided by the embodiment of the present application is applicable. As shown in Figure 1, the system includes at least a memory, a processor and an information management interface.
  • the memory includes a memory controller and a storage unit, the memory controller is used to control the memory, and the storage unit is used to provide a physical storage space of the memory.
  • the storage may be SSD or other storage devices.
  • the storage system may be an inseparable storage system.
  • the processor and the memory are located in the same electronic device, and the entire storage system is located in the electronic device.
  • the storage system may also be a detachable storage system, for example, DSS.
  • the processor may be a host, and the storage may be an SSD, that is, the processor and the storage may be located in different devices.
  • the processor and the memory can communicate through the information management interface and transmit GC information.
  • the processor can send GC information to the memory through the information management interface to perform some control on the memory.
  • the memory can also pass information
  • the management interface responds to GC messages from the processor.
  • the memory controller in the memory may further include an information parsing module, an information management interface and an FTL module, as shown in FIG. 1 .
  • the FTL module may further include an address conversion module and a GC module.
  • the information management interface can be used to transfer GC information.
  • the information analysis module can be used to analyze GC information, and can also be used to send the analysis result to the address translation module in the FTL module; the address translation module can be used to perform address translation on LBA and PBA.
  • the GC module is used to determine the target physical storage area for performing GC operation next time according to the received GC information, and perform GC operation on the target physical storage area.
  • the storage unit is the physical carrier for the final storage of data.
  • the storage unit may be non-volatile medium particles such as Flash, and the Flash includes many blocks.
  • the processor may further include a GC module.
  • the GC module can be used to determine the logical storage area to perform GC operation next time, perform GC operation on the logical storage area, and generate GC information for indicating the logical storage area to perform GC operation.
  • the logical storage space controlled by the processor is obtained by externally mapping the physical storage space controlled by the memory controller.
  • the processor controls the physical storage space by controlling the logical storage space.
  • the LBA of the logical storage area is determined through the information parsing module.
  • the memory controller converts the LBA into the PBA through the address translation table in the address translation module.
  • the address translation table is used to represent the mapping relationship between the LBA in the logical storage space and the PBA in the physical storage space.
  • the processor determines the first logical storage area that needs to perform the first GC operation through the GC module, and obtains the first GC information; the processor sends the first GC information to the memory controller through the information management interface.
  • the memory controller After the memory controller receives the first GC information through the information management interface, it can analyze the first GC information through the information analysis module to obtain the first physical storage area. Then, the memory controller determines the first target physical storage area where the memory controller performs the second GC operation next time according to the first physical storage area through the GC module.
  • the information management interface may exist in a logical form or in a physical form.
  • the information management interface may be a transmission line between the processor and the memory, connecting the memory and the processor so that the memory and the processor can communicate through the information management interface.
  • FIG. 2 is a schematic structural diagram of another possible storage system to which the solution provided by the embodiment of the present application is applicable.
  • the system at least includes a memory, a processor and an information management interface.
  • the memory is the same as that in FIG. 1 , and will not be repeated here.
  • the memory controller may include an FTL module.
  • the FTL module may further include an address translation module and a GC module; the address translation module may be used to perform address translation on the LBA and the PBA.
  • the GC module is used to determine the physical storage area to perform GC operation next time, perform GC operation on the physical storage area, and generate GC information for indicating the physical storage area to perform GC operation.
  • the processor may include an information parsing module and a GC module.
  • the information analysis module can be used to analyze the received GC information, and can also be used to send the analysis result to the GC module.
  • the GC module can be used to determine the logical storage area for performing GC operation next time according to the received parsing result, and perform GC operation on the logical storage area.
  • the memory controller determines at least one third physical storage area that needs to perform the third GC operation in the physical storage space through the GC module.
  • the memory controller maps at least one third physical storage area to at least one second logical storage area in the logical storage space through the address translation module.
  • the memory controller obtains second GC information indicating at least one second logical storage area based on the GC module, and sends the second GC information to the processor through the information management interface.
  • the processor receives the second GC information through the information management interface, and analyzes the second GC information through the information analysis module to obtain at least one second logical storage area.
  • the processor determines the first target logical storage area for the processor to perform the fourth GC operation next time according to the at least one second logical storage area through the GC module.
  • FIG. 3 is a schematic structural diagram of another possible storage system to which the solution provided by the embodiment of the present application is applicable.
  • the system at least includes a memory, a processor and an information management interface.
  • the memory is the same as the memory shown in FIG. 1
  • the processor is the same as the processor shown in FIG. 2 , which will not be repeated here.
  • the processor may generate the first GC information through the GC module, and send the first GC information to the memory controller through the information management interface.
  • the memory controller parses the first GC information through the information parsing module to obtain the first logical storage area.
  • the memory controller determines the first target physical storage area according to the first logical storage area through the GC module.
  • the memory controller may generate the second GC information through the GC module, and send the second GC information to the processor through the information management interface.
  • the processor parses the second GC information through the information parsing module to obtain the second logical storage area.
  • the processor determines the first target logical storage area according to the second logical storage area through the GC module.
  • FIGS. 1-3 are only exemplary descriptions of storage systems applicable to the solution of this application, and do not limit the system architecture applicable to the solution of this application.
  • Other devices or modules may also be added to the above system architecture, or some devices or modules may be reduced or modified.
  • FIG. 4 is a schematic diagram of a garbage collection method provided by an embodiment of the present application, which can be applied to the processor in the storage system as shown in FIG. 1 , and can also be applied to the processor in the storage system as shown in FIG. 3 .
  • the method includes:
  • S401 In a logical storage space, determine a first logical storage area that needs to perform a first GC operation.
  • the logical storage space is obtained by mapping the physical storage space managed by the memory.
  • the processor determines the first logical storage area that needs to perform the first GC operation according to the logical garbage collection strategy.
  • the logical garbage collection policy may be pre-configured.
  • the processor determines a logical storage area satisfying the logical garbage collection policy as the first logical storage area.
  • the logical garbage collection strategy may be that the invalid data or garbage data in the logical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
  • the number of first logical storage areas that need to perform the first GC operation determined by the processor may be multiple, or may be one.
  • S402 Send the first GC information to the memory controller through the information management interface.
  • the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation, that is, before executing S402, the processor has not performed the first GC operation on the first logical storage area. GC operation.
  • the processor determines at least one first logical storage area that needs to perform the first GC operation, select the first logical storage area from the at least one first logical storage area; and according to the description information of the selected first logical storage area , to determine the first GC information.
  • the first GC information includes, but is not limited to: description information of valid data in the first logical storage area, and an execution sequence number of the first logical storage area.
  • the format of the first GC information is a format supported by the information management interface.
  • the description information of the valid data is used to describe the LBA and the LBA length of the valid data.
  • the description information of valid data may be ⁇ start address, length ⁇ , such as: ⁇ 0x10000, 32KB ⁇ , ⁇ (0x40000000, 256KB), (0x40100000, 256KB) ⁇ .
  • the processor may send the first GC information to the memory controller through the information management interface.
  • the memory controller After the memory controller receives the first GC information through the information management interface, according to the first GC information, determine the first target physical storage area where the memory controller performs the second GC operation.
  • a garbage collection method provided in the embodiment of the present application can be applied to the memory controller in the storage system as shown in FIG. 1 , and can also be applied to the memory controller in the storage system as shown in FIG. 3 controller. As shown in Figure 5, the method includes:
  • S501 Receive first GC information sent by a processor through an information management interface.
  • the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation on the logical storage space.
  • S502 Map the first logical storage area to at least one first physical storage area in the physical storage space.
  • the memory controller After receiving the first GC information, the memory controller analyzes the first GC information; and determines the first logical storage area according to the analysis result.
  • the parsing result includes, but is not limited to: the LBA of the first valid data located in the first logical storage area (hereinafter may be referred to as the first LBA for short), and the LBA length.
  • the memory controller may map the first LBA to the first PBA according to the mapping relationship between the LBA and the PBA, and finally use the physical storage area corresponding to the first PBA as the first LBA.
  • a physical storage area may be used.
  • S503 In the physical storage space, determine multiple second physical storage areas that need to perform the second GC operation.
  • the memory controller may determine multiple second physical storage areas in the physical storage space according to a preconfigured physical garbage collection policy.
  • the physical garbage collection strategy may be that the invalid data or garbage data stored in the physical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
  • the memory controller may add the multiple second physical storage areas to the management queue.
  • the second physical storage area in the management queue can be sorted according to the size of the invalid ratio.
  • the memory controller may sort the multiple second physical storage areas according to the size of the invalid ratio from large to small. For another example, when the memory controller sorts the multiple second physical storage areas in the management queue, it may sort the invalid ratios from small to large.
  • the embodiments of the present application include but are not limited to determining the second physical storage area in the above manner, and the memory controller may also determine in other manners, which will not be listed here.
  • the data in the physical storage space is finally processed. Therefore, if there is an intersection between the data processed by the first GC operation and the data processed by the second GC operation, the first GC operation to be executed by the processor may have an impact on the second GC operation to be executed by the memory controller, That is, performance degradation of the memory may occur due to superposition of GC functions of the memory controller and the processor.
  • step S504 is performed.
  • the memory controller may, but is not limited to, determine the at least one second physical storage area to be selected through the following steps.
  • the memory controller may select from the multiple second physical storage areas that the impact factor is less than the set threshold according to the first valid data located in the first logical storage area and the second valid data stored in the multiple second physical storage areas At least one second physical storage area to be selected.
  • each second physical storage area is used to represent the intersection of the first valid data and the second valid data in the second physical storage area occupied by the second physical storage area storage.
  • the memory controller selects a candidate second physical storage area whose impact factor is smaller than a set threshold among the plurality of second physical storage areas.
  • the second physical storage area whose impact factor is less than the set threshold means that the intersection of the second physical storage area and the valid data stored in the first logical storage area is not high, therefore, the valid data in the second physical storage area is affected by The first GC operation has less impact.
  • the memory controller determines the second physical storage area to be selected, the following operations may be performed for each second physical storage area: the memory controller determines the first PBA of the first valid data, and the The intersection of the second PBAs of the second valid data in the second physical storage area, and use the storage space occupied by the valid data corresponding to the intersection in the second physical storage area as an influencing factor of the second physical storage area.
  • S505 Determine a first target physical storage area where the memory controller performs the second GC operation in the at least one candidate second physical storage area.
  • the memory controller determines a first target physical storage area in at least one second physical storage area to be selected.
  • the second physical storage area to be selected whose impact factor is less than the set threshold indicates that the intersection of the second physical storage area to be selected and the valid data stored in the first logical storage area is not high, therefore, the second physical storage area to be selected Valid data in a region is less affected by the first GC operation. Therefore, when the processor executes the first GC operation on the first logical storage area, the invalidated valid data in the candidate second physical storage area whose impact factor is smaller than the set threshold is less, and the memory controller will use the GC operation on the candidate second physical storage area. The impact on the execution efficiency of the second GC operation performed by the second physical storage area is small.
  • the impact factor of the second physical storage area is greater than or equal to the set threshold, which means that the intersection of the second physical storage area and the valid data stored in the first logical storage area is relatively high, and when the processor compares the first logical storage area When the first GC operation is performed in the second physical storage area, there are more valid data invalidated in the second physical storage area, which greatly affects the execution efficiency of the second GC operation performed by the memory controller in the second physical storage area.
  • the memory controller selects the second physical storage area whose impact factor is less than the set threshold as the first target physical storage area, so that the second physical storage area whose impact factor is greater than or equal to the set threshold is executed later, so that the processor can When performing the first GC operation on the first logical storage area, reduce the effective data in the second physical storage area whose impact factor is greater than or equal to the set threshold, so as to reduce the memory controller's subsequent impact on the impact factor greater than or equal to the set threshold.
  • the workload of moving valid data when performing the second GC operation in the second physical storage area To sum up, it can be seen that determining the first target physical storage area from the candidate second physical storage areas whose impact factor is smaller than the set threshold can reduce the workload of invalidly moving valid data when the memory controller subsequently executes the second GC operation.
  • the memory controller selects at least one candidate second physical storage zone whose impact factor is smaller than a set threshold among the plurality of second physical storage zones, and determines each candidate second physical storage zone in the at least one candidate second physical storage zone. Invalid scale for bucket. Then, the memory controller may, but not limited to, select the first target physical storage area among the plurality of second physical storage areas to be selected according to the invalid ratio of the plurality of second physical storage areas to be selected in the following manner.
  • the memory controller may select the second physical storage area to be selected with the largest invalidation ratio among multiple second physical storage areas to be selected as the first target physical storage area.
  • the invalid proportions of physical storage area 8 and physical storage area 305 are 78% and 70% respectively, and when the impact factors of physical storage area 8 and physical storage area 305 are less than the set threshold, the storage will invalidate the physical storage area with a proportion of 78%.
  • Area 8 serves as the first target physical storage area.
  • the memory controller uses method 1 to determine the first target physical storage area, since it selects the first target physical storage area from multiple candidate second physical storage areas that are less affected by the first GC operation, it can further reduce memory consumption.
  • the controller performs the subsequent second GC operation, it invalidates the workload of moving valid data; and, since the memory controller selects the candidate second physical storage area with the largest invalid ratio as the first target physical storage area, it can be guaranteed that the memory controller is The efficiency with which the second GC operation is performed on the first target physical storage area.
  • the memory controller uses method 1 to determine the first target physical storage area, which can reduce the memory controller’s subsequent execution of the second GC operation while ensuring the efficiency of the memory controller’s execution of the second GC operation on the first target physical storage area. The workload of effectively moving valid data during GC operations.
  • the memory controller may select the second physical storage area to be selected with the second largest invalidation ratio among multiple second physical storage areas to be selected as the first target physical storage area.
  • the invalid ratios of physical block 8, physical block 80, and physical block 305 are 78%, 75%, and 70% respectively, and the memory controller may use physical block 80 with an invalid ratio of 75% as the first target physical storage area.
  • the memory controller uses method 2 to determine the first target physical storage area, since the first target physical storage area is selected from multiple candidate second physical storage areas that are less affected by the first GC operation, the memory can be reduced.
  • the controller invalidates the workload of moving valid data when performing subsequent GC operations; and, since the memory controller selects the candidate second physical storage area with the second largest invalid ratio as the first target physical storage area, it can ensure that the memory Efficiency with which the controller performs the second GC operation on the first target physical storage area.
  • the memory controller adopts method 2 to determine the first target physical storage area, which can reduce the workload of the memory controller to invalidly move valid data when the memory controller subsequently executes the second GC operation, and at the same time ensure that the memory controller is as good as possible. The efficiency with which the second GC operation is performed on the first target physical storage area.
  • the memory controller may select a candidate second physical storage area with a relatively large invalidation ratio and a relatively small impact factor among multiple candidate second physical storage areas as the first target physical storage area.
  • the threshold is set at 5%; the invalid ratios of physical block 8, physical block 80, and physical block 305 are 78%, 75%, and 70% respectively, and the impact factors of physical block 8, physical block 80, and physical block 305 are respectively.
  • the memory controller may use the physical block 80 with an invalid ratio of 75% as the first target physical storage area.
  • the memory controller uses method 3 to determine the first target physical storage area, since it is selected from multiple candidate second physical storage areas that are less affected by the first GC operation, the invalid ratio is relatively large and the impact factor is relatively small.
  • the small second physical storage area to be selected is the first target physical storage area, which can further reduce the memory control workload as much as possible on the basis of reducing the workload of the memory controller to move valid data ineffectively when executing the subsequent second GC operation. While reducing the workload of effectively moving valid data when the memory controller performs the second GC operation on the first target physical storage area, the efficiency of the second GC operation performed by the memory controller on the first target physical storage area is ensured.
  • the memory controller may also, but not limited to The first target physical storage area is selected from the second physical storage area.
  • the remaining second physical storage area is a second physical storage area whose impact factor is greater than or equal to a set threshold.
  • Mode 4 The memory controller selects a second physical storage area with a larger invalidation ratio and a smaller impact factor among the remaining second physical storage areas as the first target physical storage area.
  • the setting threshold is 5%; the second physical storage area 20, the second physical storage area 30, the second physical storage area 40, the second physical storage area 83, the second physical storage area 8, the second physical storage area 305 and the invalid proportions of the second physical storage area 80 are 61%, 62%, 61%, 63%, 80%, 76% and 72% respectively, the second physical storage area 20, the second physical storage area 30, the second physical storage area
  • the influence factors of storage area 40, second physical storage area 83, second physical storage area 8, second physical storage area 80 and second physical storage area 305 are 2%, 4%, 3%, 2%, 9% respectively , 8%, 11%, wherein, the second physical storage area 20, the second physical storage area 30, the second physical storage area 40, the second physical storage area 83 are the second physical storage areas to be selected; when multiple When the invalid proportions of the second physical storage areas are all less than 65%, the memory controller can select the second physical storage area 305 with an invalid proportion of 76% and an impact factor of 8% as the first target physical storage area; the memory controller can
  • the memory controller selects the first target physical storage area from multiple second physical storage areas to be selected, it can properly reduce the subsequent When the second GC operation is performed, the workload of moving valid data is invalid, but because the invalid ratio of the second physical storage area to be selected is relatively small, the memory controller will reduce the workload of moving valid data by a little bit.
  • the first target physical storage area performs the second GC operation, the workload of valid data that needs to be moved increases, resulting in low efficiency of the memory controller performing the second GC operation on the first target physical storage area.
  • the memory controller uses method 4 to determine the first target physical storage area, it will select the remaining second physical storage area with a relatively large invalidation ratio and a relatively small impact factor as the first target physical storage area, thereby ensuring that the memory controller On the basis of the efficiency of performing the second GC operation on the first target physical storage area, the workload of the memory controller for invalidly moving valid data when performing subsequent GC operations is reduced as much as possible.
  • the memory controller may also determine the first target in the plurality of second physical storage areas according to the impact factor of each second physical storage area, but not limited to the following scheme: Physical storage area.
  • the memory controller may use the second physical storage area with the smallest impact factor as the second physical storage area.
  • a target physical storage area, the second physical storage area with the largest invalid ratio can also be used as the first target physical storage area, or the second physical storage area with a larger invalid ratio and a smaller impact factor can be used as the first target physical storage area district.
  • the threshold is set at 5%; the invalid ratios of physical block 8, physical block 305, and physical block 211 are 80%, 76%, and 70% respectively, and the impact factors of physical block 8, physical block 305, and physical block 211 are respectively
  • the memory controller may use the physical block 305 with the smallest impact factor as the first target physical storage area, and may also use the physical block 8 with the largest invalid ratio as the first target. Physical storage area.
  • using the second physical storage area with the smallest impact factor as the first target physical storage area can reduce the work of invalidly moving valid data when the memory controller subsequently executes the second GC operation amount; using the second physical storage area with the largest invalid ratio as the first target physical storage area can ensure the execution efficiency of the second GC operation performed by the memory controller on the first target physical storage area; if the invalid ratio is large, the impact factor is small
  • the second physical storage area as the first target physical storage area can reduce the subsequent execution of the second GC operation by the memory controller as much as possible while ensuring the execution efficiency of the second GC operation performed by the memory controller on the first target physical storage area.
  • the workload of effectively moving valid data is invalid.
  • the embodiments of the present application include but are not limited to determining the first target physical storage area in the above manner, and the memory controller may also determine in other manners, which will not be listed here.
  • the memory controller when the memory controller adds the determined multiple second physical storage areas to the management queue, it may sort the multiple second physical storage areas according to their The size of the influence factor of the physical storage area is sorted. Moreover, after the memory controller determines the first target physical storage area, when performing the second GC operation on the first target physical storage area, the first target physical storage area needs to be deleted from the management queue.
  • the physical block 8, the physical block 305, and the physical block 211 in the management queue 1 determine the second physical storage area for the memory controller, wherein the physical block 8, the physical block 305, and the physical block 211
  • the invalid ratios are 80%, 76% and 70%; wherein, the second physical storage area in the management queue 1 is sorted according to the size of the invalid ratio from large to small.
  • the second physical storage area at the first position is the first target physical storage area for the memory controller to perform the second GC operation next time.
  • the memory controller After receiving the first GC information sent by the processor, the memory controller determines that the first physical storage area obtained by mapping the first logical storage area in the physical storage space is physical block 8; the memory controller determines that a part of the physical block 8 or All valid data will be moved to other physical storage areas by the processor. After the memory controller determines that the influence factor of the physical block 8 is 10% greater than the set threshold, it adjusts the sequence of the physical block 8 , the physical block 305 , and the physical block 211 in the management queue 1 . The memory controller may move the position of the physical block 305 in the management queue 1 to the first position, and obtain the management queue 2 as the first target physical storage area.
  • the memory controller performs the second GC operation on the physical block 305 of the first target physical storage area, and deletes the physical block 305 from the management queue 2; after the memory controller completes the second GC operation on the physical block 305, the processor also The first GC operation on the first logical storage area previously sent to the memory controller is completed, and the first valid data in the first logical storage area is moved to other storage areas. At this time, the invalid ratio of physical block 8 is changed from 80 % changed to 90% to get admin queue 3.
  • the memory controller can reduce the workload of performing the second GC operation to move valid data.
  • the physical block 8 reduces the workload of moving valid data by about 10%.
  • the memory controller performs the second GC operation on the physical block 8. Efficiency increased by 50%.
  • the processor performs the first GC operation after sending the first GC information to the memory controller.
  • the processor may, but is not limited to, execute the first GC operation through the following steps.
  • the processor executes the first GC operation on the first logical storage area, it moves the first valid data located in the first logical storage area to other logical storage areas.
  • the other logical storage area is a logical storage area that does not need to perform the first GC operation.
  • the logical storage space includes logical blocks 1 and 2; wherein, valid data is stored in the logical storage interval 1 and the logical storage interval 3 in the logical block 1, and the logical storage interval 2 and the logical storage interval 4 are Free area: valid data is stored in the logical storage area 3 in the logical block 2, and the logical storage area 1, the logical storage area 2 and the logical storage area 4 are free areas.
  • logical block 1 is the first logical storage area that needs to perform the first GC operation
  • logical block 2 is the logical storage area that does not need to perform the first GC operation.
  • the processor performs the first GC operation on logical block 1, and can move the valid data stored in logical storage interval 1 and logical storage interval 3 in logical block 1 to logical storage interval 1 in logical block 2 and logical bucket 4.
  • the processor may write the first valid data moved to other logical storage areas into other physical storage areas in the memory corresponding to the other logical storage areas through the I/O interface. Wherein, the processor may write the first valid data into other physical storage areas through remote updating.
  • the processor when it moves the first valid data to other logical storage areas, it can send the rewrite first valid data to the memory controller through the I/O interface between the processor and the memory. IO request, so that the memory controller can rewrite the first valid data in other physical storage areas according to the IO request through the I/O interface.
  • the memory controller may, but not limited to, rewrite the first valid data in other physical storage areas through the following steps.
  • the memory controller determines the initial LBA and updated LBA of the first valid data according to the IO request; wherein, the initial LBA indicates the LBA before the first valid data is moved, and the updated LBA indicates the LBA after the first valid data is moved.
  • the memory controller maps the initial LBA to the initial PBA, and marks the first valid data stored in the storage area corresponding to the initial PBA as invalid data.
  • the memory marks the originally stored first valid data as invalid data, reducing the invalidity of the memory controller when performing the second space operation. data workload.
  • the memory controller maps the updated LBA to the updated PBA, and rewrites the first valid data contained in the IO request to the storage space in other physical storage areas corresponding to the updated PBA.
  • the logical storage space includes logical block 1 and logical block 2; wherein, logical storage interval 1 and logical storage interval 3 in logical block 1 store valid data, logical storage interval 2 and logical storage interval 4 is a free area; valid data is stored in logical storage interval 3 in logical block 2, logical storage interval 1, logical storage interval 2 and logical storage interval 4 are free areas; logical storage interval 1 in logical block 1 in logical storage space
  • the logical storage interval 3 and the physical storage interval 1 and the physical storage interval 2 in the physical block 1 in the physical storage space respectively have a one-to-one mapping relationship.
  • the processor sends an I/O request to the memory controller through the I/O interface, and rewrites the valid data moved to the logic block 2 into the storage unit. Specifically, the processor sends an IO request for rewriting valid data to the memory controller through the IO interface. Based on the IO request, the memory controller determines that the storage area where the valid data is rewritten is the physical storage interval 2 and the physical storage interval 5 in the physical block 2, and the original storage area of the valid data in the memory is physically stored in the physical block 1 Interval 1 and Physical Storage Interval 2. The memory controller marks the valid data stored in physical storage interval 1 and physical storage interval 2 in physical block 1 as invalid data, and rewrites valid data in physical storage interval 2 and physical storage interval 5 in physical block 2.
  • the processor may also write the first valid data into other physical storage areas by means of append writing. Specifically, the processor writes the first valid data to the end of the storage space of the other physical storage area, and marks the first valid data originally stored in the memory as invalid data.
  • the processor executes the first GC operation on the first logical storage area, deletes the first valid data in the first logical storage area, and deletes the first valid data stored in the memory through the I/O interface. Data marked as invalid data.
  • the processor may send the first GC operation completion information to the memory controller through the information management interface, or may not send the first GC operation completion information to the memory controller Send the completion message of the first GC operation.
  • the first GC operation completion information is used to indicate that the processor has completed the first GC operation on the first logical storage area.
  • the memory controller after receiving the first GC operation completion information sent by the processor through the information management interface, the memory controller sends a first response message to the processor, notifying the processor that the first GC operation completion information has been received. Then, the memory controller determines the invalid ratio of each second physical storage area in the current management queue; the memory controller may use the second physical storage area with the largest invalid ratio as the second target for the memory controller to perform the second GC operation next time The physical storage area may also use the second physical storage area with the largest invalid ratio in the current management queue as the second target physical storage area for the memory controller to perform the second GC operation next time.
  • the processor executes the first GC on the first logical storage area.
  • the valid data in the first logical storage area will be moved correspondingly, thereby reducing the workload of invalidly moving valid data when the memory controller performs the second GC operation, improving the efficiency of the memory controller performing the second GC operation, and then Guaranteed memory performance.
  • FIG. 9 is a schematic diagram of an interaction flow of a garbage collection method based on SSD and host provided by an embodiment of the present application. The specific flow of the method will be described below with reference to FIG. 9 .
  • S901 In the logical storage space, the host determines the first logical storage area that needs to perform the first GC operation.
  • the host can determine the first logical storage area that needs to perform the first GC operation according to the set logical garbage collection policy.
  • the host takes the logical storage area with an invalid ratio greater than 50% as the first logical storage area that needs to perform the first GC operation.
  • S902 The host sends the first GC information to the SSD through the information management interface.
  • the host converts the format of the description information of the first logical storage area into a format satisfying the information management interface, and obtains the first GC information.
  • the host sends the first GC information to the SSD through the information management interface.
  • the SSD After receiving the first GC information through the information management interface, the SSD parses the first GC information to obtain a first logical storage area.
  • the SSD After receiving the first GC information, the SSD sends a first response message to the host through the information management interface, to inform the host that the first GC information has been received.
  • the SSD parses the first GC information to obtain the first logical address of the first valid data located in the first logical storage area.
  • S904 The SSD maps the first logical storage area to at least one first physical storage area in the physical storage space.
  • the SSD maps the first logical address of the first valid data to the first physical address, and uses the physical storage area corresponding to the first physical address as the first physical storage area.
  • the SSD determines multiple second physical storage areas that need to perform the second GC operation, and adds the multiple second physical storage areas to the management queue.
  • S904 and S905 can be executed concurrently, and there is no execution sequence dependency between S904 and S905.
  • the SSD determines that there is an intersection between at least one first physical storage area and multiple second physical storage areas.
  • the SSD determines an impact factor of the first GC operation on each second physical storage area according to the first valid data located in the first logical storage area and the second valid data stored in the plurality of second physical storage areas.
  • the impact factor is used to characterize the storage space occupied by the intersection of the first valid data and the second valid data in the second physical storage area.
  • the SSD selects multiple second physical storage areas to be selected whose influence factors are smaller than a set threshold.
  • the SSD determines an invalid ratio of each second physical storage area to be selected in the plurality of second physical storage areas to be selected.
  • the invalid ratio of any second physical storage area to be selected is the ratio of invalid data in the second physical storage area to be selected to the storage space of the second physical storage area to be selected.
  • the SSD selects the second physical storage area to be selected with the largest invalid ratio as the first target physical storage area.
  • S911 The SSD performs a second GC operation on the first target physical storage area, and deletes the first target physical storage area from the management queue.
  • S912 the host performs a first GC operation on the first logical storage area.
  • S913 the host sends the first GC operation completion information to the SSD through the information management interface.
  • the first GC operation completion information is used to indicate that the SSD has completed the first GC operation on the first logical storage area.
  • the SSD After receiving the completion information of the first GC operation, the SSD sends a second response message to the host through the information management interface to inform the host that the information of the completion of the first GC operation has been received.
  • S915 The SSD selects the second physical storage area with the largest invalid ratio as the second target physical storage area for the SSD to perform the second GC operation next time.
  • the SSD since the SSD receives the first GC information sent by the host through the information management interface, after determining the first logical storage area where the host is about to perform the first GC operation according to the first GC information, based on the first The intersection of the first valid data stored in a logical storage area and the second valid data stored in the second physical storage area determines the influence of the second physical storage area.
  • the SSD selects the first target physical storage area from the second physical storage area based on the impact factor, when the host performs the first GC operation to move valid data in the first logical storage area, the second physical storage area will The valid data in the storage area that is the same as the valid data in the first logical storage area is invalidated, thereby reducing the workload of invalidly moving valid data when the SSD subsequently executes the second GC operation, and improving the efficiency of the SSD's subsequent execution of the second GC operation, Further, the performance of the SSD is guaranteed; at the same time, since the SSD selects the second physical storage area whose impact factor is less than the set threshold and has the largest invalid ratio as the first target physical storage area, the SSD performs the second GC on the first target physical storage area. During operation, while reducing the workload of invalidly moving valid data when the SSD performs the second GC operation as much as possible, the execution efficiency of the SSD performing the second GC operation is guaranteed.
  • a garbage collection method provided in the embodiment of the present application can be applied to the storage system shown in Figure 2, and can also be applied to the storage system shown in Figure 3, the storage system includes: memory and processor, and information management interface.
  • the method includes:
  • the memory controller sends the second GC information to the processor, and the processor determines the first target logical storage area where the processor performs the fourth GC operation according to the second GC information.
  • the memory controller may, but not limited to, send the second GC information to the processor through the following steps.
  • the memory controller determines at least one third physical storage area that needs to perform the third GC operation in the physical storage space.
  • the memory is in the physical storage space, and at least one third physical storage area that needs to perform the third GC operation is determined according to the physical garbage collection policy.
  • the physical garbage collection policy may be pre-configured in the memory.
  • the memory controller determines a physical storage area that satisfies the physical garbage collection strategy in the physical storage space as the third physical storage area.
  • the physical garbage collection strategy may be that the invalid data or garbage data stored in the physical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
  • the memory controller after determining the multiple third physical storage areas, adds the multiple third physical storage areas to the management queue.
  • the memory controller maps the PBA of the valid data stored in the third physical storage area to the LBA of the logical storage space, and determines the valid data stored in the third physical storage area according to the PBA length of the valid data stored in the third physical storage area
  • the LBA length in the logical storage space obtains the description information of valid data in the second logical storage area corresponding to the third physical storage area in the logical storage space.
  • the memory controller sends the second GC information to the processor through the information management interface.
  • the second GC information is used to indicate at least one second logical storage area where the memory controller needs to perform the third GC operation, that is, before performing S902, the memory has not yet performed the third GC operation.
  • the memory controller obtains the second GC information based on the description information of the selected at least one second logical storage area.
  • the format of the second GC information is a format supported by the information management interface.
  • the second GC information includes, but is not limited to: description information of valid data located in the second logical storage area, and an execution sequence number of the third physical storage area corresponding to the second logical storage area.
  • the description information of the valid data is used to describe the LBA and LBA length of the valid data in the logical storage space.
  • the description information of valid data may be ⁇ start address, length ⁇ , such as: ⁇ 0x10000, 32KB ⁇ , ⁇ (0x40000000, 256KB), (0x40100000, 256KB) ⁇ .
  • the memory controller may send the second GC information to the processor through the information management interface.
  • the memory controller after the memory controller sends the second GC information to the processor through the information management interface, it determines the invalid ratio of each third physical storage area in the plurality of third physical storage areas.
  • the memory controller takes the third physical storage area with the largest invalid ratio as the second target physical storage area for the memory controller to perform the third GC operation next time.
  • the memory performs a third GC operation on the second target physical storage area, and deletes the second target physical storage area from the management queue.
  • the processor may, but not limited to, determine the first target logical storage area through the following steps according to the second GC information.
  • the processor receives the second GC information from the memory controller through the information management interface.
  • the second GC information is used to indicate that the memory controller needs to perform the third GC operation on the physical storage space to map at least one second logic in the logical storage space to the third physical storage area storage area.
  • the processor After receiving the second GC information, the processor analyzes the second GC information, and determines the second logical storage area according to the analysis result.
  • the parsing result includes, but is not limited to: the PBA of the third valid data located in the second logical storage area (hereinafter may be referred to as the third PBA for short), and the length of the PBA.
  • the processor determines a plurality of third logical storage areas that need to perform the fourth GC operation.
  • the processor may determine a plurality of third logical storage areas that need to perform the fourth GC operation in the logical storage space according to a preconfigured logical garbage collection policy.
  • the logical garbage collection strategy may be that the invalid data or garbage data in the logical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
  • the processor may add the multiple third logical storage areas to the management queue.
  • the third logical storage area in the management queue can be sorted according to the size of the invalid ratio.
  • the embodiment of the present application includes but is not limited to determining the third logical storage area in the above manner, and the processor may also determine in other manners, which will not be listed here.
  • the data in the physical storage space is finally processed. Therefore, if there is an intersection between the data processed by the third GC operation and the data processed by the fourth GC operation, the fourth GC operation to be executed by the processor may have an impact on the third GC operation to be executed by the memory controller, That is, performance degradation of the memory may occur due to superposition of GC functions of the memory controller and the processor.
  • the processor determines at least one second logical storage area through d1, and determines a plurality of third logical storage areas through d2, it can also Judging whether there is an intersection between at least one first logical storage area and multiple third logical storage areas; if there is an intersection, perform step d3.
  • the processor selects from at least one candidate third logical storage area among the plurality of third logical storage areas , selecting a first target logical storage area where the processor executes the fourth GC operation; wherein, there is an intersection between the at least one candidate third logical storage area and the at least one second logical storage area.
  • the processor determines the first target logical storage area according to at least one third logical storage area to be selected in the following manner.
  • the processor selects the first target logical storage area with the largest invalid ratio among at least one third logical storage area to be selected.
  • the processor determines the first target logical storage area
  • the third logical storage area to be selected with the largest invalid ratio is directly used as the first target logical storage area for the processor to perform the fourth GC operation next time.
  • the workload of effectively moving valid data is invalidated, while improving the efficiency of the subsequent execution of the third GC operation by the memory controller, and ensuring the execution efficiency of the fourth GC operation by the processor.
  • the processor determines that the third logical storage area that needs to perform the fourth GC operation is the logical block 16, the logical block 300, and the logical block 119, wherein the logical block 16, the logical block 300, the logical block The invalid ratios of block 119 are 88%, 86% and 72%, respectively.
  • the memory controller determines that the third physical storage area that needs to perform the third GC operation is the physical block 410, the physical block 502, and the physical block 95, wherein the physical block 410, the physical block 502, and the physical block 95 are invalid The proportions were 78%, 73% and 68%, respectively.
  • the memory controller maps the physical block 502 into a second logical storage area of the logical storage space, and obtains second GC information based on the second logical storage area.
  • the memory controller sends the second GC information to the processor through the information management interface; the processor obtains the second logical storage area as a logical block 300 based on the second GC information, and determines that there is an intersection between the second logical storage area and the third logical storage area .
  • stage 2 when the processor determines that the logical block 300 of the second logical storage area is also the third logical storage area, the processor takes the logical block 300 of the second logical storage area as the first target logical storage area, and sets the location of the logical block 300 Move to the first location in the third logical bank of the processor.
  • the memory controller performs the third GC operation on the physical block 410, and deletes the physical block 410 from the management queue of the memory controller; the processor performs the fourth GC operation on the logical block 300, and removes the logical block 300 Removed from the processor's administrative queue. After the processor completes the fourth GC operation on the logical block 300, the invalid ratio of the physical block 502 in the memory increases from 73% to 77%.
  • the memory controller can reduce the workload of performing the fourth GC operation to move valid data.
  • the physical block 502 reduces the workload of valid data that needs to be moved by about 4%.
  • the memory controller performs the fourth GC operation on the physical block 502. Efficiency increased by 15%.
  • the processor determines the first target logical storage area, it performs a fourth GC operation on the first target logical storage area.
  • the processor executes the first target logical storage area, it not only moves the third valid data stored in the first target logical storage area to other logical storage areas, but also rewrites the third valid data in the memory, the processor The process of rewriting the third valid data in the memory is the same as the process of rewriting the first valid data in the memory by the processor in Embodiment 1, and will not be repeated here.
  • the processor rewrites the third valid data in the memory through the information management interface, so that the memory marks the originally stored third valid data as invalid data, thereby reducing the cost of valid data stored in the third physical storage area in the memory.
  • the ratio reduces the workload of moving valid data when the memory controller executes the third GC operation, thereby improving the efficiency of the memory controller executing the third GC operation to ensure the performance of the memory.
  • the processor rewrites the third valid data in the memory by means of append writing or remote updating.
  • the processor may send the fourth GC operation completion information to the memory controller through the information management interface, or may not send the fourth GC operation completion information to the memory controller. Fourth GC operation completion message.
  • the first target logical storage area is the second logical storage area
  • the fourth GC operation completion information is used to indicate that the processor has completed the fourth GC operation on the first target logical storage area; the fourth GC operation completion information Including but not limited to: the LBA and the length of the LBA of the invalid data located in the first target logical storage area.
  • the memory controller after the memory controller receives the fourth GC operation completion information from the processor through the information management interface, determine the invalid ratio of each third physical storage area in the current management queue; and select the third physical storage area with the largest invalid ratio The third target physical storage area for the memory controller to perform the third GC operation next time.
  • the memory controller selects the third physical storage area from the multiple third physical storage areas, and obtains the second GC information from the second logical storage area obtained by mapping the selected third physical storage area.
  • the memory controller sends the second GC information to the processor through the information management interface, and then, when the second logical storage area intersects with the third logical storage area, the processor selects the second logical storage area to be selected from the second logical storage area.
  • the first target logical storage area is determined among the three logical storage areas. Since the processor is based on the third physical storage area where the memory controller does not perform the third GC operation, determine the first target logical storage area for performing the fourth GC operation next time, so that the processor performs the fourth GC operation on the first target logical storage area.
  • the GC operation moves the valid data located in the first target logical storage area, so that the valid data stored in the third physical storage area corresponding to the first target logical storage area in the physical storage space is reduced, reducing the memory controller's impact on the third physical storage area.
  • the storage area performs the third GC operation, the workload of effectively moving valid data is invalidated, the efficiency of the memory controller performing the third GC operation is improved, and the performance of the memory is guaranteed.
  • FIG. 11 is a schematic flow chart of a garbage collection method based on SSD and host provided in the embodiment of the present application. The specific flow of the method will be described below with reference to FIG. 11 .
  • the SSD determines at least one third physical storage area that needs to perform a third GC operation, and adds the at least one third physical storage area to a management queue.
  • the SSD maps at least one third physical storage area to at least one second logical storage area in the logical storage space.
  • S1103 The SSD sends the second GC information to the host through the information management interface.
  • the second GC information is used to indicate at least one second logical storage area obtained by mapping the third physical storage area in the logical storage space where the SSD needs to perform the third GC operation on the physical storage space.
  • S1104 In the logical storage space, the host determines multiple third logical storage areas that need to perform the fourth GC operation.
  • S1105 When at least one second logical storage area intersects with multiple third logical storage areas, the host selects the host from at least one candidate third logical storage area among the multiple third logical storage areas to execute the second logical storage area next time.
  • One possible manner is that the host determines the invalid ratio of each third logical storage area to be selected, and selects the third logical storage area to be selected with the largest invalid ratio as the first target logical storage area.
  • the SSD takes the third physical storage area with the largest invalid ratio as the second target physical storage area for the SSD to perform the third GC operation next time.
  • S1108 The SSD performs a third GC operation on the second target physical storage area, and deletes the second target physical storage area from the management queue.
  • S1109 the host performs a fourth GC operation on the first target logical storage area.
  • S1110 the host sends fourth GC operation completion information to the SSD through the information management interface.
  • the first target logical storage area is the second logical storage area
  • the fourth GC operation completion information is used to indicate that the host has completed the fourth GC operation on the first target logical storage area.
  • S1112 The SSD selects the third physical storage area with the largest invalid ratio as the third target physical storage area for the SSD to perform the third GC operation next time.
  • the SSD selects a third physical storage area from at least one third physical storage area, maps at least one physical storage area to a second logical storage area in the logical storage space, and based on at least one The second logical storage area obtains the second GC information.
  • the SSD sends the second GC information to the host through the information management interface, and then, the host determines whether there is an intersection between at least one second logical storage area and multiple third logical storage areas according to the second GC information received through the information management interface; And, after the host determines that there is an intersection, select a third logical storage area to be selected that has an intersection with at least one second logical storage area from the plurality of third logical storage areas, and select a third logical storage area from the at least one third logical storage area to be selected.
  • FIG. 12 is a schematic diagram of an interaction flow of a garbage collection method provided in the present application, which is applied to the storage system shown in FIG. 3 .
  • the memory and the processor in the storage system can implement the method provided by Embodiment 1 and the method provided by Embodiment 2.
  • the two execution processes may or may not overlap in time, which is not limited in this application.
  • the method includes:
  • the processor determines a first logical storage area that needs to perform a first GC operation.
  • the logical storage space is obtained by mapping the physical storage space managed by the memory controller.
  • S1202 The processor sends first GC information to the memory controller through the information management interface.
  • the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation.
  • S1203 The memory controller maps the first logical storage area to at least one first physical storage area in the physical storage space.
  • the memory controller determines, in the physical storage space, multiple second physical storage areas that need to perform the second GC operation.
  • the memory controller determines at least one second physical storage area to be selected from the multiple second physical storage areas when the at least one first physical storage area overlaps with the multiple second physical storage areas. .
  • the memory controller determines, in the at least one second physical storage area to be selected, a first target physical storage area where the memory controller executes the second GC operation.
  • the memory controller determines at least one third physical storage area that needs to perform the third GC operation.
  • the memory controller maps the at least one third physical storage area to at least one second logical storage area in the logical storage space.
  • the memory controller sends the second GC information to the processor through the information management interface.
  • the second GC information is used to indicate the at least one second logical storage area that needs to perform the third GC operation.
  • S1210 In the logical storage space, the processor determines a plurality of third logical storage areas that need to perform a fourth GC operation.
  • S1211 When at least one second logical storage area intersects with multiple third logical storage areas, the processor selects the processor from at least one candidate third logical storage area among the multiple third logical storage areas to execute the second logical storage area.
  • the embodiment of the present application further provides a memory.
  • the memory includes: a memory controller and a storage unit; wherein the storage unit includes a physical storage space;
  • the memory controller is configured to receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first GC operation on the logical storage space.
  • a logical storage area; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • At least one candidate second physical storage area is determined from the plurality of second physical storage areas; the at least one There is no intersection between the second physical storage area to be selected and the at least one first physical storage area;
  • a first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one second physical storage area to be selected.
  • the memory controller is specifically used for:
  • the impact factor of each second physical storage area is used to characterize the intersection of the first valid data and the second valid data in the second physical storage area in the The storage space occupied by the second physical storage area.
  • the memory controller is specifically used for:
  • the at least one candidate second physical storage area select the first target physical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate second physical storage area is the candidate second physical storage area The ratio of invalid data in the storage area to the storage space of the second physical storage area to be selected.
  • the memory controller is also used for:
  • the embodiment of the present application also provides a memory management device.
  • the memory management device 1300 includes: a processor 1301, a signal management interface 1302;
  • the signal management interface 1302 is used to transmit GC information
  • the processor 1301 is configured to: in the logical storage space, determine the first logical storage area that needs to perform the first GC operation; the logical storage space is obtained by mapping the physical storage space managed by the memory controller; through the information management interface 1302 Send first GC information to the memory controller; where the first GC information is used to indicate a first logical storage area where the processor needs to perform a first GC operation.
  • the processor 1301 is specifically used for:
  • the second GC information from the memory controller is received through the information management interface 1302; wherein, the second GC information is used to indicate that the memory controller needs to perform a third GC operation on the physical storage space.
  • At least one second logical storage area obtained by mapping the storage area in the logical storage space;
  • the processor executes the first target logical storage area of the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
  • the processor 1301 is specifically used for:
  • the at least one candidate third logical storage area select the first target logical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate third logical storage area is the candidate third logical storage area The ratio of invalid data in the storage area to the storage space of the third logical storage area to be selected.
  • the embodiment of the present application also provides a garbage collection device.
  • the garbage collection device 1400 is applied to a memory controller in a memory; the device 1400 includes:
  • the transmission module 1401 is configured to receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first GC operation on the logical storage space.
  • a logical storage area; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • a mapping module 1402 configured to map the first logical storage area to at least one first physical storage area in the physical storage space
  • the determining module 1403 is configured to determine, in the physical storage space, a plurality of second physical storage areas that need to perform a second GC operation; when the at least one first physical storage area overlaps with the plurality of second physical storage areas , determining at least one second physical storage area to be selected from the plurality of second physical storage areas; there is no intersection between the at least one second physical storage area to be selected and the at least one first physical storage area; A first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one candidate second physical storage area.
  • the determination module 1403 is specifically used to:
  • the impact factor of each second physical storage area is used to characterize the intersection of the first valid data and the second valid data in the second physical storage area in the The storage space occupied by the second physical storage area.
  • the determination module 1403 is specifically used to:
  • the at least one candidate second physical storage area select the first target physical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate second physical storage area is the candidate second physical storage area The ratio of invalid data in the storage area to the storage space of the second physical storage area to be selected.
  • the determining module 1403 is specifically configured to: in the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
  • the mapping module 1402 is specifically configured to: map the at least one third physical storage area to at least one second logical storage area in the logical storage space;
  • the transmission module 1401 is specifically configured to: send second GC information to the processor through the information management interface; where the second GC information is used to indicate the at least one GC that needs to perform the third GC operation. Second logical storage area.
  • the embodiment of the present application also provides a garbage collection device.
  • the garbage collection device 1500 is applied to a processor; the device 1500 includes:
  • the processing module 1501 is configured to determine the first logical storage area that needs to perform the first GC operation in the logical storage space; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
  • a transmission module 1502 configured to send first GC information to the memory controller through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first logical storage of the first GC operation district.
  • the transmission module 1502 is specifically configured to: receive second GC information from the memory controller through the information management interface; where the second GC information is used to indicate that the memory The controller needs to perform at least one second logical storage area mapped in the logical storage space from the third physical storage area that performs the third GC operation on the physical storage space;
  • the processing module 1501 is specifically configured to: in the logical storage space, determine multiple third logical storage areas that need to perform the fourth GC operation; when the at least one second logical storage area and the multiple third logical storage areas When there is an intersection of logical storage areas, selecting a first target logical storage area for the processor to perform the fourth GC operation from at least one third logical storage area to be selected among the plurality of third logical storage areas; Wherein, there is an intersection between the at least one candidate third logical storage area and the at least one second logical storage area.
  • the processing module 1501 is specifically configured to:
  • the at least one candidate third logical storage area select the first target logical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate third logical storage area is the candidate third logical storage area The ratio of invalid data in the storage area to the storage space of the third logical storage area to be selected.
  • the present application provides a computer-readable storage medium on which a computer program or instruction is stored, and when the computer program or instruction is executed, the computing device executes the method in the above method embodiment.
  • the present application provides a computer program product, which enables the computing device to execute the methods in the above method embodiments when the computer executes the computer program product.
  • each functional module in each embodiment of the present application may be integrated into one processor, or physically exist separately, or two or more modules may be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules.
  • the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

Abstract

A garbage collection method, and a memory and a memory management apparatus. In the method, a memory controller can receive first garbage collection (GC) information from a processor by means of an information management interface, and map a first logic storage area in the first GC information into a first physical storage area; and the memory controller determines a plurality of second physical storage areas, on which the memory controller needs to execute a second GC operation, and when the first physical storage area has intersections with a plurality of second physical storage areas, selects a first target physical storage area from among the second physical storage areas, which have intersections with the first physical storage area. In this way, the influence, on the execution of the second GC operation by the memory controller, of the execution of the first GC operation on the first logic storage area by the processor is reduced, that is, the workload of the memory controller ineffectively transferring valid data when the second GC operation is subsequently executed can be reduced, thereby improving the efficiency of the memory controller executing the second GC operation, and ensuring the performance of the memory.

Description

一种垃圾回收方法、存储器和存储器管理装置A garbage collection method, memory and memory management device 技术领域technical field
本申请涉及存储技术领域,尤其涉及一种垃圾回收方法、存储器和存储器管理装置。The present application relates to the technical field of storage, and in particular to a garbage collection method, a memory and a memory management device.
背景技术Background technique
存储器主要由存储器控制器和提供物理存储空间的存储单元构成。为了保证物理存储空间的存储效率,物理存储空间一般会对外映射为虚拟存储空间。其中,物理存储空间可以被划分为多个物理块(physical block),而虚拟存储空间也会被划分为很多逻辑块(logical block)。The memory is mainly composed of a memory controller and a storage unit that provides physical storage space. In order to ensure the storage efficiency of the physical storage space, the physical storage space is generally mapped to the virtual storage space. Among them, the physical storage space can be divided into multiple physical blocks (physical block), and the virtual storage space can also be divided into many logical blocks (logical block).
下面以固态硬盘(solid state disk,SSD)为例进行说明。SSD中的存储器控制器可以对存储单元中的物理存储空间进行空间管理。例如,存储器控制器不仅可以利用闪存转换层(flash translation layer,FTL)进行逻辑存储空间中的逻辑块地址(logical block address,LBA)与物理存储空间中的物理块地址(physical block address,PBA)之间的映射和转换,还可以进行垃圾回收GC(garbage collection,GC)操作。The following uses a solid state disk (SSD) as an example for illustration. The memory controller in the SSD can perform space management on the physical storage space in the storage unit. For example, the memory controller can not only use the flash translation layer (flash translation layer, FTL) to perform logical block address (logical block address, LBA) in the logical storage space and physical block address (physical block address, PBA) in the physical storage space The mapping and conversion between them can also perform garbage collection GC (garbage collection, GC) operations.
将存储器(继续以SSD为例说明)应用在分布式存储系统(distributed storage system,DSS)中,是目前通用的一种应用模式。DSS可以通过追加写(append write)模式往SSD中写入数据,从而可以实现快照、异常处理等目的,同时也可以提升SSD的性能。与SSD类似,DSS也可以使用FTL技术或者与FTL技术类似的其他技术,进行DSS有效存储空间与SSD LBA之间的映射和转换。当然,DSS也设计有对SSD的逻辑存储空间的GC功能,由存储器管理装置执行。Applying storage (continuing to use SSD as an example) in a distributed storage system (distributed storage system, DSS) is a common application mode at present. DSS can write data to SSD through append write mode, so as to realize the purposes of snapshot and exception handling, and also improve the performance of SSD. Similar to SSD, DSS can also use FTL technology or other technologies similar to FTL technology to map and convert between DSS effective storage space and SSD LBA. Of course, the DSS is also designed with a GC function for the logical storage space of the SSD, which is executed by the storage management device.
然而,SSD和DSS的GC功能叠加时,可能会对SSD的性能造成负面影响。其中,GC操作的基本单元为存储块。However, when the GC functions of SSD and DSS are superimposed, it may have a negative impact on the performance of SSD. Among them, the basic unit of GC operation is a storage block.
SSD在执行GC操作时,会将一个物理块中的有效数据搬移到其他物理块中,即每次执行GC操作,SSD会将GC操作对应的物理存储区中的有效数据在Flash介质中的其他物理存储区上重新持久化写一次,消耗Flash介质中的P/E次数,从而会降低SSD呈现给存储器管理装置的写性能。针对同一份有效数据在Flash介质上被多次持久化存储的影响,业界使用写放大因子(write amplification factor,WAF)来衡量。WAF是一个数值,是用SSD中的存储器控制器写入Flash介质的数据量除以存储器管理装置写入SSD的数据量得到的比值。通常,有效数据在Flash介质上持久化存储的次数越多,SSD的WAF越大;即SSD内部GC操作搬移有效数据的量越大,SSD的WAF越大,SSD执行GC操作的效率越低,导致SSD呈现给DSS的性能,特别是写性能,也就越低。When SSD performs GC operation, it will move valid data in one physical block to other physical blocks, that is, every time GC operation is performed, SSD will transfer valid data in the physical storage area corresponding to GC operation to other physical blocks in the Flash medium. Re-persistent writing on the physical storage area consumes the P/E times in the Flash medium, thereby reducing the write performance presented by the SSD to the storage management device. The industry uses the write amplification factor (WAF) to measure the impact of the same valid data being persistently stored multiple times on the Flash medium. WAF is a numerical value, which is a ratio obtained by dividing the amount of data written into the Flash medium by the memory controller in the SSD by the amount of data written into the SSD by the memory management device. Generally, the more times valid data is persistently stored on the Flash medium, the greater the WAF of the SSD; that is, the greater the amount of valid data moved by GC operations inside the SSD, the greater the WAF of the SSD, and the lower the efficiency of SSD GC operations. As a result, the performance presented by SSD to DSS, especially the write performance, is also lower.
并且,DSS在执行GC操作时,DSS本身也会存在WAF值;DSS的WAF值会降低其呈现给上层应用程序的写性能。显然,在DSS和SSD均执行GC操作时,SSD和DSS的WAF值会降低SSD呈现给存储器管理装置的写性能。Moreover, when the DSS performs GC operations, the DSS itself also has a WAF value; the WAF value of the DSS will reduce the write performance presented to the upper-layer application. Apparently, when both the DSS and the SSD perform GC operations, the WAF values of the SSD and the DSS will reduce the write performance presented by the SSD to the storage management device.
发明内容Contents of the invention
本申请提供一种垃圾回收方法、存储器和存储器管理装置,用以在存储器管理装置和 存储器的GC功能叠加的情况下,提高存储器控制器执行GC操作的效率,来保证存储器的性能。The present application provides a garbage collection method, a memory and a memory management device, which are used to improve the efficiency of the memory controller to perform GC operations to ensure the performance of the memory when the memory management device and the GC function of the memory are superimposed.
第一方面,提供一种垃圾回收方法,应用于存储器控制器,所述方法包括:In a first aspect, a garbage collection method is provided, which is applied to a memory controller, and the method includes:
通过信息管理接口接收处理器发送的第一GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;然后,将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;当确定所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;并在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。Receive the first GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation on the logical storage space; the logical storage The space is obtained by mapping the physical storage space managed by the memory controller; then, mapping the first logical storage area to at least one first physical storage area in the physical storage space; in the physical storage space, determining A plurality of second physical storage areas that need to perform a second GC operation; when it is determined that there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas, from the plurality of second physical storage areas Determine at least one second physical storage area to be selected; there is no intersection between the at least one second physical storage area to be selected and the at least one first physical storage area; and in the at least one second physical storage area to be selected Determine the first target physical storage area where the memory controller performs the second GC operation.
在该方法中,由于存储器控制器在接收到第一GC信息后,根据接收到的第一GC信息确定处理器需要执行第一GC操作的第一逻辑存储区;然后,存储器控制器将第一逻辑存储区映射为至少一个第一物理存储区,其中,位于第一逻辑存储区的第一有效数据在物理存储空间中存储于至少一个第一物理存储区。存储器控制器在确定出多个第二物理存储区后,通过判断至少一个第一物理存储区与多个第二物理存储区之间是否存在交集,来确定第二物理存储区中是否存有第一有效数据,进而能够确定第二物理存储区是否受处理器的第一GC操作的影响。当至少一个第一物理存储区与多个第二物理存储区存在交集时,表示存储器控制器的第二GC操作受到了第一GC操作的影响,然后,存储器控制器在多个第二物理存储区中选择出与第一物理存储区不存在交集的至少一个待选第二物理存储区,并从至少一个待选第二物理存储区中确定存储器控制器执行第二GC操作的第一目标物理存储区,来减少第一GC操作对存储器控制器执行第二GC操作的影响;并且,当处理器对第一逻辑存储区执行第一GC操作时,处理器通过搬移第一有效数据,使得物理存储空间中存储的相应的第一有效数据的存储区域发生变化,以此来降低第二物理存储区中存储的第一有效数据,减少存储器控制器后续执行第二GC操作的无效搬移有效数据的工作量,提高存储器控制器执行第二GC操作的效率。In this method, after the memory controller receives the first GC information, it determines the first logical storage area where the processor needs to perform the first GC operation according to the received first GC information; then, the memory controller sets the first The logical storage area is mapped to at least one first physical storage area, wherein the first valid data located in the first logical storage area is stored in the at least one first physical storage area in the physical storage space. After determining the plurality of second physical storage areas, the memory controller determines whether the second physical storage area stores the second physical storage area by judging whether there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas. A valid data, and then it can be determined whether the second physical storage area is affected by the processor's first GC operation. When at least one first physical storage area intersects with multiple second physical storage areas, it means that the second GC operation of the memory controller is affected by the first GC operation. Select at least one candidate second physical storage area that does not overlap with the first physical storage area in the area, and determine the first target physical storage area for the memory controller to perform the second GC operation from the at least one candidate second physical storage area Storage area, to reduce the impact of the first GC operation on the second GC operation performed by the memory controller; and, when the processor performs the first GC operation on the first logical storage area, the processor moves the first valid data so that the physical The storage area of the corresponding first valid data stored in the storage space changes, so as to reduce the first valid data stored in the second physical storage area, and reduce the number of valid data that is invalidly moved by the memory controller in subsequent second GC operations. workload, improving the efficiency with which the memory controller performs the second GC operation.
在一种可能的设计中,存储器控制器根据位于第一逻辑存储区的第一有效数据与多个第二物理存储区中存储的第二有效数据,从多个第二物理存储区中选择影响因子小于设定阈值的至少一个待选第二物理存储区;其中,每个第二物理存储区的影响因子用于表征所述第一有效数据和所述第二物理存储区中第二有效数据的交集在所述第二物理存储区中占用的存储空间。并且,影响因子表征处理器执行第一GC操作对存储器控制器对第二物理存储区执行第二GC操作的影响。In a possible design, the memory controller selects from the plurality of second physical storage areas to affect the At least one candidate second physical storage area whose factor is smaller than the set threshold; wherein, the impact factor of each second physical storage area is used to characterize the first valid data and the second valid data in the second physical storage area The storage space occupied by the intersection of in the second physical storage area. In addition, the impact factor represents the influence of the processor executing the first GC operation on the memory controller executing the second GC operation on the second physical storage area.
通过该设计,存储器控制器根据第一有效数据和第二有效数据,确定处理器对第一逻辑存储区执行第一GC操作对每个第二物理存储区的影响因子,并且,存储器控制器可以根据确定出的影响因子来确定第一GC操作对第二物理存储区的影响程度;存储器控制器从多个第二物理存储区中影响因子小于设定阈值的至少一个待选第二物理存储区;然后,使得存储器控制器从至少一个待选第二物理存储区中选择第一目标物理存储区,并且,同时将影响因子大于或等于设定阈值的第二物理存储区放到后面进行处理,能够在尽量降低存储器控制器执行第二GC操作时无效搬移有效数据的工作量的基础上,降低存储器控制 器后续执行第二GC操作的无效搬移有效数据的工作量,从而提高存储器控制器后续执行第二GC操作的效率。Through this design, the memory controller determines the impact factor of the processor performing the first GC operation on the first logical storage area on each second physical storage area according to the first valid data and the second valid data, and the memory controller can Determine the degree of influence of the first GC operation on the second physical storage area according to the determined impact factor; the memory controller selects at least one candidate second physical storage area whose impact factor is less than the set threshold from the plurality of second physical storage areas ; Then, the memory controller is made to select the first target physical storage area from at least one second physical storage area to be selected, and at the same time, the second physical storage area whose impact factor is greater than or equal to the set threshold is put behind for processing, On the basis of minimizing the workload of invalidly moving valid data when the memory controller performs the second GC operation, the workload of the memory controller for subsequently executing the second GC operation for invalidly moving valid data can be reduced, thereby improving the subsequent performance of the memory controller. The efficiency of the second GC operation.
在一种可能的设计中,所述存储器控制器在物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区,并将至少一个第三物理存储区映射为逻辑存储空间中的至少一个第二逻辑存储区;然后,通过信息管理接口向处理器发送第二GC信息,其中,第二GC信息用于指示需要执行第三GC操作的至少一个逻辑存储区。In a possible design, the memory controller determines at least one third physical storage area that needs to perform the third GC operation in the physical storage space, and maps at least one third physical storage area to the logical storage space at least one second logical storage area; then, sending second GC information to the processor through an information management interface, wherein the second GC information is used to indicate at least one logical storage area that needs to perform a third GC operation.
通过该设计,存储器控制器通过向处理器发送第二GC信息,使处理器能够根据接收到的第二GC信息,确定存储器控制器需要执行第三GC操作的至少一个第二逻辑存储区,并将确定出的至少一个第二逻辑存储区应用到处理器确定执行第四GC操作的第一目标逻辑存储区的过程中,使得处理器对第一目标逻辑存储区执行第四GC操作时,能够通过处理位于第一目标逻辑存储区中的有效数据,来降低第三物理存储区中存储的有效数据,减少存储器控制器对第三物理存储区执行第三GC操作时无效搬移有效数据的工作量,提高了后续对第三物理存储区执行第三GC操作的效率,从而达到保证存储器性能的目的。With this design, the memory controller sends the second GC information to the processor, so that the processor can determine at least one second logical storage area where the memory controller needs to perform the third GC operation according to the received second GC information, and Applying the determined at least one second logical storage area to the process of the processor determining the first target logical storage area for performing the fourth GC operation, so that when the processor performs the fourth GC operation on the first target logical storage area, it can Reduce the valid data stored in the third physical storage area by processing the valid data located in the first target logical storage area, and reduce the workload of invalidly moving valid data when the memory controller performs the third GC operation on the third physical storage area , improving the efficiency of the subsequent third GC operation on the third physical storage area, so as to achieve the purpose of ensuring memory performance.
第二方面,提供一种垃圾回收方法,应用于处理器,所述方法包括:In a second aspect, a garbage collection method is provided, which is applied to a processor, and the method includes:
在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;其中,逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;然后,通过信息管理接口向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行所述第一GC操作的所述第一逻辑存储区。In the logical storage space, determine the first logical storage area that needs to perform the first GC operation; wherein, the logical storage space is obtained by mapping the physical storage space managed by the memory controller; then, report to the memory controller through the information management interface Sending first GC information; wherein, the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation.
在该方法中,由于处理器在确定出需要执行第一GC操作的第一逻辑存储区后,向存储器控制器发送第一GC信息,使存储器控制器根据接收到的第一GC信息,从与第一逻辑存储区不存在交集的第二物理存储区中,确定执行第二GC操作的第一目标物理存储区,来降低处理器对第一逻辑存储区执行第一GC操作时,对存储器控制器对第一目标物理存储区执行第二GC操作的影响,并且减少存储器控制器对第一目标物理存储区执行第二GC操作时无效搬移有效数据的工作量,提高了存储器控制器执行第二GC操作的效率,从而达到保证存储器性能的目的。In this method, since the processor sends the first GC information to the memory controller after determining the first logical storage area that needs to perform the first GC operation, the memory controller makes the first GC information from the memory controller according to the received first GC information. In the second physical storage area where there is no intersection of the first logical storage area, determine the first target physical storage area for performing the second GC operation, so as to reduce the memory control of the processor when performing the first GC operation on the first logical storage area The impact of the memory controller performing the second GC operation on the first target physical storage area, and reducing the workload of invalidly moving valid data when the memory controller performs the second GC operation on the first target physical storage area, and improving the memory controller's execution of the second GC operation The efficiency of GC operation, so as to achieve the purpose of guaranteeing memory performance.
在一种可能的设计中,处理器通过所述信息管理接口接收存储器控制器发送的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;并且,在所述逻辑存储空间中,处理器确定需要执行第四GC操作的多个第三逻辑存储区;然后,当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。In a possible design, the processor receives the second GC information sent by the memory controller through the information management interface; where the second GC information is used to indicate that the memory controller needs to perform the first GC on the physical storage space At least one second logical storage area obtained by mapping the third physical storage area of the three GC operations in the logical storage space; and, in the logical storage space, the processor determines that a plurality of second logical storage areas that need to perform the fourth GC operation Three logical storage areas; then, when there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, the third logical storage area to be selected from at least one of the plurality of third logical storage areas In the storage area, select the first target logical storage area where the processor performs the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
通过该设计,处理器根据接收到第二GC信息,确定存储器控制器执行第三GC操作的第三物理存储区在逻辑存储空间中映射得到的至少一个第二逻辑存储区,并且,确定需要执行第四GC操作的多个第三逻辑存储区,并通过判断至少一个第二逻辑存储区与多个第三逻辑存储区是否存在交集,确定处理器对第三逻辑存储区执行第四GC操作是否会对存储器控制器对第三物理存储区执行第三GC操作造成影响。当至少一个第二逻辑存储区与多个第三逻辑存储区存在交集时,从与至少一个第二逻辑存储区存在交集的至少一个待 选第三逻辑存储区中,选择处理器执行第四GC操作的第一目标逻辑存储区,能够使得处理器在对第一目标逻辑存储区执行第四GC操作时,能够通过处理第一目标逻辑存储区的有效数据,来降低第三物理存储区中存储的有效数据,从而降低存储器控制器对第三物理存储区执行第三GC操作时的无效搬移有效数据的工作量,提高存储器控制器执行第三GC操作的执行效率,达到保证存储器性能的目的。Through this design, according to the received second GC information, the processor determines at least one second logical storage area mapped in the logical storage space by the third physical storage area where the memory controller performs the third GC operation, and determines that it needs to execute A plurality of third logical storage areas operated by the fourth GC, and by judging whether there is an intersection between at least one second logical storage area and a plurality of third logical storage areas, it is determined whether the processor performs a fourth GC operation on the third logical storage area It will affect the execution of the third GC operation on the third physical storage area by the memory controller. When at least one second logical storage area intersects with multiple third logical storage areas, from at least one candidate third logical storage area intersecting with at least one second logical storage area, the selection processor executes a fourth GC The first target logical storage area of the operation can enable the processor to reduce the amount stored in the third physical storage area by processing the valid data in the first target logical storage area when performing the fourth GC operation on the first target logical storage area. valid data, thereby reducing the workload of the memory controller for invalidly moving valid data when performing the third GC operation on the third physical storage area, improving the execution efficiency of the memory controller performing the third GC operation, and achieving the purpose of ensuring memory performance.
在一种可能的设计中,处理器在所述至少一个待选第三逻辑存储区中,选择无效比例最大的所述第一目标逻辑存储区;其中,每个待选第三逻辑存储区的无效比例为所述待选第三逻辑存储区中无效数据占所述待选第三逻辑存储区的存储空间的比值。In a possible design, the processor selects the first target logical storage area with the largest invalid ratio among the at least one third logical storage area to be selected; wherein, each third logical storage area to be selected The invalid ratio is a ratio of invalid data in the third logical storage area to be selected to the storage space of the third logical storage area to be selected.
通过该设计,处理器在至少一个待选第三逻辑存储区中,选择无效比例最大的第一目标逻辑存储区,能够保证处理器在执行第四GC操作时的执行效率。Through this design, the processor selects the first target logical storage area with the largest invalid ratio among at least one third logical storage area to be selected, which can ensure the execution efficiency of the processor when executing the fourth GC operation.
第三方面,提供一种存储器,所述存储器包含:存储器控制器和存储单元;所述存储器控制器用于:In a third aspect, a memory is provided, and the memory includes: a memory controller and a storage unit; the memory controller is used for:
通过信息管理接口接收处理器发送的第一垃圾回收GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;Receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation on the logical storage space; the said The logical storage space is obtained by mapping the physical storage space managed by the memory controller;
将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;mapping the first logical storage area to at least one first physical storage area in the physical storage space;
在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;In the physical storage space, determine a plurality of second physical storage areas that need to perform the second GC operation;
当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;When there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas, at least one candidate second physical storage area is determined from the plurality of second physical storage areas; the at least one There is no intersection between the second physical storage area to be selected and the at least one first physical storage area;
在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。A first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one second physical storage area to be selected.
在一种可能的设计中,所述存储器控制器还用于:In a possible design, the memory controller is also used for:
在所述物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区;In the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区;mapping the at least one third physical storage area to at least one second logical storage area in the logical storage space;
通过所述信息管理接口向所述处理器发送第二GC信息;其中,所述第二GC信息用于指示需要执行所述第三GC操作的所述至少一个第二逻辑存储区。Sending second GC information to the processor through the information management interface; wherein the second GC information is used to indicate the at least one second logical storage area that needs to perform the third GC operation.
第四方面,提供一种存储器管理装置,所述存储器管理装置包含:处理器和信息管理接口;所述处理器用于:In a fourth aspect, a memory management device is provided, the memory management device includes: a processor and an information management interface; the processor is used for:
在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;In the logical storage space, determine the first logical storage area that needs to perform the first GC operation; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
通过所述信息管理接口向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行第一GC操作的第一逻辑存储区。Sending first GC information to the memory controller through the information management interface; wherein the first GC information is used to indicate a first logical storage area where the processor needs to perform a first GC operation.
在一种可能的设计中,所述处理器还用于:In a possible design, the processor is also used for:
通过所述信息管理接口接收来自所述存储器控制器的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;Receive second GC information from the memory controller through the information management interface; wherein the second GC information is used to indicate that the memory controller needs to perform a third GC operation on the physical storage space for the third physical storage At least one second logical storage area obtained by mapping the area in the logical storage space;
在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区;In the logical storage space, determine a plurality of third logical storage areas that need to perform the fourth GC operation;
当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。When there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, selecting the at least one candidate third logical storage area among the plurality of third logical storage areas The processor executes the first target logical storage area of the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
第五方面,提供一种垃圾回收装置,所述垃圾回收装置应用于存储器中的存储器控制器;所述装置包括:In a fifth aspect, a garbage collection device is provided, and the garbage collection device is applied to a memory controller in a memory; the device includes:
传输模块,用于通过信息管理接口接收处理器发送的第一垃圾回收GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;The transmission module is configured to receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first logic of the first GC operation on the logical storage space storage area; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
映射模块,用于将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;a mapping module, configured to map the first logical storage area to at least one first physical storage area in the physical storage space;
确定模块,用于在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。A determining module, configured to determine a plurality of second physical storage areas that need to perform a second GC operation in the physical storage space; when there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas , determining at least one second physical storage area to be selected from the plurality of second physical storage areas; there is no intersection between the at least one second physical storage area to be selected and the at least one first physical storage area; Determine the first target physical storage area where the memory controller executes the second GC operation in the at least one second physical storage area to be selected.
在一种可能的设计中,所述确定模块具体用于:在所述物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区;In a possible design, the determining module is specifically configured to: in the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
所述映射模块具体用于:将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区;The mapping module is specifically configured to: map the at least one third physical storage area to at least one second logical storage area in the logical storage space;
所述传输模块具体用于:通过所述信息管理接口向所述处理器发送第二GC信息;其中,所述第二GC信息用于指示需要执行所述第三GC操作的所述至少一个第二逻辑存储区。The transmission module is specifically configured to: send second GC information to the processor through the information management interface; wherein the second GC information is used to indicate the at least one first GC that needs to perform the third GC operation. Two logical storage areas.
第六方面,提供一种垃圾回收装置,所述垃圾回收装置应用于处理器;所述装置包括:In a sixth aspect, a garbage collection device is provided, the garbage collection device is applied to a processor; the device includes:
处理模块,用于在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;The processing module is configured to determine the first logical storage area that needs to perform the first GC operation in the logical storage space; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
传输模块,用于通过所述信息管理接口向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行第一GC操作的第一逻辑存储区。A transmission module, configured to send first GC information to the memory controller through the information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation .
在一种可能的设计中,所述传输模块具体用于:通过所述信息管理接口接收来自所述存储器控制器的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;In a possible design, the transmission module is specifically configured to: receive second GC information from the memory controller through the information management interface; where the second GC information is used to indicate that the memory controller At least one second logical storage area obtained by mapping the third physical storage area in the logical storage space where the controller needs to perform the third GC operation on the physical storage space;
所述处理模块具体用于:在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区;当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。The processing module is specifically configured to: in the logical storage space, determine a plurality of third logical storage areas that need to perform the fourth GC operation; when the at least one second logical storage area and the plurality of third logical storage areas When there is an intersection of the storage areas, selecting the first target logical storage area for the processor to perform the fourth GC operation from at least one candidate third logical storage area among the plurality of third logical storage areas; wherein , there is an intersection between the at least one candidate third logical storage area and the at least one second logical storage area.
第七方面,本申请提供一种计算机可读存储介质,其上存储有计算机程序或指令,当该计算机程序或指令被执行时,使得计算机执行上述第一方面或第一方面的任一种可能的实现方式中的方法,或使得计算机执行上述第二方面或第二方面的任一种可能的实现方式中的方法。In the seventh aspect, the present application provides a computer-readable storage medium, on which a computer program or instruction is stored, and when the computer program or instruction is executed, the computer can execute any one of the above-mentioned first aspect or the first aspect. The method in the implementation manner of the above-mentioned second aspect or the method in any possible implementation manner of the second aspect.
第八方面,本申请提供一种计算机程序产品,当计算机执行计算机程序产品时,使得计算机执行上述第一方面或第一方面的任一种可能的实现方式中的方法,或使得计算机执行上述第二方面或第二方面的任一种可能的实现方式中的方法。In an eighth aspect, the present application provides a computer program product. When the computer executes the computer program product, the computer is made to execute the method in the above-mentioned first aspect or any possible implementation manner of the first aspect, or the computer is made to execute the above-mentioned first aspect. The method in the second aspect or any possible implementation of the second aspect.
上述第三方面和第五方面的有益效果,请参见上述第一方面的有益效果的描述,上述第四方面和第六方面的有益效果,请参见上述第二方面的有益效果的描述,这里不再重复赘述。For the above-mentioned beneficial effects of the third aspect and the fifth aspect, please refer to the description of the above-mentioned beneficial effects of the first aspect, and for the above-mentioned beneficial effects of the fourth and sixth aspects, please refer to the description of the above-mentioned beneficial effects of the second aspect. Repeat it again.
附图说明Description of drawings
图1为本申请实施例提供的方案的一种可能的存储系统的架构示意图;FIG. 1 is a schematic structural diagram of a possible storage system of the solution provided by the embodiment of the present application;
图2为本申请实施例提供的方案的另一种可能的存储系统的架构示意图;FIG. 2 is a schematic structural diagram of another possible storage system of the solution provided by the embodiment of the present application;
图3为本申请实施例提供的方案的又一种可能的存储系统的架构示意图;FIG. 3 is a schematic structural diagram of another possible storage system of the solution provided by the embodiment of the present application;
图4为本申请实施例提供的方案的一种可能的垃圾回收方法的示意图;FIG. 4 is a schematic diagram of a possible garbage collection method of the solution provided by the embodiment of the present application;
图5为本申请实施例提供的方案的一种可能的垃圾回收方法的示意图;FIG. 5 is a schematic diagram of a possible garbage collection method of the solution provided by the embodiment of the present application;
图6为本申请实施例提供的方案的一种可能的存储器控制器的管理队列的示意图;FIG. 6 is a schematic diagram of a possible memory controller management queue of the solution provided by the embodiment of the present application;
图7为本申请实施例提供的方案的一种可能的存储空间示意图;FIG. 7 is a schematic diagram of a possible storage space of the solution provided by the embodiment of the present application;
图8为本申请实施例提供的方案的另一种可能的存储空间示意图;FIG. 8 is a schematic diagram of another possible storage space of the solution provided by the embodiment of the present application;
图9为本申请实施例提供的方案的一种可能的垃圾回收方法的流程示意图;FIG. 9 is a schematic flowchart of a possible garbage collection method of the solution provided by the embodiment of the present application;
图10为本申请实施例提供的方案的另一种可能的管理队列示意图;FIG. 10 is a schematic diagram of another possible management queue of the solution provided by the embodiment of the present application;
图11为本申请实施例提供的方案的另一种可能的垃圾回收方法的流程示意图;FIG. 11 is a schematic flowchart of another possible garbage collection method of the solution provided by the embodiment of the present application;
图12为本申请实施例提供的方案的一种可能的垃圾回收方法的交互流程示意图;FIG. 12 is a schematic diagram of an interaction process of a possible garbage collection method of the solution provided by the embodiment of the present application;
图13为本申请实施例提供的方案的一种存储器管理装置的结构示意图;FIG. 13 is a schematic structural diagram of a memory management device according to the solution provided by the embodiment of the present application;
图14为本申请实施例提供的方案的一种垃圾回收装置的结构示意图;Fig. 14 is a schematic structural diagram of a garbage collection device according to the solution provided by the embodiment of the present application;
图15为本申请实施例提供的方案的又一种垃圾回收装置的结构示意图。Fig. 15 is a schematic structural diagram of another garbage collection device according to the solution provided by the embodiment of the present application.
具体实施方式Detailed ways
本申请实施例提供一种垃圾回收方法、存储器及存储器管理装置。其中,方法和存储器、存储器管理装置是基于同一构思的,由于方法、存储器及存储器管理装置解决问题的原理相似,因此存储器、存储器管理装置与方法的实施可以相互参见,重复之处不再赘述。Embodiments of the present application provide a garbage collection method, a memory, and a memory management device. Wherein, the method, the memory, and the memory management device are based on the same idea. Since the method, the memory, and the memory management device have similar problem-solving principles, the implementation of the memory, the memory management device, and the method can be referred to each other, and repeated descriptions will not be repeated.
为了使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施例作进一步地详细描述。其中,在本申请实施例的描述中,以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特 征。In order to make the purpose, technical solutions, and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. Among them, in the description of the embodiments of the present application, the terms "first" and "second" are used for description purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features . Thus, a feature defined as "first" or "second" may expressly or implicitly include one or more of these features.
为了便于理解,示例性的给出了与本申请相关概念的说明以供参考。In order to facilitate understanding, descriptions of concepts related to the present application are provided as examples for reference.
1)存储器,由存储器控制器和Flash等非挥发介质颗粒的存储单元构成。其中,存储单元为存储器提供物理存储空间,存储单元中包括很多个存储块(block),block中包含很多个存储页(page)。目前的存储器包括:SSD,分层磁记录硬盘驱动器(shingled magnetic recording hard disk drive,SMR HDD)等具备和SSD类似的GC功能的存储设备。1) The memory is composed of a memory controller and a storage unit of non-volatile medium particles such as Flash. Wherein, the storage unit provides physical storage space for the memory, and the storage unit includes many storage blocks (block), and the block includes many storage pages (page). The current storage includes: SSD, shingled magnetic recording hard disk drive (SMR HDD) and other storage devices with GC functions similar to SSD.
下面以SSD为例进行说明。The following uses SSD as an example for description.
SSD,是用固态电子存储芯片阵列制成的硬盘,又称固态驱动器。SSD中一般至少包括存储器控制器和存储阵列两部分,存储器控制器可以用于对存储阵列进行控制。存储阵列由提供物理存储空间的存储单元组成,用于提供SSD的存储区域,可以存储数据。存储单元由多个block组成。其中,block可以为闪存(flash),下面以闪存为例进行说明。SSD is a hard disk made of solid-state electronic memory chip arrays, also known as solid-state drives. An SSD generally includes at least two parts, a memory controller and a storage array, and the memory controller can be used to control the storage array. The storage array is composed of storage units that provide physical storage space, and are used to provide the storage area of the SSD and can store data. A storage unit consists of multiple blocks. Wherein, the block may be a flash memory (flash), and the following uses a flash memory as an example for description.
SSD采用闪存作为存储介质时,存储阵列中通常包括几十、几百甚至上千片闪存,每片闪存可以包括几百到几千个闪存块,每个闪存块里可以包括几千个闪存页。闪存有读、写、擦除三种基本操作,其中,读操作和写操作的操作粒度为一个闪存页,擦除操作的操作粒度为一个闪存块,因此闪存具有异地更新和非对称读写擦时延的特性。When SSD uses flash memory as the storage medium, the storage array usually includes dozens, hundreds or even thousands of flash memories, each flash memory can include hundreds to thousands of flash memory blocks, and each flash memory block can include thousands of flash memory pages . Flash memory has three basic operations: read, write, and erase. Among them, the operation granularity of read operation and write operation is a flash memory page, and the operation granularity of erase operation is a flash memory block. Therefore, flash memory has remote update and asymmetric read/write erase. Latency characteristics.
为了更好地使用block,SSD中的存储器控制器可以对存储单元中的物理存储空间进行空间管理。例如,存储器控制器不仅可以利用FTL中的FTL映射表进行逻辑存储空间中的LBA与物理存储空间中的PBA之间的映射和转换,还可以进行GC操作,以保证SSD的性能。In order to better use blocks, the memory controller in the SSD can perform space management on the physical storage space in the storage unit. For example, the memory controller can not only use the FTL mapping table in the FTL to map and convert between the LBA in the logical storage space and the PBA in the physical storage space, but also perform GC operations to ensure the performance of the SSD.
FTL映射表为地址转换表,用于指示逻辑存储空间中的LBA与物理存储空间中的PBA之间的映射关系。其中,LBA为写到block前系统为数据生成的逻辑块地址,而PBA为写入block后的物理块地址。当数据处理请求(或用户请求)下发到SSD后,SSD通过FTL映射表可以确定该数据处理请求对应的block中的PBA。若该数据处理请求是读请求(用于请求进行读操作),则将block中对应的PBA的数据读出;若该数据处理请求是写请求(用于请求执行写操作),且该写操作为初次写入某一数据,则将该数据写入存储块中的空白PBA;若该数据处理请求是请求执行写操作,且该写操作用于对已存储的某一数据进行更新,则标记该数据在存储块中对应的PBA为无效,并将该数据对应的更新后的数据写入存储块中的空白PBA,接着更新FTL映射表中对应的地址映射关系,即完成操作。若该数据处理请求是擦除请求(用于请求执行擦除操作),则将存储块中对应的物理地址的数据删除,并删除FTL映射表中对应的地址映射关系。The FTL mapping table is an address translation table, which is used to indicate the mapping relationship between the LBA in the logical storage space and the PBA in the physical storage space. Among them, LBA is the logical block address generated by the system for data before writing to the block, and PBA is the physical block address after writing to the block. After the data processing request (or user request) is sent to the SSD, the SSD can determine the PBA in the block corresponding to the data processing request through the FTL mapping table. If the data processing request is a read request (for requesting a read operation), the data of the corresponding PBA in the block is read out; if the data processing request is a write request (for requesting to perform a write operation), and the write operation If it is the first time to write a certain data, then write the data into the blank PBA in the storage block; The PBA corresponding to the data in the storage block is invalid, and the updated data corresponding to the data is written into the blank PBA in the storage block, and then the corresponding address mapping relationship in the FTL mapping table is updated to complete the operation. If the data processing request is an erase request (for requesting to perform an erase operation), delete the data of the corresponding physical address in the storage block, and delete the corresponding address mapping relationship in the FTL mapping table.
2)GC操作,是当存储空间中的可用存储空间(空白存储空间或空闲存储空间)较小时的回收已使用空间的操作,其具体操作包括:读出选择的待回收存储块中的有效数据并将其迁移入可用存储空间中的目标存储块中,然后擦除该待回收存储块中的所有数据,从而通过GC操作回收该存储块对应的存储空间。2) GC operation is the operation of reclaiming the used space when the available storage space (blank storage space or free storage space) in the storage space is small, and its specific operation includes: reading the valid data in the selected storage block to be reclaimed And migrate it into the target storage block in the available storage space, and then erase all the data in the storage block to be reclaimed, so as to reclaim the storage space corresponding to the storage block through GC operation.
3)存储系统,主要由存储器和处理器构成,其中,存储器和处理器的数量并不作限。可选的,存储系统为可分离式存储系统,例如,DSS。3) The storage system is mainly composed of a memory and a processor, wherein the number of the memory and the processor is not limited. Optionally, the storage system is a detachable storage system, for example, DSS.
DSS,由管理设备和多个存储服务器构成;其中,存储服务器用于存放数据,管理设备用于管理存储服务器。DSS中的管理设备相当于存储系统中的处理器,任一个存储服务器相当于存储器。The DSS consists of a management device and multiple storage servers; the storage server is used to store data, and the management device is used to manage the storage servers. The management device in the DSS is equivalent to the processor in the storage system, and any storage server is equivalent to the memory.
4)数据处理请求,可以简称为输入输出(input/output,IO)请求、IO,以下简称为 IO请求,指其它装置(例如处理器)下发到存储器的用于指示存储器控制器进行数据处理操作的请求。示例性的,IO请求可以包括读请求、写请求、擦除请求中的至少一项。4) Data processing request, which may be referred to as input/output (IO) request, IO, hereinafter referred to as IO request, refers to other devices (such as processors) issued to the memory to instruct the memory controller to perform data processing Action request. Exemplarily, the IO request may include at least one of a read request, a write request, and an erase request.
以存储器为SSD为例,IO操作指SSD根据接收到的IO请求执行对应操作的过程,是SSD在响应IO请求时执行的操作。例如,IO操作可以包括读操作、写操作、擦除操作中的至少一项。Taking the storage as an SSD as an example, the IO operation refers to the process in which the SSD executes the corresponding operation according to the received IO request, which is the operation performed by the SSD when responding to the IO request. For example, the IO operation may include at least one of a read operation, a write operation, and an erase operation.
5)信息管理接口,是指位于存储器和处理器中的接口,用于传输GC信息。其中,信息管理接口可以为物理意义上的接口,还可以为逻辑意义上的接口。5) The information management interface refers to the interface located in the memory and the processor, and is used to transmit GC information. Wherein, the information management interface may be an interface in a physical sense, or an interface in a logical sense.
6)I/O接口,是指位于存储器和处理器中的接口,用于传输IO请求。6) The I/O interface refers to the interface located in the memory and the processor, and is used to transmit IO requests.
7)存储空间,分为物理存储空间和逻辑存储空间。7) The storage space is divided into physical storage space and logical storage space.
物理存储空间,是指存储器中的存储单元所提供的数据实际存储的空间。The physical storage space refers to the space in which the data provided by the storage unit in the memory is actually stored.
逻辑存储空间,是指物理存储空间对外映射的存储空间,受处理器控制。处理器可通过管理逻辑存储空间,实现对物理存储空间的管理。The logical storage space refers to the storage space mapped to the outside of the physical storage space, which is controlled by the processor. The processor can manage the physical storage space by managing the logical storage space.
8)存储区,是指对存储空间中执行GC操作的基本单元,即存储块。8) The storage area refers to the basic unit for performing GC operations in the storage space, that is, the storage block.
9)无效比例,是指存储区中无效数据占存储区的存储空间的比值。9) The invalid ratio refers to the ratio of invalid data in the storage area to the storage space of the storage area.
由于存储空间分为物理存储空间和逻辑存储空间,因此为了便于区分,在本申请实施例中,物理存储空间中的存储块可以称为物理块,逻辑存储空间中的存储块可以称为逻辑块。Since the storage space is divided into physical storage space and logical storage space, for the convenience of distinction, in the embodiment of the present application, the storage blocks in the physical storage space may be called physical blocks, and the storage blocks in the logical storage space may be called logical blocks .
本申请实施例的描述中,“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。本申请中所涉及的至少一个是指一个或多个;多个,是指两个或两个以上。另外,需要理解的是,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。下面将结合附图,对本申请实施例进行详细描述。In the description of the embodiments of the present application, "and/or" describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B, which may mean: A exists alone, A and B exist simultaneously, and There are three cases of B. The character "/" generally indicates that the contextual objects are an "or" relationship. The at least one involved in this application refers to one or more; a plurality refers to two or more than two. In addition, it should be understood that in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or imply order. Embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
通常,存储器和存储器管理装置在执行GC操作时,会将GC操作对应的存储块中的有效数据搬移到其他存储块中。下面以存储器为SSD,存储器管理装置为DSS为例进行说明。SSD在执行GC操作时,将GC操作对应的物理存储区中的有效数据搬移到其他物理存储区中,当GC操作搬移的有效数据越多,SSD的WAF越大,SSD执行GC操作的效率越低,使得SSD呈现的写性能较差;并且,当DSS也执行GC操作时,DSS本身存在的WAF值会降低SSD呈现给上层应用程序的写性能。显然,在存储器和处理器的GC功能叠加的时候,可能会影响存储器的性能。Usually, when the memory and the memory management device execute the GC operation, the valid data in the storage block corresponding to the GC operation will be moved to other storage blocks. In the following, description will be made by taking the storage as an SSD and the storage management device as a DSS as an example. When an SSD performs a GC operation, it moves the valid data in the physical storage area corresponding to the GC operation to other physical storage areas. When the GC operation moves more valid data, the WAF of the SSD is larger, and the efficiency of the SSD to perform GC operations is higher. If the value is low, the write performance presented by the SSD is poor; and, when the DSS also performs GC operations, the WAF value of the DSS itself will reduce the write performance presented by the SSD to the upper-layer application. Obviously, when the GC functions of the memory and the processor are superimposed, the performance of the memory may be affected.
为了提高存储器控制器执行GC操作的效率,保证存储器的写性能,本申请实施例提供了一种垃圾回收方法,应用于存储器管理装置和存储器,该存储器具备进行GC操作和IO操作的能力。在该方法中,存储器管理装置中的处理器和存储器中的第一器件可通过信息管理接口向第二器件传输GC信息,其中,GC信息用于指示第一器件执行GC操作的存储区;第二器件根据接收到的GC信息,确定下一次执行GC操作的存储区,从而降低存储器控制器执行GC操作时的无效的数据搬移量,进而提高了存储器控制器执行GC操作的效率,最终保证存储器的性能。In order to improve the efficiency of the GC operation performed by the memory controller and ensure the write performance of the memory, an embodiment of the present application provides a garbage collection method, which is applied to a memory management device and a memory, and the memory is capable of performing GC operations and IO operations. In this method, the processor in the memory management device and the first device in the memory can transmit GC information to the second device through an information management interface, wherein the GC information is used to indicate the storage area where the first device performs GC operations; the second The second device determines the storage area for the next GC operation according to the received GC information, thereby reducing the amount of invalid data transfer when the memory controller performs GC operations, thereby improving the efficiency of the memory controller to perform GC operations, and finally ensuring that the memory performance.
下面将结合附图,对本申请实施例进行详细描述。Embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
图1为本申请实施例提供的方案适用的一种可能的存储系统的架构示意图。如图1所示,该系统中至少包括存储器,处理器和信息管理接口。FIG. 1 is a schematic structural diagram of a possible storage system to which the solution provided by the embodiment of the present application is applicable. As shown in Figure 1, the system includes at least a memory, a processor and an information management interface.
其中,该存储器包括存储器控制器和存储单元,存储器控制器用于对存储器进行控制,存储单元用于提供存储器的物理存储空间。可选的,该存储器可以为SSD,也可为其他存储设备。Wherein, the memory includes a memory controller and a storage unit, the memory controller is used to control the memory, and the storage unit is used to provide a physical storage space of the memory. Optionally, the storage may be SSD or other storage devices.
本申请不限定所述存储系统的部署形式。在一种实施方式中,存储系统可以为不可分离式的存储系统,此时,处理器和存储器位于同一电子设备中,整个存储系统位于电子设备内。在另一种实施方式中,存储系统也可以为可分离式的存储系统,例如,DSS,此时,处理器可以为主机,存储器可以为SSD,即处理器和存储器可以位于不同的设备中。This application does not limit the deployment form of the storage system. In an implementation manner, the storage system may be an inseparable storage system. In this case, the processor and the memory are located in the same electronic device, and the entire storage system is located in the electronic device. In another embodiment, the storage system may also be a detachable storage system, for example, DSS. In this case, the processor may be a host, and the storage may be an SSD, that is, the processor and the storage may be located in different devices.
在本存储系统中,处理器与存储器之间可以通过信息管理接口进行通信,传输GC信息,所述处理器可以通过信息管理接口向存储器发送GC信息,对存储器进行一些控制,存储器也可以通过信息管理接口响应来自处理器的GC信息。In this storage system, the processor and the memory can communicate through the information management interface and transmit GC information. The processor can send GC information to the memory through the information management interface to perform some control on the memory. The memory can also pass information The management interface responds to GC messages from the processor.
在一种实施方式中,存储器中的存储器控制器可以进一步包括信息解析模块、信息管理接口和FTL模块,如图1所示。其中,FTL模块可以进一步包括地址转换模块和GC模块。信息管理接口可以用于传输GC信息。信息解析模块可以用于解析GC信息,还可以用于将解析结果发送到FTL模块中的地址转换模块;地址转换模块可以用于将LBA和PBA进行地址转换。GC模块用于根据接收到的GC信息确定下一次执行GC操作的目标物理存储区,并对目标物理存储区执行GC操作。In one embodiment, the memory controller in the memory may further include an information parsing module, an information management interface and an FTL module, as shown in FIG. 1 . Wherein, the FTL module may further include an address conversion module and a GC module. The information management interface can be used to transfer GC information. The information analysis module can be used to analyze GC information, and can also be used to send the analysis result to the address translation module in the FTL module; the address translation module can be used to perform address translation on LBA and PBA. The GC module is used to determine the target physical storage area for performing GC operation next time according to the received GC information, and perform GC operation on the target physical storage area.
在存储器中,存储单元是数据最终存储的物理载体。示例性的,存储单元可以为Flash等非挥发介质颗粒,Flash中包含很多个block。In the memory, the storage unit is the physical carrier for the final storage of data. Exemplarily, the storage unit may be non-volatile medium particles such as Flash, and the Flash includes many blocks.
在一种实施方式中,处理器中可以进一步包括GC模块。其中,GC模块可以用于确定下一次执行GC操作的逻辑存储区,并对逻辑存储区执行GC操作,以及生成用于指示即将执行GC操作的逻辑存储区的GC信息。In an implementation manner, the processor may further include a GC module. Wherein, the GC module can be used to determine the logical storage area to perform GC operation next time, perform GC operation on the logical storage area, and generate GC information for indicating the logical storage area to perform GC operation.
在一种实施方式中,处理器控制的逻辑存储空间为存储器控制器控制的物理存储空间对外映射得到的。处理器通过控制逻辑存储空间进而对物理存储空间进行控制。其中,当存储器控制器通过信息管理接口接收到GC信息后,通过信息解析模块确定逻辑存储区的LBA。存储器控制器通过地址转换模块中的地址转换表将LBA转换为PBA。其中,地址转换表用于表示逻辑存储空间中的LBA与物理存储空间中的PBA之间的映射关系。In one embodiment, the logical storage space controlled by the processor is obtained by externally mapping the physical storage space controlled by the memory controller. The processor controls the physical storage space by controlling the logical storage space. Wherein, after the memory controller receives the GC information through the information management interface, the LBA of the logical storage area is determined through the information parsing module. The memory controller converts the LBA into the PBA through the address translation table in the address translation module. Wherein, the address translation table is used to represent the mapping relationship between the LBA in the logical storage space and the PBA in the physical storage space.
在一种实施方式中,处理器通过GC模块确定需要执行第一GC操作的第一逻辑存储区,并得到第一GC信息;处理器通过信息管理接口将第一GC信息发送给存储器控制器。In one embodiment, the processor determines the first logical storage area that needs to perform the first GC operation through the GC module, and obtains the first GC information; the processor sends the first GC information to the memory controller through the information management interface.
存储器控制器通过信息管理接口接收到第一GC信息后,可以通过信息解析模块对第一GC信息进行解析,得到第一物理存储区。然后,存储器控制器通过GC模块根据第一物理存储区,确定存储器控制器下一次执行第二GC操作的第一目标物理存储区。After the memory controller receives the first GC information through the information management interface, it can analyze the first GC information through the information analysis module to obtain the first physical storage area. Then, the memory controller determines the first target physical storage area where the memory controller performs the second GC operation next time according to the first physical storage area through the GC module.
在一种实施方式中,信息管理接口可以是以逻辑形式存在的,也可以是以物理形式存在的。例如,信息管理接口可以为位于处理器和存储器之间的传输线,连接存储器和处理器,使存储器和处理器能够通过信息管理接口进行通信。In an implementation manner, the information management interface may exist in a logical form or in a physical form. For example, the information management interface may be a transmission line between the processor and the memory, connecting the memory and the processor so that the memory and the processor can communicate through the information management interface.
图2为本申请实施例提供的方案适用的另一种可能的存储系统的架构示意图。如图2所示,该系统中至少包括存储器,处理器和信息管理接口,该存储器与图1中的存储器相同,此处不再赘述。FIG. 2 is a schematic structural diagram of another possible storage system to which the solution provided by the embodiment of the present application is applicable. As shown in FIG. 2 , the system at least includes a memory, a processor and an information management interface. The memory is the same as that in FIG. 1 , and will not be repeated here.
如图2所示,存储器控制器可以包括FTL模块。其中,FTL模块可以进一步包括地址转换模块和GC模块;地址转换模块可以用于将LBA和PBA进行地址转换。GC模块用于确定下一次执行GC操作的物理存储区,并对物理存储区执行GC操作,以及生成用于指示即将执行GC操作的物理存储区的GC信息。As shown in FIG. 2, the memory controller may include an FTL module. Wherein, the FTL module may further include an address translation module and a GC module; the address translation module may be used to perform address translation on the LBA and the PBA. The GC module is used to determine the physical storage area to perform GC operation next time, perform GC operation on the physical storage area, and generate GC information for indicating the physical storage area to perform GC operation.
如图2所示,处理器中可以包括信息解析模块和GC模块。其中,信息解析模块可以用于解析接收到的GC信息,还可以用于将解析结果发送给GC模块。GC模块可以用于根据接收到的解析结果确定下一次执行GC操作的逻辑存储区,并对逻辑存储区执行GC操作。As shown in FIG. 2, the processor may include an information parsing module and a GC module. Wherein, the information analysis module can be used to analyze the received GC information, and can also be used to send the analysis result to the GC module. The GC module can be used to determine the logical storage area for performing GC operation next time according to the received parsing result, and perform GC operation on the logical storage area.
在一种实施方式中,存储器控制器通过GC模块,在物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区。存储器控制器通过地址转换模块将至少一个第三物理存储区映射为逻辑存储空间中的至少一个第二逻辑存储区。存储器控制器基于GC模块得到用于指示至少一个第二逻辑存储区的第二GC信息,并通过信息管理接口将第二GC信息发送给处理器。In one implementation manner, the memory controller determines at least one third physical storage area that needs to perform the third GC operation in the physical storage space through the GC module. The memory controller maps at least one third physical storage area to at least one second logical storage area in the logical storage space through the address translation module. The memory controller obtains second GC information indicating at least one second logical storage area based on the GC module, and sends the second GC information to the processor through the information management interface.
处理器通过信息管理接口接收第二GC信息,并通过信息解析模块对第二GC信息进行解析得到至少一个第二逻辑存储区。处理器通过GC模块,根据至少一个第二逻辑存储区确定处理器下一次执行第四GC操作的第一目标逻辑存储区。The processor receives the second GC information through the information management interface, and analyzes the second GC information through the information analysis module to obtain at least one second logical storage area. The processor determines the first target logical storage area for the processor to perform the fourth GC operation next time according to the at least one second logical storage area through the GC module.
图3为本申请实施例提供的方案适用的又一种可能的存储系统的架构示意图。如图3所示,该系统中至少包括存储器,处理器和信息管理接口,该存储器与图1所示的存储器相同,该处理器与图2所示的处理器相同,此处不再赘述。FIG. 3 is a schematic structural diagram of another possible storage system to which the solution provided by the embodiment of the present application is applicable. As shown in FIG. 3 , the system at least includes a memory, a processor and an information management interface. The memory is the same as the memory shown in FIG. 1 , and the processor is the same as the processor shown in FIG. 2 , which will not be repeated here.
在一种实施方式中,处理器可通过GC模块生成第一GC信息,并通过信息管理接口向存储器控制器发送第一GC信息。存储器控制器通过信息解析模块对第一GC信息进行解析,得到第一逻辑存储区。存储器控制器通过GC模块根据第一逻辑存储区确定第一目标物理存储区。In an implementation manner, the processor may generate the first GC information through the GC module, and send the first GC information to the memory controller through the information management interface. The memory controller parses the first GC information through the information parsing module to obtain the first logical storage area. The memory controller determines the first target physical storage area according to the first logical storage area through the GC module.
在另一种实施方式中,存储器控制器可通过GC模块生成第二GC信息,并通过信息管理接口向处理器发送第二GC信息。处理器通过信息解析模块对第二GC信息进行解析,得到第二逻辑存储区。处理器通过GC模块根据第二逻辑存储区,确定第一目标逻辑存储区。In another implementation manner, the memory controller may generate the second GC information through the GC module, and send the second GC information to the processor through the information management interface. The processor parses the second GC information through the information parsing module to obtain the second logical storage area. The processor determines the first target logical storage area according to the second logical storage area through the GC module.
需要说明的是,上述图1-图3所示的存储系统仅是对本申请方案适用的存储系统的一种示例性说明,并不对本申请方案适用的系统架构造成限制。上述系统架构中也可以增加其它的装置或模块,或者减少、修改部分装置或模块。It should be noted that the above-mentioned storage systems shown in FIGS. 1-3 are only exemplary descriptions of storage systems applicable to the solution of this application, and do not limit the system architecture applicable to the solution of this application. Other devices or modules may also be added to the above system architecture, or some devices or modules may be reduced or modified.
下面结合具体实施例对本申请提供的方案进行介绍。The solution provided by the present application will be introduced below in combination with specific embodiments.
实施例1Example 1
图4为本申请实施例提供的一种垃圾回收方法的示意图,可以应用于如图1所示的存储系统中的处理器,还可以应用于如图3所示的存储系统中的处理器。如图4所示,该方法包括:FIG. 4 is a schematic diagram of a garbage collection method provided by an embodiment of the present application, which can be applied to the processor in the storage system as shown in FIG. 1 , and can also be applied to the processor in the storage system as shown in FIG. 3 . As shown in Figure 4, the method includes:
S401:在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区。S401: In a logical storage space, determine a first logical storage area that needs to perform a first GC operation.
需要说明的是,逻辑存储空间为存储器管理的物理存储空间映射得到的。It should be noted that the logical storage space is obtained by mapping the physical storage space managed by the memory.
处理器在逻辑存储空间中,根据逻辑垃圾回收策略确定需要执行第一GC操作的第一 逻辑存储区。其中,逻辑垃圾回收策略可以是预先配置的。In the logical storage space, the processor determines the first logical storage area that needs to perform the first GC operation according to the logical garbage collection strategy. Wherein, the logical garbage collection policy may be pre-configured.
处理器在逻辑存储空间中,将满足逻辑垃圾回收策略的逻辑存储区确定为第一逻辑存储区。其中,逻辑垃圾回收策略可以为逻辑存储区中的无效数据或垃圾数据达到一定比例,也可以为其他垃圾回收条件,本申请在此并不作限。In the logical storage space, the processor determines a logical storage area satisfying the logical garbage collection policy as the first logical storage area. Wherein, the logical garbage collection strategy may be that the invalid data or garbage data in the logical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
进一步地,处理器在逻辑存储空间中,确定出的需要执行第一GC操作的第一逻辑存储区的数量可以为多个,也可以为一个。Further, in the logical storage space, the number of first logical storage areas that need to perform the first GC operation determined by the processor may be multiple, or may be one.
S402:通过信息管理接口向存储器控制器发送第一GC信息。S402: Send the first GC information to the memory controller through the information management interface.
需要说明的是,第一GC信息用于指示处理器需要执行第一GC操作的第一逻辑存储区,即在执行S402之前,所述处理器还未对第一逻辑存储区执行所述第一GC操作。It should be noted that the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation, that is, before executing S402, the processor has not performed the first GC operation on the first logical storage area. GC operation.
处理器在确定出需要执行第一GC操作的至少一个第一逻辑存储区后,从至少一个第一逻辑存储区中选择第一逻辑存储区;并根据选择出的第一逻辑存储区的描述信息,确定第一GC信息。After the processor determines at least one first logical storage area that needs to perform the first GC operation, select the first logical storage area from the at least one first logical storage area; and according to the description information of the selected first logical storage area , to determine the first GC information.
其中,第一GC信息包括但不限于:第一逻辑存储区中的有效数据的描述信息、第一逻辑存储区的执行序号。并且,第一GC信息的格式为信息管理接口支持的格式。Wherein, the first GC information includes, but is not limited to: description information of valid data in the first logical storage area, and an execution sequence number of the first logical storage area. Moreover, the format of the first GC information is a format supported by the information management interface.
其中,有效数据的描述信息用于描述有效数据的LBA和LBA长度。例如,有效数据的描述信息可以为{起始地址,长度},比如:{0x10000,32KB},{(0x40000000,256KB),(0x40100000,256KB)}。Wherein, the description information of the valid data is used to describe the LBA and the LBA length of the valid data. For example, the description information of valid data may be {start address, length}, such as: {0x10000, 32KB}, {(0x40000000, 256KB), (0x40100000, 256KB)}.
处理器在得到第一GC信息后,可以通过信息管理接口向存储器控制器发送第一GC信息。After obtaining the first GC information, the processor may send the first GC information to the memory controller through the information management interface.
存储器控制器在通过信息管理接口接收到第一GC信息后,根据第一GC信息,确定存储器控制器执行第二GC操作的第一目标物理存储区。After the memory controller receives the first GC information through the information management interface, according to the first GC information, determine the first target physical storage area where the memory controller performs the second GC operation.
在一些实施例中,本申请实施例提供的一种垃圾回收方法,可以应用于如图1所示的存储系统中的存储器控制器,还可以应用于如图3所示的存储系统中的存储器控制器。如图5所示,该方法包括:In some embodiments, a garbage collection method provided in the embodiment of the present application can be applied to the memory controller in the storage system as shown in FIG. 1 , and can also be applied to the memory controller in the storage system as shown in FIG. 3 controller. As shown in Figure 5, the method includes:
S501:通过信息管理接口接收处理器发送的第一GC信息。S501: Receive first GC information sent by a processor through an information management interface.
需要说明的是,第一GC信息用于指示处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区。It should be noted that the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation on the logical storage space.
S502:将第一逻辑存储区映射为物理存储空间中的至少一个第一物理存储区。S502: Map the first logical storage area to at least one first physical storage area in the physical storage space.
存储器控制器在接收到第一GC信息后,对第一GC信息进行解析;并根据解析结果,确定第一逻辑存储区。其中,解析结果包括但不限于:位于第一逻辑存储区的第一有效数据的LBA(后续可以简称为第一LBA),以及LBA长度。After receiving the first GC information, the memory controller analyzes the first GC information; and determines the first logical storage area according to the analysis result. Wherein, the parsing result includes, but is not limited to: the LBA of the first valid data located in the first logical storage area (hereinafter may be referred to as the first LBA for short), and the LBA length.
可选的,当所述存储器控制器确定所述第一LBA之后,可以根据LBA和PBA的映射关系,将第一LBA映射为第一PBA,最后将该第一PBA对应的物理存储区作为第一物理存储区。Optionally, after the memory controller determines the first LBA, it may map the first LBA to the first PBA according to the mapping relationship between the LBA and the PBA, and finally use the physical storage area corresponding to the first PBA as the first LBA. A physical storage area.
S503:在所述物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区。S503: In the physical storage space, determine multiple second physical storage areas that need to perform the second GC operation.
存储器控制器可以根据预先配置的物理垃圾回收策略,在物理存储空间中,确定多个第二物理存储区。其中,物理垃圾回收策略可以为物理存储区中存储的无效数据或垃圾数据达到一定比例,也可以为其他垃圾回收条件,本申请在此并不作限。The memory controller may determine multiple second physical storage areas in the physical storage space according to a preconfigured physical garbage collection policy. Wherein, the physical garbage collection strategy may be that the invalid data or garbage data stored in the physical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
存储器控制器在确定需要执行第二GC操作的多个第二物理存储区之后,可以将多个第二物理存储区添加到管理队列中。其中,管理队列中的第二物理存储区可以按照无效比 例的大小进行排序。After the memory controller determines the multiple second physical storage areas that need to perform the second GC operation, it may add the multiple second physical storage areas to the management queue. Wherein, the second physical storage area in the management queue can be sorted according to the size of the invalid ratio.
例如,如图6所示,存储器控制器将第二物理存储区添加到管理队列时,可以将多个二物理存储区按照无效比例的大小从大到小排序。又例如,存储器控制器在对管理队列中的多个第二物理存储区进行排序时,可以按照无效比例的大小从小到大排序。For example, as shown in FIG. 6 , when adding the second physical storage area to the management queue, the memory controller may sort the multiple second physical storage areas according to the size of the invalid ratio from large to small. For another example, when the memory controller sorts the multiple second physical storage areas in the management queue, it may sort the invalid ratios from small to large.
需要说明的是,本申请实施例中包括但不限于采用上述方式确定第二物理存储区,存储器控制器也可以采用其它方式进行确定,此处不再一一列举说明。It should be noted that the embodiments of the present application include but are not limited to determining the second physical storage area in the above manner, and the memory controller may also determine in other manners, which will not be listed here.
无论是处理器的GC操作,还是存储器控制器的GC操作,最终都是对物理存储空间中的数据进行处理。因此,当第一GC操作所处理的数据和第二GC操作所处理的数据存在交集的话,那么处理器即将执行的第一GC操作可能会对存储器控制器即将执行的第二GC操作产生影响,即可能会发生由于存储器控制器和处理器的GC功能叠加导致存储器的性能下降。Regardless of the GC operation of the processor or the GC operation of the memory controller, the data in the physical storage space is finally processed. Therefore, if there is an intersection between the data processed by the first GC operation and the data processed by the second GC operation, the first GC operation to be executed by the processor may have an impact on the second GC operation to be executed by the memory controller, That is, performance degradation of the memory may occur due to superposition of GC functions of the memory controller and the processor.
为了降低由于上述情况对存储器的性能产生的影响,在本申请实施例中,存储器控制器在通过S502确定出至少一个第一物理存储区,并通过S503确定多个第二物理存储区后,还可以判断多个第二物理存储区与至少一个第一物理存储区之间是否存在交集;若存在交集,则执行步骤S504。In order to reduce the impact of the above situation on the performance of the memory, in the embodiment of the present application, after the memory controller determines at least one first physical storage area through S502 and determines multiple second physical storage areas through S503, it also It may be determined whether there is an intersection between the plurality of second physical storage areas and at least one first physical storage area; if there is an intersection, step S504 is performed.
S504:当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区。S504: When there is an intersection between the at least one first physical storage area and the multiple second physical storage areas, determine at least one second physical storage area to be selected from the multiple second physical storage areas.
需要说明的是,至少一个待选第二物理存储区与至少一个第一物理存储区不存在交集。It should be noted that there is no intersection between at least one second physical storage area to be selected and at least one first physical storage area.
可选的,存储器控制器可以但不限于通过以下步骤,确定所述至少一个待选第二物理存储区。Optionally, the memory controller may, but is not limited to, determine the at least one second physical storage area to be selected through the following steps.
所述存储器控制器可以根据位于第一逻辑存储区的第一有效数据与多个第二物理存储区中存储的第二有效数据,从多个第二物理存储区中选择影响因子小于设定阈值的至少一个待选第二物理存储区。The memory controller may select from the multiple second physical storage areas that the impact factor is less than the set threshold according to the first valid data located in the first logical storage area and the second valid data stored in the multiple second physical storage areas At least one second physical storage area to be selected.
需要说明的是,每个第二物理存储区的影响因子用于表征所述第一有效数据和所述第二物理存储区中第二有效数据的交集在所述第二物理存储区中占用的存储空间。It should be noted that the impact factor of each second physical storage area is used to represent the intersection of the first valid data and the second valid data in the second physical storage area occupied by the second physical storage area storage.
所述存储器控制器在多个第二物理存储区中,选择影响因子小于设定阈值的待选第二物理存储区。其中,影响因子小于设定阈值的第二物理存储区,表示该第二物理存储区与第一逻辑存储区中存储的有效数据的交集不高,因此,第二物理存储区中的有效数据受到第一GC操作的影响较小。The memory controller selects a candidate second physical storage area whose impact factor is smaller than a set threshold among the plurality of second physical storage areas. Wherein, the second physical storage area whose impact factor is less than the set threshold means that the intersection of the second physical storage area and the valid data stored in the first logical storage area is not high, therefore, the valid data in the second physical storage area is affected by The first GC operation has less impact.
可选的,所述存储器控制器在确定待选第二物理存储区时,可以针对每个第二物理存储区,分别执行如下操作:存储器控制器确定第一有效数据的第一PBA,与该第二物理存储区中的第二有效数据的第二PBA的交集,并将该交集对应的有效数据在第二物理存储区中占用的存储空间作为第二物理存储区的影响因子。Optionally, when the memory controller determines the second physical storage area to be selected, the following operations may be performed for each second physical storage area: the memory controller determines the first PBA of the first valid data, and the The intersection of the second PBAs of the second valid data in the second physical storage area, and use the storage space occupied by the valid data corresponding to the intersection in the second physical storage area as an influencing factor of the second physical storage area.
S505:在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。S505: Determine a first target physical storage area where the memory controller performs the second GC operation in the at least one candidate second physical storage area.
所述存储器控制器在至少一个待选第二物理存储区中,确定第一目标物理存储区。其中,影响因子小于设定阈值的待选第二物理存储区,表示该待选第二物理存储区与第一逻辑存储区中存储的有效数据的交集不高,因此,待选第二物理存储区中的有效数据受到第一GC操作的影响较小。因此,当处理器对第一逻辑存储区执行第一GC操作时,影响因子小于设定阈值的待选第二物理存储区中被无效化的有效数据较少,对存储器控制器对该 待选第二物理存储区执行第二GC操作的执行效率的影响较小。然而,第二物理存储区的影响因子大于或等于设定阈值,表示该第二物理存储区与第一逻辑存储区中存储的有效数据的交集较高,并且,当处理器对第一逻辑存储区执行第一GC操作时,该第二物理存储区中被无效化的有效数据较多,对存储器控制器对该第二物理存储区执行第二GC操作的执行效率的影响较大。存储器控制器从影响因子小于设定阈值的待选第二物理存储区为第一目标物理存储区,使得影响因子大于或等于设定阈值的第二物理存储区靠后一些执行,能够使处理器在对第一逻辑存储区执行第一GC操作时,减少影响因子大于或等于设定阈值的第二物理存储区中的有效数据,从而达到降低存储器控制器后续对影响因子大于或等于设定阈值的第二物理存储区执行第二GC操作时搬移有效数据的工作量。综上可知,从影响因子小于设定阈值的待选第二物理存储区中确定第一目标物理存储区,可以降低存储器控制器后续执行第二GC操作时无效搬移有效数据的工作量。The memory controller determines a first target physical storage area in at least one second physical storage area to be selected. Among them, the second physical storage area to be selected whose impact factor is less than the set threshold indicates that the intersection of the second physical storage area to be selected and the valid data stored in the first logical storage area is not high, therefore, the second physical storage area to be selected Valid data in a region is less affected by the first GC operation. Therefore, when the processor executes the first GC operation on the first logical storage area, the invalidated valid data in the candidate second physical storage area whose impact factor is smaller than the set threshold is less, and the memory controller will use the GC operation on the candidate second physical storage area. The impact on the execution efficiency of the second GC operation performed by the second physical storage area is small. However, the impact factor of the second physical storage area is greater than or equal to the set threshold, which means that the intersection of the second physical storage area and the valid data stored in the first logical storage area is relatively high, and when the processor compares the first logical storage area When the first GC operation is performed in the second physical storage area, there are more valid data invalidated in the second physical storage area, which greatly affects the execution efficiency of the second GC operation performed by the memory controller in the second physical storage area. The memory controller selects the second physical storage area whose impact factor is less than the set threshold as the first target physical storage area, so that the second physical storage area whose impact factor is greater than or equal to the set threshold is executed later, so that the processor can When performing the first GC operation on the first logical storage area, reduce the effective data in the second physical storage area whose impact factor is greater than or equal to the set threshold, so as to reduce the memory controller's subsequent impact on the impact factor greater than or equal to the set threshold The workload of moving valid data when performing the second GC operation in the second physical storage area. To sum up, it can be seen that determining the first target physical storage area from the candidate second physical storage areas whose impact factor is smaller than the set threshold can reduce the workload of invalidly moving valid data when the memory controller subsequently executes the second GC operation.
存储器控制器在多个第二物理存储区中,选择影响因子小于设定阈值的至少一个待选第二物理存储区,并确定至少一个待选第二物理存储区中每个待选第二物理存储区的无效比例。然后,存储器控制器可以但不限于通过下列方式根据多个待选第二物理存储区的无效比例,在多个待选第二物理存储区中选择第一目标物理存储区。The memory controller selects at least one candidate second physical storage zone whose impact factor is smaller than a set threshold among the plurality of second physical storage zones, and determines each candidate second physical storage zone in the at least one candidate second physical storage zone. Invalid scale for bucket. Then, the memory controller may, but not limited to, select the first target physical storage area among the plurality of second physical storage areas to be selected according to the invalid ratio of the plurality of second physical storage areas to be selected in the following manner.
方式1:存储器控制器在多个待选第二物理存储区中,可以选择无效比例最大的待选二物理存储区为第一目标物理存储区。Mode 1: The memory controller may select the second physical storage area to be selected with the largest invalidation ratio among multiple second physical storage areas to be selected as the first target physical storage area.
例如,物理存储区8和物理存储区305的无效比例分别为78%和70%,物理存储区8和物理存储区305的影响因子小于设定阈值时,存储器将无效比例为78%的物理存储区8作为第一目标物理存储区。For example, the invalid proportions of physical storage area 8 and physical storage area 305 are 78% and 70% respectively, and when the impact factors of physical storage area 8 and physical storage area 305 are less than the set threshold, the storage will invalidate the physical storage area with a proportion of 78%. Area 8 serves as the first target physical storage area.
存储器控制器采用方式1确定第一目标物理存储区时,由于是从受到第一GC操作的影响较小的多个待选第二物理存储区中选择第一目标物理存储区,进而可以降低存储器控制器在执行后续第二GC操作时无效搬移有效数据的工作量;并且,由于存储器控制器选择无效比例最大的待选第二物理存储区作为第一目标物理存储区,可以保证存储器控制器对第一目标物理存储区执行第二GC操作的效率。综上所述,存储器控制器采用方式1确定第一目标物理存储区,可以在保证存储器控制器对第一目标物理存储区执行第二GC操作的效率的同时,降低存储器控制器后续执行第二GC操作时无效搬移有效数据的工作量。When the memory controller uses method 1 to determine the first target physical storage area, since it selects the first target physical storage area from multiple candidate second physical storage areas that are less affected by the first GC operation, it can further reduce memory consumption. When the controller performs the subsequent second GC operation, it invalidates the workload of moving valid data; and, since the memory controller selects the candidate second physical storage area with the largest invalid ratio as the first target physical storage area, it can be guaranteed that the memory controller is The efficiency with which the second GC operation is performed on the first target physical storage area. To sum up, the memory controller uses method 1 to determine the first target physical storage area, which can reduce the memory controller’s subsequent execution of the second GC operation while ensuring the efficiency of the memory controller’s execution of the second GC operation on the first target physical storage area. The workload of effectively moving valid data during GC operations.
方式2:存储器控制器可在多个待选第二物理存储区中,选择无效比例第二大的待选第二物理存储区为第一目标物理存储区。Way 2: The memory controller may select the second physical storage area to be selected with the second largest invalidation ratio among multiple second physical storage areas to be selected as the first target physical storage area.
例如,物理块8、物理块80和物理块305的无效比例分别为78%、75%和70%,存储器控制器可以将无效比例为75%的物理块80作为第一目标物理存储区。For example, the invalid ratios of physical block 8, physical block 80, and physical block 305 are 78%, 75%, and 70% respectively, and the memory controller may use physical block 80 with an invalid ratio of 75% as the first target physical storage area.
存储器控制器采用方式2确定第一目标物理存储区时,由于是从受到第一GC操作的影响较小的多个待选第二物理存储区中选择第一目标物理存储区,进而可以降低存储器控制器在执行后续GC操作时无效搬移有效数据的工作量;并且,由于存储器控制器选择无效比例第二大的待选第二物理存储区作为第一目标物理存储区,可以尽可能地保证存储器控制器对第一目标物理存储区执行第二GC操作的效率。综上所述,存储器控制器采用方式2确定第一目标物理存储区,可以在降低存储器控制器后续执行第二GC操作时无效搬移有效数据的工作量的同时,尽可能地保证存储器控制器对第一目标物理存储区执行第二GC操作的效率。When the memory controller uses method 2 to determine the first target physical storage area, since the first target physical storage area is selected from multiple candidate second physical storage areas that are less affected by the first GC operation, the memory can be reduced. The controller invalidates the workload of moving valid data when performing subsequent GC operations; and, since the memory controller selects the candidate second physical storage area with the second largest invalid ratio as the first target physical storage area, it can ensure that the memory Efficiency with which the controller performs the second GC operation on the first target physical storage area. To sum up, the memory controller adopts method 2 to determine the first target physical storage area, which can reduce the workload of the memory controller to invalidly move valid data when the memory controller subsequently executes the second GC operation, and at the same time ensure that the memory controller is as good as possible. The efficiency with which the second GC operation is performed on the first target physical storage area.
方式3:存储器控制器可在多个待选第二物理存储区中,选择无效比例相对较大、影 响因子相对较小的待选第二物理存储区为第一目标物理存储区。Mode 3: The memory controller may select a candidate second physical storage area with a relatively large invalidation ratio and a relatively small impact factor among multiple candidate second physical storage areas as the first target physical storage area.
例如,设定阈值为5%;物理块8、物理块80和物理块305的无效比例分别为78%、75%和70%,物理块8、物理块80和物理块305的影响因子分别为4%、1%和3%时,存储器控制器可以将无效比例为75%的物理块80作为第一目标物理存储区。For example, the threshold is set at 5%; the invalid ratios of physical block 8, physical block 80, and physical block 305 are 78%, 75%, and 70% respectively, and the impact factors of physical block 8, physical block 80, and physical block 305 are respectively When 4%, 1% and 3%, the memory controller may use the physical block 80 with an invalid ratio of 75% as the first target physical storage area.
存储器控制器采用方式3确定第一目标物理存储区时,由于是从受到第一GC操作的影响较小的多个待选第二物理存储区中,选择无效比例相对较大、影响因子相对较小的待选第二物理存储区为第一目标物理存储区,进而可以在降低存储器控制器在执行后续第二GC操作时无效搬移有效数据的工作量的基础上,尽可能地在降低存储器控制器对第一目标物理存储区执行第二GC操作时的无效搬移有效数据的工作量的同时,保证存储器控制器对第一目标物理存储区执行第二GC操作的效率。When the memory controller uses method 3 to determine the first target physical storage area, since it is selected from multiple candidate second physical storage areas that are less affected by the first GC operation, the invalid ratio is relatively large and the impact factor is relatively small. The small second physical storage area to be selected is the first target physical storage area, which can further reduce the memory control workload as much as possible on the basis of reducing the workload of the memory controller to move valid data ineffectively when executing the subsequent second GC operation. While reducing the workload of effectively moving valid data when the memory controller performs the second GC operation on the first target physical storage area, the efficiency of the second GC operation performed by the memory controller on the first target physical storage area is ensured.
另外,当存储器控制器确定多个待选第二物理存储区的无效比例均较小时,存储器控制器还可以但不限于通过下列方式根据多个待选第二物理存储区的无效比例,在剩余第二物理存储区中选择第一目标物理存储区。其中,所述剩余第二物理存储区为影响因子大于或等于设定阈值的第二物理存储区。In addition, when the memory controller determines that the invalid ratios of the plurality of second physical storage areas to be selected are all relatively small, the memory controller may also, but not limited to The first target physical storage area is selected from the second physical storage area. Wherein, the remaining second physical storage area is a second physical storage area whose impact factor is greater than or equal to a set threshold.
方式4:存储器控制器在多个剩余第二物理存储区中选取无效比例较大、影响因子较小的第二物理存储区作为第一目标物理存储区。Mode 4: The memory controller selects a second physical storage area with a larger invalidation ratio and a smaller impact factor among the remaining second physical storage areas as the first target physical storage area.
例如,设定阈值为5%;第二物理存储区20、第二物理存储区30、第二物理存储区40、第二物理存储区83、第二物理存储区8、第二物理存储区305和第二物理存储区80的无效比例分别为61%、62%、61%、63%、80%、76%和72%,第二物理存储区20、第二物理存储区30、第二物理存储区40、第二物理存储区83、第二物理存储区8、第二物理存储区80和第二物理存储区305的影响因子分别为2%,4%,3%,2%,9%,8%,11%,其中,第二物理存储区20、第二物理存储区30、第二物理存储区40、第二物理存储区83为待选第二物理存储区;当多个待选第二物理存储区的无效比例均小于65%时,存储器控制器可以选取无效比例为76%、影响因子为8%的第二物理存储区305作为第一目标物理存储区;存储器控制器还可以选取无效比例为80%、影响因子为9%的第二物理存储区8作为第一目标物理存储区。For example, the setting threshold is 5%; the second physical storage area 20, the second physical storage area 30, the second physical storage area 40, the second physical storage area 83, the second physical storage area 8, the second physical storage area 305 and the invalid proportions of the second physical storage area 80 are 61%, 62%, 61%, 63%, 80%, 76% and 72% respectively, the second physical storage area 20, the second physical storage area 30, the second physical storage area The influence factors of storage area 40, second physical storage area 83, second physical storage area 8, second physical storage area 80 and second physical storage area 305 are 2%, 4%, 3%, 2%, 9% respectively , 8%, 11%, wherein, the second physical storage area 20, the second physical storage area 30, the second physical storage area 40, the second physical storage area 83 are the second physical storage areas to be selected; when multiple When the invalid proportions of the second physical storage areas are all less than 65%, the memory controller can select the second physical storage area 305 with an invalid proportion of 76% and an impact factor of 8% as the first target physical storage area; the memory controller can also The second physical storage area 8 with an invalid ratio of 80% and an impact factor of 9% is selected as the first target physical storage area.
在多个待选第二物理存储区的无效比例均较小时,即使存储器控制器从多个待选第二物理存储区中选择第一目标物理存储区,能够适当地减少一点降低存储器控制器后续执行第二GC操作时无效搬移有效数据的工作量,但是由于待选第二物理存储区的无效比例较小,会使得存储器控制器在降低一点点无效搬移有效数据的工作量的基础上,对第一目标物理存储区执行第二GC操作时需要搬移的有效数据的工作量增加,导致存储器控制器对第一目标物理存储区执行第二GC操作的效率较低。存储器控制器采用方式4确定第一目标物理存储区时,会选择无效比例相对较大、影响因子相对较小的剩余第二物理存储区为第一目标物理存储区,进而可以在保证存储器控制器对第一目标物理存储区执行第二GC操作的效率的基础上,尽可能地降低存储器控制器在执行后续GC操作时无效搬移有效数据的工作量。When the invalid ratios of multiple second physical storage areas to be selected are small, even if the memory controller selects the first target physical storage area from multiple second physical storage areas to be selected, it can properly reduce the subsequent When the second GC operation is performed, the workload of moving valid data is invalid, but because the invalid ratio of the second physical storage area to be selected is relatively small, the memory controller will reduce the workload of moving valid data by a little bit. When the first target physical storage area performs the second GC operation, the workload of valid data that needs to be moved increases, resulting in low efficiency of the memory controller performing the second GC operation on the first target physical storage area. When the memory controller uses method 4 to determine the first target physical storage area, it will select the remaining second physical storage area with a relatively large invalidation ratio and a relatively small impact factor as the first target physical storage area, thereby ensuring that the memory controller On the basis of the efficiency of performing the second GC operation on the first target physical storage area, the workload of the memory controller for invalidly moving valid data when performing subsequent GC operations is reduced as much as possible.
在另一些实施例中,所述存储器控制器根据每个第二物理存储区的影响因子,还可以但不限于通过以下方案,在所述多个第二物理存储区中确定所述第一目标物理存储区。In some other embodiments, the memory controller may also determine the first target in the plurality of second physical storage areas according to the impact factor of each second physical storage area, but not limited to the following scheme: Physical storage area.
存储器控制器在多个第二物理存储区中,确定影响因子小于设定阈值的待选第二物理存储区的数量为0时,存储器控制器可以将影响因子最小的第二物理存储区作为第一目标 物理存储区,还可以将无效比例最大的第二物理存储区作为第一目标物理存储区,也可以将无效比例较大、影响因子较小的第二物理存储区作为第一目标物理存储区。When the memory controller determines that the number of candidate second physical storage areas whose impact factor is smaller than the set threshold is 0 among the plurality of second physical storage areas, the memory controller may use the second physical storage area with the smallest impact factor as the second physical storage area. A target physical storage area, the second physical storage area with the largest invalid ratio can also be used as the first target physical storage area, or the second physical storage area with a larger invalid ratio and a smaller impact factor can be used as the first target physical storage area district.
例如,设定阈值为5%;物理块8、物理块305和物理块211的无效比例分别为80%、76%和70%,物理块8、物理块305和物理块211的影响因子分别为9%,8%,11%,均大于设定阈值时,存储器控制器可以将影响因子最小的物理块305作为第一目标物理存储区,还可以将无效比例最大的物理块8作为第一目标物理存储区。For example, the threshold is set at 5%; the invalid ratios of physical block 8, physical block 305, and physical block 211 are 80%, 76%, and 70% respectively, and the impact factors of physical block 8, physical block 305, and physical block 211 are respectively When 9%, 8%, and 11% are all greater than the set threshold, the memory controller may use the physical block 305 with the smallest impact factor as the first target physical storage area, and may also use the physical block 8 with the largest invalid ratio as the first target. Physical storage area.
存储器控制器采用上述方案确定第一目标物理存储区时,将影响因子最小的第二物理存储区作为第一目标物理存储区可以降低存储器控制器后续执行第二GC操作时无效搬移有效数据的工作量;将无效比例最大的第二物理存储区作为第一目标物理存储区可以保证存储器控制器对第一目标物理存储区执行第二GC操作的执行效率;将无效比例较大、影响因子较小的第二物理存储区作为第一目标物理存储区可以在保证存储器控制器对第一目标物理存储区执行第二GC操作的执行效率的同时,尽可能地降低存储器控制器后续执行第二GC操作时无效搬移有效数据的工作量。When the memory controller uses the above scheme to determine the first target physical storage area, using the second physical storage area with the smallest impact factor as the first target physical storage area can reduce the work of invalidly moving valid data when the memory controller subsequently executes the second GC operation amount; using the second physical storage area with the largest invalid ratio as the first target physical storage area can ensure the execution efficiency of the second GC operation performed by the memory controller on the first target physical storage area; if the invalid ratio is large, the impact factor is small The second physical storage area as the first target physical storage area can reduce the subsequent execution of the second GC operation by the memory controller as much as possible while ensuring the execution efficiency of the second GC operation performed by the memory controller on the first target physical storage area. The workload of effectively moving valid data is invalid.
需要说明的是,本申请实施例中包括但不限于采用上述方式确定第一目标物理存储区,存储器控制器也可以采用其它方式进行确定,此处不再一一列举说明。It should be noted that the embodiments of the present application include but are not limited to determining the first target physical storage area in the above manner, and the memory controller may also determine in other manners, which will not be listed here.
在前面各个方式中,存储器控制器将确定出多个第二物理存储区添加到管理队列中时,可以按照多个第二物理存储区的无效比例的大小进行排序,还可以按照多个第二物理存储区的影响因子的大小进行排序。并且,在存储器控制器确定出第一目标物理存储区后,对第一目标物理存储区执行第二GC操作时,需要从管理队列中删除第一目标物理存储区。In the foregoing manners, when the memory controller adds the determined multiple second physical storage areas to the management queue, it may sort the multiple second physical storage areas according to their The size of the influence factor of the physical storage area is sorted. Moreover, after the memory controller determines the first target physical storage area, when performing the second GC operation on the first target physical storage area, the first target physical storage area needs to be deleted from the management queue.
例如,如图6所示,管理队列1中的物理块8、物理块305、物理块211为存储器控制器确定出第二物理存储区,其中,物理块8、物理块305、物理块211的无效比例为80%、76%和70%;其中,管理队列1中的第二物理存储区是按照无效比例的大小由大到小进行排序的。其中,位于第一位的第二物理存储区为存储器控制器下一次执行第二GC操作的第一目标物理存储区。For example, as shown in FIG. 6, the physical block 8, the physical block 305, and the physical block 211 in the management queue 1 determine the second physical storage area for the memory controller, wherein the physical block 8, the physical block 305, and the physical block 211 The invalid ratios are 80%, 76% and 70%; wherein, the second physical storage area in the management queue 1 is sorted according to the size of the invalid ratio from large to small. Wherein, the second physical storage area at the first position is the first target physical storage area for the memory controller to perform the second GC operation next time.
存储器控制器在接收到处理器发送的第一GC信息后,确定第一逻辑存储区在物理存储空间映射得到的第一物理存储区为物理块8;存储器控制器确定物理块8中的部分或者全部有效数据将会被处理器搬移到其他物理存储区中。存储器控制器确定物理块8的影响因子为10%大于设定阈值后,调整管理队列1中物理块8、物理块305、物理块211的顺序。存储器控制器可以将管理队列1中物理块305的位置移动到首位,作为第一目标物理存储区,得到管理队列2。存储器控制器对第一目标物理存储区物理块305执行第二GC操作,并将物理块305从管理队列2中删除;存储器控制器在完成对物理块305的第二GC操作后,处理器也完成了对之前发送给存储器控制器的第一逻辑存储区的第一GC操作,将第一逻辑存储区中的第一有效数据搬移到其他存储区域,此时,物理块8的无效比例由80%变更为90%,得到管理队列3。After receiving the first GC information sent by the processor, the memory controller determines that the first physical storage area obtained by mapping the first logical storage area in the physical storage space is physical block 8; the memory controller determines that a part of the physical block 8 or All valid data will be moved to other physical storage areas by the processor. After the memory controller determines that the influence factor of the physical block 8 is 10% greater than the set threshold, it adjusts the sequence of the physical block 8 , the physical block 305 , and the physical block 211 in the management queue 1 . The memory controller may move the position of the physical block 305 in the management queue 1 to the first position, and obtain the management queue 2 as the first target physical storage area. The memory controller performs the second GC operation on the physical block 305 of the first target physical storage area, and deletes the physical block 305 from the management queue 2; after the memory controller completes the second GC operation on the physical block 305, the processor also The first GC operation on the first logical storage area previously sent to the memory controller is completed, and the first valid data in the first logical storage area is moved to other storage areas. At this time, the invalid ratio of physical block 8 is changed from 80 % changed to 90% to get admin queue 3.
从物理块8的无效比例变化可以看出,采用本申请中的垃圾回收方案,存储器控制器可以降低执行第二GC操作的搬移的有效数据的工作量。在本实施例中,物理块8大约减少了需要搬移的10%的有效数据的工作量,相对于原先20%的搬移有效数据的工作量,存储器控制器对物理块8执行第二GC操作的效率提升了50%。It can be seen from the change of the invalid ratio of the physical block 8 that by adopting the garbage collection scheme in the present application, the memory controller can reduce the workload of performing the second GC operation to move valid data. In this embodiment, the physical block 8 reduces the workload of moving valid data by about 10%. Compared with the original 20% workload of moving valid data, the memory controller performs the second GC operation on the physical block 8. Efficiency increased by 50%.
在一种实施方式中,处理器在向存储器控制器发送第一GC信息后,执行第一GC操作。In one embodiment, the processor performs the first GC operation after sending the first GC information to the memory controller.
可选的,处理器可以但不限于通过以下步骤,执行第一GC操作。Optionally, the processor may, but is not limited to, execute the first GC operation through the following steps.
a1:处理器对第一逻辑存储区执行第一GC操作时,将位于第一逻辑存储区的第一有效数据搬移至其他逻辑存储区中。其中,该其他逻辑存储区为无需执行第一GC操作的逻辑存储区。a1: when the processor executes the first GC operation on the first logical storage area, it moves the first valid data located in the first logical storage area to other logical storage areas. Wherein, the other logical storage area is a logical storage area that does not need to perform the first GC operation.
例如,如图7所示,逻辑存储空间中包含逻辑块1和2;其中,逻辑块1中的逻辑存储区间1和逻辑存储区间3中存储有效数据,逻辑存储区间2和逻辑存储区间4为空闲区域;逻辑块2中的逻辑存储区间3中存储有效数据,逻辑存储区间1、逻辑存储区间2和逻辑存储区间4为空闲区域。其中,逻辑块1为需要执行第一GC操作的第一逻辑存储区,逻辑块2为无需执行第一GC操作的逻辑存储区。For example, as shown in Figure 7, the logical storage space includes logical blocks 1 and 2; wherein, valid data is stored in the logical storage interval 1 and the logical storage interval 3 in the logical block 1, and the logical storage interval 2 and the logical storage interval 4 are Free area: valid data is stored in the logical storage area 3 in the logical block 2, and the logical storage area 1, the logical storage area 2 and the logical storage area 4 are free areas. Wherein, logical block 1 is the first logical storage area that needs to perform the first GC operation, and logical block 2 is the logical storage area that does not need to perform the first GC operation.
如图8所示,处理器对逻辑块1执行第一GC操作,可以将逻辑块1中的逻辑存储区间1和逻辑存储区间3中存储的有效数据搬移至逻辑块2中的逻辑存储区间1和逻辑存储区间4。As shown in Figure 8, the processor performs the first GC operation on logical block 1, and can move the valid data stored in logical storage interval 1 and logical storage interval 3 in logical block 1 to logical storage interval 1 in logical block 2 and logical bucket 4.
a2:处理器可以通过I/O接口将搬移至其他逻辑存储区中的第一有效数据写入到存储器中与其他逻辑存储区对应的其他物理存储区中。其中,处理器可以通过异地更新将第一有效数据写入到其他物理存储区中。a2: The processor may write the first valid data moved to other logical storage areas into other physical storage areas in the memory corresponding to the other logical storage areas through the I/O interface. Wherein, the processor may write the first valid data into other physical storage areas through remote updating.
可选的,在a2中,处理器在将第一有效数据搬移至其他逻辑存储区中时,可以通过处理器与存储器之间的I/O接口向存储器控制器发送重新写入第一有效数据的IO请求,以使存储器控制器通过I/O接口可以根据该IO请求在其他物理存储区中重新写入第一有效数据。可选的,存储器控制器根据接收到的IO请求,可以但不限于通过以下步骤,在其他物理存储区中重新写入第一有效数据。Optionally, in a2, when the processor moves the first valid data to other logical storage areas, it can send the rewrite first valid data to the memory controller through the I/O interface between the processor and the memory. IO request, so that the memory controller can rewrite the first valid data in other physical storage areas according to the IO request through the I/O interface. Optionally, according to the received IO request, the memory controller may, but not limited to, rewrite the first valid data in other physical storage areas through the following steps.
b1:存储器控制器根据IO请求,确定第一有效数据的初始LBA和更新LBA;其中,初始LBA表示第一有效数据搬移前的LBA,更新LBA表示第一有效数据搬移后的LBA。b1: The memory controller determines the initial LBA and updated LBA of the first valid data according to the IO request; wherein, the initial LBA indicates the LBA before the first valid data is moved, and the updated LBA indicates the LBA after the first valid data is moved.
b2:存储器控制器将初始LBA映射为初始PBA,并将初始PBA对应的存储区域中存储的第一有效数据标记为无效数据。b2: the memory controller maps the initial LBA to the initial PBA, and marks the first valid data stored in the storage area corresponding to the initial PBA as invalid data.
可选的,当处理器将初始有效数据重新写入到存储器中的存储单元时,存储器将原本存储的第一有效数据标记为无效数据,降低存储器控制器执行第二空间操作时的无效搬移有效数据的工作量。Optionally, when the processor rewrites the initial valid data to the storage unit in the memory, the memory marks the originally stored first valid data as invalid data, reducing the invalidity of the memory controller when performing the second space operation. data workload.
b3:存储器控制器将更新LBA映射为更新PBA,并将IO请求中包含的第一有效数据,重新写入到更新PBA对应的其他物理存储区中的存储空间。b3: the memory controller maps the updated LBA to the updated PBA, and rewrites the first valid data contained in the IO request to the storage space in other physical storage areas corresponding to the updated PBA.
例如,如图7所示,逻辑存储空间中包含逻辑块1和逻辑块2;其中,逻辑块1中的逻辑存储区间1和逻辑存储区间3中存储有效数据,逻辑存储区间2和逻辑存储区间4为空闲区域;逻辑块2中的逻辑存储区间3中存储有效数据,逻辑存储区间1、逻辑存储区间2和逻辑存储区间4为空闲区域;逻辑存储空间中的逻辑块1中逻辑存储区间1的和逻辑存储区间3与物理存储空间中的物理块1中物理存储区间1和物理存储区间2分别为一一映射关系。For example, as shown in Figure 7, the logical storage space includes logical block 1 and logical block 2; wherein, logical storage interval 1 and logical storage interval 3 in logical block 1 store valid data, logical storage interval 2 and logical storage interval 4 is a free area; valid data is stored in logical storage interval 3 in logical block 2, logical storage interval 1, logical storage interval 2 and logical storage interval 4 are free areas; logical storage interval 1 in logical block 1 in logical storage space The logical storage interval 3 and the physical storage interval 1 and the physical storage interval 2 in the physical block 1 in the physical storage space respectively have a one-to-one mapping relationship.
进一步的,如图8所示,处理器通过I/O接口向存储器控制器发送I/O请求,将搬移至逻辑块2中的有效数据重新写入到存储单元中。具体地,处理器通过IO接口向存储器控制器发送重新写入有效数据的IO请求。存储器控制器基于该IO请求,确定有效数据重新写入的存储区域为物理块2中的物理存储区间2和物理存储区间5,以及有效数据在存储器中原本的存储区域为物理块1中物理存储区间1和物理存储区间2。存储器控制器将 物理块1中物理存储区间1和物理存储区间2中存储的有效数据标记为无效数据,并在物理块2中的物理存储区间2和物理存储区间5中重新写入有效数据。Further, as shown in FIG. 8 , the processor sends an I/O request to the memory controller through the I/O interface, and rewrites the valid data moved to the logic block 2 into the storage unit. Specifically, the processor sends an IO request for rewriting valid data to the memory controller through the IO interface. Based on the IO request, the memory controller determines that the storage area where the valid data is rewritten is the physical storage interval 2 and the physical storage interval 5 in the physical block 2, and the original storage area of the valid data in the memory is physically stored in the physical block 1 Interval 1 and Physical Storage Interval 2. The memory controller marks the valid data stored in physical storage interval 1 and physical storage interval 2 in physical block 1 as invalid data, and rewrites valid data in physical storage interval 2 and physical storage interval 5 in physical block 2.
在另一种可能的方式中,处理器还可以通过追加写的方式将第一有效数据写入到其他物理存储区中。具体地,处理器将第一有效数据写入到其他物理存储区的存储空间的尾部,并将存储器中原本存储的第一有效数据标记为无效数据。In another possible manner, the processor may also write the first valid data into other physical storage areas by means of append writing. Specifically, the processor writes the first valid data to the end of the storage space of the other physical storage area, and marks the first valid data originally stored in the memory as invalid data.
在另一种实施方式中,处理器对第一逻辑存储区执行第一GC操作,将第一逻辑存储区中的第一有效数据删除,并通过I/O接口将存储器中存储的第一有效数据标记为无效数据。In another embodiment, the processor executes the first GC operation on the first logical storage area, deletes the first valid data in the first logical storage area, and deletes the first valid data stored in the memory through the I/O interface. Data marked as invalid data.
在一种实施方式中,当处理器对第一逻辑存储区执行完第一GC操作后,处理器可以通过信息管理接口向存储器控制器发送第一GC操作完成信息,还可以不向存储器控制器发送第一GC操作完成信息。其中,第一GC操作完成信息用于指示处理器已完成对第一逻辑存储区的第一GC操作。In one embodiment, after the processor finishes performing the first GC operation on the first logical storage area, the processor may send the first GC operation completion information to the memory controller through the information management interface, or may not send the first GC operation completion information to the memory controller Send the completion message of the first GC operation. Wherein, the first GC operation completion information is used to indicate that the processor has completed the first GC operation on the first logical storage area.
可选的,存储器控制器通过信息管理接口接收处理器发送的第一GC操作完成信息后,向处理器发送第一响应消息,通知处理器接收到了第一GC操作完成信息。然后,存储器控制器确定当前管理队列中每个第二物理存储区的无效比例;存储器控制器可以将无效比例最大的第二物理存储区作为存储器控制器下一次执行第二GC操作的第二目标物理存储区,还可以将当前管理队列中无效比例最大的第二物理存储区作为存储器控制器下一次执行第二GC操作的第二目标物理存储区。Optionally, after receiving the first GC operation completion information sent by the processor through the information management interface, the memory controller sends a first response message to the processor, notifying the processor that the first GC operation completion information has been received. Then, the memory controller determines the invalid ratio of each second physical storage area in the current management queue; the memory controller may use the second physical storage area with the largest invalid ratio as the second target for the memory controller to perform the second GC operation next time The physical storage area may also use the second physical storage area with the largest invalid ratio in the current management queue as the second target physical storage area for the memory controller to perform the second GC operation next time.
在该本申请实施例中,由于存储器控制器根据第一逻辑存储区确定存储器控制器下一次执行第二GC操作的第一目标物理存储区,在处理器对第一逻辑存储区执行第一GC操作时,会对应的搬移第一逻辑存储区中的有效数据,从而降低存储器控制器执行第二GC操作时的无效搬移有效数据的工作量,提高存储器控制器执行第二GC操作的效率,进而保证存储器的性能。In this embodiment of the present application, since the memory controller determines the first target physical storage area for the memory controller to perform the second GC operation on the basis of the first logical storage area, the processor executes the first GC on the first logical storage area. During operation, the valid data in the first logical storage area will be moved correspondingly, thereby reducing the workload of invalidly moving valid data when the memory controller performs the second GC operation, improving the efficiency of the memory controller performing the second GC operation, and then Guaranteed memory performance.
基于图4和图5所示的垃圾回收方案,下面以存储系统中的存储器为SSD,处理器为主机(host)为例,对该方案进行具体介绍。图9为本申请实施例提供的一种基于SSD和host的垃圾回收方法的交互流程示意图,下面参阅图9对该方法的具体流程进行说明。Based on the garbage collection scheme shown in FIG. 4 and FIG. 5 , the following takes the memory in the storage system as an SSD and the processor as a host (host) as an example to introduce the scheme in detail. FIG. 9 is a schematic diagram of an interaction flow of a garbage collection method based on SSD and host provided by an embodiment of the present application. The specific flow of the method will be described below with reference to FIG. 9 .
S901:host在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区。S901: In the logical storage space, the host determines the first logical storage area that needs to perform the first GC operation.
具体地,host可根据设定的逻辑垃圾回收策略,确定需要执行第一GC操作的第一逻辑存储区。Specifically, the host can determine the first logical storage area that needs to perform the first GC operation according to the set logical garbage collection policy.
例如,host根据逻辑垃圾回收策略,将无效比例大于50%的逻辑存储区作为需要执行第一GC操作的第一逻辑存储区。For example, according to the logical garbage collection policy, the host takes the logical storage area with an invalid ratio greater than 50% as the first logical storage area that needs to perform the first GC operation.
S902:host通过信息管理接口向SSD发送第一GC信息。S902: The host sends the first GC information to the SSD through the information management interface.
host将第一逻辑存储区的描述信息的格式转换为满足信息管理接口格式,得到第一GC信息。host通过信息管理接口向SSD发送第一GC信息。The host converts the format of the description information of the first logical storage area into a format satisfying the information management interface, and obtains the first GC information. The host sends the first GC information to the SSD through the information management interface.
S903:SSD在通过信息管理接口接收到第一GC信息后,对第一GC信息进行解析,得到第一逻辑存储区。S903: After receiving the first GC information through the information management interface, the SSD parses the first GC information to obtain a first logical storage area.
在一种可能的方式中,SSD在接收到第一GC信息后,通过信息管理接口向host发送第一响应消息,用以告知host已接收到第一GC信息。In a possible manner, after receiving the first GC information, the SSD sends a first response message to the host through the information management interface, to inform the host that the first GC information has been received.
具体的,SSD对第一GC信息进行解析,得到位于第一逻辑存储区的第一有效数据的 第一逻辑地址。Specifically, the SSD parses the first GC information to obtain the first logical address of the first valid data located in the first logical storage area.
S904:SSD将第一逻辑存储区映射为物理存储空间中的至少一个第一物理存储区。S904: The SSD maps the first logical storage area to at least one first physical storage area in the physical storage space.
具体地,SSD将第一有效数据的第一逻辑地址映射为第一物理地址,将第一物理地址对应的物理存储区作为第一物理存储区。Specifically, the SSD maps the first logical address of the first valid data to the first physical address, and uses the physical storage area corresponding to the first physical address as the first physical storage area.
S905:SSD在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区,并将多个第二物理存储区添加到管理队列中。S905: In the physical storage space, the SSD determines multiple second physical storage areas that need to perform the second GC operation, and adds the multiple second physical storage areas to the management queue.
需要说明的是,S904和S905可以并发执行,S904和S905之间没有执行顺序的依赖关系。It should be noted that S904 and S905 can be executed concurrently, and there is no execution sequence dependency between S904 and S905.
S906:SSD确定至少一个第一物理存储区与多个第二物理存储区存在交集。S906: The SSD determines that there is an intersection between at least one first physical storage area and multiple second physical storage areas.
S907:SSD根据位于第一逻辑存储区的第一有效数据与多个第二物理存储区中存储的第二有效数据,确定第一GC操作对每个第二物理存储区的影响因子。S907: The SSD determines an impact factor of the first GC operation on each second physical storage area according to the first valid data located in the first logical storage area and the second valid data stored in the plurality of second physical storage areas.
需要说明的是,影响因子用于表征第一有效数据和所述第二有效数据的交集在第二物理存储区中占用的存储空间。It should be noted that the impact factor is used to characterize the storage space occupied by the intersection of the first valid data and the second valid data in the second physical storage area.
S908:SSD在多个第二物理存储区中,选择影响因子小于设定阈值的多个待选第二物理存储区。S908: Among the multiple second physical storage areas, the SSD selects multiple second physical storage areas to be selected whose influence factors are smaller than a set threshold.
S909:SSD确定多个待选第二物理存储区中每个待选第二物理存储区的无效比例。S909: The SSD determines an invalid ratio of each second physical storage area to be selected in the plurality of second physical storage areas to be selected.
其中,任一个待选第二物理存储区的无效比例为待选第二物理存储区中无效数据占待选第二物理存储区的存储空间的比值。Wherein, the invalid ratio of any second physical storage area to be selected is the ratio of invalid data in the second physical storage area to be selected to the storage space of the second physical storage area to be selected.
S910:SSD在多个待选第二物理存储区中,选择无效比例最大的待选第二物理存储区为第一目标物理存储区。S910: Among the multiple second physical storage areas to be selected, the SSD selects the second physical storage area to be selected with the largest invalid ratio as the first target physical storage area.
S911:SSD对第一目标物理存储区执行第二GC操作,并从管理队列中删除第一目标物理存储区。S911: The SSD performs a second GC operation on the first target physical storage area, and deletes the first target physical storage area from the management queue.
S912:host对第一逻辑存储区执行第一GC操作。S912: the host performs a first GC operation on the first logical storage area.
S913:host通过信息管理接口向SSD发送第一GC操作完成信息。S913: the host sends the first GC operation completion information to the SSD through the information management interface.
其中,第一GC操作完成信息用于指示SSD已完成对第一逻辑存储区的第一GC操作。Wherein, the first GC operation completion information is used to indicate that the SSD has completed the first GC operation on the first logical storage area.
S914:SSD在通过信息管理接口接收到第一GC操作完成信息后,确定当前管理队列中每个第二物理存储区的无效比例。S914: After receiving the completion information of the first GC operation through the information management interface, the SSD determines the invalid ratio of each second physical storage area in the current management queue.
在一种可能的方式中,SSD在接收到第一GC操作完成信息后,通过信息管理接口向host发送第二响应消息,用以告知host已接收到第一GC操作完成信息。In a possible manner, after receiving the completion information of the first GC operation, the SSD sends a second response message to the host through the information management interface to inform the host that the information of the completion of the first GC operation has been received.
S915:SSD选择无效比例最大的第二物理存储区为SSD再下一次执行第二GC操作的第二目标物理存储区。S915: The SSD selects the second physical storage area with the largest invalid ratio as the second target physical storage area for the SSD to perform the second GC operation next time.
在图9所示的实施例中,由于SSD在通过信息管理接口接收到host发送的第一GC信息,根据第一GC信息确定host即将执行第一GC操作的第一逻辑存储区后,基于第一逻辑存储区中存储的第一有效数据和第二物理存储区中存储的第二有效数据的交集,确定第二物理存储区的影响。并且,由于SSD是根据影响因子,从第二物理存储区中选择第一目标物理存储区的,在host执行第一GC操作,搬移第一逻辑存储区中的有效数据时,会使得第二物理存储区中与第一逻辑存储区中的有效数据相同的有效数据无效化,从而降低SSD后续执行第二GC操作时的无效搬移有效数据的工作量,提高SSD后续执行第二GC操作的效率,进而保证SSD的性能;同时,由于SSD是选取影响因子小于设定阈值且无效比例最大的第二物理存储区为第一目标物理存储区,使得SSD在对第一目标物理存储区 执行第二GC操作时,在尽可能降低SSD执行第二GC操作时的无效搬移有效数据的工作量的同时,保证SSD执行第二GC操作的执行效率。In the embodiment shown in FIG. 9, since the SSD receives the first GC information sent by the host through the information management interface, after determining the first logical storage area where the host is about to perform the first GC operation according to the first GC information, based on the first The intersection of the first valid data stored in a logical storage area and the second valid data stored in the second physical storage area determines the influence of the second physical storage area. Moreover, since the SSD selects the first target physical storage area from the second physical storage area based on the impact factor, when the host performs the first GC operation to move valid data in the first logical storage area, the second physical storage area will The valid data in the storage area that is the same as the valid data in the first logical storage area is invalidated, thereby reducing the workload of invalidly moving valid data when the SSD subsequently executes the second GC operation, and improving the efficiency of the SSD's subsequent execution of the second GC operation, Further, the performance of the SSD is guaranteed; at the same time, since the SSD selects the second physical storage area whose impact factor is less than the set threshold and has the largest invalid ratio as the first target physical storage area, the SSD performs the second GC on the first target physical storage area. During operation, while reducing the workload of invalidly moving valid data when the SSD performs the second GC operation as much as possible, the execution efficiency of the SSD performing the second GC operation is guaranteed.
实施例2Example 2
本申请实施例提供的一种垃圾回收方法,可以应用于如图2所示的存储系统,还可以应用于如图3所示的存储系统,该存储系统包含:存储器和处理器,以及信息管理接口。该方法包括:A garbage collection method provided in the embodiment of the present application can be applied to the storage system shown in Figure 2, and can also be applied to the storage system shown in Figure 3, the storage system includes: memory and processor, and information management interface. The method includes:
存储器控制器向处理器发送第二GC信息,处理器根据第二GC信息确定处理器执行第四GC操作的第一目标逻辑存储区。The memory controller sends the second GC information to the processor, and the processor determines the first target logical storage area where the processor performs the fourth GC operation according to the second GC information.
可选的,存储器控制器可以但不限于通过以下步骤,向处理器发送第二GC信息。Optionally, the memory controller may, but not limited to, send the second GC information to the processor through the following steps.
c1:存储器控制器在物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区。c1: the memory controller determines at least one third physical storage area that needs to perform the third GC operation in the physical storage space.
可选的,存储器在物理存储空间中,根据物理垃圾回收策略确定需要执行第三GC操作的至少一个第三物理存储区。其中,物理垃圾回收策略可以是预先配置在存储器中的。Optionally, the memory is in the physical storage space, and at least one third physical storage area that needs to perform the third GC operation is determined according to the physical garbage collection policy. Wherein, the physical garbage collection policy may be pre-configured in the memory.
存储器控制器将物理存储空间中满足物理垃圾回收策略的物理存储区,确定为第三物理存储区。其中,物理垃圾回收策略可以为物理存储区中存储的无效数据或垃圾数据达到一定比例,也可以为其他垃圾回收条件,本申请在此并不作限。The memory controller determines a physical storage area that satisfies the physical garbage collection strategy in the physical storage space as the third physical storage area. Wherein, the physical garbage collection strategy may be that the invalid data or garbage data stored in the physical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
实施中,存储器控制器在确定多个第三物理存储区后,将多个第三物理存储区添加到管理队列中。In implementation, after determining the multiple third physical storage areas, the memory controller adds the multiple third physical storage areas to the management queue.
c2:将至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区。c2: mapping at least one third physical storage area to at least one second logical storage area in the logical storage space.
存储器控制器将第三物理存储区中存储的有效数据的PBA映射为逻辑存储空间的LBA,并根据第三物理存储区中存储的有效数据的PBA长度确定第三物理存储区中存储的有效数据在逻辑存储空间中的LBA长度,得到第三物理存储区在逻辑存储空间中对应的第二逻辑存储区中的有效数据的描述信息。The memory controller maps the PBA of the valid data stored in the third physical storage area to the LBA of the logical storage space, and determines the valid data stored in the third physical storage area according to the PBA length of the valid data stored in the third physical storage area The LBA length in the logical storage space obtains the description information of valid data in the second logical storage area corresponding to the third physical storage area in the logical storage space.
c3:存储器控制器通过信息管理接口向处理器发送第二GC信息。c3: the memory controller sends the second GC information to the processor through the information management interface.
需要说明的是,第二GC信息用于指示存储器控制器需要执行第三GC操作的至少一个第二逻辑存储区,即在执行S902之前,所述存储器还未执行所述第三GC操作。It should be noted that the second GC information is used to indicate at least one second logical storage area where the memory controller needs to perform the third GC operation, that is, before performing S902, the memory has not yet performed the third GC operation.
实施中,存储器控制器基于选择出的至少一个第二逻辑存储区的描述信息,得到第二GC信息。In an implementation, the memory controller obtains the second GC information based on the description information of the selected at least one second logical storage area.
其中,第二GC信息的格式为信息管理接口支持的格式。第二GC信息包括但不限于:位于第二逻辑存储区的有效数据的描述信息、第二逻辑存储区对应的第三物理存储区的执行序号。Wherein, the format of the second GC information is a format supported by the information management interface. The second GC information includes, but is not limited to: description information of valid data located in the second logical storage area, and an execution sequence number of the third physical storage area corresponding to the second logical storage area.
其中,有效数据的描述信息用于描述有效数据在逻辑存储空间的LBA和LBA长度。例如,有效数据的描述信息可以为{起始地址,长度},比如:{0x10000,32KB},{(0x40000000,256KB),(0x40100000,256KB)}。Wherein, the description information of the valid data is used to describe the LBA and LBA length of the valid data in the logical storage space. For example, the description information of valid data may be {start address, length}, such as: {0x10000, 32KB}, {(0x40000000, 256KB), (0x40100000, 256KB)}.
进一步的,存储器控制器在得到第二GC信息后,可以通过信息管理接口向处理器发送第二GC信息。Further, after obtaining the second GC information, the memory controller may send the second GC information to the processor through the information management interface.
在一种实施方式中,存储器控制器在通过信息管理接口向处理器发送第二GC信息之后,确定多个第三物理存储区中每个第三物理存储区的无效比例。存储器控制器将无效比 例最大的第三物理存储区作为存储器控制器下一次执行第三GC操作的第二目标物理存储区。存储器对第二目标物理存储区执行第三GC操作,从管理队列中删除第二目标物理存储区。In one embodiment, after the memory controller sends the second GC information to the processor through the information management interface, it determines the invalid ratio of each third physical storage area in the plurality of third physical storage areas. The memory controller takes the third physical storage area with the largest invalid ratio as the second target physical storage area for the memory controller to perform the third GC operation next time. The memory performs a third GC operation on the second target physical storage area, and deletes the second target physical storage area from the management queue.
可选的,存储器控制器向处理器发送第二GC信息后,处理器根据第二GC信息,可以但不限于通过以下步骤,确定第一目标逻辑存储区。Optionally, after the memory controller sends the second GC information to the processor, the processor may, but not limited to, determine the first target logical storage area through the following steps according to the second GC information.
d1:处理器通过信息管理接口接收来自存储器控制器的第二GC信息。d1: The processor receives the second GC information from the memory controller through the information management interface.
需要说明的是,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区。It should be noted that, the second GC information is used to indicate that the memory controller needs to perform the third GC operation on the physical storage space to map at least one second logic in the logical storage space to the third physical storage area storage area.
处理器在接收到第二GC信息后,对第二GC信息进行解析,并根据解析结果,确定第二逻辑存储区。其中,解析结果包括但不限于:位于第二逻辑存储区的第三有效数据的PBA(后续可以简称为第三PBA),以及PBA长度。After receiving the second GC information, the processor analyzes the second GC information, and determines the second logical storage area according to the analysis result. Wherein, the parsing result includes, but is not limited to: the PBA of the third valid data located in the second logical storage area (hereinafter may be referred to as the third PBA for short), and the length of the PBA.
d2:处理器在逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区。d2: In the logical storage space, the processor determines a plurality of third logical storage areas that need to perform the fourth GC operation.
在一种实施方式中,处理器可以根据预先配置的逻辑垃圾回收策略,在逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区。其中,逻辑垃圾回收策略可以为位于逻辑存储区的无效数据或垃圾数据达到一定比例,也可以为其他垃圾回收条件,本申请在此并不作限。In an implementation manner, the processor may determine a plurality of third logical storage areas that need to perform the fourth GC operation in the logical storage space according to a preconfigured logical garbage collection policy. Wherein, the logical garbage collection strategy may be that the invalid data or garbage data in the logical storage area reaches a certain percentage, or other garbage collection conditions, which are not limited in this application.
实施中,处理器在确定需要执行第四GC操作的多个第三逻辑存储区后,可以将多个第三逻辑存储区添加到管理队列中。其中,管理队列中的第三逻辑存储区可以按照无效比例的大小进行排序。In an implementation, after the processor determines the multiple third logical storage areas that need to perform the fourth GC operation, it may add the multiple third logical storage areas to the management queue. Wherein, the third logical storage area in the management queue can be sorted according to the size of the invalid ratio.
需要说明的是,本申请实施例中包括但不限于采用上述方式确定第三逻辑存储区,处理器也可以采用其它方式进行确定,此处不再一一列举说明。It should be noted that the embodiment of the present application includes but is not limited to determining the third logical storage area in the above manner, and the processor may also determine in other manners, which will not be listed here.
无论是处理器的GC操作,还是存储器控制器的GC操作,最终都是对物理存储空间中的数据进行处理。因此,当第三GC操作所处理的数据和第四GC操作所处理的数据存在交集的话,那么处理器即将执行的第四GC操作可能会对存储器控制器即将执行的第三GC操作产生影响,即可能会发生由于存储器控制器和处理器的GC功能叠加导致存储器的性能下降。Regardless of the GC operation of the processor or the GC operation of the memory controller, the data in the physical storage space is finally processed. Therefore, if there is an intersection between the data processed by the third GC operation and the data processed by the fourth GC operation, the fourth GC operation to be executed by the processor may have an impact on the third GC operation to be executed by the memory controller, That is, performance degradation of the memory may occur due to superposition of GC functions of the memory controller and the processor.
为了降低由于上述情况对存储器的性能产生的影响,在本申请实施例中,处理器在通过d1确定出至少一个第二逻辑存储区,并通过d2确定出多个第三逻辑存储区后还可以判断至少一个第逻辑存储区与多个第三逻辑存储区之间是否存在交集;若存在交集,则执行步骤d3。In order to reduce the impact of the above situation on the performance of the memory, in the embodiment of the present application, after the processor determines at least one second logical storage area through d1, and determines a plurality of third logical storage areas through d2, it can also Judging whether there is an intersection between at least one first logical storage area and multiple third logical storage areas; if there is an intersection, perform step d3.
d3:当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,所述处理器从多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。d3: When there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, the processor selects from at least one candidate third logical storage area among the plurality of third logical storage areas , selecting a first target logical storage area where the processor executes the fourth GC operation; wherein, there is an intersection between the at least one candidate third logical storage area and the at least one second logical storage area.
可选的,处理器根据至少一个待选第三逻辑存储区,通过以下方式,确定所述第一目标逻辑存储区。Optionally, the processor determines the first target logical storage area according to at least one third logical storage area to be selected in the following manner.
处理器在至少一个待选第三逻辑存储区中,选择无效比例最大的第一目标逻辑存储区。The processor selects the first target logical storage area with the largest invalid ratio among at least one third logical storage area to be selected.
处理器确定第一目标逻辑存储区时,直接将无效比例最大的待选第三逻辑存储区作为处理器下一次执行第四GC操作的第一目标逻辑存储区,在降低存储器控制器后续对第三 物理存储区执行第三GC操作时无效搬移有效数据的工作量,提高存储器控制器后续执行第三GC操作的效率的同时,保证处理器执行第四GC操作的执行效率。When the processor determines the first target logical storage area, the third logical storage area to be selected with the largest invalid ratio is directly used as the first target logical storage area for the processor to perform the fourth GC operation next time. When the three physical storage areas perform the third GC operation, the workload of effectively moving valid data is invalidated, while improving the efficiency of the subsequent execution of the third GC operation by the memory controller, and ensuring the execution efficiency of the fourth GC operation by the processor.
如图10所示,下面以一个具体实施例对本申请中处理器执行第四GC操作的过程进行说明。As shown in FIG. 10 , a process in which the processor executes the fourth GC operation in this application will be described below with a specific embodiment.
在阶段1中,处理器在逻辑存储空间中,确定需要执行第四GC操作的第三逻辑存储区为逻辑块16、逻辑块300、逻辑块119,其中,逻辑块16、逻辑块300、逻辑块119的无效比例分别为88%、86%和72%。存储器控制器在物理存储空间中,确定需要执行第三GC操作的第三物理存储区为物理块410、物理块502、物理块95,其中,物理块410、物理块502、物理块95的无效比例分别为78%、73%和68%。其中,存储器控制器将物理块502映射为逻辑存储空间的第二逻辑存储区,并基于第二逻辑存储区,得到第二GC信息。存储器控制器通过信息管理接口将第二GC信息发送给处理器;处理器基于第二GC信息得到第二逻辑存储区为逻辑块300,并确定第二逻辑存储区与第三逻辑存储区存在交集。In stage 1, in the logical storage space, the processor determines that the third logical storage area that needs to perform the fourth GC operation is the logical block 16, the logical block 300, and the logical block 119, wherein the logical block 16, the logical block 300, the logical block The invalid ratios of block 119 are 88%, 86% and 72%, respectively. In the physical storage space, the memory controller determines that the third physical storage area that needs to perform the third GC operation is the physical block 410, the physical block 502, and the physical block 95, wherein the physical block 410, the physical block 502, and the physical block 95 are invalid The proportions were 78%, 73% and 68%, respectively. Wherein, the memory controller maps the physical block 502 into a second logical storage area of the logical storage space, and obtains second GC information based on the second logical storage area. The memory controller sends the second GC information to the processor through the information management interface; the processor obtains the second logical storage area as a logical block 300 based on the second GC information, and determines that there is an intersection between the second logical storage area and the third logical storage area .
在阶段2中,处理器在确定第二逻辑存储区逻辑块300也为第三逻辑存储区时,将第二逻辑存储区逻辑块300作为第一目标逻辑存储区,并将逻辑块300的位置移动到处理器第三逻辑存储区中的首位。In stage 2, when the processor determines that the logical block 300 of the second logical storage area is also the third logical storage area, the processor takes the logical block 300 of the second logical storage area as the first target logical storage area, and sets the location of the logical block 300 Move to the first location in the third logical bank of the processor.
在阶段3中,存储器控制器对物理块410执行第三GC操作,并将物理块410从存储器控制器的管理队列中删除;处理器对逻辑块300执行第四GC操作,并将逻辑块300从处理器的管理队列中删除。处理器在完成对逻辑块300执行的第四GC操作后,存储器中的物理块502的无效比例从73%增加到77%。In phase 3, the memory controller performs the third GC operation on the physical block 410, and deletes the physical block 410 from the management queue of the memory controller; the processor performs the fourth GC operation on the logical block 300, and removes the logical block 300 Removed from the processor's administrative queue. After the processor completes the fourth GC operation on the logical block 300, the invalid ratio of the physical block 502 in the memory increases from 73% to 77%.
从物理块502的无效比例变化可以看出,采用本申请中的垃圾回收方案,存储器控制器可以降低执行第四GC操作的搬移的有效数据的工作量。在本实施例中,物理块502大约减少了4%的需要搬移的有效数据的工作量,相对于原先27%的搬移有效数据的工作量,存储器控制器对物理块502执行第四GC操作的效率提升了15%。It can be seen from the change of the invalid ratio of the physical block 502 that by adopting the garbage collection solution in the present application, the memory controller can reduce the workload of performing the fourth GC operation to move valid data. In this embodiment, the physical block 502 reduces the workload of valid data that needs to be moved by about 4%. Compared with the original 27% workload of moving valid data, the memory controller performs the fourth GC operation on the physical block 502. Efficiency increased by 15%.
实施中,处理器在确定出第一目标逻辑存储区后,对第一目标逻辑存储区执行第四GC操作。处理器在执行第一目标逻辑存储区时,不仅将第一目标逻辑存储区中存储的第三有效数据搬移至其他逻辑存储区,还将在存储器中重新写入第三有效数据,该处理器在存储器中重新写入第三有效数据的过程与实施例1中的处理器在存储器中重新写入第一有效数据的过程相同,此处不再赘述。In an implementation, after the processor determines the first target logical storage area, it performs a fourth GC operation on the first target logical storage area. When the processor executes the first target logical storage area, it not only moves the third valid data stored in the first target logical storage area to other logical storage areas, but also rewrites the third valid data in the memory, the processor The process of rewriting the third valid data in the memory is the same as the process of rewriting the first valid data in the memory by the processor in Embodiment 1, and will not be repeated here.
具体的,处理器通过信息管理接口在存储器中重新写入第三有效数据,使得存储器将原先存储的第三有效数据标记为无效数据,从而降低存储器中第三物理存储区中存储的有效数据的比例,减小了存储器控制器执行第三GC操作时搬移有效数据的工作量,进而提高了存储器控制器执行第三GC操作的效率,来保证存储器的性能。Specifically, the processor rewrites the third valid data in the memory through the information management interface, so that the memory marks the originally stored third valid data as invalid data, thereby reducing the cost of valid data stored in the third physical storage area in the memory. The ratio reduces the workload of moving valid data when the memory controller executes the third GC operation, thereby improving the efficiency of the memory controller executing the third GC operation to ensure the performance of the memory.
可选的,处理器通过追加写或异地更新的方式在存储器中重新写入第三有效数据。Optionally, the processor rewrites the third valid data in the memory by means of append writing or remote updating.
在一种实施方式中,处理器在对第一目标逻辑存储区执行完第四GC操作后,可以通过信息管理接口向存储器控制器发送第四GC操作完成信息,还可以不向存储器控制器发送第四GC操作完成信息。In one embodiment, after the processor executes the fourth GC operation on the first target logical storage area, it may send the fourth GC operation completion information to the memory controller through the information management interface, or may not send the fourth GC operation completion information to the memory controller. Fourth GC operation completion message.
需要说明的是,第一目标逻辑存储区为第二逻辑存储区,第四GC操作完成信息用于指示处理器已完成对第一目标逻辑存储区的第四GC操作;第四GC操作完成信息包括但不限于:位于第一目标逻辑存储区的无效数据的LBA和LBA的长度。It should be noted that the first target logical storage area is the second logical storage area, and the fourth GC operation completion information is used to indicate that the processor has completed the fourth GC operation on the first target logical storage area; the fourth GC operation completion information Including but not limited to: the LBA and the length of the LBA of the invalid data located in the first target logical storage area.
实施中,存储器控制器通过信息管理接口接收来自处理器的第四GC操作完成信息后, 确定当前管理队列中每个第三物理存储区的无效比例;并选择无效比例最大的第三物理存储区为存储器控制器再下一次执行第三GC操作的第三目标物理存储区。In implementation, after the memory controller receives the fourth GC operation completion information from the processor through the information management interface, determine the invalid ratio of each third physical storage area in the current management queue; and select the third physical storage area with the largest invalid ratio The third target physical storage area for the memory controller to perform the third GC operation next time.
在本申请实施例中,存储器控制器从多个第三物理存储区中选择第三物理存储区,并基于选择的第三物理存储区映射得到的第二逻辑存储区得到第二GC信息。存储器控制器通过信息管理接口将第二GC信息发送给处理器,然后,处理器在第二逻辑存储区与第三逻辑存储区存在交集时,从与第二逻辑存储区存在交集的待选第三逻辑存储区中确定第一目标逻辑存储区。由于处理器是根据存储器控制器未执行第三GC操作的第三物理存储区,确定下一次执行第四GC操作的第一目标逻辑存储区,使得处理器对第一目标逻辑存储区执行第四GC操作,搬移位于第一目标逻辑存储区的有效数据,使得第一目标逻辑存储区在物理存储空间中对应的第三物理存储区中存储的有效数据得到减少,降低存储器控制器对第三物理存储区执行第三GC操作时无效搬移有效数据的工作量,提高存储器控制器执行第三GC操作的效率,保证存储器的性能。In the embodiment of the present application, the memory controller selects the third physical storage area from the multiple third physical storage areas, and obtains the second GC information from the second logical storage area obtained by mapping the selected third physical storage area. The memory controller sends the second GC information to the processor through the information management interface, and then, when the second logical storage area intersects with the third logical storage area, the processor selects the second logical storage area to be selected from the second logical storage area. The first target logical storage area is determined among the three logical storage areas. Since the processor is based on the third physical storage area where the memory controller does not perform the third GC operation, determine the first target logical storage area for performing the fourth GC operation next time, so that the processor performs the fourth GC operation on the first target logical storage area. The GC operation moves the valid data located in the first target logical storage area, so that the valid data stored in the third physical storage area corresponding to the first target logical storage area in the physical storage space is reduced, reducing the memory controller's impact on the third physical storage area. When the storage area performs the third GC operation, the workload of effectively moving valid data is invalidated, the efficiency of the memory controller performing the third GC operation is improved, and the performance of the memory is guaranteed.
基于实施例2所述的垃圾回收方案,下面继续以存储系统中的存储器为SSD,处理器为host为例,对该方案进行具体介绍。图11为本申请实施例提供的一种基于SSD和host的垃圾回收方法的流程示意图,下面参阅图11对该方法的具体流程进行说明。Based on the garbage collection scheme described in Embodiment 2, the following continues to take the example in which the memory in the storage system is an SSD and the processor is a host to introduce the scheme in detail. FIG. 11 is a schematic flow chart of a garbage collection method based on SSD and host provided in the embodiment of the present application. The specific flow of the method will be described below with reference to FIG. 11 .
S1101:SSD在物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区,并将至少一个第三物理存储区添加到管理队列中。S1101: In the physical storage space, the SSD determines at least one third physical storage area that needs to perform a third GC operation, and adds the at least one third physical storage area to a management queue.
S1102:SSD将至少一个第三物理存储区映射为逻辑存储空间中的至少一个第二逻辑存储区。S1102: The SSD maps at least one third physical storage area to at least one second logical storage area in the logical storage space.
S1103:SSD通过信息管理接口向host发送第二GC信息。S1103: The SSD sends the second GC information to the host through the information management interface.
其中,第二GC信息用于指示SSD需要对物理存储空间执行第三GC操作的第三物理存储区在逻辑存储空间中映射得到的至少一个第二逻辑存储区。Wherein, the second GC information is used to indicate at least one second logical storage area obtained by mapping the third physical storage area in the logical storage space where the SSD needs to perform the third GC operation on the physical storage space.
S1104:host在逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区。S1104: In the logical storage space, the host determines multiple third logical storage areas that need to perform the fourth GC operation.
S1105:当至少一个第二逻辑存储区与多个第三逻辑存储区存在交集时,host从多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择host下一次执行第四GC操作的第一目标逻辑存储区。S1105: When at least one second logical storage area intersects with multiple third logical storage areas, the host selects the host from at least one candidate third logical storage area among the multiple third logical storage areas to execute the second logical storage area next time. The first target logical storage area for four GC operations.
其中,至少一个待选第三逻辑存储区与至少一个第二逻辑存储区存在交集。Wherein, there is an intersection between at least one candidate third logical storage area and at least one second logical storage area.
一种可能的方式为,host确定每个待选第三逻辑存储区的无效比例,并择无效比例最大的待选第三逻辑存储区为第一目标逻辑存储区。One possible manner is that the host determines the invalid ratio of each third logical storage area to be selected, and selects the third logical storage area to be selected with the largest invalid ratio as the first target logical storage area.
S1106:SSD通过信息管理接口向host发送第二GC信息之后,确定至少一个第三物理存储区中每个第三物理存储区的无效比例。S1106: After the SSD sends the second GC information to the host through the information management interface, determine an invalid ratio of each third physical storage area in the at least one third physical storage area.
S1107:SSD将无效比例最大的第三物理存储区作为SSD下一次执行第三GC操作的第二目标物理存储区。S1107: The SSD takes the third physical storage area with the largest invalid ratio as the second target physical storage area for the SSD to perform the third GC operation next time.
S1108:SSD对第二目标物理存储区执行第三GC操作,从管理队列中删除第二目标物理存储区。S1108: The SSD performs a third GC operation on the second target physical storage area, and deletes the second target physical storage area from the management queue.
S1109:host对第一目标逻辑存储区执行第四GC操作。S1109: the host performs a fourth GC operation on the first target logical storage area.
S1110:host通过信息管理接口向SSD发送第四GC操作完成信息。S1110: the host sends fourth GC operation completion information to the SSD through the information management interface.
其中,第一目标逻辑存储区为第二逻辑存储区,第四GC操作完成信息用于指示host已完成对第一目标逻辑存储区的第四GC操作。Wherein, the first target logical storage area is the second logical storage area, and the fourth GC operation completion information is used to indicate that the host has completed the fourth GC operation on the first target logical storage area.
S1111:SSD通过信息管理接口接收来自host的第四GC操作完成信息后,确定当前管理队列中每个第三物理存储区的无效比例。S1111: After the SSD receives the completion information of the fourth GC operation from the host through the information management interface, determine the invalid ratio of each third physical storage area in the current management queue.
S1112:SSD选择无效比例最大的第三物理存储区为SSD再下一次执行第三GC操作的第三目标物理存储区。S1112: The SSD selects the third physical storage area with the largest invalid ratio as the third target physical storage area for the SSD to perform the third GC operation next time.
在图11所示的实施例中,SSD从至少一个第三物理存储区中选择第三物理存储区,将至少一个物理存储区映射为逻辑存储空间中的第二逻辑存储区,并基于至少一个第二逻辑存储区得到第二GC信息。SSD通过信息管理接口将第二GC信息发送给host,然后,host根据通过信息管理接口接收到的第二GC信息,确定至少一个第二逻辑存储区与多个第三逻辑存储区是否存在交集;并且,host在确定存在交集后,从多个第三逻辑存储区中选择与至少一个第二逻辑存储区存在交集的待选第三逻辑存储区,并从至少一个待选第三逻辑存储区中选择下一次执行第四GC操作的第一目标逻辑存储区,使得host对第一目标逻辑存储区执行第四GC操作,搬移位于第一目标逻辑存储区的有效数据,使得第一目标逻辑存储区在物理存储空间中对应的第三物理存储区中存储的有效数据得到减少,降低SSD对第三物理存储区执行第三GC操作时无效搬移有效数据的工作量,提高SSD执行第三GC操作的效率,保证SSD的性能。In the embodiment shown in FIG. 11, the SSD selects a third physical storage area from at least one third physical storage area, maps at least one physical storage area to a second logical storage area in the logical storage space, and based on at least one The second logical storage area obtains the second GC information. The SSD sends the second GC information to the host through the information management interface, and then, the host determines whether there is an intersection between at least one second logical storage area and multiple third logical storage areas according to the second GC information received through the information management interface; And, after the host determines that there is an intersection, select a third logical storage area to be selected that has an intersection with at least one second logical storage area from the plurality of third logical storage areas, and select a third logical storage area from the at least one third logical storage area to be selected. Select the first target logical storage area to perform the fourth GC operation next time, so that the host performs the fourth GC operation on the first target logical storage area, and move the valid data located in the first target logical storage area, so that the first target logical storage area The valid data stored in the corresponding third physical storage area in the physical storage space is reduced, reducing the workload of invalidly moving valid data when the SSD performs the third GC operation on the third physical storage area, and improving the efficiency of the SSD performing the third GC operation Efficiency, guarantee the performance of SSD.
基于实施例1和实施例2提供的方法,图12为本申请提供的一种垃圾回收方法的交互流程示意图,应用于图3所示的存储系统中。在该方法中,存储系统中的存储器和处理器即可以实现实施例1提供的方法,又可以实现实施例2提供的方法。并且两个执行过程在时间上可以存在交集,也可以不存在交集,本申请对此不作限定。如图12所示,该方法包括:Based on the methods provided in Embodiment 1 and Embodiment 2, FIG. 12 is a schematic diagram of an interaction flow of a garbage collection method provided in the present application, which is applied to the storage system shown in FIG. 3 . In this method, the memory and the processor in the storage system can implement the method provided by Embodiment 1 and the method provided by Embodiment 2. In addition, the two execution processes may or may not overlap in time, which is not limited in this application. As shown in Figure 12, the method includes:
S1201:处理器在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区。S1201: In the logical storage space, the processor determines a first logical storage area that needs to perform a first GC operation.
需要说明的是,逻辑存储空间为存储器控制器管理的物理存储空间映射得到的。It should be noted that the logical storage space is obtained by mapping the physical storage space managed by the memory controller.
S1202:处理器通过信息管理接口向存储器控制器发送第一GC信息。S1202: The processor sends first GC information to the memory controller through the information management interface.
其中,所述第一GC信息用于指示所述处理器需要执行所述第一GC操作的所述第一逻辑存储区。Wherein, the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation.
S1203:存储器控制器将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区。S1203: The memory controller maps the first logical storage area to at least one first physical storage area in the physical storage space.
S1204:存储器控制器在所述物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区。S1204: The memory controller determines, in the physical storage space, multiple second physical storage areas that need to perform the second GC operation.
S1205:存储器控制器当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区。S1205: The memory controller determines at least one second physical storage area to be selected from the multiple second physical storage areas when the at least one first physical storage area overlaps with the multiple second physical storage areas. .
其中,至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集。Wherein, there is no intersection between at least one second physical storage area to be selected and the at least one first physical storage area.
S1206:存储器控制器在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。S1206: The memory controller determines, in the at least one second physical storage area to be selected, a first target physical storage area where the memory controller executes the second GC operation.
S1207:存储器控制器在物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区。S1207: In the physical storage space, the memory controller determines at least one third physical storage area that needs to perform the third GC operation.
S1208:存储器控制器将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区。S1208: The memory controller maps the at least one third physical storage area to at least one second logical storage area in the logical storage space.
S1209:存储器控制器通过信息管理接口向处理器发送第二GC信息。S1209: The memory controller sends the second GC information to the processor through the information management interface.
其中,所述第二GC信息用于指示需要执行第三GC操作的所述至少一个第二逻辑存储区。Wherein, the second GC information is used to indicate the at least one second logical storage area that needs to perform the third GC operation.
S1210:处理器在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区。S1210: In the logical storage space, the processor determines a plurality of third logical storage areas that need to perform a fourth GC operation.
S1211:当至少一个第二逻辑存储区与多个第三逻辑存储区存在交集时,处理器从多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择处理器执行第四GC操作的第一目标逻辑存储区。S1211: When at least one second logical storage area intersects with multiple third logical storage areas, the processor selects the processor from at least one candidate third logical storage area among the multiple third logical storage areas to execute the second logical storage area. The first target logical storage area for four GC operations.
其中,至少一个待选第三逻辑存储区与至少一个第二逻辑存储区存在交集。Wherein, there is an intersection between at least one candidate third logical storage area and at least one second logical storage area.
另外,图12中的每个步骤的执行过程均可以参考以上相应实施例中的描述,此处不再赘述。In addition, for the execution process of each step in FIG. 12 , reference may be made to the descriptions in the above corresponding embodiments, and details are not repeated here.
基于以上实施例及相同构思,本申请实施例还提供了一种存储器。所述存储器包括:存储器控制器、存储单元;其中,存储单元包括物理存储空间;Based on the above embodiments and the same idea, the embodiment of the present application further provides a memory. The memory includes: a memory controller and a storage unit; wherein the storage unit includes a physical storage space;
存储器控制器,用于通过信息管理接口接收处理器发送的第一垃圾回收GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;The memory controller is configured to receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first GC operation on the logical storage space. A logical storage area; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;mapping the first logical storage area to at least one first physical storage area in the physical storage space;
在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;In the physical storage space, determine a plurality of second physical storage areas that need to perform the second GC operation;
当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;When there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas, at least one candidate second physical storage area is determined from the plurality of second physical storage areas; the at least one There is no intersection between the second physical storage area to be selected and the at least one first physical storage area;
在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。A first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one second physical storage area to be selected.
在一种可能的设计中,所述存储器控制器具体用于:In a possible design, the memory controller is specifically used for:
根据位于所述第一逻辑存储区的第一有效数据与所述多个第二物理存储区中存储的第二有效数据,从所述多个第二物理存储区中选择影响因子小于设定阈值的所述至少一个待选第二物理存储区;每个第二物理存储区的影响因子用于表征所述第一有效数据和所述第二物理存储区中第二有效数据的交集在所述第二物理存储区中占用的存储空间。According to the first valid data located in the first logical storage area and the second valid data stored in the plurality of second physical storage areas, selecting from the plurality of second physical storage areas that the impact factor is less than a set threshold The at least one candidate second physical storage area; the impact factor of each second physical storage area is used to characterize the intersection of the first valid data and the second valid data in the second physical storage area in the The storage space occupied by the second physical storage area.
在一种可能的设计中,所述存储器控制器具体用于:In a possible design, the memory controller is specifically used for:
在所述至少一个待选第二物理存储区中,选择无效比例最大的所述第一目标物理存储区;其中,每个待选第二物理存储区的无效比例为所述待选第二物理存储区中无效数据占所述待选第二物理存储区的存储空间的比值。In the at least one candidate second physical storage area, select the first target physical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate second physical storage area is the candidate second physical storage area The ratio of invalid data in the storage area to the storage space of the second physical storage area to be selected.
在一种可能的设计中,所述存储器控制器还用于:In a possible design, the memory controller is also used for:
在所述物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区;In the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区;mapping the at least one third physical storage area to at least one second logical storage area in the logical storage space;
通过所述信息管理接口向所述处理器发送第二GC信息;其中,所述第二GC信息用于指示需要执行所述第三GC操作的所述至少一个第二逻辑存储区。Sending second GC information to the processor through the information management interface; wherein the second GC information is used to indicate the at least one second logical storage area that needs to perform the third GC operation.
本申请实施例还提供了一种存储器管理装置。如图13所示,所述存储器管理装置1300包括:处理器1301、信号管理接口1302;The embodiment of the present application also provides a memory management device. As shown in FIG. 13, the memory management device 1300 includes: a processor 1301, a signal management interface 1302;
其中,信号管理接口1302,用于传输GC信息;Among them, the signal management interface 1302 is used to transmit GC information;
处理器1301用于:在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;通过所述信息管理接口1302向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行第一GC操作的第一逻辑存储区。The processor 1301 is configured to: in the logical storage space, determine the first logical storage area that needs to perform the first GC operation; the logical storage space is obtained by mapping the physical storage space managed by the memory controller; through the information management interface 1302 Send first GC information to the memory controller; where the first GC information is used to indicate a first logical storage area where the processor needs to perform a first GC operation.
在一种可能的设计中,处理器1301具体用于:In a possible design, the processor 1301 is specifically used for:
通过所述信息管理接口1302接收来自所述存储器控制器的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;The second GC information from the memory controller is received through the information management interface 1302; wherein, the second GC information is used to indicate that the memory controller needs to perform a third GC operation on the physical storage space. At least one second logical storage area obtained by mapping the storage area in the logical storage space;
在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区;In the logical storage space, determine a plurality of third logical storage areas that need to perform the fourth GC operation;
当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。When there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, selecting the at least one candidate third logical storage area among the plurality of third logical storage areas The processor executes the first target logical storage area of the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
在一种可能的设计中,处理器1301具体用于:In a possible design, the processor 1301 is specifically used for:
在所述至少一个待选第三逻辑存储区中,选择无效比例最大的所述第一目标逻辑存储区;其中,每个待选第三逻辑存储区的无效比例为所述待选第三逻辑存储区中无效数据占所述待选第三逻辑存储区的存储空间的比值。In the at least one candidate third logical storage area, select the first target logical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate third logical storage area is the candidate third logical storage area The ratio of invalid data in the storage area to the storage space of the third logical storage area to be selected.
基于以上实施例及相同构思,本申请实施例还提供了一种垃圾回收装置。如图14所示,所述垃圾回收装置1400应用于存储器中的存储器控制器;所述装置1400包括:Based on the above embodiments and the same idea, the embodiment of the present application also provides a garbage collection device. As shown in FIG. 14, the garbage collection device 1400 is applied to a memory controller in a memory; the device 1400 includes:
传输模块1401,用于通过信息管理接口接收处理器发送的第一垃圾回收GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;The transmission module 1401 is configured to receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first GC operation on the logical storage space. A logical storage area; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
映射模块1402,用于将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;A mapping module 1402, configured to map the first logical storage area to at least one first physical storage area in the physical storage space;
确定模块1403,用于在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。The determining module 1403 is configured to determine, in the physical storage space, a plurality of second physical storage areas that need to perform a second GC operation; when the at least one first physical storage area overlaps with the plurality of second physical storage areas , determining at least one second physical storage area to be selected from the plurality of second physical storage areas; there is no intersection between the at least one second physical storage area to be selected and the at least one first physical storage area; A first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one candidate second physical storage area.
在一种可能的设计中,确定模块1403具体用于:In a possible design, the determination module 1403 is specifically used to:
根据位于所述第一逻辑存储区的第一有效数据与所述多个第二物理存储区中存储的第二有效数据,从所述多个第二物理存储区中选择影响因子小于设定阈值的所述至少一个待选第二物理存储区;每个第二物理存储区的影响因子用于表征所述第一有效数据和所述第二物理存储区中第二有效数据的交集在所述第二物理存储区中占用的存储空间。According to the first valid data located in the first logical storage area and the second valid data stored in the plurality of second physical storage areas, selecting from the plurality of second physical storage areas that the impact factor is less than a set threshold The at least one candidate second physical storage area; the impact factor of each second physical storage area is used to characterize the intersection of the first valid data and the second valid data in the second physical storage area in the The storage space occupied by the second physical storage area.
在一种可能的设计中,确定模块1403具体用于:In a possible design, the determination module 1403 is specifically used to:
在所述至少一个待选第二物理存储区中,选择无效比例最大的所述第一目标物理存储区;其中,每个待选第二物理存储区的无效比例为所述待选第二物理存储区中无效数据占所述待选第二物理存储区的存储空间的比值。In the at least one candidate second physical storage area, select the first target physical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate second physical storage area is the candidate second physical storage area The ratio of invalid data in the storage area to the storage space of the second physical storage area to be selected.
在一种可能的设计中,所述确定模块1403具体用于:在所述物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区;In a possible design, the determining module 1403 is specifically configured to: in the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
所述映射模块1402具体用于:将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区;The mapping module 1402 is specifically configured to: map the at least one third physical storage area to at least one second logical storage area in the logical storage space;
所述传输模块1401具体用于:通过所述信息管理接口向所述处理器发送第二GC信息;其中,所述第二GC信息用于指示需要执行所述第三GC操作的所述至少一个第二逻辑存储区。The transmission module 1401 is specifically configured to: send second GC information to the processor through the information management interface; where the second GC information is used to indicate the at least one GC that needs to perform the third GC operation. Second logical storage area.
基于以上实施例及相同构思,本申请实施例还提供了一种垃圾回收装置。如图15所示,所述垃圾回收装置1500应用于处理器;所述装置1500包括:Based on the above embodiments and the same idea, the embodiment of the present application also provides a garbage collection device. As shown in Figure 15, the garbage collection device 1500 is applied to a processor; the device 1500 includes:
处理模块1501,用于在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;The processing module 1501 is configured to determine the first logical storage area that needs to perform the first GC operation in the logical storage space; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
传输模块1502,用于通过所述信息管理接口向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行第一GC操作的第一逻辑存储区。A transmission module 1502, configured to send first GC information to the memory controller through the information management interface; wherein the first GC information is used to indicate that the processor needs to perform the first logical storage of the first GC operation district.
在一种可能的设计中,所述传输模块1502具体用于:通过所述信息管理接口接收来自所述存储器控制器的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;In a possible design, the transmission module 1502 is specifically configured to: receive second GC information from the memory controller through the information management interface; where the second GC information is used to indicate that the memory The controller needs to perform at least one second logical storage area mapped in the logical storage space from the third physical storage area that performs the third GC operation on the physical storage space;
所述处理模块1501具体用于:在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区;当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。The processing module 1501 is specifically configured to: in the logical storage space, determine multiple third logical storage areas that need to perform the fourth GC operation; when the at least one second logical storage area and the multiple third logical storage areas When there is an intersection of logical storage areas, selecting a first target logical storage area for the processor to perform the fourth GC operation from at least one third logical storage area to be selected among the plurality of third logical storage areas; Wherein, there is an intersection between the at least one candidate third logical storage area and the at least one second logical storage area.
在一种可能的设计中,所述处理模块1501具体用于:In a possible design, the processing module 1501 is specifically configured to:
在所述至少一个待选第三逻辑存储区中,选择无效比例最大的所述第一目标逻辑存储区;其中,每个待选第三逻辑存储区的无效比例为所述待选第三逻辑存储区中无效数据占所述待选第三逻辑存储区的存储空间的比值。In the at least one candidate third logical storage area, select the first target logical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate third logical storage area is the candidate third logical storage area The ratio of invalid data in the storage area to the storage space of the third logical storage area to be selected.
基于上述内容和相同构思,本申请提供一种计算机可读存储介质,其上存储有计算机程序或指令,当该计算机程序或指令被执行时,以使得计算设备执行上述方法实施例中的方法。Based on the above content and the same idea, the present application provides a computer-readable storage medium on which a computer program or instruction is stored, and when the computer program or instruction is executed, the computing device executes the method in the above method embodiment.
基于上述内容和相同构思,本申请提供一种计算机程序产品,当计算机执行计算机程序产品时,以使得计算设备执行上述方法实施例中的方法。Based on the above content and the same idea, the present application provides a computer program product, which enables the computing device to execute the methods in the above method embodiments when the computer executes the computer program product.
应理解,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。另外,在本申请各个实施例中的各功能模块可以集成在一个处理器中,也可以是单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。It should be understood that the division of modules in the embodiment of the present application is schematic, and is only a logical function division, and there may be another division manner in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into one processor, or physically exist separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机 可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的保护范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Apparently, those skilled in the art can make various changes and modifications to this application without departing from the protection scope of this application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.

Claims (14)

  1. 一种垃圾回收方法,应用于存储器控制器,其特征在于,所述方法包括:A garbage collection method applied to a memory controller, wherein the method comprises:
    通过信息管理接口接收处理器发送的第一垃圾回收GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;Receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation on the logical storage space; the said The logical storage space is obtained by mapping the physical storage space managed by the memory controller;
    将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;mapping the first logical storage area to at least one first physical storage area in the physical storage space;
    在所述物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;In the physical storage space, determine a plurality of second physical storage areas that need to perform a second GC operation;
    当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;When there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas, at least one candidate second physical storage area is determined from the plurality of second physical storage areas; the at least one There is no intersection between the second physical storage area to be selected and the at least one first physical storage area;
    在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。A first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one second physical storage area to be selected.
  2. 根据权利要求1所述的方法,其特征在于,所述从所述多个第二物理存储区中确定至少一个待选第二物理存储区,包括:The method according to claim 1, wherein the determining at least one second physical storage area to be selected from the plurality of second physical storage areas comprises:
    根据位于所述第一逻辑存储区的第一有效数据与所述多个第二物理存储区中存储的第二有效数据,从所述多个第二物理存储区中选择影响因子小于设定阈值的所述至少一个待选第二物理存储区;每个第二物理存储区的影响因子用于表征所述第一有效数据和所述第二物理存储区中第二有效数据的交集在所述第二物理存储区中占用的存储空间。According to the first valid data located in the first logical storage area and the second valid data stored in the plurality of second physical storage areas, selecting from the plurality of second physical storage areas that the impact factor is less than a set threshold The at least one candidate second physical storage area; the impact factor of each second physical storage area is used to characterize the intersection of the first valid data and the second valid data in the second physical storage area in the The storage space occupied by the second physical storage area.
  3. 根据权利要求1或2所述的方法,其特征在于,所述在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区,包括:The method according to claim 1 or 2, wherein the first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one candidate second physical storage area ,include:
    在所述至少一个待选第二物理存储区中,选择无效比例最大的所述第一目标物理存储区;其中,每个待选第二物理存储区的无效比例为所述待选第二物理存储区中无效数据占所述待选第二物理存储区的存储空间的比值。In the at least one candidate second physical storage area, select the first target physical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate second physical storage area is the candidate second physical storage area The ratio of invalid data in the storage area to the storage space of the second physical storage area to be selected.
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 3, wherein the method further comprises:
    在所述物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区;In the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
    将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区;mapping the at least one third physical storage area to at least one second logical storage area in the logical storage space;
    通过所述信息管理接口向所述处理器发送第二GC信息;其中,所述第二GC信息用于指示需要执行所述第三GC操作的所述至少一个第二逻辑存储区。Sending second GC information to the processor through the information management interface; wherein the second GC information is used to indicate the at least one second logical storage area that needs to perform the third GC operation.
  5. 一种垃圾回收方法,应用于处理器,其特征在于,所述方法包括:A garbage collection method applied to a processor, wherein the method comprises:
    在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;In the logical storage space, determine the first logical storage area that needs to perform the first GC operation; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
    通过信息管理接口向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行所述第一GC操作的所述第一逻辑存储区。Sending first GC information to the memory controller through an information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method according to claim 5, wherein the method further comprises:
    通过所述信息管理接口接收来自所述存储器控制器的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;Receive second GC information from the memory controller through the information management interface; wherein the second GC information is used to indicate that the memory controller needs to perform a third GC operation on the physical storage space for the third physical storage At least one second logical storage area obtained by mapping the area in the logical storage space;
    在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区;In the logical storage space, determine a plurality of third logical storage areas that need to perform the fourth GC operation;
    当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。When there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, selecting the at least one candidate third logical storage area among the plurality of third logical storage areas The processor executes the first target logical storage area of the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
  7. 根据权利要求6所述的方法,其特征在于,所述从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区,包括:The method according to claim 6, wherein the processor is selected from at least one candidate third logical storage area among the plurality of third logical storage areas to perform the fourth GC operation The first target logical store, consisting of:
    在所述至少一个待选第三逻辑存储区中,选择无效比例最大的所述第一目标逻辑存储区;其中,每个待选第三逻辑存储区的无效比例为所述待选第三逻辑存储区中无效数据占所述待选第三逻辑存储区的存储空间的比值。In the at least one candidate third logical storage area, select the first target logical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate third logical storage area is the candidate third logical storage area The ratio of invalid data in the storage area to the storage space of the third logical storage area to be selected.
  8. 一种存储器,所述存储器包含:存储器控制器和存储单元,所述存储单元包括物理存储空间;其特征在于,所述存储器控制器用于:A kind of memory, described memory comprises: memory controller and storage unit, and described storage unit comprises physical storage space; It is characterized in that, described memory controller is used for:
    通过信息管理接口接收处理器发送的第一垃圾回收GC信息;其中,所述第一GC信息用于指示所述处理器需要对逻辑存储空间执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为所述存储器控制器管理的物理存储空间映射得到的;Receive the first garbage collection GC information sent by the processor through the information management interface; wherein the first GC information is used to indicate the first logical storage area where the processor needs to perform the first GC operation on the logical storage space; the said The logical storage space is obtained by mapping the physical storage space managed by the memory controller;
    将所述第一逻辑存储区映射为所述物理存储空间中的至少一个第一物理存储区;mapping the first logical storage area to at least one first physical storage area in the physical storage space;
    在物理存储空间中,确定需要执行第二GC操作的多个第二物理存储区;In the physical storage space, determine a plurality of second physical storage areas that need to perform the second GC operation;
    当所述至少一个第一物理存储区与所述多个第二物理存储区存在交集时,从所述多个第二物理存储区中确定至少一个待选第二物理存储区;所述至少一个待选第二物理存储区与所述至少一个第一物理存储区不存在交集;When there is an intersection between the at least one first physical storage area and the plurality of second physical storage areas, at least one candidate second physical storage area is determined from the plurality of second physical storage areas; the at least one There is no intersection between the second physical storage area to be selected and the at least one first physical storage area;
    在所述至少一个待选第二物理存储区中确定所述存储器控制器执行所述第二GC操作的第一目标物理存储区。A first target physical storage area for the memory controller to perform the second GC operation is determined in the at least one second physical storage area to be selected.
  9. 根据权利要求8所述的存储器,其特征在于,所述存储器控制器具体用于:The memory according to claim 8, wherein the memory controller is specifically used for:
    根据位于所述第一逻辑存储区的第一有效数据与所述多个第二物理存储区中存储的第二有效数据,从所述多个第二物理存储区中选择影响因子小于设定阈值的所述至少一个待选第二物理存储区;每个第二物理存储区的影响因子用于表征所述第一有效数据和所述第二物理存储区中第二有效数据的交集在所述第二物理存储区中占用的存储空间。According to the first valid data located in the first logical storage area and the second valid data stored in the plurality of second physical storage areas, selecting from the plurality of second physical storage areas that the impact factor is less than a set threshold The at least one candidate second physical storage area; the impact factor of each second physical storage area is used to characterize the intersection of the first valid data and the second valid data in the second physical storage area in the The storage space occupied by the second physical storage area.
  10. 根据权利要求8或9所述的存储器,其特征在于,所述存储器控制器具体用于:The memory according to claim 8 or 9, wherein the memory controller is specifically used for:
    在所述至少一个待选第二物理存储区中,选择无效比例最大的所述第一目标物理存储区;其中,每个待选第二物理存储区的无效比例为所述待选第二物理存储区中无效数据占所述待选第二物理存储区的存储空间的比值。In the at least one candidate second physical storage area, select the first target physical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate second physical storage area is the candidate second physical storage area The ratio of invalid data in the storage area to the storage space of the second physical storage area to be selected.
  11. 根据权利要求8至10中任一项所述的存储器,其特征在于,所述存储器控制器还用于:The memory according to any one of claims 8 to 10, wherein the memory controller is further used for:
    在所述物理存储空间中,确定需要执行第三GC操作的至少一个第三物理存储区;In the physical storage space, determine at least one third physical storage area that needs to perform a third GC operation;
    将所述至少一个第三物理存储区映射为所述逻辑存储空间中的至少一个第二逻辑存储区;mapping the at least one third physical storage area to at least one second logical storage area in the logical storage space;
    通过所述信息管理接口向所述处理器发送第二GC信息;其中,所述第二GC信息用于指示需要执行所述第三GC操作的所述至少一个第二逻辑存储区。Sending second GC information to the processor through the information management interface; wherein the second GC information is used to indicate the at least one second logical storage area that needs to perform the third GC operation.
  12. 一种存储器管理装置,所述存储器管理装置包含:处理器和信息管理接口,其特征在于,所述处理器用于:A memory management device, the memory management device comprising: a processor and an information management interface, characterized in that the processor is used for:
    在逻辑存储空间中,确定需要执行第一GC操作的第一逻辑存储区;所述逻辑存储空间为存储器控制器管理的物理存储空间映射得到的;In the logical storage space, determine the first logical storage area that needs to perform the first GC operation; the logical storage space is obtained by mapping the physical storage space managed by the memory controller;
    通过所述信息管理接口向所述存储器控制器发送第一GC信息;其中,所述第一GC信息用于指示所述处理器需要执行第一GC操作的第一逻辑存储区。Sending first GC information to the memory controller through the information management interface; wherein the first GC information is used to indicate a first logical storage area where the processor needs to perform a first GC operation.
  13. 根据权利要求12所述的存储器管理装置,其特征在于,所述处理器还用于:The memory management device according to claim 12, wherein the processor is further configured to:
    通过所述信息管理接口接收来自所述存储器控制器的第二GC信息;其中,所述第二GC信息用于指示所述存储器控制器需要对物理存储空间执行第三GC操作的第三物理存储区在所述逻辑存储空间中映射得到的至少一个第二逻辑存储区;Receive second GC information from the memory controller through the information management interface; wherein the second GC information is used to indicate that the memory controller needs to perform a third GC operation on the physical storage space for the third physical storage At least one second logical storage area obtained by mapping the area in the logical storage space;
    在所述逻辑存储空间中,确定需要执行第四GC操作的多个第三逻辑存储区;In the logical storage space, determine a plurality of third logical storage areas that need to perform the fourth GC operation;
    当所述至少一个第二逻辑存储区与所述多个第三逻辑存储区存在交集时,从所述多个第三逻辑存储区中的至少一个待选第三逻辑存储区中,选择所述处理器执行所述第四GC操作的第一目标逻辑存储区;其中,所述至少一个待选第三逻辑存储区与所述至少一个第二逻辑存储区存在交集。When there is an intersection between the at least one second logical storage area and the plurality of third logical storage areas, selecting the at least one candidate third logical storage area among the plurality of third logical storage areas The processor executes the first target logical storage area of the fourth GC operation; wherein, the at least one third logical storage area to be selected has an intersection with the at least one second logical storage area.
  14. 根据权利要求13所述的存储器管理装置,其特征在于,所述处理器具体用于:The memory management device according to claim 13, wherein the processor is specifically configured to:
    在所述至少一个待选第三逻辑存储区中,选择无效比例最大的所述第一目标逻辑存储区;其中,每个待选第三逻辑存储区的无效比例为所述待选第三逻辑存储区中无效数据占所述待选第三逻辑存储区的存储空间的比值。In the at least one candidate third logical storage area, select the first target logical storage area with the largest invalid ratio; wherein, the invalid ratio of each candidate third logical storage area is the candidate third logical storage area The ratio of invalid data in the storage area to the storage space of the third logical storage area to be selected.
PCT/CN2021/130653 2021-11-15 2021-11-15 Garbage collection method, and memory and memory management apparatus WO2023082252A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/130653 WO2023082252A1 (en) 2021-11-15 2021-11-15 Garbage collection method, and memory and memory management apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/130653 WO2023082252A1 (en) 2021-11-15 2021-11-15 Garbage collection method, and memory and memory management apparatus

Publications (1)

Publication Number Publication Date
WO2023082252A1 true WO2023082252A1 (en) 2023-05-19

Family

ID=86334943

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/130653 WO2023082252A1 (en) 2021-11-15 2021-11-15 Garbage collection method, and memory and memory management apparatus

Country Status (1)

Country Link
WO (1) WO2023082252A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009503744A (en) * 2005-08-03 2009-01-29 サンディスク コーポレイション Non-volatile memory with scheduled playback operation
CN111090595A (en) * 2019-11-19 2020-05-01 中国航空工业集团公司西安航空计算技术研究所 NAND FLASH garbage recovery balance optimization method
US10740228B2 (en) * 2017-05-18 2020-08-11 Sandisk Technologies Llc Locality grouping during garbage collection of a storage device
US11169889B1 (en) * 2017-05-05 2021-11-09 Open Invention Network Llc Systems, devices and methods for determining and reclaiming snapshot storage consumption in data storage systems

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009503744A (en) * 2005-08-03 2009-01-29 サンディスク コーポレイション Non-volatile memory with scheduled playback operation
US11169889B1 (en) * 2017-05-05 2021-11-09 Open Invention Network Llc Systems, devices and methods for determining and reclaiming snapshot storage consumption in data storage systems
US10740228B2 (en) * 2017-05-18 2020-08-11 Sandisk Technologies Llc Locality grouping during garbage collection of a storage device
CN111090595A (en) * 2019-11-19 2020-05-01 中国航空工业集团公司西安航空计算技术研究所 NAND FLASH garbage recovery balance optimization method

Similar Documents

Publication Publication Date Title
TWI653533B (en) Data storage device and method of operation thereof
CN109582599B (en) Data storage device and non-volatile memory operation method
CN101784993B (en) Apparatus using flash memory as storage and method of operating the same
US5745418A (en) Flash memory mass storage system
KR101465789B1 (en) Write and merge methods in memory card systems for reducing the number of page copies
US8055873B2 (en) Data writing method for flash memory, and controller and system using the same
JP4738038B2 (en) Memory card
TWI569139B (en) Valid data merging method, memory controller and memory storage apparatus
EP1909184A2 (en) Mapping information managing apparatus and method for non-volatile memory supporting different cell types
US10296250B2 (en) Method and apparatus for improving performance of sequential logging in a storage device
US7971022B2 (en) Apparatus and method of processing data of non-volatile memory using transaction block
US10922011B2 (en) Controllers configured to perform secure deletion, key-value storage devices including said controllers, and methods of operation thereof
KR20100011698A (en) Solid state storage system for data merging and method of controlling the same
TW200417856A (en) Method and apparatus for splitting a logical block
CN107203330B (en) Read-write data stream oriented flash memory data distribution method
CN111108488B (en) Memory block recovery method and device
WO2019000982A1 (en) Storage system, solid state disk, and data storage method
CN110389712B (en) Data writing method and device, solid state disk and computer readable storage medium
KR20180126656A (en) Data storage device and operating method thereof
KR20220050407A (en) Controller and operation method thereof
TW201126338A (en) Flash memory device and data access method for flash memories
WO2023082252A1 (en) Garbage collection method, and memory and memory management apparatus
CN113641597A (en) Method and apparatus for managing data storage and computer readable storage medium
TWI457941B (en) Method and apparatus for high-speed byte-access in block-based flash memory
US11461225B2 (en) Storage device, control method of storage device, and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21963698

Country of ref document: EP

Kind code of ref document: A1