WO2020052216A1 - System garbage collection method and method for collecting garbage in solid state hard disk - Google Patents

System garbage collection method and method for collecting garbage in solid state hard disk Download PDF

Info

Publication number
WO2020052216A1
WO2020052216A1 PCT/CN2019/079391 CN2019079391W WO2020052216A1 WO 2020052216 A1 WO2020052216 A1 WO 2020052216A1 CN 2019079391 W CN2019079391 W CN 2019079391W WO 2020052216 A1 WO2020052216 A1 WO 2020052216A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
logical
logical block
valid data
state hard
Prior art date
Application number
PCT/CN2019/079391
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
Priority claimed from CN201811233512.7A external-priority patent/CN110895513A/en
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP19859851.8A priority Critical patent/EP3748509B1/en
Priority to JP2020526891A priority patent/JP7315130B2/en
Publication of WO2020052216A1 publication Critical patent/WO2020052216A1/en
Priority to US17/021,413 priority patent/US11928053B2/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
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems

Definitions

  • the present application relates to the storage field, and more particularly, to a system garbage collection method and a solid state hard disk garbage collection method.
  • a flash array is a storage system that contains a solid state drive and a system controller.
  • the system controller allocates logical addresses to solid state disks in units of logical block groups (CKGs).
  • CKGs logical block groups
  • the system controller performs system garbage collection.
  • the system controller instructs the solid-state hard disk to move all valid data in the logical block group to the new logical block group, which causes the valid data to be moved inside the solid-state hard disk. Therefore, the number of write amplification is increased.
  • This application proposes a system garbage collection method and a garbage collection method in a solid state hard disk, which can reduce the number of write amplifications.
  • a first aspect provides a system garbage collection method, which is applied to a flash memory array, which includes a system controller and a plurality of solid state hard disks.
  • the system controller determines a first logical block group to be recycled.
  • the first logical block group includes a plurality of first data logical blocks, and the plurality of first data logical blocks are distributed in different solid state hard disks.
  • the data stored in at least one first data logical block of the plurality of first data logical blocks includes valid data.
  • the address of the valid data in the first logical block is a first logical address, and the first logical address and The actual address of the valid data stored in the solid state hard disk has a corresponding relationship.
  • the system controller creates a second logical block group, the second logical block group includes a plurality of second data logical blocks, and the second logical block group includes a second data logical block, where at least one of the first
  • the two data logical blocks are distributed in the solid state hard disk where the first data logical block storing the valid data is located.
  • the system controller allocates a second logical address to the valid data in the at least one of the second data logical blocks, and then instructs the solid-state hard disk storing the valid data to compare the first logical address with the first logical address.
  • the correspondence between the actual addresses is modified to the correspondence between the second logical address and the actual addresses.
  • the first logical block group to be recycled includes a plurality of first data logical blocks, and at least one of the data stored in the first data logical block is valid data. At least one data logical block of the block group is distributed in the solid-state hard disk where the first data logical block storing valid data is stored. Therefore, the valid data does not need to be physically moved, and only the solid-state hard disk storing the valid data needs to be instructed to transfer the valid data.
  • the correspondence between the first logical address and the actual address is modified to the correspondence between the second logical address and the actual address, so that at least one data in the first logical block group to be recovered is valid data in the logical block. Migrate to the created second logical block group. Since the effective data is not actually moved, write amplification can be reduced.
  • the first logical block group can be realized.
  • the valid data in is migrated to the second logical block group without actually moving the valid data.
  • the solid state hard disk where the data logic block storing valid data is located can also reduce write amplification to a certain extent.
  • each data logical block included in the second logical block group is distributed in a solid state hard disk where one of the data logical blocks included in the first logical block group is located. In this way, write amplification can be minimized.
  • the number of the first data logical blocks storing valid data is the same as the number of the at least one second data logical block. For example, if there is a first data logical block in the first logical block group that stores valid data, then a second data logical block in the second logical block group is also distributed over the first data that stores the valid data The solid state drive where the logical block is located. If two first data logical blocks in the first logical block group store valid data, then two second data logical blocks in the second logical block group are also distributed among two first data blocks storing the valid data. The solid state drive where the data logic blocks are located. If each first data logical block in the first logical block group stores valid data, then all second data logical blocks in the second logical block group must also be distributed on the solid state hard disk where all the first data logical blocks are located. in.
  • the creating a second logical block group may specifically be created based on the distribution of multiple first data logical blocks among multiple solid state drives.
  • all the second data logical blocks in the created second logical block group are distributed in a solid state hard disk where all the first data logical blocks are located.
  • the second logical block group created in this way can minimize write amplification.
  • the first logical block group further includes a first check logical block, and the first check logical block is distributed between the first check logical block and the multiple first logical block.
  • the second logical block group further includes a second check logical block, and the second check logical block is distributed on a solid state hard disk different from the plurality of second data logical blocks. in.
  • the number of the first check logical block is the same as the number of the second check logical block, and both are determined according to the RAID type.
  • the solid state disk where the second verification logic block is located may be the same as or different from the solid state disk where the first verification logic block is located.
  • valid data needs to be recalculated and stored after the valid data is migrated from the first logical block group to the second logical block group. Therefore, the application does not limit the distribution of the second logical block.
  • the first logical block group to be recycled may be selected according to certain conditions, for example, when a logical block group in a flash memory array contains When the data amount of the valid data is lower than the set threshold, it can be used as the first logical block group to be recycled. Alternatively, when the data amount of invalid data contained in a certain logical block group in the flash memory array is higher than the set threshold, it may be used as the first logical block group to be recovered. Alternatively, the logical block group with the most invalid data or the least valid data in the flash array is selected as the first logical block group to be recovered. This can improve the efficiency of system garbage collection.
  • a second aspect provides a method for garbage collection in a solid state hard disk.
  • the method is applied to a solid state hard disk, and the solid state hard disk is connected to a system controller.
  • the solid state hard disk reads valid data and reverse mapping information of the valid data from the first physical block to be recycled, and sends the reverse mapping information of the valid data to the system controller, thereby obtaining the reverse data.
  • the solid state hard disk assigns a target logical address to the valid data, and copies the valid data to a second physical block.
  • the reverse mapping information in the second aspect may be the virtual address of the valid data, or the fingerprint of the valid data, or the offset address of the valid data in the file, as long as it can pass the forward direction. Information that finds the actual address of the valid data by index is within the protection scope of this application.
  • the reverse mapping information of the data is usually written into the solid-state drive with the data as a whole. This is to facilitate the search for the logical address of the data to modify the logical address in the flash translation layer and the actual data when performing garbage collection inside the solid-state drive Correspondence between addresses.
  • reverse mapping information refers to the logical address of the data.
  • in this application in order to keep the actual address of the valid data unchanged, it is also necessary to ensure that the actual address of the reverse mapping information of the valid data does not change.
  • the reverse mapping information of the valid data cannot be the logical address of the data, it can be the virtual address of the data, or the fingerprint of the data, etc. information.
  • the logical address of the valid data can be queried by the system controller according to the reverse mapping information of the valid data, thereby completing the garbage collection inside the solid state disk.
  • a third aspect of the present application provides a system controller.
  • the system controller includes an interface and a processor.
  • the interface is used to connect to multiple solid-state hard disks, and the processor is used to execute any one of the methods in the first aspect.
  • the fourth aspect of the present application provides a system garbage collection device.
  • the device is located in a system controller of a flash memory array, and is configured to execute any one of the methods in the first aspect.
  • a fifth aspect of the present application provides a solid state hard disk, which includes a flash memory controller, a first physical block, and a second physical block.
  • the flash memory controller is configured to perform the method of the second aspect.
  • a sixth aspect of the present application provides a garbage collection device in a solid state hard disk, for performing the method of the second aspect.
  • a seventh aspect of the present application provides a flash memory array including a system controller and a solid state hard disk, wherein the system controller is configured to perform any one of the methods of the first aspect and the solid state hard disk is configured to perform the method of the second aspect .
  • An eighth aspect of the present application provides a computer program product for system garbage collection, including a computer-readable storage medium storing program code, where the program code includes instructions for performing the method described in the first aspect.
  • a ninth aspect of the present application provides a computer program product for garbage collection in a solid state hard disk, including a computer-readable storage medium storing program code, where the program code includes instructions for performing the method described in the second aspect.
  • FIG. 1 is an application scenario diagram provided by an embodiment of the present invention
  • FIG. 2 is a structural diagram of a controller according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a logical block group according to an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of a system garbage collection method according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a system garbage collection method according to an embodiment of the present invention.
  • FIG. 7 is a schematic flowchart of a garbage collection method in a solid-state hard disk according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a system garbage recovery device according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a garbage collection device in a solid state hard disk according to an embodiment of the present invention.
  • Embodiments of the present invention provide a system garbage collection method and a storage system, which can reduce write amplification and thereby increase the service life of a solid state hard disk.
  • FIG. 1 depicts a composition diagram of a flash memory array provided by an embodiment of the present invention.
  • the flash memory array shown in FIG. 1 includes at least one controller (such as the controller 11 shown in FIG. 1) and a plurality of solid state hard disks 22 (as shown in FIG. 1). (Solid state drive 22A, solid state drive 22B, solid state drive 22C, solid state drive 22G).
  • the controller 11 is connected to a host (not shown in the figure) through a storage area network (English: storage area network, SAN).
  • the controller 11 may be a computing device, such as a server, a desktop computer, and the like.
  • An operating system and application programs are installed on the controller 11.
  • the controller 11 can receive input / output (I / O) requests from the host.
  • the controller 11 may also store data (if any) carried in the I / O request, and write the data into the solid state hard disk 22.
  • a solid state hard disk (English: Solid State Disk, SSD) is a memory using a flash memory (English: flash memory) chip as a medium, also known as a solid state drive (SSD).
  • FIG. 1 is only an exemplary illustration.
  • a storage system may include two or more controllers.
  • the physical structure and functions of each controller are similar to those of the controller 11, and this embodiment does not limit the number of controllers.
  • the connection between any controller and the solid state hard disk 22 As long as the controllers can communicate with each other and between the controllers and the solid state hard disk 22.
  • the controller 11 when the controller 11 sends an instruction to the solid-state hard disk, the controller 11 often sends it to multiple solid-state hard disks.
  • a set including multiple solid-state hard disks 22 is referred to as a solid-state hard disk group.
  • FIG. 2 is a structural example diagram of the controller 11. As shown in FIG. 2, the controller 11 includes an interface card 110, a processor 112, and an interface card 113.
  • the interface card 110 is used to communicate with the host, and the controller 11 may receive an operation instruction of the host through the interface card 110.
  • the processor 112 may be a central processing unit (English: central processing unit, CPU). In the embodiment of the present invention, the processor 112 may be configured to receive an I / O request from a host and process the I / O request.
  • the I / O request may be a write data request or a read data request, and the processor 112 may also send data in the write data request to the solid state hard disk 22.
  • the processor 112 may also be used to perform a system garbage collection operation.
  • the interface card 113 is configured to communicate with the solid state hard disk 22, and the controller 11 may send a write data request (including data, a logical address of the data, and a virtual address of the data) to the solid state hard disk 22 for storage through the interface card 113.
  • the controller 11 may further include a memory 111.
  • the memory 111 is configured to temporarily store data received from the host or data read from the solid state hard disk 22.
  • the controller 11 may temporarily store data in the multiple write data requests in the memory 111.
  • the capacity of the memory 111 reaches a certain threshold, the data stored in the memory 111, the virtual address of the data, and the logical address allocated for the data are sent to the solid state hard disk 22.
  • the solid state hard disk 22 stores the data.
  • the memory 111 includes a volatile memory, a flash memory chip, or a combination thereof.
  • the volatile memory is, for example, a random access memory (English: random-access memory, RAM).
  • Flash memory chips such as floppy disks, hard disks, solid state disks (SSDs), optical disks, and other machine-readable media that can store program code.
  • the memory 111 has a power-saving function.
  • the power-saving function means that when the system is powered off and powered on again, the data stored in the memory 111 will not be lost.
  • the controller 11 After the data is written into the flash memory array, the controller 11 needs to record the validity of the data.
  • the validity of the data is determined by whether the data has been modified. If the data is written for the first time, the data can be recorded as valid (referred to as valid data). If the data is modified, the data before the modification is recorded as invalid (referred to as invalid data).
  • the validity of the data can be recorded with a bitmap. For example, each "bit" of a bitmap corresponds to a logical address of data having a size of 1KB. When “bit" is 1, it means that the data stored in the logical address is valid. When "bit" is 0, it means that the The data stored in the logical address is invalid.
  • the bitmap may be stored in the memory 111 or in a solid state hard disk.
  • controller 11 belongs to a system controller, and the system controller is an independent device, which is different from a control chip in a solid state hard disk.
  • the control chip of the solid state hard disk is referred to as a flash memory controller.
  • the solid state hard disk 22 includes a flash memory controller and a plurality of flash memory chips.
  • the flash memory controller is configured to perform operations such as a write data request or a read data request sent by the controller 11.
  • the flash memory controller may be a processor located inside the solid state hard disk 22, or a field programmable logic gate array (Field Programmable Gate Array, FPGA) located outside the solid state hard disk 22.
  • FPGA Field Programmable Gate Array
  • the flash memory controller includes a flash translation layer (English: flash translation layer, FTL).
  • the flash translation layer is used to store the correspondence between the logical address and the actual address of the data. Therefore, the flash translation layer is used to convert the logical address in the write data request or read data request sent by the system controller to the actual address of the data in the solid state disk.
  • the logical address of the data is allocated by the system controller, and the solid state disk provides a subset of the logical address range of the system controller.
  • the logical address of the data includes a start logical address and a length. The start logical address indicates the position of the logical block group where the data is located, and the length represents the size of the data.
  • the actual address of the data may be a physical address of the data in the solid state disk, or an address that is virtualized based on the physical address and is only visible to the flash memory controller. This virtualized actual address is not visible to the system controller.
  • the physical address includes the number of the physical block where the data is located and the number of the page.
  • Solid-state drives usually include one or more flash memory chips. Each flash memory chip includes several physical blocks (may be referred to as "blocks"). A solid state drive is based on a page (English: page) when reading or writing, but the erase operation can only be based on a physical block. An erase operation refers to setting all bits of this block to " 1". Before erasing, the flash controller needs to copy the valid data in this physical block to a blank page in another block.
  • Each physical block contains multiple pages.
  • a solid-state drive performs a data write request, it writes data in units of pages.
  • the controller 11 sends a write data request to the flash memory controller.
  • the write data request includes a logical address of the data.
  • the flash memory controller continuously writes the data into one or more physical blocks according to the received time sequence. Writing one or more physical blocks continuously means that the flash memory controller searches for a blank physical block and writes data into the blank physical block until the blank physical block is filled. When the capacity of the physical block is exceeded, the flash controller looks for the next blank physical block and continues writing.
  • the flash translation layer establishes and saves the correspondence between the logical address and the actual address of the page where the data is written.
  • the read data request includes the logical address.
  • the flash memory controller reads the data according to the logical address and the correspondence between the logical address and the actual address, and sends the data to the controller 11.
  • redundant data array Redundant Array of Inexpensive Disks, RAID
  • RAID Redundant Array of Inexpensive Disks
  • the controller 11 performs space management on the solid state hard disk in the form of a logical block (English: chunk, CK for short).
  • a logical block is a space concept. Its size is 4MB as an example, but it is not limited to 4MB.
  • the logical blocks from different solid state hard disks can form a logical block set.
  • the controller 11 then divides the logical blocks in the logical block set into a data logical block group and a check logical block group according to the set RAID type.
  • the data logical block group includes at least two logical blocks for storing data
  • the check logical block group includes at least one check logical block for storing check data of the data.
  • a logical block set including a data logical block group and a check logical block group is referred to as a logical block group.
  • the controller 11 fills up a certain size of data in the memory 111, it can be divided into a plurality of data units according to the set RAID type, and a check unit is calculated to obtain the data unit and the check unit.
  • a solid state drive to save in the logical block group.
  • Each logical block in the data group is used to store data units, and each logical block in the check group is used to store check units. After storage, these data units and corresponding check units constitute a stripe.
  • a logical block group includes multiple stripes.
  • the data unit and check unit included in the stripe can be called the stripe unit.
  • the size of the stripe unit is 8 KB as an example, but it is not limited to 8 KB.
  • the controller 11 groups logical blocks in the logical block set according to a RAID type (taking RAID 6 as an example), such as logical Block 1, logical block 2, and logical block 3 are data logical block groups, and logical block 4 and logical block 5 are check logical block groups.
  • the data stored in the memory 111 reaches 24KB (8KB * 3)
  • the data is divided into 3 data units, each data unit is 8KB, and then 2 check units are calculated and each check unit is also 8KB.
  • the controller 11 sends these data units and check units to the solid state hard disk and stores them in the logical block group (shown as a shaded part in FIG. 3). It can be understood that according to the redundancy protection mechanism of RAID 6, when any two data units or check units fail, the failed units can be reconstructed according to the remaining data units or check units.
  • the following describes the data writing method provided by the embodiment of the present invention with reference to FIG. 4.
  • This method can be applied to the flash memory array shown in FIG. 1 and can be executed by the processor 112 in the controller 11 shown in FIG. 2 or the solid state hard disk 22. carried out.
  • the method includes the following steps:
  • the controller 11 receives a write data request sent by the host, where the write data request includes data to be written and a virtual address of the data to be written.
  • the controller 11 provides its storage space to the host in the form of a logical unit (LU), and the host has a binding relationship with one or more logical units.
  • LU logical unit
  • the virtual address is an identifier of a logical unit and an offset address where the data is located in the logical unit.
  • the controller 11 writes the data to be written into the memory 111.
  • the controller 11 determines that the target stripe is used to receive the data.
  • the stripe is a subset of the logical block group shown in FIG. 3, and the logical address of the target stripe is a subset of the logical address of the logical block group in which it is located.
  • the stripe size referred to here actually refers to the size of all data units in the stripe. Then, the controller 11 calculates check data of these data. The data and the verification data together form a stripe.
  • the controller 11 assigns a logical address to the target stripe. It should be understood that the logical address here is different from the virtual address in 401, the virtual address is an address that is visible to the controller 11 and the host, but not visible to the solid state hard disk 22, and the logical address in 404 is to the controller 11 and Addresses where the solid state drive 22 is visible but not visible to the host.
  • the controller 11 needs to determine whether there is an already allocated logical block group. If there is an allocated logical block group and the logical block group still has enough space to accommodate the data, the controller 11 may instruct the multiple solid state hard disks to This data is written into the allocated logical block group. Specifically, the controller 11 obtains an unused logical address from the logical address range of the allocated logical block group, and carries the logical address in the write data request to the solid state hard disk 22 in 405. The controller 11 determines that there are no logical block groups allocated in the system, or that the allocated logical block groups are filled with data, then the controller 11 needs to create a new logical block group.
  • the creation process may be that the controller 11 determines that the remaining space of the system is sufficient to create a new logical block group according to its own record of the available space owned by each solid state hard disk.
  • the controller 11 obtains a logical block from different solid-state hard disks 22 respectively, and will construct these logical blocks into a new logical block group according to the set RAID type (refer to the description of the logical block group in FIG. 3) .
  • the controller 11 allocates a segment of logical addresses to each logical block, and these logical address sets are the logical addresses of the new logical block group.
  • the controller 11 may obtain one of them as the logical address of the target stripe.
  • the controller 11 sends a write data instruction to the multiple solid state hard disks 22, respectively. Since the data in the target stripe should be distributed among multiple solid-state hard disks, it is necessary to send a write data instruction to each solid-state hard disk 22 in the multiple solid-state hard disks.
  • the number of solid-state hard disks 22 receiving the write data instruction depends on the RAID type. Taking the RAID type as 3 + 2 (3 data units and 2 parity units) as an example, the data in the target stripe will be Distributed in five solid state hard disks, the controller 11 needs to generate five write data instructions, and each write data instruction is sent to one of the five solid state hard disks.
  • Each of the write data instructions carries the part of data or part of the check data, a logical address of the part of data or the part of check data, and a virtual address of the part of the data or part of the check data. It should be understood that the logical address in each write data instruction is a subset of the logical address allocated by the controller 11 for the target stripe, and the virtual address in each write data instruction is from a write data request sent by the host.
  • the solid state hard disk 22 For each solid state hard disk 22 that receives the write data instruction, the solid state hard disk 22 writes data in the write data instruction and a virtual address of the data into a physical block.
  • the write data instruction may be a custom command to ensure that the data and the virtual address are written into the same physical block.
  • the address where the data is located in the block is called the actual address (including the number of the physical block and the page number where the data is located).
  • the solid-state hard disk 22 stores the logic of the data in the flash translation layer. Correspondence between the address and the actual address.
  • the virtual address written in the physical block with the data is also called reverse mapping information, which can enable the solid state hard disk 22 to obtain the logical address of the data according to the virtual address of the data when performing in-disk garbage collection, and Find the logical address of the data from the flash translation layer and modify it to the new logical address.
  • the controller 11 After the solid-state hard disk 22 successfully writes the data into the block, the controller 11 creates a correspondence between the virtual address of the data and the logical address. Subsequently, if the host sends a data read request to read the data in the virtual address, the controller 11 may read the data from the solid state hard disk 22 according to the correspondence between the virtual address and the logical address. .
  • the reverse mapping information written into the physical block with the data is the logical address of the data. Because the logical address of the data describes where the data is located in the logical block group, when the data is migrated from one logical block group to another logical block group, its logical address will change. Then, it also means that the data information including the data and the logical address of the data will change.
  • the system controller instead of actually moving the data, writes the data and the virtual address of the data instead of actually moving the data. Logical addresses are written into physical blocks together. This is because the virtual address of the data does not change during this process.
  • the reverse mapping information refers to a virtual address of data, because when data is migrated between logical block groups, the virtual address of the data does not change.
  • the reverse mapping information refers to a fingerprint of data, and the so-called fingerprint refers to a result obtained by performing a hash operation on the data.
  • the reverse mapping information is an offset address of data in a file.
  • the write data request sent by the host to the controller 11 includes a keyword of data to be written instead of a virtual address. The word is obtained by the virtual address calculation.
  • the reverse mapping information refers to a keyword of the data to be written.
  • the controller 11 creates a correspondence between the keyword of the data information and the logical address. relationship.
  • the write data request sent by the host to the controller 11 includes the log address of the data to be written instead of the virtual address.
  • the reverse mapping information is Refers to the log address of the data to be written.
  • the controller 11 creates a correspondence between the log address of the data information and the logical address.
  • the reverse mapping information in the embodiments of the present invention refers to any information that can find the actual address of the data through the forward index, and is not limited to the various cases listed above. When the data migrates between logical block groups This information does not change from time to time. In the following description, this embodiment still takes a virtual address as an example. If the reverse mapping information refers to other information that finds the actual address of the data through a forward index, the operation mode is similar.
  • the controller 11 can monitor the available space of each solid state hard disk 22 in real time or periodically, so as to know the available space of the entire system.
  • the free space of the system is lower than the set space threshold, the system garbage collection is started.
  • the capacity of a solid state hard disk 22 is 128G
  • the total capacity of all solid state drives (assuming that the flash memory array includes 10 solid state drives) included in the flash memory array shown in FIG. 1 is 1280G
  • the space threshold can be set to 640G. That is, when the data stored in the flash memory array reaches half of the total capacity, the remaining available space also reaches the space threshold, and the controller 11 may perform system garbage collection at this time.
  • 640G is only an example of a spatial threshold, and the spatial threshold may also be set to another value.
  • the system garbage collection can also be triggered. System garbage collection is different from garbage collection inside a solid state drive. Garbage collection inside a solid state drive is done by the solid state drive itself.
  • the controller 11 performs system garbage collection in units of logical block groups. For example, the controller 11 obtains the logical address of valid data in a logical block group according to the bitmap, and sends the logical address of the valid data to the solid-state hard disk group, so that each solid-state hard disk 22 can according to the logical address of the valid data The data is read and sent to the controller 11. The controller 11 assigns a new logical address to the valid data, the new logical address belongs to a new logical block group, and sends the allocated new logical address to the solid state disk group, and each solid state disk 22 sends the valid data After writing a new physical block, the mapping relationship between the actual address and the new logical address is saved.
  • the controller 11 sends an unmap command or a trim command to the solid-state hard disk group, where the de-mapping command includes a logical address range of the logical block group to be recycled, and each solid-state hard disk 22 receives the de-mapping.
  • the mapping command the correspondence between the logical address and the actual address of the logical address section stored in the flash translation layer is deleted.
  • the solid state hard disk 22 may also mark the block corresponding to the actual address of the valid data before the transfer as a block that does not contain valid data or directly erase the block that does not contain valid data.
  • the controller 11 may release a logical address range of the logical block group to be recovered and an actual physical space (which may also be understood as an actual address) occupied by the logical block group.
  • An embodiment of the present invention provides a system garbage collection method, which can complete the migration of valid data between logical block groups during the system garbage collection process without actually moving the data, thereby reducing write amplification.
  • FIG. 5 is a schematic flowchart of a system garbage collection method provided in this embodiment
  • FIG. 6 is a schematic diagram of implementing data migration between two logical block groups. As shown in Figure 5, the method includes the following steps:
  • the controller 11 selects at least one logical block group from a plurality of logical block groups as an object of garbage collection.
  • the selected logical block group needs to satisfy a certain condition, for example, the invalid data contained in the logical block group reaches a first set threshold, or the logical block group is the logical block containing the most invalid data among the multiple logical block groups Group, or the logical block group contains valid data lower than a second set threshold, or the logical block group is the logical block group containing the least effective data among the plurality of logical block groups.
  • the amount of invalid data or valid data can be counted according to the bitmap described previously.
  • the selected logical block group for garbage collection is referred to as a first logical block group.
  • the first logical block group includes a first data logical block group and a first check logical block group.
  • the first data logical block group includes at least two data logical blocks.
  • the first check logic block group includes at least one logic block for storing check data.
  • Each data logical block included in the first data logical block group and a check logical block included in the first check logical block group are all from different solid state drives.
  • the first logical block group contains valid data and invalid data. Generally, during the system garbage collection process, valid data in the first logical block group needs to be migrated to a new logical block group, and then the data is released.
  • the first logical block group In this embodiment, the position where valid data in the first logical block group is located in the first logical block group is a first logical address. There is a corresponding relationship between the first logical address and the actual address where the valid data is stored in the solid state hard disk.
  • the controller 11 creates a second logical block group according to the distribution of the first data logical block group among the multiple solid-state hard disks.
  • the second logical block group is a logical block group that receives valid data in the first logical block group.
  • the RAID type of the created second logical block group is the same as the RAID type of the first logical block group.
  • the second logical block group includes a second data logical block group and a second check logical block group, where the second The number of data logical blocks included in the data logical block group is the same as the number of data logical blocks included in the first data logical block group, and the number of check logical blocks included in the second check logical block group is the same as the first check
  • the logical block group contains the same number of check logical blocks.
  • the distribution of the second data logical block group in the plurality of solid state hard disks is the same as the distribution of the first data logical block group in the plurality of solid state hard disks.
  • the logical block 1, logical block 2, and logical block 3 included in the first data logical block group are respectively located in the solid state hard disk 22A, the solid state hard disk 22B, and the solid state hard disk 22C.
  • the controller 11 obtains one data logical block from the solid-state hard disk 22A, the solid-state hard disk 22B, and the solid-state hard disk 22C, respectively, and creates a second logical block group.
  • the logical block 1 ', the logical block 2', and the logical block 3 'in the second logical block group are also located in the solid state hard disk 22A, the solid state hard disk 22B, and the solid state hard disk 22C, respectively.
  • the logical block 1 included in the first logical block group is distributed in the solid state hard disk 22A.
  • the controller 11 obtains the logical block 1 'from the solid state hard disk 22A.
  • the controller 11 also obtains data logic block 2 'and data logic block 3 from the corresponding solid state hard disks according to their distribution in the solid state hard disk. '.
  • this embodiment does not require the controller 11 to create a second verification logic block group according to the distribution of the first verification block group among the plurality of solid state hard disks.
  • the controller 11 can freely select a solid state hard disk that provides a verification logic block among the plurality of solid state hard disks, as long as it does not duplicate the solid state hard disk that provides a data logic block. This is because, generally, the verification data stored in the second verification logic block needs to be recalculated and obtained instead of being directly migrated from the first verification logic block.
  • each data logical block included in the second logical block group is distributed in a solid state hard disk where one of the data logical blocks included in the first logical block group is located.
  • the data stored in the data logical block included in the first data logical block group may be valid data or invalid data. That is, among the plurality of data logical blocks, only a part of the data logical blocks (or even only one data logical block) may store valid data.
  • the solid state hard disk where it is located can perform garbage collection of the first logical block group.
  • the controller 11 allocates a second logical address to valid data in the first logical block group.
  • the valid data can refer to the small shaded block in logic block 1 shown in FIG. 6. It should be noted that the small shaded block shown in FIG. 6 is only a part of the valid data in the first logical block group. Data may also be distributed in data logic block 2 and data logic block 3.
  • the allocated second logical address is a subset of the logical addresses of the second logical block group.
  • the second logical block group created in 502 may not only be used to store valid data in one logical block group, but may also be used to store valid data in multiple logical block groups.
  • the controller 11 changes the first logical address of the valid data stored in the memory 111 to a second logical address.
  • the controller 11 needs to read valid data from the first logical block group and rewrite it to the second logical block group. This means that the valid data will move between the physical blocks of the solid state hard disk, and accordingly, both the logical address and the actual address of the valid data will change.
  • to migrate the valid data from the first logical block group to the second logical block group only the logical address of the valid data needs to be modified (the first logical address that will belong to the first logical block group).
  • the controller 11 stores the correspondence between the virtual address of the valid data and the first logical address.
  • the controller 11 may modify the correspondence between the virtual address of the valid data and the first logical address to the correspondence between the virtual address and the allocated second logical address.
  • the controller 11 sends a mapping relationship modification instruction to the multiple solid-state hard disks, where the mapping relationship modification instruction is used to instruct the multiple solid-state hard disks to associate the first logical address of the valid data with the actual address The relationship is modified to a correspondence relationship between the second logical address and the actual address.
  • the controller 11 changes the logical address of the valid data. The change of the logical address also needs to notify the solid state hard disk to ensure that the logical addresses of the valid data stored in the controller 11 and the solid state hard disk 22 are consistent. It is convenient to read the valid data in the future.
  • each solid-state hard disk in the plurality of solid-state hard disks stores some valid data
  • the controller 11 needs to send a mapping relationship modification instruction to each solid-state hard disk to instruct the solid-state hard disk to modify its own storage Correspondence of some valid data.
  • the storage is valid.
  • the solid state hard disks where the first data logical block of data is the same, then the controller 11 only needs to send a mapping relationship modification instruction to the solid state hard disk where the first data logical block containing valid data is located.
  • the controller 11 if there is a certain number (greater than or equal to 2) of the first data logical block in the first logical block group containing valid data, and the created second logical block group also has the same number of second data logical blocks.
  • the solid-state hard disk is the same as the solid-state hard disk where the first data logical block storing valid data is stored, and the controller 11 only needs to send a mapping relationship modification instruction to the solid-state hard disk holding valid data.
  • N is an integer greater than or equal to 2
  • M is greater than or
  • the solid-state hard disk where the second data logical blocks are located is the same as the solid-state hard disk where some of the first data logical blocks of the N first data logical blocks are located, and M is less than N.
  • the controller 11 only needs to send a mapping relationship modification instruction to the solid state disk where the M first data logical blocks are located.
  • the system garbage collection method shown in FIG. 5 may be implemented in the entire flash memory array, or may be applied to a part of the flash memory array.
  • the logical addresses provided by the multiple solid-state hard disks 22 to the controller 11 can be divided into two sets, where the system garbage collection in the first set adopts the method provided by the embodiment of the present invention, and the system in the second set Garbage recycling is traditional.
  • the controller 11 may transfer the first logical block
  • the information that the data of the block group becomes invalid data (for example, the logical address of the first logical block group) is passed to each solid state hard disk 22 distributed by the first logical block group.
  • the invalid data is described.
  • the solid state hard disk 22 performs internal garbage collection, the physical block containing the invalid data can be directly recovered without copying the valid data.
  • FIG. 5 introduces the process of system garbage collection. It can be known from the above description that the system garbage collection is triggered and completed by the controller 11. However, the solid state hard disk 22 may also perform its own garbage collection, and for the time being, the garbage collection inside the solid state hard disk is referred to as on-disk garbage collection. Most operations of garbage collection in the disk are completed by the flash memory controller, and in a few cases, the cooperation of the controller 11 is required.
  • FIG. 7 is a schematic flowchart of a method for garbage collection in a tray provided in this embodiment. As shown in FIG. 7, the method includes the following steps.
  • the flash memory controller of the solid state hard disk 22 selects at least one physical block to be recovered from a plurality of physical blocks.
  • the solid state hard disk 22 is any one of the solid state hard disks shown in FIG. 1.
  • the selected physical block needs to meet certain conditions, for example, the invalid data contained in the physical block reaches a third set threshold, or the physical block is the physical block containing the most invalid data among the plurality of physical blocks, or the physical block
  • the valid data contained in the block is lower than the fourth set threshold, or the physical block is a physical block containing the least effective data among the plurality of physical blocks.
  • the selected physical block for garbage collection is referred to as a first physical block.
  • the data amount of invalid data or valid data can be counted according to the bitmap inside the solid state hard disk 22.
  • a bitmap is stored in the solid state hard disk 22, and the bitmap, as shown in Table 1, is used to describe the validity of the data stored in the actual address.
  • the solid state hard disk 22 can acquire the data amount of valid data or invalid data of each physical block, thereby selecting the first physical block to be recovered.
  • the flash memory controller reads valid data and a virtual address of the valid data from the first physical block.
  • the actual address where valid data is stored can be obtained from Table 1, such as block0, page2.
  • the solid state hard disk 22 reads the stored valid data from the actual address. Since the virtual address of the data and the data are stored as a whole, the virtual address of the valid data can be read when the valid data is read.
  • the flash memory controller sends the virtual address to the controller 11. If the logical address of the valid data and the valid data are stored together in a conventional manner, the solid state hard disk 22 can directly obtain the logical address of the valid data. However, in this embodiment, the virtual address of the valid data is stored in the solid-state hard disk 22 instead of a logical address. Therefore, the solid-state hard disk 22 needs to send the virtual address to the controller 11 to query the valid data. Logical address.
  • the flash memory controller receives a logical address corresponding to the virtual address sent by the controller 11.
  • the controller 11 stores the correspondence between the virtual address and the logical address.
  • the logical address herein may be the second logical address in the embodiment shown in FIG. 5, and may also be referred to as a source logical address.
  • the flash memory controller allocates a target logical address.
  • the flash memory controller copies the valid data to a second physical block, where the second physical block is a blank physical block. Since the valid data and the virtual address of the valid data are stored as a whole, when the flash memory controller copies the valid data to the second physical block, it also copies the virtual address of the valid data to The second physical block.
  • the flash memory controller modifies the corresponding relationship stored in the flash memory translation layer. Specifically, the flash memory controller deletes the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and creates the target logical address and the valid data save A correspondence between actual addresses in the second physical block.
  • the solid state hard disk 22 may select other physical blocks as the object of garbage collection, and repeatedly perform 701 to 707, thereby completing the garbage collection of the entire solid state hard disk 22.
  • this embodiment uses the virtual address as an example. However, it can be understood that the virtual address may be replaced with other forms of reverse mapping information.
  • the operation mode of garbage collection on the disk is similar to that described in FIG. 7, and is not repeated here.
  • this embodiment is also applicable to another storage system.
  • the storage system includes a system controller and multiple shingled magnetic recording (SMR) hard disks.
  • SMR shingled magnetic recording
  • the storage system can also execute the method flow shown in FIG. 4, FIG. 5, and FIG. 7. It only needs to replace the solid-state hard disk with a shingled magnetic recording technology hard disk, which will not be repeated here.
  • FIG. 8 is a schematic structural diagram of a system garbage collection device according to an embodiment of the present invention.
  • the device is located in a controller 11 of a flash memory array. As shown in FIG. 8, the device includes a determination module 801, a creation module 802, an allocation module 803, and an instruction. Block 804.
  • the determining module 801 is configured to determine a first logical block group to be recycled, where the first logical block group includes multiple first data logical blocks, and the multiple first data logical blocks are distributed in the flash memory array.
  • the first logical block group includes multiple first data logical blocks, and the multiple first data logical blocks are distributed in the flash memory array.
  • data stored in at least one of the plurality of first data logical blocks includes valid data
  • the position of the valid data in the first logical block is A first logical address
  • the first logical address has a corresponding relationship with an actual address where the valid data is stored in the solid state hard disk.
  • the function of this module may be executed by the processor 112 alone or executed by the processor 112 calling a program in the memory 111. For details, refer to step 501 and related description shown in FIG. 5, and details are not described herein again.
  • a creating module 802 is configured to create a second logical block group, where the second logical block group includes a plurality of second data logical blocks, wherein at least one of the second data logical blocks is distributed in a first storage block storing the valid data.
  • An allocation module 803 is configured to allocate a second logical address to the valid data in a second logical block distributed in the solid state hard disk where the first logical block storing the valid data is located.
  • the functions of this module can be executed by the processor 112 alone or executed by the processor 112 calling a program in the memory 111. For details, refer to step 503 and related description shown in FIG. 5, and details are not described herein again.
  • An instruction module 804 is configured to instruct the solid-state hard disk storing the valid data to modify a correspondence between the first logical address and the actual address to a correspondence between the second logical address and the actual address.
  • the function of this module can be executed by the processor 112 alone or executed by the processor 112 calling the program in the memory 111. For details, refer to step 505 and related description shown in FIG.
  • FIG. 9 is a schematic structural diagram of a garbage collection device in a solid state hard disk according to an embodiment of the present invention. As shown in FIG. 9, the device includes a processing module 901 and a recycling module 902.
  • a processing module 901 configured to read valid data and reverse mapping information of the valid data from the first physical block to be recycled; send the reverse mapping information to the system controller; and receive the system controller A source logical address corresponding to the reverse mapping information sent; assigning a target logical address to the valid data, and copying the valid data to a second physical block.
  • the function of this module can be executed by the controller inside the solid state hard disk 22. For details, refer to steps 701 to 705 shown in FIG. 7 and related descriptions, which will not be repeated here.
  • the recycling module 902 is configured to delete the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and create the target logical address and the valid data to be stored in the Correspondence between actual addresses in the second physical block; erasing data in the first physical block.
  • the functions of this module can be executed by the controller inside the solid state hard disk 22. For details, refer to steps 706 to 707 shown in FIG. 7 and related descriptions, and details are not described herein again.
  • each aspect of the present invention, or possible implementation manners of each aspect may be specifically implemented as a system, method, or computer program product. Therefore, aspects of the present invention, or possible implementations of various aspects, may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, etc.), or an embodiment combining software and hardware aspects. These are collectively referred to as “circuits", “modules” or “systems”.
  • each aspect of the present invention, or a possible implementation manner of each aspect may take the form of a computer program product, where the computer program product refers to computer-readable program code stored in a computer-readable medium.
  • Computer-readable media includes, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, equipment, or devices, or any suitable combination of the foregoing, such as random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM), optical disc.
  • RAM random access memory
  • ROM read-only memory
  • EPROM erasable Programmable read-only memory
  • the processor in the computer reads the computer-readable program code stored in the computer-readable medium, so that the processor can execute the functional actions specified in each step or a combination of steps in the flowchart.
  • the computer-readable program code can be executed entirely on the user's computer, partly on the user's computer, as a separate software package, partly on the user's computer and partly on a remote computer, or entirely on a remote computer or server . It should also be noted that in some alternative implementations, the functions noted in the steps in the flowchart or in the blocks in the block diagram may occur out of the order noted in the figure. For example, two steps shown in succession, or two blocks may in fact be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.

Abstract

A system garbage collection method and a method for collecting garbage in a solid state hard disk. A system controller determines a first logical block group to be collected, the first logical block group comprises a first data logical block, the first data logical block is located in a first solid state hard disk among a plurality of solid state hard disks, valid data is stored in a first logical address in the first logical block group, and the first logical address has a correlation with an actual address where the valid data is stored in the plurality of solid state hard disks. The system controller creates a second logical block group, and at least one second data logical block in the second logical block group is distributed on the solid state hard disk where the first data logical block storing valid data is located, thereby ensuring that the valid data migrates from the first logical block group to the second logical block group while the actual address thereof remains unchanged so as to reduce write amplification.

Description

一种系统垃圾回收方法和固态硬盘中的垃圾回收方法System garbage recycling method and garbage recycling method in solid state hard disk 技术领域Technical field
本申请涉及存储领域,并且更具体地,涉及一种系统垃圾回收方法和固态硬盘垃圾回收方法。The present application relates to the storage field, and more particularly, to a system garbage collection method and a solid state hard disk garbage collection method.
背景技术Background technique
闪存阵列是指包含固态硬盘和系统控制器的存储系统。其中,系统控制器以逻辑块组(chunk group,CKG)为单位为固态硬盘分配逻辑地址,当系统中可用空间不足时系统控制器会进行系统垃圾回收。在系统垃圾回收操作中,系统控制器指令固态硬盘将逻辑块组中所有的有效数据搬移到新的逻辑块组,这就导致有效数据在固态硬盘内部发生搬移。因此增加了写放大的次数。A flash array is a storage system that contains a solid state drive and a system controller. Among them, the system controller allocates logical addresses to solid state disks in units of logical block groups (CKGs). When the available space in the system is insufficient, the system controller performs system garbage collection. In the system garbage collection operation, the system controller instructs the solid-state hard disk to move all valid data in the logical block group to the new logical block group, which causes the valid data to be moved inside the solid-state hard disk. Therefore, the number of write amplification is increased.
发明内容Summary of the Invention
本申请提出了一种系统垃圾回收方法和固态硬盘中的垃圾回收方法,可以减少写放大的次数。This application proposes a system garbage collection method and a garbage collection method in a solid state hard disk, which can reduce the number of write amplifications.
第一方面提供了一种系统垃圾回收方法,该方法应用于闪存阵列中,所述闪存阵列包括系统控制器和多个固态硬盘。系统控制器确定待回收的第一逻辑块组,所述第一逻辑块组包括多个第一数据逻辑块,所述多个第一数据逻辑块分布在不同的固态硬盘中,其中,所述多个第一数据逻辑块中至少有一个第一数据逻辑块存储的数据包括有效数据,所述有效数据位于所述第一逻辑块中的地址为第一逻辑地址,所述第一逻辑地址与所述有效数据保存在固态硬盘中的实际地址具有对应关系。所述系统控制器创建第二逻辑块组,所述第二逻辑块组包括多个第二数据逻辑块,所述第二逻辑块组包括第二数据逻辑块,其中,至少有一个所述第二数据逻辑块分布在存储所述有效数据的第一数据逻辑块所在的固态硬盘中。所述系统控制器在所述至少一个所述第二数据逻辑块中为所述有效数据分配第二逻辑地址,然后,指示所述保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系。A first aspect provides a system garbage collection method, which is applied to a flash memory array, which includes a system controller and a plurality of solid state hard disks. The system controller determines a first logical block group to be recycled. The first logical block group includes a plurality of first data logical blocks, and the plurality of first data logical blocks are distributed in different solid state hard disks. The data stored in at least one first data logical block of the plurality of first data logical blocks includes valid data. The address of the valid data in the first logical block is a first logical address, and the first logical address and The actual address of the valid data stored in the solid state hard disk has a corresponding relationship. The system controller creates a second logical block group, the second logical block group includes a plurality of second data logical blocks, and the second logical block group includes a second data logical block, where at least one of the first The two data logical blocks are distributed in the solid state hard disk where the first data logical block storing the valid data is located. The system controller allocates a second logical address to the valid data in the at least one of the second data logical blocks, and then instructs the solid-state hard disk storing the valid data to compare the first logical address with the first logical address. The correspondence between the actual addresses is modified to the correspondence between the second logical address and the actual addresses.
在第一方面提供的系统垃圾回收方法中,待回收的第一逻辑块组包括多个第一数据逻辑块,至少有一个第一数据逻辑块存储的数据是有效数据,由于创建的第二逻辑块组至少有一个数据逻辑块分布在存储有效数据的第一数据逻辑块所在的固态硬盘中,因此所述有效数据并不需要实际移动,只需要指示保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系就可以将待回收的第一逻辑块组中的至少一个数据逻辑块中的有效数据迁移至所述创建的第二逻辑块组中。由于所述有效数据并没有实际移动,所以能够减小写放大。In the system garbage collection method provided by the first aspect, the first logical block group to be recycled includes a plurality of first data logical blocks, and at least one of the data stored in the first data logical block is valid data. At least one data logical block of the block group is distributed in the solid-state hard disk where the first data logical block storing valid data is stored. Therefore, the valid data does not need to be physically moved, and only the solid-state hard disk storing the valid data needs to be instructed to transfer the valid data. The correspondence between the first logical address and the actual address is modified to the correspondence between the second logical address and the actual address, so that at least one data in the first logical block group to be recovered is valid data in the logical block. Migrate to the created second logical block group. Since the effective data is not actually moved, write amplification can be reduced.
在所述第一逻辑块组所包含的多个数据逻辑块中,可能只有部分数据逻辑块(甚至只有一个数据逻辑块)存储有效数据,那么在创建第二逻辑块组时,只需要保证所述第二逻辑块组中有部分数据逻辑块或者一个数据逻辑块分布在所述第一数据逻辑块组中存储有有效数据的数据逻辑块所在的固态硬盘,就可以实现将第一逻辑块组中的有效数据迁移至第二逻辑块组而并没有真实地移动所述有效数据。另外,可以理解的是,即使所述第一逻辑块组中有部分或者全部数据逻辑块存储有有效数据,只要保证创建的第二逻 辑块组中至少有一个数据逻辑块分布在所述第一数据逻辑块组中存储有有效数据的数据逻辑块所在的固态硬盘中,也可以在一定程度上减小写放大。Among the plurality of data logical blocks included in the first logical block group, only a part of the data logical blocks (or even only one data logical block) may store valid data, then when creating the second logical block group, it is only necessary to ensure that all Said that the second logical block group has a part of the data logical block or a data logical block distributed on the solid state hard disk where the data logical block in the first data logical block group stores valid data, the first logical block group can be realized. The valid data in is migrated to the second logical block group without actually moving the valid data. In addition, it can be understood that even if some or all of the data logical blocks in the first logical block group store valid data, as long as at least one data logical block in the created second logical block group is guaranteed to be distributed in the first In the data logic block group, the solid state hard disk where the data logic block storing valid data is located can also reduce write amplification to a certain extent.
可选的,在另一种实现中,第二逻辑块组所包含的每个数据逻辑块都分布在第一逻辑块组所包含的其中一个数据逻辑块所在的固态硬盘中。这样,可以最大程度地减小写放大。Optionally, in another implementation, each data logical block included in the second logical block group is distributed in a solid state hard disk where one of the data logical blocks included in the first logical block group is located. In this way, write amplification can be minimized.
在第一方面的第一种实现中,所述存储有效数据的第一数据逻辑块的数量和所述至少一个所述第二数据逻辑块的数量相同。例如,如果所述第一逻辑块组中有一个第一数据逻辑块存储有有效数据,那么第二逻辑块组中也有一个第二数据逻辑块分布在所述存储所述有效数据的第一数据逻辑块所在的固态硬盘中。如果所述第一逻辑块组中有两个第一数据逻辑块存储有有效数据,那么第二逻辑块组中也有两个第二数据逻辑块分别分布在两个存储所述有效数据的第一数据逻辑块所在的固态硬盘中。如果所述第一逻辑块组中每个第一数据逻辑块都存储有有效数据,那么第二逻辑块组中的所有第二数据逻辑块也要分布在所有第一数据逻辑块所在的固态硬盘中。In a first implementation of the first aspect, the number of the first data logical blocks storing valid data is the same as the number of the at least one second data logical block. For example, if there is a first data logical block in the first logical block group that stores valid data, then a second data logical block in the second logical block group is also distributed over the first data that stores the valid data The solid state drive where the logical block is located. If two first data logical blocks in the first logical block group store valid data, then two second data logical blocks in the second logical block group are also distributed among two first data blocks storing the valid data. The solid state drive where the data logic blocks are located. If each first data logical block in the first logical block group stores valid data, then all second data logical blocks in the second logical block group must also be distributed on the solid state hard disk where all the first data logical blocks are located. in.
结合第一方面的第一种实现,在第一方面的第二种实现中,所述创建第二逻辑块组具体可以是根据多个第一数据逻辑块在多个固态硬盘中的分布情况创建所述第二逻辑块组,所述创建的第二逻辑块组中的所有第二数据逻辑块分布在所有第一数据逻辑块所在的固态硬盘中。按照这种方式创建的第二逻辑块组,可以最大程度地减小写放大。With reference to the first implementation of the first aspect, in the second implementation of the first aspect, the creating a second logical block group may specifically be created based on the distribution of multiple first data logical blocks among multiple solid state drives. In the second logical block group, all the second data logical blocks in the created second logical block group are distributed in a solid state hard disk where all the first data logical blocks are located. The second logical block group created in this way can minimize write amplification.
结合以上任意一种实现,在第一方面的第三种实现中,所述第一逻辑块组还包括第一校验逻辑块,所述第一校验逻辑块分布在与所述多个第一数据逻辑块不同的固态硬盘中,所述第二逻辑块组还包括第二校验逻辑块,所述第二校验逻辑块分布在与所述多个第二数据逻辑块不同的固态硬盘中。第一校验逻辑块的数量和第二校验逻辑块的数量相同,都是根据RAID类型来确定的。所述第二校验逻辑块所在的固态硬盘可以和所述第一校验逻辑块所在的固态硬盘相同,也可以不同。通常情况下,有效数据从第一逻辑块组迁移至第二逻辑块组之后都需要重新计算并存储校验数据,因此本申请并不限定第二校验逻辑块的分布。With reference to any one of the above implementations, in a third implementation of the first aspect, the first logical block group further includes a first check logical block, and the first check logical block is distributed between the first check logical block and the multiple first logical block. In a solid state hard disk having a different data logical block, the second logical block group further includes a second check logical block, and the second check logical block is distributed on a solid state hard disk different from the plurality of second data logical blocks. in. The number of the first check logical block is the same as the number of the second check logical block, and both are determined according to the RAID type. The solid state disk where the second verification logic block is located may be the same as or different from the solid state disk where the first verification logic block is located. Generally, valid data needs to be recalculated and stored after the valid data is migrated from the first logical block group to the second logical block group. Therefore, the application does not limit the distribution of the second logical block.
结合以上任意一种实现,在第一方面的第四种实现中,所述待回收的第一逻辑块组可以根据一定条件来选择,例如,当闪存阵列中的某一个逻辑块组所包含的有效数据的数据量低于设定阈值时,可以将其作为待回收的第一逻辑块组。或者,当闪存阵列中的某一个逻辑块组所包含的无效数据的数据量高于所述设定阈值时,可以将其作为待回收的第一逻辑块组。或者,选择闪存阵列中无效数据最多或者有效数据最少的逻辑块组作为待回收的第一逻辑块组。这样可以提高系统垃圾回收的效率。In combination with any one of the above implementations, in the fourth implementation of the first aspect, the first logical block group to be recycled may be selected according to certain conditions, for example, when a logical block group in a flash memory array contains When the data amount of the valid data is lower than the set threshold, it can be used as the first logical block group to be recycled. Alternatively, when the data amount of invalid data contained in a certain logical block group in the flash memory array is higher than the set threshold, it may be used as the first logical block group to be recovered. Alternatively, the logical block group with the most invalid data or the least valid data in the flash array is selected as the first logical block group to be recovered. This can improve the efficiency of system garbage collection.
第二方面提供了一种固态硬盘中垃圾回收方法,该方法应用于固态硬盘中,所述固态硬盘与系统控制器连接。所述固态硬盘从待回收的第一物理块中读取有效数据以及所述有效数据的反向映射信息,向所述系统控制器发送所述有效数据的反向映射信息,从而获得所述反向映射信息对应的源逻辑地址。然后,所述固态硬盘为所述有效数据分配目标逻辑地址,并且将有效数据复制到第二物理块。再删除所述源逻辑地址与所述有效数据保存在第一物理块中的实际地址之间的对应关系,创建所述目标逻辑地址与所述有效数据信息保存在第二物理块中的实际地址之间的对应关系。最后,所述固态硬盘擦除所述第一物理块中的数据。A second aspect provides a method for garbage collection in a solid state hard disk. The method is applied to a solid state hard disk, and the solid state hard disk is connected to a system controller. The solid state hard disk reads valid data and reverse mapping information of the valid data from the first physical block to be recycled, and sends the reverse mapping information of the valid data to the system controller, thereby obtaining the reverse data. The source logical address corresponding to the mapping information. Then, the solid state hard disk assigns a target logical address to the valid data, and copies the valid data to a second physical block. Delete the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and create the actual address where the target logical address and the valid data information are stored in the second physical block Correspondence between. Finally, the solid state hard disk erases data in the first physical block.
第二方面中的反向映射信息可以是所述有效数据的虚拟地址,也可以是所述有效数 据的指纹,还可以是所述有效数据在文件内的偏移地址,只要是能够通过正向索引找到所述有效数据的实际地址的信息都在本申请的保护范围以内。The reverse mapping information in the second aspect may be the virtual address of the valid data, or the fingerprint of the valid data, or the offset address of the valid data in the file, as long as it can pass the forward direction. Information that finds the actual address of the valid data by index is within the protection scope of this application.
数据的反向映射信息通常是和数据一起作为一个整体写入固态硬盘的,这是为了在执行固态硬盘内部的垃圾回收时方便查找该数据的逻辑地址以修改闪存翻译层中的逻辑地址与实际地址的对应关系。按照传统的方式,反向映射信息是指数据的逻辑地址。然而,在本申请中,为了保持有效数据的实际地址不变化,也需要同时保证该有效数据的反向映射信息的实际地址不变化,而当有效数据从第一逻辑块组迁移至第二逻辑块组时,其逻辑地址是会发生变化的,所以在本申请中,所述有效数据的反向映射信息不能是该数据的逻辑地址,可以是该数据的虚拟地址,或者该数据的指纹等信息。The reverse mapping information of the data is usually written into the solid-state drive with the data as a whole. This is to facilitate the search for the logical address of the data to modify the logical address in the flash translation layer and the actual data when performing garbage collection inside the solid-state drive Correspondence between addresses. Traditionally, reverse mapping information refers to the logical address of the data. However, in this application, in order to keep the actual address of the valid data unchanged, it is also necessary to ensure that the actual address of the reverse mapping information of the valid data does not change. When valid data is migrated from the first logical block group to the second logical block, When a block group, its logical address will change, so in this application, the reverse mapping information of the valid data cannot be the logical address of the data, it can be the virtual address of the data, or the fingerprint of the data, etc. information.
由此,按照本申请第二方面的实现,可以根据有效数据的反向映射信息向系统控制器查询该有效数据的逻辑地址,从而完成固态硬盘内部的垃圾回收。Therefore, according to the implementation of the second aspect of the present application, the logical address of the valid data can be queried by the system controller according to the reverse mapping information of the valid data, thereby completing the garbage collection inside the solid state disk.
本申请第三方面提供了一种系统控制器,该系统控制器包括接口和处理器。其中,接口用于和多个固态硬盘连接,处理器用于执行第一方面任意一种方法。A third aspect of the present application provides a system controller. The system controller includes an interface and a processor. The interface is used to connect to multiple solid-state hard disks, and the processor is used to execute any one of the methods in the first aspect.
本申请第四方面提供了一种系统垃圾回收装置,该装置位于闪存阵列的系统控制器中,用于执行第一方面任意一种方法。The fourth aspect of the present application provides a system garbage collection device. The device is located in a system controller of a flash memory array, and is configured to execute any one of the methods in the first aspect.
本申请第五方面提供了一种固态硬盘,该固态硬盘包括闪存控制器、第一物理块和第二物理块。所述闪存控制器用于执行第二方面的方法。A fifth aspect of the present application provides a solid state hard disk, which includes a flash memory controller, a first physical block, and a second physical block. The flash memory controller is configured to perform the method of the second aspect.
本申请第六方面提供了一种固态硬盘中的垃圾回收装置,用于执行第二方面的方法。A sixth aspect of the present application provides a garbage collection device in a solid state hard disk, for performing the method of the second aspect.
本申请第七方面提供了一种闪存阵列,该闪存阵列包括系统控制器和固态硬盘,其中,所述系统控制器用于执行第一方面任意一种方法,固态硬盘用于执行第二方面的方法。A seventh aspect of the present application provides a flash memory array including a system controller and a solid state hard disk, wherein the system controller is configured to perform any one of the methods of the first aspect and the solid state hard disk is configured to perform the method of the second aspect .
本申请第八方面提供了一种系统垃圾回收的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令用于执行第一方面所描述的方法。An eighth aspect of the present application provides a computer program product for system garbage collection, including a computer-readable storage medium storing program code, where the program code includes instructions for performing the method described in the first aspect.
本申请第九方面提供了一种固态硬盘中的垃圾回收的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令用于执行第二方面所描述的方法。A ninth aspect of the present application provides a computer program product for garbage collection in a solid state hard disk, including a computer-readable storage medium storing program code, where the program code includes instructions for performing the method described in the second aspect.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本发明实施例提供的应用场景图;FIG. 1 is an application scenario diagram provided by an embodiment of the present invention;
图2是本发明实施例提供的控制器的结构图;2 is a structural diagram of a controller according to an embodiment of the present invention;
图3是本发明实施例提供的逻辑块组的示意图;3 is a schematic diagram of a logical block group according to an embodiment of the present invention;
图4是本发明实施例提供的写数据的流程示意图;4 is a schematic flowchart of writing data according to an embodiment of the present invention;
图5是本发明实施例提供的系统垃圾回收方法的流程示意图;5 is a schematic flowchart of a system garbage collection method according to an embodiment of the present invention;
图6是本发明实施例提供的系统垃圾回收方法的示意图;6 is a schematic diagram of a system garbage collection method according to an embodiment of the present invention;
图7是本发明实施例提供的固态硬盘中的垃圾回收方法的流程示意图;7 is a schematic flowchart of a garbage collection method in a solid-state hard disk according to an embodiment of the present invention;
图8是本发明实施例提供的系统垃圾回收装置的结构示意图;8 is a schematic structural diagram of a system garbage recovery device according to an embodiment of the present invention;
图9是本发明实施例提供的固态硬盘中的垃圾回收装置的结构示意图。FIG. 9 is a schematic structural diagram of a garbage collection device in a solid state hard disk according to an embodiment of the present invention.
具体实施方式detailed description
本发明实施例提出了一种系统垃圾回收的方法以及存储系统,可以减小写放大,从 而提升固态硬盘的使用寿命。Embodiments of the present invention provide a system garbage collection method and a storage system, which can reduce write amplification and thereby increase the service life of a solid state hard disk.
图1描绘了本发明实施例提供的闪存阵列的组成图,图1所示的闪存阵列包括至少一个控制器(如图1所示的控制器11)和多个固态硬盘22(如图1中的固态硬盘22A、固态硬盘22B、固态硬盘22C、固态硬盘22G)。控制器11通过存储区域网络(英文:storage area network,SAN)与主机(图中未示出)连接。控制器11可以是一种计算设备,如服务器、台式计算机等等。在控制器11上安装有操作系统以及应用程序。控制器11可以接收来自主机的输入输出(I/O)请求。控制器11还可以存储I/O请求中携带的数据(如果有的话),并且将该数据写入固态硬盘22中。固态硬盘(英文:Solid State Disk,SSD)是以闪存(英文:flash memory)芯片为介质的存储器,又名固态驱动器(Solid State Drive,SSD)。FIG. 1 depicts a composition diagram of a flash memory array provided by an embodiment of the present invention. The flash memory array shown in FIG. 1 includes at least one controller (such as the controller 11 shown in FIG. 1) and a plurality of solid state hard disks 22 (as shown in FIG. 1). (Solid state drive 22A, solid state drive 22B, solid state drive 22C, solid state drive 22G). The controller 11 is connected to a host (not shown in the figure) through a storage area network (English: storage area network, SAN). The controller 11 may be a computing device, such as a server, a desktop computer, and the like. An operating system and application programs are installed on the controller 11. The controller 11 can receive input / output (I / O) requests from the host. The controller 11 may also store data (if any) carried in the I / O request, and write the data into the solid state hard disk 22. A solid state hard disk (English: Solid State Disk, SSD) is a memory using a flash memory (English: flash memory) chip as a medium, also known as a solid state drive (SSD).
图1仅是示例性说明,在实际应用中存储系统可包含两个或两个以上控制器,每个控制器的物理结构和功能与控制器11类似,并且本实施例并不限定控制器之间,以及任意一个控制器与固态硬盘22之间的连接方式。只要各个控制器之间,以及各个控制器和固态硬盘22之间能够相互通信。另外,在本实施例中,控制器11在向固态硬盘发指令时往往是向多个固态硬盘发送,为了方便描述,将包含多个固态硬盘22的集合称为固态硬盘组。FIG. 1 is only an exemplary illustration. In a practical application, a storage system may include two or more controllers. The physical structure and functions of each controller are similar to those of the controller 11, and this embodiment does not limit the number of controllers. And the connection between any controller and the solid state hard disk 22. As long as the controllers can communicate with each other and between the controllers and the solid state hard disk 22. In addition, in this embodiment, when the controller 11 sends an instruction to the solid-state hard disk, the controller 11 often sends it to multiple solid-state hard disks. For convenience of description, a set including multiple solid-state hard disks 22 is referred to as a solid-state hard disk group.
图2是控制器11的结构示例图,如图2所示,控制器11包括接口卡110、处理器112和接口卡113。FIG. 2 is a structural example diagram of the controller 11. As shown in FIG. 2, the controller 11 includes an interface card 110, a processor 112, and an interface card 113.
接口卡110用于和主机通信,控制器11可以通过接口卡110接收主机的操作指令。处理器112可能是一个中央处理器(英文:central processing unit,CPU)。在本发明实施例中,处理器112可以用于接收来自主机的I/O请求、处理所述I/O请求。所述I/O请求可以是写数据请求或者读数据请求,处理器112还可以将写数据请求中的数据发送给固态硬盘22。此外,处理器112还可以用于执行系统垃圾回收操作。接口卡113,用于和固态硬盘22通信,控制器11可以通过接口卡113将写数据请求(包括数据、所述数据的逻辑地址以及所述数据的虚拟地址)发送给固态硬盘22存储。The interface card 110 is used to communicate with the host, and the controller 11 may receive an operation instruction of the host through the interface card 110. The processor 112 may be a central processing unit (English: central processing unit, CPU). In the embodiment of the present invention, the processor 112 may be configured to receive an I / O request from a host and process the I / O request. The I / O request may be a write data request or a read data request, and the processor 112 may also send data in the write data request to the solid state hard disk 22. In addition, the processor 112 may also be used to perform a system garbage collection operation. The interface card 113 is configured to communicate with the solid state hard disk 22, and the controller 11 may send a write data request (including data, a logical address of the data, and a virtual address of the data) to the solid state hard disk 22 for storage through the interface card 113.
可选地,控制器11还可以包括存储器111。存储器111用于临时存储从主机接收的数据或从固态硬盘22读取的数据。控制器11接收主机发送的多个写数据请求时,可以将所述多个写数据请求中的数据暂时保存在存储器111中。当存储器111的容量达到一定阈值时,将存储器111存储的数据、所述数据的虚拟地址以及为所述数据分配的逻辑地址发送给固态硬盘22。固态硬盘22存储所述数据。存储器111包括易失性存储器,闪存芯片或其组合。易失性存储器例如为随机访问存储器(英文:random-access memory,RAM)。闪存芯片例如软盘、硬盘、固态硬盘(solid state disk,SSD)、光盘等各种可以存储程序代码的机器可读介质。存储器111具有保电功能,保电功能是指系统发生掉电又重新上电时,存储器111中存储的数据也不会丢失。Optionally, the controller 11 may further include a memory 111. The memory 111 is configured to temporarily store data received from the host or data read from the solid state hard disk 22. When the controller 11 receives multiple write data requests sent by the host, the controller 11 may temporarily store data in the multiple write data requests in the memory 111. When the capacity of the memory 111 reaches a certain threshold, the data stored in the memory 111, the virtual address of the data, and the logical address allocated for the data are sent to the solid state hard disk 22. The solid state hard disk 22 stores the data. The memory 111 includes a volatile memory, a flash memory chip, or a combination thereof. The volatile memory is, for example, a random access memory (English: random-access memory, RAM). Flash memory chips such as floppy disks, hard disks, solid state disks (SSDs), optical disks, and other machine-readable media that can store program code. The memory 111 has a power-saving function. The power-saving function means that when the system is powered off and powered on again, the data stored in the memory 111 will not be lost.
当数据写入闪存阵列之后,控制器11需要记录该数据的有效性。数据的有效性是以所述数据是否被修改来确定的。如果所述数据是第一次写入,可以将所述数据记录为有效(称为有效数据)。如果所述数据被修改,则将所述修改前的数据记录为无效(称为无效数据)。具体的,可以用位图记录数据的有效性。例如,位图的每个“位”对应大小为1KB的数据的逻辑地址,当“位”为1时,代表所述逻辑地址中存储的数据有效,当“位”为0时,代表所述逻辑地址中存储的数据无效。所述位图可以保存在存储器111 中,也可以保存在固态硬盘中。After the data is written into the flash memory array, the controller 11 needs to record the validity of the data. The validity of the data is determined by whether the data has been modified. If the data is written for the first time, the data can be recorded as valid (referred to as valid data). If the data is modified, the data before the modification is recorded as invalid (referred to as invalid data). Specifically, the validity of the data can be recorded with a bitmap. For example, each "bit" of a bitmap corresponds to a logical address of data having a size of 1KB. When "bit" is 1, it means that the data stored in the logical address is valid. When "bit" is 0, it means that the The data stored in the logical address is invalid. The bitmap may be stored in the memory 111 or in a solid state hard disk.
需要说明的是,控制器11属于系统控制器,系统控制器是独立的设备,不同于固态硬盘中的控制芯片。本实施例将固态硬盘的控制芯片称为闪存控制器。It should be noted that the controller 11 belongs to a system controller, and the system controller is an independent device, which is different from a control chip in a solid state hard disk. In this embodiment, the control chip of the solid state hard disk is referred to as a flash memory controller.
固态硬盘22包括闪存控制器和多个闪存芯片。其中,闪存控制器用于执行控制器11发送的写数据请求或者读数据请求等操作。所述闪存控制器可以是位于固态硬盘22内部的处理器,也可以是位于固态硬盘22外部的现场可编程逻辑门阵列(Field Programmable Gate Array,FPGA)。The solid state hard disk 22 includes a flash memory controller and a plurality of flash memory chips. The flash memory controller is configured to perform operations such as a write data request or a read data request sent by the controller 11. The flash memory controller may be a processor located inside the solid state hard disk 22, or a field programmable logic gate array (Field Programmable Gate Array, FPGA) located outside the solid state hard disk 22.
闪存控制器中包含闪存翻译层(英文:flash translation layer,FTL)。闪存翻译层用于保存有数据的逻辑地址与实际地址之间的对应关系。因此,闪存翻译层用于将系统控制器发送的写数据请求或者读数据请求中的逻辑地址转化为固态硬盘中数据的实际地址。数据的逻辑地址是由系统控制器分配的,固态硬盘提供给系统控制器的逻辑地址区间的子集。数据的逻辑地址包括起始逻辑地址和长度,起始逻辑地址指示所述数据位于的逻辑块组的位置,长度代表所述数据的大小。数据的实际地址可以是固态硬盘中该数据的物理地址,也可以是在所述物理地址的基础上经过虚拟化,只对闪存控制器可见的地址。该经过虚拟化的实际地址对系统控制器不可见。通常情况下,物理地址包括数据所位于的物理块的编号以及页的编号。The flash memory controller includes a flash translation layer (English: flash translation layer, FTL). The flash translation layer is used to store the correspondence between the logical address and the actual address of the data. Therefore, the flash translation layer is used to convert the logical address in the write data request or read data request sent by the system controller to the actual address of the data in the solid state disk. The logical address of the data is allocated by the system controller, and the solid state disk provides a subset of the logical address range of the system controller. The logical address of the data includes a start logical address and a length. The start logical address indicates the position of the logical block group where the data is located, and the length represents the size of the data. The actual address of the data may be a physical address of the data in the solid state disk, or an address that is virtualized based on the physical address and is only visible to the flash memory controller. This virtualized actual address is not visible to the system controller. Generally, the physical address includes the number of the physical block where the data is located and the number of the page.
固态硬盘通常包括一个或多个闪存芯片。每个闪存芯片包括若干个物理块(可以简称“块”)。固态硬盘在读取或写入时是以一个页(英文:page)为基础的,但擦除操作只能以一个物理块为基础,擦除操作是指将这个块的所有位都设置为“1”。在擦除之前,闪存控制器需要先将这个物理块中的有效数据复制到另一个块的空白页中去。Solid-state drives usually include one or more flash memory chips. Each flash memory chip includes several physical blocks (may be referred to as "blocks"). A solid state drive is based on a page (English: page) when reading or writing, but the erase operation can only be based on a physical block. An erase operation refers to setting all bits of this block to " 1". Before erasing, the flash controller needs to copy the valid data in this physical block to a blank page in another block.
每个物理块包含多个页(英文:page)。固态硬盘在执行写数据请求时,是以页为单位来写数据的。举例来说,控制器11向闪存控制器发送一个写数据请求。所述写数据请求包括数据的逻辑地址。闪存控制器在接收所述写数据请求之后,按照接收的时间顺序将所述数据连续写入一个或多个物理块中。连续写入一个或多个物理块是指,闪存控制器查找一个空白的物理块,将数据写入所述空白的物理块,直至将所述空白的物理块填满,当所述数据的大小超过物理块的容量时,闪存控制器再查找下一个空白的物理块,继续写入。闪存翻译层建立并保存所述逻辑地址与写入所述数据的页的实际地址之间的对应关系。当控制器11向闪存控制器发送读数据请求,要求读取所述数据时,所述读数据请求中包括所述逻辑地址。闪存控制器根据所述逻辑地址、以及所述逻辑地址与实际地址之间的对应关系读取所述数据,并将该数据发送给控制器11。Each physical block contains multiple pages. When a solid-state drive performs a data write request, it writes data in units of pages. For example, the controller 11 sends a write data request to the flash memory controller. The write data request includes a logical address of the data. After receiving the write data request, the flash memory controller continuously writes the data into one or more physical blocks according to the received time sequence. Writing one or more physical blocks continuously means that the flash memory controller searches for a blank physical block and writes data into the blank physical block until the blank physical block is filled. When the capacity of the physical block is exceeded, the flash controller looks for the next blank physical block and continues writing. The flash translation layer establishes and saves the correspondence between the logical address and the actual address of the page where the data is written. When the controller 11 sends a read data request to the flash memory controller to read the data, the read data request includes the logical address. The flash memory controller reads the data according to the logical address and the correspondence between the logical address and the actual address, and sends the data to the controller 11.
在闪存阵列中,单个固态硬盘都有可能发生故障,从而导致数据丢失。本实施例采用廉价磁盘冗余阵列(Redundant Array of Inexpensive Disks,RAID)技术保障数据的可能性。下面介绍一下在对固态硬盘中的数据进行冗余保护的机制。In a flash memory array, a single solid state drive can fail, resulting in data loss. In this embodiment, redundant data array (Redundant Array of Inexpensive Disks, RAID) technology is adopted to guarantee the possibility of data. The following introduces the mechanism for redundant protection of data in solid state drives.
首先,控制器11以逻辑块(英文:chunk,简称:CK)的形式对固态硬盘进行空间管理。逻辑块是一个空间概念,其大小以4MB为例,但不限定为4MB。来自不同固态硬盘的逻辑块可以构成一个逻辑块集合,控制器11再根据设定的RAID类型将这个逻辑块集合中的逻辑块划分为数据逻辑块组和校验逻辑块组。数据逻辑块组中包括至少两个逻辑块,用于存储数据,校验逻辑块组中包括至少一个校验逻辑块,用于存储所述数据的校验数据。本实施例中,将包含数据逻辑块组和校验逻辑块组的逻辑块集合称为逻辑块组。当控制器11在存储器111中凑满一定大小的数据时,可以根据所述设定的RAID类型切 分为多个数据单元,并计算获得校验单元,将所述数据单元以及校验单元发送给固态硬盘,以保存在所述逻辑块组中。数据组中的每个逻辑块用于存储数据单元,校验组中的每个逻辑块用于存储校验单元。存储之后,这些数据单元和对应的校验单元就构成一个分条。逻辑块组包括多个分条。First, the controller 11 performs space management on the solid state hard disk in the form of a logical block (English: chunk, CK for short). A logical block is a space concept. Its size is 4MB as an example, but it is not limited to 4MB. The logical blocks from different solid state hard disks can form a logical block set. The controller 11 then divides the logical blocks in the logical block set into a data logical block group and a check logical block group according to the set RAID type. The data logical block group includes at least two logical blocks for storing data, and the check logical block group includes at least one check logical block for storing check data of the data. In this embodiment, a logical block set including a data logical block group and a check logical block group is referred to as a logical block group. When the controller 11 fills up a certain size of data in the memory 111, it can be divided into a plurality of data units according to the set RAID type, and a check unit is calculated to obtain the data unit and the check unit. Give a solid state drive to save in the logical block group. Each logical block in the data group is used to store data units, and each logical block in the check group is used to store check units. After storage, these data units and corresponding check units constitute a stripe. A logical block group includes multiple stripes.
分条所包含的数据单元和校验单元都可以称作分条单元。本实施例中,以分条单元的大小为8KB为例,但不限定为8KB。如图3所示,假设从5个固态硬盘中各取出一个逻辑块构成逻辑块集合,然后控制器11根据RAID类型(以RAID6为例)对该逻辑块集合中的逻辑块进行分组,例如逻辑块1、逻辑块2和逻辑块3为数据逻辑块组,逻辑块4和逻辑块5为校验逻辑块组。当存储器111中存储的数据达到24KB(8KB*3)时,将所述数据划分为3个数据单元,每个数据单元为8KB,然后计算获得2个校验单元,每个校验单元也为8KB。控制器11将这些数据单元和校验单元发送给固态硬盘,存储在所述逻辑块组中(如图3中阴影部分所示)。可以理解的是,按照RAID6的冗余保护机制,任意两个数据单元或者校验单元失效时,可以根据剩下的数据单元或者校验单元重构出失效的单元。The data unit and check unit included in the stripe can be called the stripe unit. In this embodiment, the size of the stripe unit is 8 KB as an example, but it is not limited to 8 KB. As shown in FIG. 3, it is assumed that one logical block is taken out of each of the five solid-state hard disks to form a logical block set, and then the controller 11 groups logical blocks in the logical block set according to a RAID type (taking RAID 6 as an example), such as logical Block 1, logical block 2, and logical block 3 are data logical block groups, and logical block 4 and logical block 5 are check logical block groups. When the data stored in the memory 111 reaches 24KB (8KB * 3), the data is divided into 3 data units, each data unit is 8KB, and then 2 check units are calculated and each check unit is also 8KB. The controller 11 sends these data units and check units to the solid state hard disk and stores them in the logical block group (shown as a shaded part in FIG. 3). It can be understood that according to the redundancy protection mechanism of RAID 6, when any two data units or check units fail, the failed units can be reconstructed according to the remaining data units or check units.
下面结合图4描述本发明实施例提供的写数据方法,该方法可以应用在图1所示的闪存阵列中,并可以由图2所示的控制器11中的处理器112执行或固态硬盘22执行。如图4所示,该方法包含如下步骤:The following describes the data writing method provided by the embodiment of the present invention with reference to FIG. 4. This method can be applied to the flash memory array shown in FIG. 1 and can be executed by the processor 112 in the controller 11 shown in FIG. 2 or the solid state hard disk 22. carried out. As shown in Figure 4, the method includes the following steps:
401:控制器11接收主机发送的写数据请求,所述写数据请求包括待写入数据和所述待写入数据的虚拟地址。控制器11将其存储空间以逻辑单元(Logical Unit,LU)的形式提供给主机,主机与一个或多个逻辑单元之间具有绑定关系。当用户通过主机向控制器11发送待写入数据时,通常需要指定存储该数据的虚拟地址。具体的,所述虚拟地址是逻辑单元的标识以及所述数据位于所述逻辑单元的偏移地址。401: The controller 11 receives a write data request sent by the host, where the write data request includes data to be written and a virtual address of the data to be written. The controller 11 provides its storage space to the host in the form of a logical unit (LU), and the host has a binding relationship with one or more logical units. When a user sends data to be written to the controller 11 through the host, it is usually necessary to specify a virtual address where the data is stored. Specifically, the virtual address is an identifier of a logical unit and an offset address where the data is located in the logical unit.
402:控制器11将所述待写入数据写入存储器111中。402: The controller 11 writes the data to be written into the memory 111.
403:当存储器111中的数据凑满一个分条大小时,控制器11确定目标分条用于接收这些数据。分条是图3所示的逻辑块组的子集,所述目标分条的逻辑地址是它所在的逻辑块组的逻辑地址的子集。这里所指的分条大小实际上是指分条中所有数据单元的大小。然后,控制器11计算这些数据的校验数据。所述数据和所述校验数据共同组成了一个分条。403: When the data in the memory 111 fills up a stripe size, the controller 11 determines that the target stripe is used to receive the data. The stripe is a subset of the logical block group shown in FIG. 3, and the logical address of the target stripe is a subset of the logical address of the logical block group in which it is located. The stripe size referred to here actually refers to the size of all data units in the stripe. Then, the controller 11 calculates check data of these data. The data and the verification data together form a stripe.
404:控制器11为所述目标分条分配逻辑地址。应理解,这里的逻辑地址不同于401中的虚拟地址,所述虚拟地址是对控制器11和主机可见,但对固态硬盘22不可见的地址,而404中的逻辑地址是对控制器11和固态硬盘22可见,但对主机不可见的地址。404: The controller 11 assigns a logical address to the target stripe. It should be understood that the logical address here is different from the virtual address in 401, the virtual address is an address that is visible to the controller 11 and the host, but not visible to the solid state hard disk 22, and the logical address in 404 is to the controller 11 and Addresses where the solid state drive 22 is visible but not visible to the host.
控制器11需判断是否存在一个已经分配的逻辑块组,如果存在已分配的逻辑块组并且该逻辑块组仍然有足够的空间容纳该数据,那么控制器11可以指令所述多个固态硬盘将该数据写入已经分配的逻辑块组中。具体的,控制器11从所述已经分配的逻辑块组的逻辑地址区间中获取一段未使用的逻辑地址,在405中将所述逻辑地址携带在所述写数据请求中发送给固态硬盘22。控制器11确定系统中并不存在已经分配的逻辑块组,或者已分配的逻辑块组均已写满数据,那么控制器11就需要创建一个新的逻辑块组。其创建过程可以是,控制器11根据自己对每个固态硬盘所拥有的可用空间的记录,确定系统剩余空间足以创建一个新的逻辑块组。接下来,控制器11分别从不同的固态硬盘22中获 取一个逻辑块,将根据设定的RAID类型将这些逻辑块构建成一个新的逻辑块组(可参考图3关于逻辑块组的描述)。然后,控制器11为每个逻辑块分配一段逻辑地址,这些逻辑地址集合就是所述新的逻辑块组的逻辑地址。在所述新的逻辑块组的逻辑地址中,控制器11可获取其中一段作为所述目标分条的逻辑地址。The controller 11 needs to determine whether there is an already allocated logical block group. If there is an allocated logical block group and the logical block group still has enough space to accommodate the data, the controller 11 may instruct the multiple solid state hard disks to This data is written into the allocated logical block group. Specifically, the controller 11 obtains an unused logical address from the logical address range of the allocated logical block group, and carries the logical address in the write data request to the solid state hard disk 22 in 405. The controller 11 determines that there are no logical block groups allocated in the system, or that the allocated logical block groups are filled with data, then the controller 11 needs to create a new logical block group. The creation process may be that the controller 11 determines that the remaining space of the system is sufficient to create a new logical block group according to its own record of the available space owned by each solid state hard disk. Next, the controller 11 obtains a logical block from different solid-state hard disks 22 respectively, and will construct these logical blocks into a new logical block group according to the set RAID type (refer to the description of the logical block group in FIG. 3) . Then, the controller 11 allocates a segment of logical addresses to each logical block, and these logical address sets are the logical addresses of the new logical block group. Among the logical addresses of the new logical block group, the controller 11 may obtain one of them as the logical address of the target stripe.
405:控制器11分别向多个固态硬盘22发送写数据指令。由于所述目标分条中的数据应分布在多个固态硬盘中,因此,需要向所述多个固态硬盘中的每个固态硬盘22发送写数据指令。接收所述写数据指令的固态硬盘22的数量视RAID类型而定,以RAID类型为3+2(3个数据单元和2个校验单元)为例,那么所述目标分条中的数据将分布在5个固态硬盘中,因此,控制器11需要生成5个写数据指令,每个写数据指令发送给所述5个固态硬盘的其中一个硬盘。其中每个写数据指令携带所述部分数据或者部分校验数据,以及所述部分数据或部分校验数据的逻辑地址,以及所述部分数据或部分校验数据的虚拟地址。应理解,每个写数据指令中的逻辑地址均是控制器11为所述目标分条分配的逻辑地址的子集,每个写数据指令中的虚拟地址来自主机发送的写数据请求。405: The controller 11 sends a write data instruction to the multiple solid state hard disks 22, respectively. Since the data in the target stripe should be distributed among multiple solid-state hard disks, it is necessary to send a write data instruction to each solid-state hard disk 22 in the multiple solid-state hard disks. The number of solid-state hard disks 22 receiving the write data instruction depends on the RAID type. Taking the RAID type as 3 + 2 (3 data units and 2 parity units) as an example, the data in the target stripe will be Distributed in five solid state hard disks, the controller 11 needs to generate five write data instructions, and each write data instruction is sent to one of the five solid state hard disks. Each of the write data instructions carries the part of data or part of the check data, a logical address of the part of data or the part of check data, and a virtual address of the part of the data or part of the check data. It should be understood that the logical address in each write data instruction is a subset of the logical address allocated by the controller 11 for the target stripe, and the virtual address in each write data instruction is from a write data request sent by the host.
406:对于每个接收到所述写数据指令的固态硬盘22来说,所述固态硬盘22将所述写数据指令中的数据和该数据的虚拟地址写入一个物理块中。可选的,所述写数据指令可以是一个定制命令以保证所述数据和所述虚拟地址被写入同一个物理块中。所述数据位于所述块的地址称为实际地址(包括所述数据所位于的物理块的编号以及页的编号),在写入之后,固态硬盘22在闪存翻译层中保存所述数据的逻辑地址与所述实际地址之间的对应关系。406: For each solid state hard disk 22 that receives the write data instruction, the solid state hard disk 22 writes data in the write data instruction and a virtual address of the data into a physical block. Optionally, the write data instruction may be a custom command to ensure that the data and the virtual address are written into the same physical block. The address where the data is located in the block is called the actual address (including the number of the physical block and the page number where the data is located). After writing, the solid-state hard disk 22 stores the logic of the data in the flash translation layer. Correspondence between the address and the actual address.
所述和数据一同写入物理块中的虚拟地址也被称为反向映射信息,它可以使得固态硬盘22在执行盘内垃圾回收时可以根据该数据的虚拟地址获取该数据的逻辑地址,并且从闪存翻译层中找到该数据的逻辑地址,将其修改为新的逻辑地址。The virtual address written in the physical block with the data is also called reverse mapping information, which can enable the solid state hard disk 22 to obtain the logical address of the data according to the virtual address of the data when performing in-disk garbage collection, and Find the logical address of the data from the flash translation layer and modify it to the new logical address.
407:在固态硬盘22将所述数据成功写入块之后,控制器11创建所述数据的虚拟地址与所述逻辑地址之间的对应关系。后续,如果主机发送读数据请求,要求读取所述虚拟地址中的数据,控制器11可以根据所述虚拟地址与所述逻辑地址之间的对应关系,从固态硬盘22中读取所述数据。407: After the solid-state hard disk 22 successfully writes the data into the block, the controller 11 creates a correspondence between the virtual address of the data and the logical address. Subsequently, if the host sends a data read request to read the data in the virtual address, the controller 11 may read the data from the solid state hard disk 22 according to the correspondence between the virtual address and the logical address. .
在现有技术中,和数据一起写入物理块的反向映射信息是所述数据的逻辑地址。由于数据的逻辑地址描述的是该数据位于逻辑块组中的位置,因此当数据从一个逻辑块组迁移至另一个逻辑块组时,其逻辑地址会发生变化。那么,这也意味着,包含数据和数据的逻辑地址的数据信息会发生变化。在本实施例中,为了在系统垃圾回收的过程中只改变数据信息所归属的逻辑块组,而并不实际移动数据,系统控制器在写数据时将数据和该数据的虚拟地址,而不是逻辑地址,一起写入物理块中。这是因为在此过程中数据的虚拟地址并不会发生改变。In the prior art, the reverse mapping information written into the physical block with the data is the logical address of the data. Because the logical address of the data describes where the data is located in the logical block group, when the data is migrated from one logical block group to another logical block group, its logical address will change. Then, it also means that the data information including the data and the logical address of the data will change. In this embodiment, in order to change only the logical block group to which the data information belongs during the garbage collection process of the system, instead of actually moving the data, the system controller writes the data and the virtual address of the data instead of actually moving the data. Logical addresses are written into physical blocks together. This is because the virtual address of the data does not change during this process.
在图4所示的实施方式中,所述反向映射信息是指数据的虚拟地址,因为当数据在逻辑块组之间迁移时,该数据的虚拟地址并不会发生变化。可选的,在另一种实施方式中,所述反向映射信息是指数据的指纹,所谓指纹是指对数据进行哈希运算获得的结果。或者,所述反向映射信息是数据在文件内的偏移地址。可选的,在关键字-数值(key-value,KV)接口的闪存阵列中,主机给控制器11发送的写数据请求中包含待写入数据的关键字,而不是虚拟地址,所述关键字是通过所述虚拟地址计算获得的。在这种情况下,所述反向映射信息是指所述待写入数据的关键字,相应的,在407中控制器 11创建的是所述数据信息的关键字与所述逻辑地址的对应关系。可选的,在日志(log)接口的闪存阵列中,主机给控制器11发送的写数据请求中包含待写入数据的日志地址,而不是虚拟地址,此时,所述反向映射信息是指所述待写入数据的日志地址,相应的,在407中控制器11创建的是所述数据信息的日志地址与所述逻辑地址的对应关系。总体而言,本发明实施例中的反向映射信息是指任何可以通过正向索引找到数据的实际地址的信息,并不局限于以上列举的各种情况,当数据在逻辑块组之间迁移时,该信息并不会发生变化。在后面的描述中,本实施例仍然以虚拟地址作为示例。如果所述反向映射信息是指其他通过正向索引找到所述数据的实际地址的信息,其操作方式类似。In the embodiment shown in FIG. 4, the reverse mapping information refers to a virtual address of data, because when data is migrated between logical block groups, the virtual address of the data does not change. Optionally, in another implementation manner, the reverse mapping information refers to a fingerprint of data, and the so-called fingerprint refers to a result obtained by performing a hash operation on the data. Alternatively, the reverse mapping information is an offset address of data in a file. Optionally, in a flash array of a key-value (KV) interface, the write data request sent by the host to the controller 11 includes a keyword of data to be written instead of a virtual address. The word is obtained by the virtual address calculation. In this case, the reverse mapping information refers to a keyword of the data to be written. Correspondingly, in 407, the controller 11 creates a correspondence between the keyword of the data information and the logical address. relationship. Optionally, in the flash array of the log interface, the write data request sent by the host to the controller 11 includes the log address of the data to be written instead of the virtual address. At this time, the reverse mapping information is Refers to the log address of the data to be written. Correspondingly, in 407, the controller 11 creates a correspondence between the log address of the data information and the logical address. In general, the reverse mapping information in the embodiments of the present invention refers to any information that can find the actual address of the data through the forward index, and is not limited to the various cases listed above. When the data migrates between logical block groups This information does not change from time to time. In the following description, this embodiment still takes a virtual address as an example. If the reverse mapping information refers to other information that finds the actual address of the data through a forward index, the operation mode is similar.
为了保证闪存阵列中始终有足够的可用空间用于创建逻辑块组,控制器11可以实时地或者定期地对每个固态硬盘22的可用空间进行监控,从而获知整个系统的可用空间。当系统的可用空间低于设定的空间阈值时,启动系统垃圾回收。例如,一个固态硬盘22的容量是128G,图1所示的闪存阵列所包含的所有固态硬盘(假设该闪存阵列包含10个固态硬盘)的总容量是1280G,所述空间阈值可以设置为640G。也就是说,当该闪存阵列存储的数据达到所述总容量的一半时,剩余的可用空间也达到了所述空间阈值,此时控制器11可以执行系统垃圾回收。可以理解的是,640G只是空间阈值的一个示例,所述空间阈值也可以设置为其他数值。另外,当系统的已使用空间达到设定的空间阈值时,也可以触发系统垃圾回收。系统垃圾回收有别于固态硬盘内部的垃圾回收。固态硬盘内部的垃圾回收是由固态硬盘自己完成的。In order to ensure that there is always enough free space in the flash memory array to create a logical block group, the controller 11 can monitor the available space of each solid state hard disk 22 in real time or periodically, so as to know the available space of the entire system. When the free space of the system is lower than the set space threshold, the system garbage collection is started. For example, the capacity of a solid state hard disk 22 is 128G, and the total capacity of all solid state drives (assuming that the flash memory array includes 10 solid state drives) included in the flash memory array shown in FIG. 1 is 1280G, and the space threshold can be set to 640G. That is, when the data stored in the flash memory array reaches half of the total capacity, the remaining available space also reaches the space threshold, and the controller 11 may perform system garbage collection at this time. It can be understood that 640G is only an example of a spatial threshold, and the spatial threshold may also be set to another value. In addition, when the used space of the system reaches the set space threshold, the system garbage collection can also be triggered. System garbage collection is different from garbage collection inside a solid state drive. Garbage collection inside a solid state drive is done by the solid state drive itself.
通常情况下,控制器11以逻辑块组为单位执行系统垃圾回收。举例来说,控制器11根据位图获取一个逻辑块组中有效数据的逻辑地址,将所述有效数据的逻辑地址发送给固态硬盘组,使得各个固态硬盘22可以根据所述有效数据的逻辑地址读取数据并发送给控制器11。控制器11为所述有效数据分配新的逻辑地址,该新的逻辑地址属于新的逻辑块组,并将该分配的新的逻辑地址发送给固态硬盘组,各个固态硬盘22将所述有效数据写入新的物理块之后,再保存实际地址与所述新的逻辑地址之间的映射关系。然后,控制器11再给固态硬盘组发送去映射(英文:unmap)命令或者trim命令,所述去映射命令包括所述待回收的逻辑块组的逻辑地址区间,各个固态硬盘22接收所述去映射命令之后,删除闪存翻译层中保存的所述逻辑地址区间的逻辑地址与实际地址之间的对应关系。固态硬盘22还可以将所述搬移前的有效数据的实际地址对应的块标记为不包含有效数据的块或者直接将不包含有效数据的块擦除掉。随后,控制器11可以释放所述待回收的逻辑块组的逻辑地址区间以及所述逻辑块组占用的实际物理空间(也可以理解为实际地址)。In general, the controller 11 performs system garbage collection in units of logical block groups. For example, the controller 11 obtains the logical address of valid data in a logical block group according to the bitmap, and sends the logical address of the valid data to the solid-state hard disk group, so that each solid-state hard disk 22 can according to the logical address of the valid data The data is read and sent to the controller 11. The controller 11 assigns a new logical address to the valid data, the new logical address belongs to a new logical block group, and sends the allocated new logical address to the solid state disk group, and each solid state disk 22 sends the valid data After writing a new physical block, the mapping relationship between the actual address and the new logical address is saved. Then, the controller 11 sends an unmap command or a trim command to the solid-state hard disk group, where the de-mapping command includes a logical address range of the logical block group to be recycled, and each solid-state hard disk 22 receives the de-mapping. After the mapping command, the correspondence between the logical address and the actual address of the logical address section stored in the flash translation layer is deleted. The solid state hard disk 22 may also mark the block corresponding to the actual address of the valid data before the transfer as a block that does not contain valid data or directly erase the block that does not contain valid data. Subsequently, the controller 11 may release a logical address range of the logical block group to be recovered and an actual physical space (which may also be understood as an actual address) occupied by the logical block group.
可见,系统垃圾回收会导致数据在物理块之间进行搬移,从而增加写放大。本发明实施例提供一种系统垃圾回收方法,可以在系统垃圾回收的过程中完成有效数据在逻辑块组之间的迁移,却不实际移动数据,从而减小写放大。It can be seen that system garbage collection will cause data to be moved between physical blocks, thereby increasing write amplification. An embodiment of the present invention provides a system garbage collection method, which can complete the migration of valid data between logical block groups during the system garbage collection process without actually moving the data, thereby reducing write amplification.
下面结合图5和图6描述本发明实施例提供的系统垃圾回收方法,该方法可以应用在图1所示的闪存阵列中,并可以由图2所示的控制器11中的处理器112执行。其中,图5是本实施例提供的系统垃圾回收方法的流程示意图,图6是在两个逻辑块组之间实现数据迁移的示意图。如图5所示,该方法包含如下步骤:The following describes the system garbage collection method provided by the embodiment of the present invention with reference to FIGS. 5 and 6. The method can be applied to the flash memory array shown in FIG. 1 and can be executed by the processor 112 in the controller 11 shown in FIG. 2. . FIG. 5 is a schematic flowchart of a system garbage collection method provided in this embodiment, and FIG. 6 is a schematic diagram of implementing data migration between two logical block groups. As shown in Figure 5, the method includes the following steps:
501:当存储系统中的空闲空间不足时,控制器11从多个逻辑块组中选择至少一个逻辑块组作为垃圾回收的对象。所述选择出的逻辑块组需要满足一定条件,例如该逻辑 块组包含的无效数据到达第一设定阈值,或者该逻辑块组是所述多个逻辑块组中包含无效数据最多的逻辑块组,或者该逻辑块组包含的有效数据低于第二设定阈值,或者该逻辑块组是所述多个逻辑块组中包含有效数据最少的逻辑块组。无效数据或者有效数据的数据量可以根据前面描述的位图来统计。该为了方便描述,本实施例将所述选择出的进行垃圾回收的逻辑块组称为第一逻辑块组。501: When the free space in the storage system is insufficient, the controller 11 selects at least one logical block group from a plurality of logical block groups as an object of garbage collection. The selected logical block group needs to satisfy a certain condition, for example, the invalid data contained in the logical block group reaches a first set threshold, or the logical block group is the logical block containing the most invalid data among the multiple logical block groups Group, or the logical block group contains valid data lower than a second set threshold, or the logical block group is the logical block group containing the least effective data among the plurality of logical block groups. The amount of invalid data or valid data can be counted according to the bitmap described previously. For convenience of description, in this embodiment, the selected logical block group for garbage collection is referred to as a first logical block group.
根据图3和图6对逻辑块组的描述可知,第一逻辑块组包括第一数据逻辑块组和第一校验逻辑块组,第一数据逻辑块组包括至少两个数据逻辑块,用于存储数据。第一校验逻辑块组包括至少一个逻辑块,用于存储校验数据。所述第一数据逻辑块组包含的每个数据逻辑块以第一校验逻辑块组包含的校验逻辑块均来自不同的固态硬盘。According to the description of the logical block group in FIG. 3 and FIG. 6, it can be known that the first logical block group includes a first data logical block group and a first check logical block group. The first data logical block group includes at least two data logical blocks. For storing data. The first check logic block group includes at least one logic block for storing check data. Each data logical block included in the first data logical block group and a check logical block included in the first check logical block group are all from different solid state drives.
所述第一逻辑块组中包含有效数据以及无效数据,通常情况下,在系统垃圾回收的过程中,需要将第一逻辑块组中的有效数据迁移至新的逻辑块组,再释放所述第一逻辑块组。在本实施例中,所述第一逻辑块组中的有效数据所位于所述第一逻辑块组中的位置为第一逻辑地址。所述第一逻辑地址与所述有效数据保存在固态硬盘中的实际地址之间具有对应关系。The first logical block group contains valid data and invalid data. Generally, during the system garbage collection process, valid data in the first logical block group needs to be migrated to a new logical block group, and then the data is released. The first logical block group. In this embodiment, the position where valid data in the first logical block group is located in the first logical block group is a first logical address. There is a corresponding relationship between the first logical address and the actual address where the valid data is stored in the solid state hard disk.
502:控制器11根据所述第一数据逻辑块组在所述多个固态硬盘中的分布情况,创建第二逻辑块组。第二逻辑块组是接收第一逻辑块组中的有效数据的逻辑块组。所述创建的第二逻辑块组的RAID类型和第一逻辑块组的RAID类型相同,因此,第二逻辑块组包括第二数据逻辑块组和第二校验逻辑块组,其中,第二数据逻辑块组所包含的数据逻辑块的数量与第一数据逻辑块组所包含的数据逻辑块的数量相同,第二校验逻辑块组所包含的校验逻辑块的数量与第一校验逻辑块组所包含的校验逻辑块的数量相同。并且,第二数据逻辑块组在所述多个固态硬盘中的分布情况与第一数据逻辑块组在所述多个固态硬盘中的分布情况相同。例如,第一数据逻辑块组所包含的逻辑块1、逻辑块2和逻辑块3分别位于固态硬盘22A、固态硬盘22B和固态硬盘22C中。根据逻辑块1、逻辑块2和逻辑块3在这些固态硬盘中的分布,控制器11从固态硬盘22A、固态硬盘22B和固态硬盘22C中分别获取一个数据逻辑块,创建第二逻辑块组。也就是说,所述第二逻辑块组中的逻辑块1’、逻辑块2’和逻辑块3’也分别位于固态硬盘22A、固态硬盘22B和固态硬盘22C中。如图6所示,第一逻辑块组所包含的逻辑块1分布在固态硬盘22A中,为了创建第二逻辑块组,控制器11从固态硬盘22A中获取逻辑块1’。同理,对于第一逻辑块组包含的数据逻辑块2和数据逻辑块3,控制器11也根据他们在固态硬盘中的分布从相应的固态硬盘中获取数据逻辑块2’和数据逻辑块3’。502: The controller 11 creates a second logical block group according to the distribution of the first data logical block group among the multiple solid-state hard disks. The second logical block group is a logical block group that receives valid data in the first logical block group. The RAID type of the created second logical block group is the same as the RAID type of the first logical block group. Therefore, the second logical block group includes a second data logical block group and a second check logical block group, where the second The number of data logical blocks included in the data logical block group is the same as the number of data logical blocks included in the first data logical block group, and the number of check logical blocks included in the second check logical block group is the same as the first check The logical block group contains the same number of check logical blocks. In addition, the distribution of the second data logical block group in the plurality of solid state hard disks is the same as the distribution of the first data logical block group in the plurality of solid state hard disks. For example, the logical block 1, logical block 2, and logical block 3 included in the first data logical block group are respectively located in the solid state hard disk 22A, the solid state hard disk 22B, and the solid state hard disk 22C. According to the distribution of logical block 1, logical block 2, and logical block 3 among these solid-state hard disks, the controller 11 obtains one data logical block from the solid-state hard disk 22A, the solid-state hard disk 22B, and the solid-state hard disk 22C, respectively, and creates a second logical block group. That is, the logical block 1 ', the logical block 2', and the logical block 3 'in the second logical block group are also located in the solid state hard disk 22A, the solid state hard disk 22B, and the solid state hard disk 22C, respectively. As shown in FIG. 6, the logical block 1 included in the first logical block group is distributed in the solid state hard disk 22A. In order to create the second logical block group, the controller 11 obtains the logical block 1 'from the solid state hard disk 22A. Similarly, for data logic block 2 and data logic block 3 included in the first logic block group, the controller 11 also obtains data logic block 2 'and data logic block 3 from the corresponding solid state hard disks according to their distribution in the solid state hard disk. '.
然而,本实施例并不要求控制器11根据第一校验块组在所述多个固态硬盘中的分布情况创建第二校验逻辑块组。事实上,控制器11可以在所述多个固态硬盘中自由选择提供校验逻辑块的固态硬盘,只要不和提供数据逻辑块的固态硬盘重复即可。这是因为,通常情况下,第二校验逻辑块中存储的校验数据需要重新计算获得,而非直接从第一校验逻辑块中迁移获得。However, this embodiment does not require the controller 11 to create a second verification logic block group according to the distribution of the first verification block group among the plurality of solid state hard disks. In fact, the controller 11 can freely select a solid state hard disk that provides a verification logic block among the plurality of solid state hard disks, as long as it does not duplicate the solid state hard disk that provides a data logic block. This is because, generally, the verification data stored in the second verification logic block needs to be recalculated and obtained instead of being directly migrated from the first verification logic block.
在502中,第二逻辑块组所包含的每个数据逻辑块都分布在第一逻辑块组所包含的其中一个数据逻辑块所在的固态硬盘中。然而,在另一种实施方式中,只要保证所述第二逻辑块组中至少有一个数据逻辑块分布在第一逻辑块组中的存储有有效数据的数据逻辑块所在的固态硬盘中即可,也可以在一定程度上减小写放大。并且,可以理解的是,第一数据逻辑块组所包含的数据逻辑块存储的数据可能是有效数据,也可能是无效数据。 也就是说,在所述多个数据逻辑块中,可能只有部分数据逻辑块(甚至只有一个数据逻辑块)存储有效数据。那么在创建第二逻辑块组时,只需要保证所述第二逻辑块组中有部分数据逻辑块或者一个数据逻辑块分布在所述第一数据逻辑块组中存储有有效数据的数据逻辑块所在的固态硬盘,就可以执行第一逻辑块组的垃圾回收了。In 502, each data logical block included in the second logical block group is distributed in a solid state hard disk where one of the data logical blocks included in the first logical block group is located. However, in another implementation manner, it is only necessary to ensure that at least one data logical block in the second logical block group is distributed in a solid state hard disk in which the data logical block storing valid data is located in the first logical block group. , Can also reduce write amplification to a certain extent. In addition, it can be understood that the data stored in the data logical block included in the first data logical block group may be valid data or invalid data. That is, among the plurality of data logical blocks, only a part of the data logical blocks (or even only one data logical block) may store valid data. Then when creating the second logical block group, it is only necessary to ensure that there are some data logical blocks in the second logical block group or one data logical block is distributed among the data logical blocks in the first data logical block group that stores valid data. The solid state hard disk where it is located can perform garbage collection of the first logical block group.
503:控制器11为所述第一逻辑块组中的有效数据分配第二逻辑地址。例如,有效数据可以参考图6所示的逻辑块1中的阴影小方块,需要说明的是,图6所示的阴影小方块只是所述第一逻辑块组中有效数据的一部分,所述有效数据可能还分布在数据逻辑块2和数据逻辑块3中。所述分配的第二逻辑地址是所述第二逻辑块组的逻辑地址的子集。502中创建的第二逻辑块组可以不仅仅用于存储一个逻辑块组中的有效数据,还可以用于存储多个逻辑块组中的有效数据。503: The controller 11 allocates a second logical address to valid data in the first logical block group. For example, the valid data can refer to the small shaded block in logic block 1 shown in FIG. 6. It should be noted that the small shaded block shown in FIG. 6 is only a part of the valid data in the first logical block group. Data may also be distributed in data logic block 2 and data logic block 3. The allocated second logical address is a subset of the logical addresses of the second logical block group. The second logical block group created in 502 may not only be used to store valid data in one logical block group, but may also be used to store valid data in multiple logical block groups.
504:控制器11将存储器111中保存的所述有效数据的第一逻辑地址修改为第二逻辑地址。在传统的系统垃圾回收中,控制器11需要将有效数据从第一逻辑块组读出,并重新写入第二逻辑块组。这意味着,所述有效数据将在固态硬盘的物理块之间发生移动,相应地,所述有效数据的逻辑地址和实际地址都会发生改变。而在本实施例中,将所述有效数据从第一逻辑块组迁移至第二逻辑块组,只需要修改所述有效数据的逻辑地址(将归属于第一逻辑块组的第一逻辑地址修改为归属于第二逻辑块组的第二逻辑地址),而所述有效数据实际存储在固态硬盘中的位置并没有发生改变。也就是说,本实施例中只需要改变所述有效数据的逻辑地址,不改变所述有效数据的实际地址。示例性的,在对第一逻辑块组执行系统垃圾回收之前,控制器11中保存有所述有效数据的虚拟地址与第一逻辑地址之间的对应关系。在504中,控制器11可以将所述有效数据的虚拟地址与第一逻辑地址之间的对应关系,修改为所述虚拟地址与分配的第二逻辑地址之间的对应关系。504: The controller 11 changes the first logical address of the valid data stored in the memory 111 to a second logical address. In the conventional system garbage collection, the controller 11 needs to read valid data from the first logical block group and rewrite it to the second logical block group. This means that the valid data will move between the physical blocks of the solid state hard disk, and accordingly, both the logical address and the actual address of the valid data will change. In this embodiment, to migrate the valid data from the first logical block group to the second logical block group, only the logical address of the valid data needs to be modified (the first logical address that will belong to the first logical block group). Modified to the second logical address belonging to the second logical block group), and the position where the valid data is actually stored in the solid state hard disk has not changed. That is, in this embodiment, only the logical address of the valid data needs to be changed, and the actual address of the valid data is not changed. Exemplarily, before performing the system garbage collection on the first logical block group, the controller 11 stores the correspondence between the virtual address of the valid data and the first logical address. In 504, the controller 11 may modify the correspondence between the virtual address of the valid data and the first logical address to the correspondence between the virtual address and the allocated second logical address.
505:控制器11向所述多个固态硬盘发送映射关系修改指令,所述映射关系修改指令用于指示所述多个固态硬盘将所述有效数据的第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系。在504中控制器11改变了所述有效数据的逻辑地址,所述逻辑地址的改变还需要通知固态硬盘,以保证控制器11和固态硬盘22中存储的所述有效数据的逻辑地址是一致,方便将来读取所述有效数据。可以理解的是,由于所述多个固态硬盘中每个固态硬盘均保存有部分有效数据,所以控制器11需要向每个固态硬盘发送映射关系修改指令,以指示该固态硬盘修改自己存储的那部分有效数据的对应关系。505: The controller 11 sends a mapping relationship modification instruction to the multiple solid-state hard disks, where the mapping relationship modification instruction is used to instruct the multiple solid-state hard disks to associate the first logical address of the valid data with the actual address The relationship is modified to a correspondence relationship between the second logical address and the actual address. In 504, the controller 11 changes the logical address of the valid data. The change of the logical address also needs to notify the solid state hard disk to ensure that the logical addresses of the valid data stored in the controller 11 and the solid state hard disk 22 are consistent. It is convenient to read the valid data in the future. It can be understood that, since each solid-state hard disk in the plurality of solid-state hard disks stores some valid data, the controller 11 needs to send a mapping relationship modification instruction to each solid-state hard disk to instruct the solid-state hard disk to modify its own storage Correspondence of some valid data.
可以理解的是,如果所述第一逻辑块组中只有一个第一数据逻辑块包含有效数据,并且创建的第二逻辑块组也只有一个第二数据逻辑块所在的固态硬盘与所述保存有效数据的第一数据逻辑块所在的固态硬盘相同,那么控制器11只需要向所述包含有效数据的第一数据逻辑块所在的固态硬盘发送映射关系修改指令。同理,如果所述第一逻辑块组中有一定数量(大于或等于2)的第一数据逻辑块包含有效数据,并且创建的第二逻辑块组也有同样数量的第二数据逻辑块所在的固态硬盘与所述保存有效数据的第一数据逻辑块所在的固态硬盘相同,那么控制器11只需要向所述保存有效数据的固态硬盘发送映射关系修改指令。It can be understood that if only one first data logical block in the first logical block group contains valid data, and the created second logical block group also has only one solid state hard disk in which the second data logical block is located, the storage is valid. The solid state hard disks where the first data logical block of data is the same, then the controller 11 only needs to send a mapping relationship modification instruction to the solid state hard disk where the first data logical block containing valid data is located. Similarly, if there is a certain number (greater than or equal to 2) of the first data logical block in the first logical block group containing valid data, and the created second logical block group also has the same number of second data logical blocks. The solid-state hard disk is the same as the solid-state hard disk where the first data logical block storing valid data is stored, and the controller 11 only needs to send a mapping relationship modification instruction to the solid-state hard disk holding valid data.
另一种情况下,所述第一逻辑块组中有N(N为大于或等于2的整数)个第一数据逻辑块包含有效数据,创建的第二逻辑块组有M(M为大于或等于1的整数)个第二数据逻 辑块所在的固态硬盘与所述N个第一数据逻辑块中的部分第一数据逻辑块所在的固态硬盘相同,M小于N。此时,控制器11只需要向M个第一数据逻辑块所在的固态硬盘发送映射关系修改指令。In another case, there are N (N is an integer greater than or equal to 2) first data logical blocks in the first logical block group containing valid data, and the created second logical block group has M (M is greater than or The solid-state hard disk where the second data logical blocks are located is the same as the solid-state hard disk where some of the first data logical blocks of the N first data logical blocks are located, and M is less than N. At this time, the controller 11 only needs to send a mapping relationship modification instruction to the solid state disk where the M first data logical blocks are located.
图5所示的系统垃圾回收方法可以实施于整个闪存阵列,也可以适用于所述闪存阵列的部分区域。例如,可以将多个固态硬盘22提供给控制器11的逻辑地址划分为两个集合,其中,针对第一集合中的系统垃圾回收采用本发明实施例提供的方式,针对第二集合中的系统垃圾回收采用传统的方式。The system garbage collection method shown in FIG. 5 may be implemented in the entire flash memory array, or may be applied to a part of the flash memory array. For example, the logical addresses provided by the multiple solid-state hard disks 22 to the controller 11 can be divided into two sets, where the system garbage collection in the first set adopts the method provided by the embodiment of the present invention, and the system in the second set Garbage recycling is traditional.
当第一逻辑块组中所有的有效数据迁移至第二逻辑块组之后,所述第一逻辑块组中所有的数据都变成无效数据,此时,控制器11可以将所述第一逻辑块组的数据变成无效数据的信息(例如第一逻辑块组的逻辑地址)传递给所述第一逻辑块组所分布的各个固态硬盘22,固态硬盘22根据该信息在物理块中标记所述无效数据,等到固态硬盘22执行内部的垃圾回收可直接回收包含无效数据的物理块,不用再进行有效数据的复制。After all valid data in the first logical block group is migrated to the second logical block group, all data in the first logical block group becomes invalid data. At this time, the controller 11 may transfer the first logical block The information that the data of the block group becomes invalid data (for example, the logical address of the first logical block group) is passed to each solid state hard disk 22 distributed by the first logical block group. The invalid data is described. When the solid state hard disk 22 performs internal garbage collection, the physical block containing the invalid data can be directly recovered without copying the valid data.
图5所示的实施方式介绍了系统垃圾回收的过程,由上面的描述可知,系统垃圾回收是由控制器11触发并完成的。然而,固态硬盘22还可以执行自己的垃圾回收,姑且将固态硬盘内部的垃圾回收称为盘内垃圾回收。盘内垃圾回收的大部分操作都由闪存控制器完成,少数情况下需要控制器11配合。图7是本实施例提供的盘内垃圾回收的方法流程示意图,如图7所示,该方法包括如下步骤。The embodiment shown in FIG. 5 introduces the process of system garbage collection. It can be known from the above description that the system garbage collection is triggered and completed by the controller 11. However, the solid state hard disk 22 may also perform its own garbage collection, and for the time being, the garbage collection inside the solid state hard disk is referred to as on-disk garbage collection. Most operations of garbage collection in the disk are completed by the flash memory controller, and in a few cases, the cooperation of the controller 11 is required. FIG. 7 is a schematic flowchart of a method for garbage collection in a tray provided in this embodiment. As shown in FIG. 7, the method includes the following steps.
701:当固态硬盘22中的空闲块不足时,所述固态硬盘22的闪存控制器从多个物理块中选择至少一个待回收的物理块。所述固态硬盘22是图1所示的任意一个固态硬盘。所述选择出的物理块需要满足一定条件,例如该物理块包含的无效数据到达第三设定阈值,或者该物理块是所述多个物理块中包含无效数据最多的物理块,或者该物理块包含的有效数据低于第四设定阈值,或者该物理块是所述多个物理块中包含有效数据最少的物理块。该为了方便描述,本实施例将所述选择出的进行垃圾回收的物理块称为第一物理块。701: When the free blocks in the solid state hard disk 22 are insufficient, the flash memory controller of the solid state hard disk 22 selects at least one physical block to be recovered from a plurality of physical blocks. The solid state hard disk 22 is any one of the solid state hard disks shown in FIG. 1. The selected physical block needs to meet certain conditions, for example, the invalid data contained in the physical block reaches a third set threshold, or the physical block is the physical block containing the most invalid data among the plurality of physical blocks, or the physical block The valid data contained in the block is lower than the fourth set threshold, or the physical block is a physical block containing the least effective data among the plurality of physical blocks. For the convenience of description, in this embodiment, the selected physical block for garbage collection is referred to as a first physical block.
无效数据或者有效数据的数据量可以根据固态硬盘22内部的位图来统计。固态硬盘22中保存有位图,所述位图,如表1所示,用于描述实际地址中存储的数据的有效性。The data amount of invalid data or valid data can be counted according to the bitmap inside the solid state hard disk 22. A bitmap is stored in the solid state hard disk 22, and the bitmap, as shown in Table 1, is used to describe the validity of the data stored in the actual address.
实际地址Actual address 有效性Effectiveness 实际地址Actual address 有效性Effectiveness
Block0,page0Block0, page0 00 Block1,page0Block1, page0 00
Block0,page1Block0, page1 00 Block1,page1Block1, page1 11
Block0,page2Block0, page2 11 Block1,page2Block1, page2 11
……... ……... ……... ……...
Block0,pageNBlock0, pageN 00 Block1,pageNBlock1, pageN 00
其中,“0”代表该地址中存储的数据是无效数据,“1”代表该地址中的存储的数据是有效数据。根据所述位图,固态硬盘22可以获取各个物理块的有效数据或者无效数据的数据量,从而选择出待回收的第一物理块。Among them, "0" indicates that the data stored in the address is invalid data, and "1" indicates that the data stored in the address is valid data. According to the bitmap, the solid state hard disk 22 can acquire the data amount of valid data or invalid data of each physical block, thereby selecting the first physical block to be recovered.
702:所述闪存控制器从所述第一物理块中读取有效数据以及所述有效数据的虚拟地址。从表1中可获知存储有效数据的实际地址,例如block0,page2。然而,固态硬盘22从该实际地址中读取出存储的有效数据。由于数据的虚拟地址和数据是作为一个整体存储的,因此在读取所述有效数据时可以读取所述有效数据的虚拟地址。702: The flash memory controller reads valid data and a virtual address of the valid data from the first physical block. The actual address where valid data is stored can be obtained from Table 1, such as block0, page2. However, the solid state hard disk 22 reads the stored valid data from the actual address. Since the virtual address of the data and the data are stored as a whole, the virtual address of the valid data can be read when the valid data is read.
703:所述闪存控制器将所述虚拟地址发送给控制器11。如果按照传统的方式,所述有效数据的逻辑地址和所述有效数据是一并存储的,因此固态硬盘22可以直接获取所述有效数据的逻辑地址。然而,在本实施例中,固态硬盘22中存储的是所述有效数据的虚拟地址,而不是逻辑地址,因此固态硬盘22需要将所述虚拟地址发送给控制器11以查询所述有效数据的逻辑地址。703: The flash memory controller sends the virtual address to the controller 11. If the logical address of the valid data and the valid data are stored together in a conventional manner, the solid state hard disk 22 can directly obtain the logical address of the valid data. However, in this embodiment, the virtual address of the valid data is stored in the solid-state hard disk 22 instead of a logical address. Therefore, the solid-state hard disk 22 needs to send the virtual address to the controller 11 to query the valid data. Logical address.
703:所述闪存控制器接收控制器11发送的所述虚拟地址对应的逻辑地址。控制器11中保存有虚拟地址与逻辑地址之间的对应关系。示例性的,这里的逻辑地址可以是图5所示的实施例中的第二逻辑地址,也可以称为源逻辑地址。703: The flash memory controller receives a logical address corresponding to the virtual address sent by the controller 11. The controller 11 stores the correspondence between the virtual address and the logical address. Exemplarily, the logical address herein may be the second logical address in the embodiment shown in FIG. 5, and may also be referred to as a source logical address.
704:所述闪存控制器分配目标逻辑地址。704: The flash memory controller allocates a target logical address.
705:所述闪存控制器将所述有效数据复制到第二物理块,所述第二物理块是一个空白的物理块。由于有效数据和所述有效数据的虚拟地址是作为一个整体存储的,因此闪存控制器在将所述有效数据复制到所述第二物理块时,也会将所述有效数据的虚拟地址复制到所述第二物理块。705: The flash memory controller copies the valid data to a second physical block, where the second physical block is a blank physical block. Since the valid data and the virtual address of the valid data are stored as a whole, when the flash memory controller copies the valid data to the second physical block, it also copies the virtual address of the valid data to The second physical block.
706:在复制完成之后,所述闪存控制器对所述闪存翻译层中保存的对应关系进行修改。具体的,所述闪存控制器删除所述源逻辑地址与所述有效数据保存在所述第一物理块中的实际地址之间的对应关系,并且创建所述目标逻辑地址与所述有效数据保存在所述第二物理块中的实际地址之间的对应关系。706: After the copying is completed, the flash memory controller modifies the corresponding relationship stored in the flash memory translation layer. Specifically, the flash memory controller deletes the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and creates the target logical address and the valid data save A correspondence between actual addresses in the second physical block.
707:擦除所述第一物理块中的数据。707: Erase data in the first physical block.
按照同样的方式,固态硬盘22可以选择其他物理块作为垃圾回收的对象,重复执行701至707,从而完成了整个固态硬盘22内部的垃圾回收。In the same way, the solid state hard disk 22 may select other physical blocks as the object of garbage collection, and repeatedly perform 701 to 707, thereby completing the garbage collection of the entire solid state hard disk 22.
在图7所示的描述中,本实施例以虚拟地址作为示例性。然而,可以理解的是,所述虚拟地址可以替换为其他形式的反向映射信息,此时盘内垃圾回收的操作方式与图7所描述的方式类似,这里不再赘述。In the description shown in FIG. 7, this embodiment uses the virtual address as an example. However, it can be understood that the virtual address may be replaced with other forms of reverse mapping information. At this time, the operation mode of garbage collection on the disk is similar to that described in FIG. 7, and is not repeated here.
另外,本实施例还适用于另一种存储系统,该存储系统包括系统控制器和多个叠瓦式磁记录技术(Shingled Magnetic Recording,SMR)硬盘。该存储系统也可以执行图4、图5以及图7所示的方法流程,只需要将固态硬盘替换为叠瓦式磁记录技术硬盘即可,这里不再赘述。In addition, this embodiment is also applicable to another storage system. The storage system includes a system controller and multiple shingled magnetic recording (SMR) hard disks. The storage system can also execute the method flow shown in FIG. 4, FIG. 5, and FIG. 7. It only needs to replace the solid-state hard disk with a shingled magnetic recording technology hard disk, which will not be repeated here.
图8是本发明实施例提供的系统垃圾回收装置的结构示意图,该装置位于闪存阵列的控制器11中,如图8所示,该装置包括确定模块801,创建模块802,分配模块803和指示模块804。8 is a schematic structural diagram of a system garbage collection device according to an embodiment of the present invention. The device is located in a controller 11 of a flash memory array. As shown in FIG. 8, the device includes a determination module 801, a creation module 802, an allocation module 803, and an instruction. Block 804.
其中,确定模块801,用于确定出待回收的第一逻辑块组,所述第一逻辑块组包括多个第一数据逻辑块,所述多个第一数据逻辑块分布在所述闪存阵列包含的不同的固态硬盘中,其中,所述多个第一数据逻辑块中至少有一个第一数据逻辑块存储的数据包括有效数据,所述有效数据在所述第一逻辑块中的位置为第一逻辑地址,所述第一逻辑地址与所述有效数据保存在固态硬盘中的实际地址具有对应关系。该模块的功能可由处理器112单独执行或者处理器112调用存储器111中的程序执行,具体可参考图5所示的步骤501及相关描述,这里不再赘述。The determining module 801 is configured to determine a first logical block group to be recycled, where the first logical block group includes multiple first data logical blocks, and the multiple first data logical blocks are distributed in the flash memory array. Among the different solid-state hard disks included, wherein data stored in at least one of the plurality of first data logical blocks includes valid data, and the position of the valid data in the first logical block is A first logical address, and the first logical address has a corresponding relationship with an actual address where the valid data is stored in the solid state hard disk. The function of this module may be executed by the processor 112 alone or executed by the processor 112 calling a program in the memory 111. For details, refer to step 501 and related description shown in FIG. 5, and details are not described herein again.
创建模块802,用于创建第二逻辑块组,所述第二逻辑块组包括多个第二数据逻辑块,其中,至少有一个所述第二数据逻辑块分布在存储所述有效数据的第一数据逻辑块所在的固态硬盘中。该模块的功能可由处理器112单独执行或者处理器112调用存储器111 中的程序执行,具体可参考图5所示的步骤502及相关描述,这里不再赘述。A creating module 802 is configured to create a second logical block group, where the second logical block group includes a plurality of second data logical blocks, wherein at least one of the second data logical blocks is distributed in a first storage block storing the valid data. A solid state drive where a data logical block is located. The function of this module can be executed by the processor 112 alone or executed by the processor 112 calling the program in the memory 111. For details, refer to step 502 shown in FIG. 5 and related descriptions, and details are not described herein again.
分配模块803,用于在所述分布在存储所述有效数据的第一逻辑块所在的固态硬盘中的第二逻辑块中为所述有效数据分配第二逻辑地址。该模块的功能可由处理器112单独执行或者处理器112调用存储器111中的程序执行,具体可参考图5所示的步骤503及相关描述,这里不再赘述。An allocation module 803 is configured to allocate a second logical address to the valid data in a second logical block distributed in the solid state hard disk where the first logical block storing the valid data is located. The functions of this module can be executed by the processor 112 alone or executed by the processor 112 calling a program in the memory 111. For details, refer to step 503 and related description shown in FIG. 5, and details are not described herein again.
指示模块804,用于指示所述保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系。该模块的功能可由处理器112单独执行或者处理器112调用存储器111中的程序执行,具体可参考图5所示的步骤505及相关描述,这里不再赘述。An instruction module 804 is configured to instruct the solid-state hard disk storing the valid data to modify a correspondence between the first logical address and the actual address to a correspondence between the second logical address and the actual address. The function of this module can be executed by the processor 112 alone or executed by the processor 112 calling the program in the memory 111. For details, refer to step 505 and related description shown in FIG.
图9是本发明实施例提供的固态硬盘中的垃圾回收装置的结构示意图,如图9所示,该装置包括处理模块901和回收模块902。FIG. 9 is a schematic structural diagram of a garbage collection device in a solid state hard disk according to an embodiment of the present invention. As shown in FIG. 9, the device includes a processing module 901 and a recycling module 902.
处理模块901,用于从待回收的第一物理块中读取有效数据以及所述有效数据的反向映射信息;向所述系统控制器发送所述反向映射信息;接收所述系统控制器发送的所述反向映射信息对应的源逻辑地址;为所述有效数据分配目标逻辑地址,并且将所述有效数据复制到第二物理块。该模块的功能可固态硬盘22内部的控制器执行,具体可参考图7所示的步骤701至705及相关描述,这里不再赘述。A processing module 901, configured to read valid data and reverse mapping information of the valid data from the first physical block to be recycled; send the reverse mapping information to the system controller; and receive the system controller A source logical address corresponding to the reverse mapping information sent; assigning a target logical address to the valid data, and copying the valid data to a second physical block. The function of this module can be executed by the controller inside the solid state hard disk 22. For details, refer to steps 701 to 705 shown in FIG. 7 and related descriptions, which will not be repeated here.
回收模块902,用于删除所述源逻辑地址与所述有效数据保存在所述第一物理块中的实际地址之间的对应关系,创建所述目标逻辑地址与所述有效数据保存在所述第二物理块中的实际地址之间的对应关系;擦除所述第一物理块中的数据。该模块的功能可固态硬盘22内部的控制器执行,具体可参考图7所示的步骤706至707及相关描述,这里不再赘述。The recycling module 902 is configured to delete the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and create the target logical address and the valid data to be stored in the Correspondence between actual addresses in the second physical block; erasing data in the first physical block. The functions of this module can be executed by the controller inside the solid state hard disk 22. For details, refer to steps 706 to 707 shown in FIG. 7 and related descriptions, and details are not described herein again.
本领域普通技术人员将会理解,本发明的各个方面、或各个方面的可能实现方式可以被具体实施为系统、方法或者计算机程序产品。因此,本发明的各方面、或各个方面的可能实现方式可以采用完全硬件实施例、完全软件实施例(包括固件、驻留软件等等),或者组合软件和硬件方面的实施例的形式,在这里都统称为“电路”、“模块”或者“系统”。此外,本发明的各方面、或各个方面的可能实现方式可以采用计算机程序产品的形式,计算机程序产品是指存储在计算机可读介质中的计算机可读程序代码。Those of ordinary skill in the art will understand that each aspect of the present invention, or possible implementation manners of each aspect, may be specifically implemented as a system, method, or computer program product. Therefore, aspects of the present invention, or possible implementations of various aspects, may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, etc.), or an embodiment combining software and hardware aspects. These are collectively referred to as "circuits", "modules" or "systems". In addition, each aspect of the present invention, or a possible implementation manner of each aspect, may take the form of a computer program product, where the computer program product refers to computer-readable program code stored in a computer-readable medium.
计算机可读介质包含但不限于电子、磁性、光学、电磁、红外或半导体系统、设备或者装置,或者前述的任意适当组合,如随机访问存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM)、光盘。Computer-readable media includes, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, equipment, or devices, or any suitable combination of the foregoing, such as random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM), optical disc.
计算机中的处理器读取存储在计算机可读介质中的计算机可读程序代码,使得处理器能够执行在流程图中每个步骤、或各步骤的组合中规定的功能动作。The processor in the computer reads the computer-readable program code stored in the computer-readable medium, so that the processor can execute the functional actions specified in each step or a combination of steps in the flowchart.
计算机可读程序代码可以完全在用户的计算机上执行、部分在用户的计算机上执行、作为单独的软件包、部分在用户的计算机上并且部分在远程计算机上,或者完全在远程计算机或者服务器上执行。也应该注意,在某些替代实施方案中,在流程图中各步骤、或框图中各块所注明的功能可能不按图中注明的顺序发生。例如,依赖于所涉及的功能,接连示出的两个步骤、或两个块实际上可能被大致同时执行,或者这些块有时候可能被以相反顺序执行。The computer-readable program code can be executed entirely on the user's computer, partly on the user's computer, as a separate software package, partly on the user's computer and partly on a remote computer, or entirely on a remote computer or server . It should also be noted that in some alternative implementations, the functions noted in the steps in the flowchart or in the blocks in the block diagram may occur out of the order noted in the figure. For example, two steps shown in succession, or two blocks may in fact be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究 竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art may realize that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software depends on the specific application and design constraints of the technical solution. Those of ordinary skill in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,本领域普通技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited to this. Those skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be covered in Within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (31)

  1. 一种系统垃圾回收方法,其特征在于,所述方法应用于闪存阵列中,所述闪存阵列包括系统控制器和多个固态硬盘,所述方法由所述系统控制器执行,包括以下步骤:A system garbage collection method, characterized in that the method is applied to a flash memory array, the flash memory array includes a system controller and a plurality of solid state hard disks, and the method is executed by the system controller and includes the following steps:
    确定出待回收的第一逻辑块组,所述第一逻辑块组包括多个第一数据逻辑块,所述多个第一数据逻辑块分布在不同的固态硬盘中,其中,所述多个第一数据逻辑块中至少有一个第一数据逻辑块存储的数据包括有效数据,所述有效数据在所述第一逻辑块中的位置为第一逻辑地址,所述第一逻辑地址与所述有效数据保存在固态硬盘中的实际地址具有对应关系;A first logical block group to be recovered is determined, the first logical block group includes a plurality of first data logical blocks, and the plurality of first data logical blocks are distributed in different solid state hard disks, wherein the plurality of The data stored in at least one first data logical block in the first data logical block includes valid data, and the position of the valid data in the first logical block is a first logical address, and the first logical address and the The actual address of valid data stored in the solid-state drive has a corresponding relationship;
    创建第二逻辑块组,所述第二逻辑块组包括多个第二数据逻辑块,其中,至少有一个所述第二数据逻辑块分布在存储所述有效数据的第一数据逻辑块所在的固态硬盘中;Creating a second logical block group, the second logical block group including a plurality of second data logical blocks, wherein at least one of the second data logical blocks is distributed in a place where the first data logical block storing the valid data is located Solid state drive
    在所述至少一个第二逻辑块中为所述有效数据分配第二逻辑地址;Assigning a second logical address to the valid data in the at least one second logical block;
    指示所述保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系。Instructing the solid-state hard disk storing the valid data to modify the correspondence between the first logical address and the actual address to the correspondence between the second logical address and the actual address.
  2. 根据权利要求1所述的方法,其特征在于,所述存储有有效数据的第一数据逻辑块的数量和所述至少一个第二数据逻辑块的数量相同。The method according to claim 1, wherein the number of the first data logical blocks storing valid data is the same as the number of the at least one second data logical block.
  3. 根据权利要求2所述的方法,其特征在于,The method according to claim 2, wherein:
    所述创建第二逻辑块组包括:根据所述多个第一数据逻辑块在所述多个固态硬盘中的分布情况创建第二逻辑块组,所述第二逻辑块组所包含的多个第二数据逻辑块分布在与所述多个第一数据逻辑块相同的固态硬盘中。The creating a second logical block group includes: creating a second logical block group according to the distribution of the plurality of first data logical blocks in the multiple solid-state hard disks. The second data logical block is distributed in the same solid state hard disk as the plurality of first data logical blocks.
  4. 根据权利要求1-3任一所述的方法,其特征在于,所述第一逻辑块组还包括第一校验逻辑块,所述第一校验逻辑块分布在与所述多个第一数据逻辑块不同的固态硬盘中,所述第二逻辑块组还包括第二校验逻辑块,所述第二校验逻辑块分布在与所述多个第二数据逻辑块不同的固态硬盘中。The method according to any one of claims 1 to 3, wherein the first logical block group further comprises a first check logical block, and the first check logical block is distributed with the plurality of first In the solid-state hard disks having different data logical blocks, the second logical block group further includes a second check logical block, and the second check logical block is distributed in a solid-state hard disk different from the plurality of second data logical blocks .
  5. 根据权利要求4所述的方法,其特征在于,所述第二校验逻辑块所在的固态硬盘与所述第一校验逻辑块所在的固态硬盘相同。The method according to claim 4, wherein the solid-state hard disk where the second verification logic block is located is the same as the solid-state hard disk where the first verification logic block is located.
  6. 根据权利要求4所述的方法,其特征在于,所述第二校验逻辑块所在的固态硬盘与所述第一校验逻辑块所在的固态硬盘不同。The method according to claim 4, wherein the solid-state hard disk where the second verification logic block is located is different from the solid-state hard disk where the first verification logic block is located.
  7. 根据权利要求1所述的方法,其特征在于,确定出待回收的第一逻辑块组之前,还包括确定出所述第一逻辑块组中有效数据的数据量低于设定阈值。The method according to claim 1, before determining the first logical block group to be recovered, further comprising determining that a data amount of valid data in the first logical block group is lower than a set threshold.
  8. 一种系统控制器,其特征在于,所述系统控制器包括:A system controller, characterized in that the system controller includes:
    接口,用于和多个固态硬盘通信;以及Interface for communicating with multiple solid state drives; and
    处理器,用于确定出待回收的第一逻辑块组,所述第一逻辑块组包括多个第一数据逻辑块,所述多个第一数据逻辑块分布在不同的固态硬盘中,其中,所述多个第一数据逻辑块中至少有一个第一数据逻辑块存储的数据包括有效数据,所述有效数据在所述第一逻辑块中的位置为第一逻辑地址,所述第一逻辑地址与所述有效数据保存在固态硬盘 中的实际地址具有对应关系;A processor, configured to determine a first logical block group to be recovered, the first logical block group includes a plurality of first data logical blocks, and the plurality of first data logical blocks are distributed in different solid state hard disks, where The data stored in at least one of the plurality of first data logical blocks includes valid data, and the position of the valid data in the first logical block is a first logical address, and the first The logical address has a corresponding relationship with the actual address where the valid data is stored in the solid state hard disk;
    创建第二逻辑块组,所述第二逻辑块组包括多个第二数据逻辑块,其中,至少有一个所述第二数据逻辑块分布在存储所述有效数据的第一数据逻辑块所在的固态硬盘中;Creating a second logical block group, the second logical block group including a plurality of second data logical blocks, wherein at least one of the second data logical blocks is distributed in a place where the first data logical block storing the valid data is located Solid state drive
    在所述至少一个所述第二逻辑块中为所述有效数据分配第二逻辑地址;Assigning a second logical address to the valid data in the at least one of the second logical blocks;
    通过所述接口指示所述保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系。Instructing, via the interface, the solid-state hard disk storing the valid data to modify the correspondence between the first logical address and the actual address to the correspondence between the second logical address and the actual address.
  9. 根据权利要求8所述的系统控制器,其特征在于,所述存储有有效数据的第一数据逻辑块的数量和所述至少一个所述第二数据逻辑块的数量相同。The system controller according to claim 8, wherein the number of the first data logical blocks storing valid data is the same as the number of the at least one second data logical block.
  10. 根据权利要求9所述的系统控制器,其特征在于,The system controller according to claim 9, wherein:
    所述处理器具体用于根据所述多个第一数据逻辑块在所述多个固态硬盘中的分布情况创建第二逻辑块组,所述第二逻辑块组所包含的多个第二数据逻辑块分布在与所述多个第一数据逻辑块相同的固态硬盘中。The processor is specifically configured to create a second logical block group according to the distribution of the multiple first data logical blocks in the multiple solid-state hard disks, and the multiple second data included in the second logical block group The logical blocks are distributed in the same solid state hard disk as the plurality of first data logical blocks.
  11. 根据权利要求8-10任一所述的系统控制器,其特征在于,所述第一逻辑块组还包括第一校验逻辑块,所述第一校验逻辑块分布在与所述多个第一数据逻辑块不同的固态硬盘中,所述第二逻辑块组还包括第二校验逻辑块,所述第二校验逻辑块分布在与所述多个第二数据逻辑块不同的固态硬盘中。The system controller according to any one of claims 8 to 10, wherein the first logic block group further comprises a first check logic block, and the first check logic block is distributed between the plurality of In a solid state hard disk having a different first data logical block, the second logical block group further includes a second check logical block, and the second check logical block is distributed in a different solid state from the plurality of second data logical blocks. Hard drive.
  12. 根据权利要求11所述的系统控制器,其特征在于,所述第二校验逻辑块所在的固态硬盘与所述第一校验逻辑块所在的固态硬盘相同。The system controller according to claim 11, wherein the solid-state hard disk where the second verification logic block is located is the same as the solid-state hard disk where the first verification logic block is located.
  13. 根据权利要求11所述的系统控制器,其特征在于,所述第二校验逻辑块所在的固态硬盘与所述第一校验逻辑块所在的固态硬盘不同。The system controller according to claim 11, wherein the solid-state hard disk where the second verification logic block is located is different from the solid-state hard disk where the first verification logic block is located.
  14. 根据权利要求8所述的系统控制器,其特征在于,The system controller according to claim 8, wherein:
    所述处理器还用于在确定出待回收的第一逻辑块组之前,确定出所述第一逻辑块组中有效数据的数据量低于设定阈值。The processor is further configured to determine, before determining the first logical block group to be recovered, that a data amount of valid data in the first logical block group is lower than a set threshold.
  15. 一种闪存阵列,其特征在于,包括系统控制器和多个固态硬盘;A flash memory array, characterized in that it includes a system controller and a plurality of solid state drives;
    所述系统控制器,用于确定出待回收的第一逻辑块组,所述第一逻辑块组包括多个第一数据逻辑块,所述多个第一数据逻辑块分布在不同的固态硬盘中,其中,所述多个第一数据逻辑块中至少有一个第一数据逻辑块存储的数据包括有效数据,所述有效数据在所述第一逻辑块中的位置为第一逻辑地址,所述第一逻辑地址与所述有效数据保存在固态硬盘中的实际地址具有对应关系;The system controller is configured to determine a first logical block group to be recycled, the first logical block group includes a plurality of first data logical blocks, and the plurality of first data logical blocks are distributed on different solid state hard disks Wherein, the data stored in at least one of the plurality of first data logical blocks includes valid data, and the position of the valid data in the first logical block is a first logical address, so The first logical address has a corresponding relationship with the actual address where the valid data is stored in the solid state hard disk;
    创建第二逻辑块组,所述第二逻辑块组包括多个第二数据逻辑块,其中,至少有一个所述第二数据逻辑块分布在存储所述有效数据的第一数据逻辑块所在的固态硬盘中;Creating a second logical block group, the second logical block group including a plurality of second data logical blocks, wherein at least one of the second data logical blocks is distributed in a place where the first data logical block storing the valid data is located Solid state drive
    在所述至少一个所述第二逻辑块中为所述有效数据分配第二逻辑地址;Assigning a second logical address to the valid data in the at least one of the second logical blocks;
    指示所述保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应 关系修改为所述第二逻辑地址与所述实际地址的对应关系。Instructing the solid state hard disk storing the valid data to modify the correspondence between the first logical address and the actual address to the correspondence between the second logical address and the actual address.
  16. 根据权利要求15所述的闪存阵列,其特征在于,所述存储有有效数据的第一数据逻辑块的数量和所述至少一个所述第二数据逻辑块的数量相同。The flash memory array according to claim 15, wherein the number of the first data logical blocks storing valid data is the same as the number of the at least one second data logical block.
  17. 根据权利要求16所述的闪存阵列,其特征在于,The flash memory array according to claim 16, wherein:
    所述系统控制器,具体用于根据所述多个第一数据逻辑块在所述多个固态硬盘中的分布情况创建第二逻辑块组,所述第二逻辑块组所包含的多个第二数据逻辑块分布在与所述多个第一数据逻辑块相同的固态硬盘中。The system controller is specifically configured to create a second logical block group according to the distribution of the multiple first data logical blocks in the multiple solid-state hard disks. The two data logic blocks are distributed in the same solid state hard disk as the plurality of first data logic blocks.
  18. 根据权利要求15-17任一所述的闪存阵列,其特征在于,所述第一逻辑块组还包括第一校验逻辑块,所述第一校验逻辑块分布在与所述多个第一数据逻辑块不同的固态硬盘中,所述第二逻辑块组还包括第二校验逻辑块,所述第二校验逻辑块分布在与所述多个第二数据逻辑块不同的固态硬盘中。The flash memory array according to any one of claims 15-17, wherein the first logic block group further comprises a first check logic block, and the first check logic block is distributed between the plurality of In a solid state hard disk having a different data logical block, the second logical block group further includes a second check logical block, and the second check logical block is distributed on a solid state hard disk different from the plurality of second data logical blocks. in.
  19. 根据权利要求15所述的闪存阵列,其特征在于,The flash memory array according to claim 15, wherein:
    所述保存所述有效数据的固态硬盘还用于从所述有效数据所在的第一物理块中读取所述有效数据以及所述有效数据的反向映射信息;向所述系统控制器发送所述反向映射信息;The solid state hard disk storing the valid data is further configured to read the valid data and reverse mapping information of the valid data from a first physical block where the valid data is located; and send the valid data to the system controller. Said reverse mapping information;
    所述系统控制器还用于根据所述反向映射信息查询所述反向映射信息对应的第二逻辑地址,并且将所述第二逻辑地址发送给所述保存所述有效数据的固态硬盘;The system controller is further configured to query a second logical address corresponding to the reverse mapping information according to the reverse mapping information, and send the second logical address to the solid-state hard disk storing the valid data;
    所述保存所述有效数据的固态硬盘还用于为所述有效数据分配第三逻辑地址,将所述有效数据复制到第二物理块;The solid state hard disk storing the valid data is further configured to allocate a third logical address to the valid data, and copy the valid data to a second physical block;
    所述保存所述有效数据的固态硬盘还用于删除所述第二逻辑地址与所述实际地址之间的对应关系,创建所述第三逻辑地址与所述有效数据保存在所述第二物理块中的实际地址之间的对应关系;The solid state hard disk storing the valid data is further configured to delete a correspondence between the second logical address and the actual address, and create the third logical address and the valid data to be stored in the second physical address. The correspondence between the actual addresses in the block;
    所述保存所述有效数据的固态硬盘还用于在确定所述第一物理块不包含其他有效数据时,擦除所述第一物理块中的数据。The solid state hard disk storing the valid data is further configured to erase data in the first physical block when it is determined that the first physical block does not contain other valid data.
  20. 根据权利要求19所述的闪存阵列,其特征在于,所述反向映射信息包括所述有效数据的虚拟地址。The flash memory array according to claim 19, wherein the reverse mapping information includes a virtual address of the valid data.
  21. 一种固态硬盘中的垃圾回收方法,其特征在于,所述固态硬盘与系统控制器连接,所述方法由所述固态硬盘执行,包括以下步骤:A method for garbage collection in a solid state hard disk, characterized in that the solid state hard disk is connected to a system controller, and the method is performed by the solid state hard disk, and includes the following steps:
    从待回收的第一物理块中读取有效数据以及所述有效数据的反向映射信息;Reading valid data and reverse mapping information of the valid data from the first physical block to be recycled;
    向所述系统控制器发送所述反向映射信息;Sending the reverse mapping information to the system controller;
    接收所述系统控制器发送的所述反向映射信息对应的源逻辑地址;Receiving a source logical address corresponding to the reverse mapping information sent by the system controller;
    为所述有效数据分配目标逻辑地址,并且将所述有效数据复制到第二物理块;Allocate a target logical address to the valid data, and copy the valid data to a second physical block;
    删除所述源逻辑地址与所述有效数据保存在所述第一物理块中的实际地址之间的对应关系,创建所述目标逻辑地址与所述有效数据保存在所述第二物理块中的实际地址之 间的对应关系;Delete the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and create the target logical address and the valid data which are stored in the second physical block Correspondence between actual addresses;
    擦除所述第一物理块中的数据。Erasing data in the first physical block.
  22. 根据权利要求21所述的方法,其特征在于,所述反向映射信息包括所述有效数据的虚拟地址。The method according to claim 21, wherein the reverse mapping information includes a virtual address of the valid data.
  23. 一种固态硬盘,其特征在于,包括控制器、第一物理块和第二物理块;A solid state hard disk, comprising a controller, a first physical block and a second physical block;
    所述控制器用于:The controller is used for:
    从待回收的所述第一物理块中读取有效数据以及所述有效数据的反向映射信息;Reading valid data and reverse mapping information of the valid data from the first physical block to be recycled;
    向所述系统控制器发送所述反向映射信息;Sending the reverse mapping information to the system controller;
    接收所述系统控制器发送的所述反向映射信息对应的源逻辑地址;Receiving a source logical address corresponding to the reverse mapping information sent by the system controller;
    为所述有效数据分配目标逻辑地址,并且将所述有效数据复制到所述第二物理块;Allocate a target logical address for the valid data, and copy the valid data to the second physical block;
    删除所述源逻辑地址与所述有效数据保存在所述第一物理块中的实际地址之间的对应关系,创建所述目标逻辑地址与所述有效数据保存在所述第二物理块中的实际地址之间的对应关系;Delete the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and create the target logical address and the valid data which are stored in the second physical block Correspondence between actual addresses;
    擦除所述第一物理块中的数据。Erasing data in the first physical block.
  24. 根据权利要求23所述的固态硬盘,其特征在于,所述反向映射信息包括所述有效数据的虚拟地址。The solid state hard disk according to claim 23, wherein the reverse mapping information includes a virtual address of the valid data.
  25. 一种系统垃圾回收装置,其特征在于,所述装置位于闪存阵列的系统控制器中,所述装置包括:A system garbage collection device is characterized in that the device is located in a system controller of a flash memory array, and the device includes:
    确定模块,用于确定出待回收的第一逻辑块组,所述第一逻辑块组包括多个第一数据逻辑块,所述多个第一数据逻辑块分布在所述闪存阵列包含的不同的固态硬盘中,其中,所述多个第一数据逻辑块中至少有一个第一数据逻辑块存储的数据包括有效数据,所述有效数据在所述第一逻辑块中的位置为第一逻辑地址,所述第一逻辑地址与所述有效数据保存在固态硬盘中的实际地址具有对应关系;A determining module, configured to determine a first logical block group to be recycled, where the first logical block group includes a plurality of first data logical blocks, and the plurality of first data logical blocks are distributed in different locations included in the flash memory array; In the solid state hard disk, wherein at least one of the plurality of first data logical blocks stores data stored in the first data logical block including valid data, and the position of the valid data in the first logical block is first logic Address, the first logical address has a corresponding relationship with the actual address where the valid data is stored in the solid state hard disk;
    创建模块,用于创建第二逻辑块组,所述第二逻辑块组包括多个第二数据逻辑块,其中,至少有一个所述第二数据逻辑块分布在存储所述有效数据的第一数据逻辑块所在的固态硬盘中;A creating module, configured to create a second logical block group, where the second logical block group includes a plurality of second data logical blocks, wherein at least one of the second data logical blocks is distributed on a first storing the valid data; The solid state disk where the data logic block is located;
    分配模块,用于在所述至少一个所述第二逻辑块中为所述有效数据分配第二逻辑地址;An allocation module, configured to allocate a second logical address to the valid data in the at least one of the second logical blocks;
    指示模块,用于指示所述保存所述有效数据的固态硬盘将所述第一逻辑地址与所述实际地址的对应关系修改为所述第二逻辑地址与所述实际地址的对应关系。An instruction module is configured to instruct the solid-state hard disk storing the valid data to modify the correspondence between the first logical address and the actual address to the correspondence between the second logical address and the actual address.
  26. 根据权利要求25所述的装置,其特征在于,所述存储有有效数据的第一数据逻辑块的数量和所述至少一个第二数据逻辑块的数量相同。The apparatus according to claim 25, wherein the number of the first data logical blocks storing valid data is the same as the number of the at least one second data logical block.
  27. 根据权利要求26所述的装置,其特征在于,The device according to claim 26, wherein:
    所述创建模块,具体用于根据所述多个第一数据逻辑块在所述多个固态硬盘中的分 布情况创建第二逻辑块组,所述第二逻辑块组所包含的多个第二数据逻辑块分布在与所述多个第一数据逻辑块相同的固态硬盘中。The creating module is specifically configured to create a second logical block group according to the distribution of the multiple first data logical blocks in the multiple solid-state hard disks, and a plurality of second logical block groups included in the second logical block group. The data logic blocks are distributed in the same solid state hard disk as the plurality of first data logic blocks.
  28. 根据权利要求25-27任一所述的装置,其特征在于,所述第一逻辑块组还包括第一校验逻辑块,所述第一校验逻辑块分布在与所述多个第一数据逻辑块不同的固态硬盘中,所述第二逻辑块组还包括第二校验逻辑块,所述第二校验逻辑块分布在与所述多个第二数据逻辑块不同的固态硬盘中。The apparatus according to any one of claims 25 to 27, wherein the first logical block group further comprises a first check logical block, and the first check logical block is distributed between the first check logical block and the plurality of first check logical blocks. In the solid-state hard disks having different data logical blocks, the second logical block group further includes a second check logical block, and the second check logical block is distributed in a solid-state hard disk different from the plurality of second data logical blocks. .
  29. 根据权利要求25所述的装置,其特征在于,所述确定模块还用于在确定待回收的第一逻辑块组之前确定出所述第一逻辑块组中有效数据的数据量低于设定阈值。The device according to claim 25, wherein the determining module is further configured to determine that a data amount of valid data in the first logical block group is lower than a set before determining the first logical block group to be recycled. Threshold.
  30. 一种固态硬盘中的垃圾回收装置,其特征在于,包括:A garbage recycling device in a solid state hard disk, which is characterized by comprising:
    处理模块,用于从待回收的第一物理块中读取有效数据以及所述有效数据的反向映射信息;向所述系统控制器发送所述反向映射信息;接收所述系统控制器发送的所述反向映射信息对应的源逻辑地址;为所述有效数据分配目标逻辑地址,并且将所述有效数据复制到第二物理块;A processing module, configured to read valid data and reverse mapping information of the valid data from the first physical block to be recycled; send the reverse mapping information to the system controller; receive the system controller sends A source logical address corresponding to the reverse mapping information; assign a target logical address to the valid data, and copy the valid data to a second physical block;
    回收模块,用于删除所述源逻辑地址与所述有效数据保存在所述第一物理块中的实际地址之间的对应关系,创建所述目标逻辑地址与所述有效数据保存在所述第二物理块中的实际地址之间的对应关系;擦除所述第一物理块中的数据。A recycling module, configured to delete the correspondence between the source logical address and the actual address where the valid data is stored in the first physical block, and create the target logical address and the valid data to be stored in the first Correspondence between actual addresses in two physical blocks; erasing data in the first physical block.
  31. 根据权利要求30所述的装置,其特征在于,所述反向映射信息包括所述有效数据的虚拟地址。The apparatus according to claim 30, wherein the reverse mapping information includes a virtual address of the valid data.
PCT/CN2019/079391 2018-09-12 2019-03-23 System garbage collection method and method for collecting garbage in solid state hard disk WO2020052216A1 (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP19859851.8A EP3748509B1 (en) 2018-09-12 2019-03-23 System garbage collection method and method for collecting garbage in solid state hard disk
JP2020526891A JP7315130B2 (en) 2018-09-12 2019-03-23 How system garbage collection works and how garbage collection works on solid state disks
US17/021,413 US11928053B2 (en) 2018-09-12 2020-09-15 System garbage collection method and method for garbage collection in solid state disk

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201811064493 2018-09-12
CN201811064493.X 2018-09-12
CN201811233512.7 2018-10-23
CN201811233512.7A CN110895513A (en) 2018-09-12 2018-10-23 System garbage recycling method and garbage recycling method in solid state disk

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/021,413 Continuation US11928053B2 (en) 2018-09-12 2020-09-15 System garbage collection method and method for garbage collection in solid state disk

Publications (1)

Publication Number Publication Date
WO2020052216A1 true WO2020052216A1 (en) 2020-03-19

Family

ID=69778137

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/079391 WO2020052216A1 (en) 2018-09-12 2019-03-23 System garbage collection method and method for collecting garbage in solid state hard disk

Country Status (1)

Country Link
WO (1) WO2020052216A1 (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744798A (en) * 2013-12-17 2014-04-23 记忆科技(深圳)有限公司 Garbage recycling method of solid state discs
CN104794070A (en) * 2015-04-23 2015-07-22 南京道熵信息技术有限公司 Solid-state flash memory write cache system and method based on dynamic non-covering RAID technology
US20160077964A1 (en) * 2014-09-11 2016-03-17 Samsung Electronics Co., Ltd. Storage device and garbage collection method of data storage system having the storage device
CN105549908A (en) * 2015-12-14 2016-05-04 深圳市万拓存储技术有限公司 Method for restoring redundancy for RAID (Redundant Array of Independent Disks) disk array
CN106095342A (en) * 2016-06-15 2016-11-09 华中科技大学 Watt recording disc array construction method and the system of a kind of dynamically changeable long strip
CN107391391A (en) * 2017-07-19 2017-11-24 深圳大普微电子科技有限公司 The method, system and solid state hard disc of data copy are realized in the FTL of solid state hard disc

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744798A (en) * 2013-12-17 2014-04-23 记忆科技(深圳)有限公司 Garbage recycling method of solid state discs
US20160077964A1 (en) * 2014-09-11 2016-03-17 Samsung Electronics Co., Ltd. Storage device and garbage collection method of data storage system having the storage device
CN104794070A (en) * 2015-04-23 2015-07-22 南京道熵信息技术有限公司 Solid-state flash memory write cache system and method based on dynamic non-covering RAID technology
CN105549908A (en) * 2015-12-14 2016-05-04 深圳市万拓存储技术有限公司 Method for restoring redundancy for RAID (Redundant Array of Independent Disks) disk array
CN106095342A (en) * 2016-06-15 2016-11-09 华中科技大学 Watt recording disc array construction method and the system of a kind of dynamically changeable long strip
CN107391391A (en) * 2017-07-19 2017-11-24 深圳大普微电子科技有限公司 The method, system and solid state hard disc of data copy are realized in the FTL of solid state hard disc

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3748509A4 *

Similar Documents

Publication Publication Date Title
US11928053B2 (en) System garbage collection method and method for garbage collection in solid state disk
US9996435B2 (en) Reliability scheme using hybrid SSD/HDD replication with log structured management
US9983993B2 (en) Apparatus, system, and method for conditional and atomic storage operations
US9606914B2 (en) Apparatus, system, and method for allocating storage
US9116622B2 (en) Storage system having nonvolatile semiconductor storage device with nonvolatile semiconductor memory
US10359967B2 (en) Computer system
US20120059978A1 (en) Storage array controller for flash-based storage devices
US10019315B2 (en) Control device for a storage apparatus, system, and method of controlling a storage apparatus
US11321229B2 (en) System controller and system garbage collection method
US20200183831A1 (en) Storage system and system garbage collection method
WO2015162758A1 (en) Storage system
US8862819B2 (en) Log structure array
WO2016056104A1 (en) Storage device and memory control method
US20190243758A1 (en) Storage control device and storage control method
WO2019000982A1 (en) Storage system, solid state disk, and data storage method
EP3798852A1 (en) System controller and system garbage recovery method
US10365846B2 (en) Storage controller, system and method using management information indicating data writing to logical blocks for deduplication and shortened logical volume deletion processing
WO2014147786A1 (en) Storage system and data management method
JP6817340B2 (en) calculator
WO2020052216A1 (en) System garbage collection method and method for collecting garbage in solid state hard disk
WO2018061161A1 (en) Storage apparatus and method for controlling same
Jeremic et al. Enabling TRIM Support in SSD RAIDs
US20190205044A1 (en) Device for restoring lost data due to failure of storage drive

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: 19859851

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020526891

Country of ref document: JP

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2019859851

Country of ref document: EP

Effective date: 20200902

NENP Non-entry into the national phase

Ref country code: DE