CN106681934B - Method and device for recycling garbage of storage device - Google Patents

Method and device for recycling garbage of storage device Download PDF

Info

Publication number
CN106681934B
CN106681934B CN201611199850.4A CN201611199850A CN106681934B CN 106681934 B CN106681934 B CN 106681934B CN 201611199850 A CN201611199850 A CN 201611199850A CN 106681934 B CN106681934 B CN 106681934B
Authority
CN
China
Prior art keywords
garbage collection
data
stripes
data block
data blocks
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201611199850.4A
Other languages
Chinese (zh)
Other versions
CN106681934A (en
Inventor
陈建辉
李挺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201611199850.4A priority Critical patent/CN106681934B/en
Publication of CN106681934A publication Critical patent/CN106681934A/en
Application granted granted Critical
Publication of CN106681934B publication Critical patent/CN106681934B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/21Employing a record carrier using a specific recording technology
    • G06F2212/214Solid state disk
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/26Using a specific storage system architecture
    • G06F2212/261Storage comprising a plurality of storage devices
    • G06F2212/262Storage comprising a plurality of storage devices configured as RAID

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)
  • Memory System (AREA)

Abstract

The invention relates to the technical field of storage, and discloses a method and a system for recovering solid state disk garbage and a solid state disk controller, wherein the method comprises the following steps: receiving a command for performing garbage collection processing on the solid state disk; determining a garbage recovery strip needing garbage recovery processing from a plurality of strips contained in the solid state disk according to the command; determining a garbage collection data block needing garbage collection processing from a plurality of data blocks contained in the garbage collection stripe; writing effective data in the garbage collection data block into data blocks of other strips, and erasing the garbage collection data block to obtain a blank data block; and building the blank data blocks in the garbage collection stripe into a first logic sub-stripe, and carrying out striping management on the first logic sub-stripe. By adopting the scheme, the garbage recovery efficiency of the solid state disk can be improved, and the performance overhead is reduced.

Description

Method and device for recycling garbage of storage device
Technical Field
The invention relates to the technical field of storage, in particular to a method and a system for recovering solid state disk garbage and a solid state disk controller.
Background
The RAID (Redundant Array of Independent Disks) algorithm is a high-performance and high-reliability storage technology, and provides a logical disk for an application terminal or a terminal cluster by combining a series of individual Disks in different ways. Among the advantages of using RAID include: the capacity of the disk is enlarged, and the read-write performance and the data safety of the disk are improved. In particular, RAID technology has been widely used in various applications of data storage, and commonly used RAID technology includes RAID0, RAID1, RAID5, RAID6, RAID10, and the like.
At present, in a solid state disk which processes data by using a RAID algorithm, a garbage collection mechanism mainly uses a data migration technology, that is, a method of moving data in a stripe in which more invalid data exists to other stripes to realize garbage collection. The moving is that the whole stripe is taken as a unit, all effective data in the whole stripe is moved to a new stripe each time, and finally the whole stripe is erased, and the available space of the whole stripe size is obtained through recycling. When the scheme is adopted to recycle garbage of the solid state disk, all effective data in the strip band need to be moved, so that the larger write amplification and performance cost is caused, and the garbage recycling efficiency is lower.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present invention is to provide a method and a system for recovering garbage from a solid state disk, and a solid state disk controller, which are used to improve garbage recovery efficiency and reduce performance overhead of the system.
The invention provides a method for recovering solid state disk garbage, which comprises the following steps:
receiving a command for performing garbage collection processing on the solid state disk;
determining one or more garbage collection strips needing garbage collection processing from the plurality of strips contained in the solid state disk according to the command;
determining one or more garbage collection data blocks needing garbage collection processing from a plurality of data blocks contained in the garbage collection stripe;
writing effective data in the one or more garbage collection data blocks into data blocks of other strips, and erasing the one or more garbage collection data blocks to obtain blank data blocks;
one or more blank data blocks in the same garbage collection stripe are assembled into a first logic sub-stripe, and the first logic sub-stripe is subjected to striping management.
In a first possible implementation manner, after the erasing the one or more garbage collection data blocks to obtain a blank data block, the method further includes:
and constructing other data blocks except one or more blank data blocks contained in the same garbage collection stripe into a second logic sub-stripe, and carrying out striping management on the second logic sub-stripe.
With reference to the first aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner, the determining, from a plurality of stripes included in the solid state disk, a garbage collection stripe that needs to be subjected to garbage collection processing includes:
calculating a first effective data proportion of each strip in a plurality of strips contained in the solid state disk and a weight of the first effective data proportion to obtain a first calculation result;
calculating the erasing times of each strip in a plurality of strips contained in the solid state disk and the weight of the erasing times to obtain a second calculation result;
calculating a sum of the first calculation result and the second calculation result of each of a plurality of stripes included in the solid state disk, and determining the priority of each of the plurality of stripes included in the solid state disk, wherein the priority of the stripe with a large sum is higher than the priority of the stripe with a small sum;
and determining N strips with the lowest priority as the garbage collection strips needing garbage collection processing from a plurality of strips contained in the solid state disk, wherein N is an integer greater than 0.
With reference to the first aspect, or the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, in a third possible implementation manner, the determining, from among a plurality of data blocks included in the garbage collection stripe, a garbage collection data block that needs to be subjected to garbage collection processing includes:
acquiring a second effective data proportion of each data block in a plurality of data blocks contained in the garbage collection stripe;
and when the second effective data proportion of the data blocks contained in the garbage collection stripe is lower than a preset collection threshold, determining the data blocks with the second effective data proportion lower than the preset collection threshold as garbage collection data blocks.
With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner, the obtaining a second valid data proportion of each data block in a plurality of data blocks included in the garbage collection stripe includes:
acquiring the number of valid data pages of each data block based on a valid data page counter preset for each data block in a plurality of data blocks contained in the garbage collection stripe;
and determining the ratio of the effective data page number of each data block to the total data page number of each data block as a second effective data proportion of each data block.
A second aspect of the present invention provides a solid state hard disk controller, comprising:
the receiving module is used for receiving a command for performing garbage collection processing on the solid state disk;
the band determination module is used for determining one or more garbage collection bands needing garbage collection processing from a plurality of bands contained in the solid state disk according to the command;
the data block determining module is used for determining one or more garbage collection data blocks needing garbage collection processing from a plurality of data blocks contained in the garbage collection stripe;
the data block processing module is used for writing effective data in the one or more garbage collection data blocks into data blocks of other strips and erasing the one or more garbage collection data blocks to obtain blank data blocks;
the building module is used for building one or more blank data blocks in the same garbage collection stripe into a first logic sub-stripe and carrying out striping management on the first logic sub-stripe.
In a first possible implementation manner, the building module is further configured to build a second logical sub-stripe from other data blocks besides one or more blank data blocks included in the same garbage collection stripe, and perform striping management on the second logical sub-stripe.
With reference to the second aspect or the first possible implementation manner of the second aspect, in a second possible implementation manner, the stripe determining module is specifically configured to calculate a first valid data proportion and a weight of the first valid data proportion of each of a plurality of stripes included in the solid state disk to obtain a first calculation result; calculating the erasing times of each strip in a plurality of strips contained in the solid state disk and the weight of the erasing times to obtain a second calculation result; calculating a sum of the first calculation result and the second calculation result of each of a plurality of stripes included in the solid state disk, and determining the priority of each of the plurality of stripes included in the solid state disk, wherein the priority of the stripe with a large sum is higher than the priority of the stripe with a small sum; and determining N strips with the lowest priority as the garbage collection strips needing garbage collection processing from a plurality of strips contained in the solid state disk, wherein N is an integer greater than 0. With reference to the second aspect, or the first possible implementation manner of the second aspect, or the second possible implementation manner of the second aspect, in a third possible implementation manner, the data block determination module is specifically configured to obtain a second effective data proportion of each data block in a plurality of data blocks included in the garbage collection stripe; and when the second effective data proportion of the data blocks contained in the garbage collection stripe is lower than a preset collection threshold, determining the data blocks with the second effective data proportion lower than the preset collection threshold as garbage collection data blocks.
With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation manner, the data block determination module is specifically configured to obtain, based on a valid data page counter preset for each of a plurality of data blocks included in the garbage collection stripe, a valid data page number of each data block; and determining the ratio of the effective data page number of each data block to the total data page number of each data block as a second effective data proportion of each data block.
A third aspect of the present invention provides a solid state disk garbage disposal system, including a solid state disk and the solid state disk controller according to the second aspect of the present invention, where the solid state disk controller is configured to control garbage collection processing on the solid state disk.
As can be seen from the above, in the garbage collection method for a solid state disk provided in the embodiment of the present invention, when a command for performing garbage collection processing on a solid state disk is received, at least one garbage collection stripe in the solid state disk and at least one garbage collection data block in the same garbage collection stripe are determined, then data erasing and moving operations are performed on the garbage collection data blocks to obtain at least one blank data block, and a logical sub-stripe is configured for striping management. According to the solid state disk garbage collection method provided by the embodiment of the invention, only the garbage data block needs to be erased, and the striping processing can be carried out, so that compared with the prior art in which the whole stripe is erased, the solid state disk garbage collection method provided by the embodiment of the invention can improve the garbage collection efficiency and reduce the performance overhead of the system.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for recycling garbage from a solid state disk according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of another solid state disk garbage collection method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a solid state hard disk controller according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a solid state disk garbage disposal system according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a specific method for recycling garbage from a solid state disk according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The solid state disk is a storage device constructed by a Flash chip, the solid state disk controller is also a chip, such as an FPGA, an ASIC and the like, and the read-write access or various operations of the solid state disk are controlled by programming the chip in the solid state disk controller. The solid state disk controller and the Flash chip forming the solid state disk can be arranged on a PCB, namely, the solid state disk controller and the Flash chip are presented in a disk or card form and are communicated with a host through an I/O interface. The solid state disk needs to obtain a required space through erasing processing, namely effective data is put in other positions, and the original positions are erased to recover invalid data space, namely a garbage recovery mechanism. The problem to be solved by the embodiment of the invention is how to improve the garbage recovery efficiency and reduce the performance overhead of the system.
Referring to fig. 1, a schematic flow chart of a method for recovering garbage from a solid state disk according to an embodiment of the present invention is shown, where the method according to the embodiment of the present invention can be implemented in the solid state disk controller, and specifically the method includes:
s101, receiving a command for performing garbage collection processing on a solid state disk;
optionally, the received command for performing garbage collection processing on the solid state disk may be a garbage collection processing command sent by a host connected to the local end.
S102, determining one or more garbage collection strips needing garbage collection processing from the plurality of strips contained in the solid state disk according to the command;
the garbage collection stripe is a storage unit which needs to collect invalid data space; the slave solid state disk packageDetermining one or more garbage collection strips needing garbage collection processing from the plurality of strips, wherein the priority P of each strip contained in the solid state disk can be calculatedkTo determine, for example:
Pk=(MXk,NYk),
wherein M represents the effective data proportion weight of the stripe, N represents the erasure number weight of the stripe, and XkRepresenting the effective data proportion of the strip denoted by k, YkThe number of erasures of the strip denoted by k, denoted by MXkAnd NYkDetermining priority P of each stripekAccording to said priority PkTo determine the strip that is preferentially garbage collected as the garbage collection strip.
More specifically, the determining the garbage collection band may include:
calculating a first effective data proportion of each strip in a plurality of strips contained in the solid state disk and a weight of the first effective data proportion to obtain a first calculation result;
calculating the erasing times of each strip in a plurality of strips contained in the solid state disk and the weight of the erasing times to obtain a second calculation result;
calculating a sum of the first calculation result and the second calculation result of each of a plurality of stripes included in the solid state disk, and determining the priority of each of the plurality of stripes included in the solid state disk, wherein the priority of the stripe with a large sum is higher than the priority of the stripe with a small sum;
and determining N strips with the lowest priority as the garbage collection strips needing garbage collection processing from a plurality of strips contained in the solid state disk, wherein N is an integer greater than 0.
S103, determining one or more garbage collection data blocks needing garbage collection processing from the plurality of data blocks contained in the garbage collection stripe;
specifically, the step of determining one or more garbage collection data blocks that need to be garbage collected from the plurality of data blocks included in the garbage collection stripe may include the following steps:
acquiring a second effective data proportion of each data block in a plurality of data blocks contained in the garbage collection stripe;
and when the second effective data proportion of the data blocks contained in the garbage collection stripe is lower than a preset collection threshold, determining the data blocks with the second effective data proportion lower than the preset collection threshold as garbage collection data blocks.
The second effective data proportion can calculate a ratio of the effective data page number to the total data page number of the data block according to the effective data page number recorded by an effective data page counter preset in the data block, and the ratio is used as the second effective data proportion; the preset recovery threshold value can be a fixed value, or a value dynamically adjusted according to a model established at the local terminal, or a value set by a user according to a provided threshold interface, and the recovery threshold value is used for judging the garbage recovery data block in the garbage recovery strip.
S104, writing effective data in the one or more garbage collection data blocks into data blocks of other strips, and erasing the one or more garbage collection data blocks to obtain blank data blocks;
s105, one or more blank data blocks in the same garbage collection stripe are assembled into a first logic sub-stripe, and the first logic sub-stripe is subjected to striping management.
The building of one or more blank data blocks in the same garbage collection stripe into a first logical sub-stripe can be specifically realized by a RAID algorithm, physical addresses of the blank data blocks included in the first logical sub-stripe may be discontinuous, and the first logical sub-stripe can realize the same function as a plurality of stripes included in a solid state disk.
The flexible RAID algorithm specifically means that in a system with a stripe size of n, a RAID (for example, a logical sub-stripe) may be constructed from all n storage units in the stripe, or a RAID may be constructed using n-m (<0m < n-2) storage units, that is, a RAID may be constructed using a part of the storage units, where m may be dynamically adjusted according to available storage units in the current stripe. For example, in the case of a stripe size of 16, a RAID may be constructed using all 16 storage units; when 6 of the storage units are unavailable, 10 storage units can be used to establish RAID.
In addition, after the erasing process is performed on one or more garbage collection data blocks to obtain a blank data block, the method further includes: and constructing other data blocks except one or more blank data blocks contained in the same garbage collection stripe into a second logic sub-stripe, and carrying out striping management on the second logic sub-stripe.
Specifically, the constructing the other data blocks except for one or more blank data blocks included in the same garbage collection stripe into the second logical sub-stripe may include: and constructing a second logic sub-stripe of the data blocks which are not determined as garbage recovery data blocks in the same garbage recovery stripe (namely the data blocks of which the second effective data proportion is greater than the preset recovery threshold value) according to the flexible RAID algorithm, wherein the physical addresses of the data blocks in the same second logic sub-stripe can be discontinuous.
Wherein the striping management of the second logical sub-stripe includes converting the reading and writing of the upper layer (for example, a host) to the second logical sub-stripe into the reading and writing of the physical storage unit of the second logical sub-stripe, allocating various access requests to each physical storage unit according to a RAID algorithm for processing, and returning the processing result to the upper layer.
According to the garbage collection method for the solid state disk, when a command for performing garbage collection processing on the solid state disk is received, at least one garbage collection strip in the solid state disk and at least one garbage collection data block in the at least one garbage collection strip are determined, then data erasing and moving operations are performed on the garbage collection data blocks to obtain at least one blank data block, and a logical sub-strip is constructed for striping management. According to the solid state disk garbage collection method provided by the embodiment of the invention, only the garbage data block needs to be erased, and the striping processing can be carried out, so that compared with the prior art in which the whole stripe is erased, the solid state disk garbage collection method provided by the embodiment of the invention can improve the garbage collection efficiency and reduce the performance overhead of the system.
Referring to fig. 2, a schematic flow chart of another method for garbage collection of a solid state disk according to an embodiment of the present invention is shown, where the method according to the embodiment of the present invention is applicable to a solid state disk controller, and the method includes:
s201, receiving a command for performing garbage collection processing on a solid state disk;
s202, calculating a first effective data proportion of each strip in a plurality of strips contained in the solid state disk and a weight of the first effective data proportion to obtain a first calculation result;
the manner of obtaining the first valid data proportion of each stripe may be: presetting an effective data page counter in each strip of a plurality of strips contained in the solid state disk, when an effective data page is increased, increasing 1 by the effective data page counter, when the effective data page is decreased, decreasing 1 by the effective data page counter, and setting the ratio of the counting result of the effective data page counter to the total data page number in each strip as a first effective data ratio; and obtaining a first calculation result according to the weight of the preset first effective data proportion.
S203, calculating the erasing times of each strip in a plurality of strips contained in the solid state disk and the weight of the erasing times to obtain a second calculation result;
optionally, the number of times of erasing of each stripe may also be obtained by presetting an erasing number counter in the stripe, taking a counting result of the erasing number counter in the stripe as the erasing number of each stripe, and combining a weight of the preset erasing number to obtain a second calculation result.
S204, calculating the sum of the first calculation result and the second calculation result of each of a plurality of strips contained in the solid state disk, and determining the priority of each of the plurality of strips contained in the solid state disk;
wherein the high-sum stripe has a higher priority than the low-sum stripe;
s205, determining N stripes with the lowest priority from the plurality of stripes included in the solid state disk as the garbage collection stripes needing garbage collection processing, wherein N is an integer larger than 0.
S206, acquiring a second effective data proportion of each data block in a plurality of data blocks contained in the garbage collection stripe;
specifically, the obtaining a second valid data proportion of each data block in the plurality of data blocks included in the garbage collection stripe includes: acquiring the number of valid data pages of each data block based on a valid data page counter preset for each data block in a plurality of data blocks contained in the garbage collection stripe; and determining the ratio of the effective data page number of each data block to the total data page number of each data block as a second effective data proportion of each data block.
S207, when the second effective data proportion of the data blocks contained in the garbage collection stripe is lower than a preset collection threshold, determining the data blocks with the second effective data proportion lower than the preset collection threshold as garbage collection data blocks.
The preset recovery threshold value can be set according to parameters set by a user through a provided threshold value interface.
S208, writing the valid data in the one or more garbage collection data blocks into data blocks of other strips, and erasing the one or more garbage collection data blocks to obtain blank data blocks;
wherein the data blocks of the other stripes are stripes containing available space; the empty data block, i.e. the data block, may be re-written into the available data space of the data.
S209, one or more blank data blocks in the same garbage collection stripe are assembled into a first logic sub-stripe, and the first logic sub-stripe is subjected to striping management.
Wherein physical addresses of data blocks in the first logical sub-stripe may be non-contiguous; the striping management comprises the steps of converting the reading and writing of the logic sub-strips/strips by the upper layer into the reading and writing of the physical disk, analyzing the request of the upper layer according to a RAID algorithm, sending the analyzed request to each storage unit, and returning the analyzed request to the upper layer after the processing is finished, namely the management of capacity and reading and writing access.
S210, building other data blocks except one or more blank data blocks contained in the same garbage collection stripe into a second logic sub-stripe, and carrying out striping management on the second logic sub-stripe.
Specifically, the other data blocks except the blank data block refer to data blocks in the garbage collection band, where the effective data proportion is greater than the preset collection threshold, a second logical sub-band is constructed for the data blocks in the garbage collection band, where the effective data proportion is greater than the preset collection threshold, based on a flexible RAID algorithm, and the striping management for the second logical sub-band includes converting read-write of an upper layer (e.g., a host) on the second logical sub-band into read-write of a physical storage unit of the second logical sub-band, allocating various access requests to the physical storage unit according to the RAID algorithm for processing, and returning a processing result to the upper layer, and the like.
Optionally, the effective data proportion of each stripe and the effective data proportion of each data block may establish a mapping table of the stripe, the data block, the effective data proportion and the erasure number, and when the system needs corresponding data, the system may directly obtain the corresponding data from the table, thereby further improving the garbage recovery efficiency.
The method comprises the steps of determining a garbage recovery strip from a solid state disk comprising at least one strip by obtaining an effective data proportion and an erasing frequency of each strip in the solid state disk, carrying out data moving and erasing processing on data blocks with the effective data proportion lower than a recovery threshold value in the garbage recovery strip, and finally respectively establishing a first logic sub-strip and a second logic sub-strip for blank data blocks obtained from the garbage recovery strip and data blocks except the blank data blocks. Compared with the prior art, the embodiment of the invention not only takes the data blocks as garbage recovery units, but also adopts RAID algorithm to construct the logic sub-strips for the obtained blank data blocks, thereby reducing the performance overhead of the solid state disk and improving the space utilization rate of the solid state disk.
Referring to fig. 3, which is a schematic structural diagram of a solid state disk controller according to an embodiment of the present invention, the apparatus according to the embodiment of the present invention includes a receiving module 1, a stripe determining module 2, a data block determining module 3, a data block processing module 4, and a building module 5, specifically:
the receiving module 1 is used for receiving a command for performing garbage collection processing on the solid state disk;
optionally, the received command for performing garbage collection processing on the solid state disk may be a garbage collection processing command sent by a host connected to the local end.
The band determining module 2 is configured to determine, according to the command, one or more garbage collection bands that need to be subjected to garbage collection processing from the multiple bands included in the solid state disk;
the garbage collection stripe is a storage unit which needs to collect invalid data space; the stripe determining module 2 determines one or more garbage collection stripes needing garbage collection processing from the plurality of stripes included in the solid state disk according to the command, and may calculate the priority P of each stripe included in the solid state diskkTo determine, for example:
Pk=(MXk,NYk),
wherein M represents the effective data proportion weight of the stripe, N represents the erasure number weight of the stripe, and XkRepresenting the effective data proportion of the strip denoted by k, YkThe number of erasures of the strip denoted by k, denoted by MXkAnd NYkDetermining priority P of each stripekAccording to said priority PkTo determine the strip that is preferentially garbage collected as the garbage collection strip.
More specifically, the determining the garbage collection strip by the strip determining module 2 may include the following steps:
calculating a first effective data proportion of each strip in a plurality of strips contained in the solid state disk and a weight of the first effective data proportion to obtain a first calculation result;
calculating the erasing times of each strip in a plurality of strips contained in the solid state disk and the weight of the erasing times to obtain a second calculation result;
calculating a sum of the first calculation result and the second calculation result of each of a plurality of stripes included in the solid state disk, and determining the priority of each of the plurality of stripes included in the solid state disk, wherein the priority of the stripe with a large sum is higher than the priority of the stripe with a small sum;
and determining N strips with the lowest priority as the garbage collection strips needing garbage collection processing from a plurality of strips contained in the solid state disk, wherein N is an integer greater than 0.
A data block determining module 3, configured to determine one or more garbage collection data blocks that need to be subjected to garbage collection processing from multiple data blocks included in the garbage collection stripe;
specifically, the determining, by the data block determining module 3, one or more garbage collection data blocks that need to be subjected to garbage collection processing from the plurality of data blocks included in the garbage collection stripe may include the following steps:
acquiring a second effective data proportion of each data block in a plurality of data blocks contained in the garbage collection stripe;
and when the second effective data proportion of the data blocks contained in the garbage collection stripe is lower than a preset collection threshold, determining the data blocks with the second effective data proportion lower than the preset collection threshold as garbage collection data blocks.
The second effective data proportion can calculate a ratio of the effective data page number to the total data page number of the data block according to the effective data page number recorded by an effective data page counter preset in the data block, and the ratio is used as the second effective data proportion; the preset recovery threshold value can be a fixed value, or a value dynamically adjusted according to a model established at the local terminal, or a value set by a user according to a provided threshold interface, and the recovery threshold value is used for judging the garbage recovery data block in the garbage recovery strip.
The data block processing module 4 is configured to write valid data in the one or more garbage collection data blocks into data blocks of other stripes, and erase the one or more garbage collection data blocks to obtain a blank data block;
the building module 5 is configured to build one or more blank data blocks in the same garbage collection stripe into a first logical sub-stripe, and perform striping management on the first logical sub-stripe.
The data block processing module 4 may specifically implement the building of one or more blank data blocks in the same garbage collection stripe into a first logical sub-stripe by using a RAID algorithm, and physical addresses of the blank data blocks included in the first logical sub-stripe may be discontinuous.
The flexible RAID algorithm specifically means that in a system with a stripe size of n, a RAID (for example, a logical sub-stripe) may be constructed from all n storage units in the stripe, or a RAID may be constructed using n-m (<0m < n-2) storage units, that is, a RAID may be constructed using a part of the storage units, where m may be dynamically adjusted according to available storage units in the current stripe. For example, in the case of a stripe size of 16, a RAID may be constructed using all 16 storage units; when 6 of the storage units are unavailable, 10 storage units can be used to establish RAID.
Further, the building module 5 in the solid state hard disk controller is further configured to build a second logical sub-stripe from other data blocks except one or more blank data blocks included in the same garbage collection stripe, and perform striping management on the second logical sub-stripe.
The stripe determining module 2 is specifically configured to calculate a first valid data proportion and a weight of the first valid data proportion of each stripe of a plurality of stripes included in the solid state disk to obtain a first calculation result; calculating the erasing times of each strip in a plurality of strips contained in the solid state disk and the weight of the erasing times to obtain a second calculation result; calculating a sum of the first calculation result and the second calculation result of each of a plurality of stripes included in the solid state disk, and determining the priority of each of the plurality of stripes included in the solid state disk, wherein the priority of the stripe with a large sum is higher than the priority of the stripe with a small sum; and determining N strips with the lowest priority as the garbage collection strips needing garbage collection processing from a plurality of strips contained in the solid state disk, wherein N is an integer greater than 0.
The data block determining module 3 is specifically configured to obtain a second valid data proportion of each data block in the more than one data blocks included in the garbage collection stripe; and when the second effective data proportion of the data blocks contained in the garbage collection stripe is lower than a preset collection threshold, determining the data blocks with the second effective data proportion lower than the preset collection threshold as garbage collection data blocks.
Further, the data block determining module 3 is specifically configured to obtain the number of valid data pages of each data block based on a valid data page counter preset for each data block of the more than one data blocks included in the garbage collection stripe; and determining the ratio of the effective data page number of each data block to the total data page number of each data block as a second effective data proportion of each data block.
When a command for performing garbage collection processing on a solid state disk is received, the solid state disk controller according to the embodiment of the present invention may determine at least one garbage collection stripe in the solid state disk and at least one garbage collection data block in the at least one garbage collection stripe, perform data erasing and moving operations on the garbage collection data block to obtain at least one blank data block, and construct a logical sub-stripe for the blank data block to perform striping management. Compared with the prior art in which the whole stripe is erased, the solid state disk controller provided by the embodiment of the invention can improve the garbage collection efficiency, reduce the performance overhead of the system and improve the processing performance of the solid state disk.
Referring to fig. 4, a solid state disk garbage disposal system provided in an embodiment of the present invention includes a solid state disk and the solid state disk controller in the embodiment of the present invention, where the solid state disk controller is configured to control garbage collection processing on the solid state disk, optionally, the solid state disk includes a plurality of Flash chip sets, supports multiple channels, and each channel may be connected with a plurality of Flash chips (for example, four Flash chips are connected as shown in fig. 4), and operates in an RAID mode.
The solid state disk controller of the embodiment of the invention adopts garbage collection processing aiming at the data blocks for the plurality of Flash chip groups, and respectively constructs the first logic sub-strip and the second logic sub-strip for the blank data blocks recovered from the garbage collection strip and other data blocks except the blank data blocks recovered from the garbage collection strip.
Referring to fig. 5, a schematic diagram of a specific method for garbage collection using a solid state disk according to an embodiment of the present invention is provided, where a premise of the embodiment of the present invention is that each stripe included in the solid state disk is respectively composed of 6 data blocks, and by using the method for determining a garbage collection stripe described in the foregoing embodiment, a stripe n is determined to be a "garbage collection stripe", a stripe m is an available stripe, and a preset collection threshold is 70%.
As shown in fig. 5, the second valid data ratios of data block 1, data block 2, data block 3, data block 4, data block 5, and data block 6 of the stripe n are respectively 100%, 90%, 10% determined by the method of the above embodiment;
according to the method for determining garbage collection data blocks described in the above embodiments,
if the effective data proportion of the data block 1 is 100 percent and is higher than the recovery threshold value of 70 percent, the data block 1 is not subjected to garbage recovery processing;
if the effective data proportion of the data block 2 is 90% and is higher than the recovery threshold value 70%, the data block 2 is not subjected to garbage recovery processing;
if the effective data proportion of the data block 3 is 10% and is lower than the recovery threshold value 70%, performing garbage recovery processing on the data block 3;
if the effective data proportion of the data block 4 is 10% and is lower than the recovery threshold value 70%, performing garbage recovery processing on the data block 4;
if the effective data proportion of the data block 5 is 10% and is lower than the recovery threshold value 70%, performing garbage recovery processing on the data block 5;
if the effective data proportion of the data block 6 is 100 percent and is lower than the recovery threshold value 70 percent, performing garbage recovery processing on the data block 6;
and executing the garbage collection processing, namely moving the valid data of the data block 3, the data block 4, the data block 5 and the data block 6 in the stripe n to the data block 1 in the stripe m, erasing the data of the data block 3, the data block 4, the data block 5 and the data block 6 in the stripe n, and then enabling the stripe n to become available and rewriting the data, namely enabling the total capacity to be 6 data blocks, enabling the number of the data blocks containing the valid data to be 2 and the number of the available data blocks to be 4, writing 40% of the valid data into the data block 1 in the stripe m, and enabling other blocks to be available.
And constructing a second logic sub-stripe by using the data blocks 1 and 2 in the stripe n based on a flexible RAID algorithm, and constructing a first logic sub-stripe by using the data blocks 3, 4, 5 and 6 in the stripe n.
When the garbage collection method of the data blocks in the solid state disk is executed, the amount of moved data is small, the number of erased data blocks is small, and the available space of 3.6 data blocks is newly increased through garbage collection processing, so that the space utilization rate of the solid state disk is improved, the performance overhead is reduced, and the service life of the solid state disk is prolonged.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (16)

1. A method of garbage collection for a storage device, comprising:
receiving a command for performing garbage collection processing on the storage equipment;
determining one or more garbage collection strips needing garbage collection processing from a plurality of strips contained in the storage device according to the command;
determining data blocks which do not need garbage collection processing from a plurality of data blocks contained in the one or more garbage collection stripes;
and constructing the data which does not need to be subjected to garbage collection processing in the one or more garbage collection strips into strips.
2. The method of claim 1, further comprising: and writing valid data in a data block which needs to be subjected to garbage collection processing in a plurality of data blocks contained in the one or more garbage collection stripes into a data block with a free address, and erasing the data block which needs to be subjected to garbage collection processing in the plurality of data blocks contained in the one or more garbage collection stripes.
3. The method of claim 1,
the determining one or more garbage collection strips needing garbage collection processing from the plurality of strips contained in the storage device includes:
calculating a first effective data proportion of each strip in the plurality of strips and a weight of the first effective data proportion to obtain a first calculation result;
calculating the erasing times of each strip in the plurality of strips and the weight of the erasing times to obtain a second calculation result;
calculating a sum of the first calculation result and the second calculation result for each of the plurality of slices, and determining a priority of each of the plurality of slices, wherein a higher-sum slice has a higher priority than a lower-sum slice;
and determining N stripes with the lowest priority levels from the plurality of stripes as the one or more garbage collection stripes needing garbage collection processing, wherein N is an integer larger than 0.
4. The method according to any one of claims 1 to 3,
the determining, from a plurality of data blocks included in the one or more garbage collection stripes, a data block that does not need garbage collection processing includes:
obtaining a second effective data proportion of each data block in a plurality of data blocks contained in the one or more garbage collection stripes;
and determining the data blocks with the second effective data proportion not lower than the preset recovery threshold value in the one or more garbage recovery strips as the data blocks which do not need garbage recovery processing.
5. The method of claim 4, wherein obtaining the second valid data proportion of each of the plurality of data blocks included in the one or more garbage collection stripes comprises:
acquiring the number of valid data pages of each data block in a plurality of data blocks contained in the one or more garbage collection stripes based on a preset valid data page counter of each data block;
and determining the ratio of the effective data page number of each data block to the total data page number of each data block as a second effective data proportion of each data block.
6. A storage device, comprising:
the receiving module is used for receiving a command for performing garbage collection processing on the storage equipment;
the stripe determining module is used for determining one or more garbage collection stripes needing garbage collection processing from a plurality of stripes contained in the storage device according to the command;
a data block determination module, configured to determine, from multiple data blocks included in the one or more garbage collection stripes, a data block that does not need to be subjected to garbage collection processing;
and the building module is used for building the data which does not need to be subjected to garbage collection processing in the one or more garbage collection strips into strips.
7. The storage device according to claim 6, further comprising a data processing module, wherein the data processing module is configured to write valid data in a data block, which needs to be garbage-recycled, of the plurality of data blocks included in the one or more garbage-recycling stripes into a data block with a free address, and erase a data block, which needs to be garbage-recycled, of the plurality of data blocks included in the one or more garbage-recycling stripes.
8. The storage device of claim 6, wherein:
the stripe determining module is specifically configured to calculate a first valid data proportion and a weight of the first valid data proportion of each of the plurality of stripes to obtain a first calculation result, calculate an erasure number and a weight of the erasure number of each of the plurality of stripes to obtain a second calculation result, calculate a sum of the first calculation result and the second calculation result of each of the plurality of stripes, determine a priority of each of the plurality of stripes, and determine N stripes with a lowest priority from the plurality of stripes as the one or more garbage collection stripes that need garbage collection processing; wherein the high-sum slice has a higher priority than the low-sum slice, and N is an integer greater than 0.
9. The storage device according to any one of claims 6 to 8, wherein:
the data block determination module is specifically configured to obtain a second valid data proportion of each data block in multiple data blocks included in the one or more garbage collection stripes, and determine that a data block in the one or more garbage collection stripes, for which the second valid data proportion is not lower than a preset collection threshold, is a data block that does not need garbage collection processing.
10. The storage device of claim 9, wherein:
the data block determination module is specifically configured to obtain a valid data page number of each data block based on a valid data page counter preset for each data block in a plurality of data blocks included in the one or more garbage collection strips, and determine that a ratio of the valid data page number of each data block to a total data page number of each data block is a second valid data ratio of each data block.
11. A storage device comprising a controller and a plurality of stripes;
the controller is configured to receive a command for performing garbage collection processing on the storage device, determine one or more garbage collection stripes that need to be performed with garbage collection processing from the plurality of stripes according to the command, determine data blocks that do not need to be performed with garbage collection processing from a plurality of data blocks included in the one or more garbage collection stripes, and establish the data blocks that do not need to be performed with garbage collection processing from the one or more garbage collection stripes into stripes.
12. The storage device according to claim 11, wherein the controller is specifically configured to write valid data in a data block that needs garbage collection processing among a plurality of data blocks included in the one or more garbage collection stripes to a data block with a free address, and erase a data block that needs garbage collection processing among a plurality of data blocks included in the one or more garbage collection stripes.
13. The storage device according to claim 11, wherein the controller is specifically configured to calculate a first ratio of valid data and a weight of the first ratio of valid data for each of the plurality of stripes to obtain a first calculation result, calculate a number of times of erasure and a weight of the number of times of erasure for each of the plurality of stripes to obtain a second calculation result, calculate a sum of the first calculation result and the second calculation result for each of the plurality of stripes, determine a priority of each of the plurality of stripes, and determine N stripes with lowest priority from the plurality of stripes as the one or more garbage collection stripes that need garbage collection; wherein the high-sum slice has a higher priority than the low-sum slice, and N is an integer greater than 0.
14. The storage device according to any one of claims 11 to 13, wherein the controller is specifically configured to obtain a second valid data proportion of each of a plurality of data blocks included in the one or more garbage collection stripes, and determine a data block of the one or more garbage collection stripes, for which the second valid data proportion is not lower than a preset collection threshold, as a data block that does not need garbage collection processing.
15. The storage device according to claim 14, wherein the controller is specifically configured to obtain a valid data page count of each of a plurality of data blocks included in the one or more garbage collection stripes based on a preset valid data page counter of each of the data blocks, and determine a ratio of the valid data page count of each of the data blocks to a total data page count of each of the data blocks as a second valid data ratio of each of the data blocks.
16. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by hardware, is capable of implementing the method of any one of claims 1 to 5.
CN201611199850.4A 2014-03-19 2014-03-19 Method and device for recycling garbage of storage device Active CN106681934B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611199850.4A CN106681934B (en) 2014-03-19 2014-03-19 Method and device for recycling garbage of storage device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410102438.0A CN103902465B (en) 2014-03-19 2014-03-19 Method and system for recycling solid state disk junk and solid state disk controller
CN201611199850.4A CN106681934B (en) 2014-03-19 2014-03-19 Method and device for recycling garbage of storage device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201410102438.0A Division CN103902465B (en) 2014-03-19 2014-03-19 Method and system for recycling solid state disk junk and solid state disk controller

Publications (2)

Publication Number Publication Date
CN106681934A CN106681934A (en) 2017-05-17
CN106681934B true CN106681934B (en) 2020-09-11

Family

ID=50993799

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201410102438.0A Active CN103902465B (en) 2014-03-19 2014-03-19 Method and system for recycling solid state disk junk and solid state disk controller
CN201611199850.4A Active CN106681934B (en) 2014-03-19 2014-03-19 Method and device for recycling garbage of storage device

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN201410102438.0A Active CN103902465B (en) 2014-03-19 2014-03-19 Method and system for recycling solid state disk junk and solid state disk controller

Country Status (1)

Country Link
CN (2) CN103902465B (en)

Families Citing this family (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8327185B1 (en) 2012-03-23 2012-12-04 DSSD, Inc. Method and system for multi-dimensional raid
CN105373487B (en) * 2015-12-16 2018-06-08 浪潮(北京)电子信息产业有限公司 The scrap cleaning method and system of a kind of storage program area
US10185658B2 (en) * 2016-02-23 2019-01-22 Sandisk Technologies Llc Efficient implementation of optimized host-based garbage collection strategies using xcopy and multiple logical stripes
CN105892939A (en) * 2016-03-28 2016-08-24 联想(北京)有限公司 Information processing method and electronic equipment
US10127113B1 (en) * 2016-03-31 2018-11-13 EMC IP Holding Company LLC Method and system for checkerboard RAID
EP3336706B1 (en) * 2016-04-07 2021-06-30 Huawei Technologies Co., Ltd. Method and storage device for processing stripes in storage device
CN107463333B (en) * 2016-06-03 2019-12-20 杭州海康威视数字技术股份有限公司 Method, device and system for recovering network hard disk space
CN106339324B (en) * 2016-08-19 2019-05-10 浪潮(北京)电子信息产业有限公司 A kind of method and device selecting garbage reclamation block
BR112017019425B1 (en) * 2016-11-11 2023-01-24 Huawei Technologies Co., Ltd STORAGE SYSTEM AND WASTE SYSTEM COLLECTION METHOD
CN106648469B (en) * 2016-12-29 2020-01-17 华为技术有限公司 Cache data processing method and device and storage controller
US10614019B2 (en) 2017-04-28 2020-04-07 EMC IP Holding Company LLC Method and system for fast ordered writes with target collaboration
US10339062B2 (en) 2017-04-28 2019-07-02 EMC IP Holding Company LLC Method and system for writing data to and read data from persistent storage
CN107544754B (en) * 2017-07-28 2021-05-25 新华三信息技术有限公司 Garbage recovery method and device
CN107632940A (en) * 2017-08-11 2018-01-26 记忆科技(深圳)有限公司 A kind of solid state hard disc RAID rubbish recovering methods
CN109426436B (en) * 2017-08-28 2024-04-12 北京忆恒创源科技股份有限公司 Variable large block-based garbage recycling method and device
WO2019062231A1 (en) * 2017-09-27 2019-04-04 北京忆恒创源科技有限公司 Garbage collection method and storage device
CN108132891A (en) * 2017-12-29 2018-06-08 北京联想核芯科技有限公司 A kind of data processing method and device of SSD hard disks
CN109496300B (en) * 2018-03-23 2021-11-19 华为技术有限公司 Storage medium garbage collection method, storage medium and program product
WO2020007030A1 (en) 2018-07-06 2020-01-09 华为技术有限公司 System controller and system garbage recovery method
CN109814805B (en) * 2018-12-25 2020-08-25 华为技术有限公司 Stripe reorganization method in storage system and stripe server
CN113490922B (en) * 2019-02-27 2023-07-18 华为技术有限公司 Write amplification optimization method for solid state disk
CN112764662B (en) * 2019-10-21 2024-04-19 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for storage management
CN111078137B (en) * 2019-11-07 2021-07-06 深圳市金泰克半导体有限公司 Method for cleaning storage space
CN113625959B (en) * 2021-06-30 2023-12-29 济南浪潮数据技术有限公司 Data processing method and device
CN114911631B (en) * 2022-07-18 2022-10-21 深圳市泛联信息科技有限公司 Global resource management method and system based on persistent memory technology

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130262920A1 (en) * 2012-04-02 2013-10-03 Samsung Electronics Co., Ltd. Raid memory system
CN103488583A (en) * 2013-09-09 2014-01-01 华中科技大学 High-performance reliable solid-state disk realizing method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8266501B2 (en) * 2009-09-29 2012-09-11 Micron Technology, Inc. Stripe based memory operation
EP2467783B1 (en) * 2009-10-09 2020-05-27 Violin Systems LLC Memory system with multiple striping of raid groups and method for performing the same

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130262920A1 (en) * 2012-04-02 2013-10-03 Samsung Electronics Co., Ltd. Raid memory system
CN103488583A (en) * 2013-09-09 2014-01-01 华中科技大学 High-performance reliable solid-state disk realizing method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Improving SSD reliability with RAID via Elastic Striping and Anywhere Parity;Jaeho Kim;Jongmin Lee;Jongmoo Choi;Donghee Lee;Sam H. Noh;《International Conference on Dependable Systems and Networks (DSN)》;20130808;全文 *

Also Published As

Publication number Publication date
CN103902465B (en) 2017-02-08
CN106681934A (en) 2017-05-17
CN103902465A (en) 2014-07-02

Similar Documents

Publication Publication Date Title
CN106681934B (en) Method and device for recycling garbage of storage device
US10303600B2 (en) Method and storage device for collecting garbage data
KR101937521B1 (en) Dynamic overprovisioning for data storage systems
CN107484427B (en) Method for processing stripes in a storage device and storage device
CN109656486B (en) Configuration method of solid state disk, data storage method, solid state disk and storage controller
CN109086219B (en) De-allocation command processing method and storage device thereof
US20200183831A1 (en) Storage system and system garbage collection method
KR20130076429A (en) Method for managing storage space in memory device and storage device using method thereof
US10203899B2 (en) Method for writing data into flash memory apparatus, flash memory apparatus, and storage system
CN113490922B (en) Write amplification optimization method for solid state disk
CN104461387A (en) Method for improving reading property of solid-state hard disk for no mapping region
CN103995855A (en) Method and device for storing data
US11210005B2 (en) Unbalanced plane management method, associated data storage device and controller thereof
US20140281132A1 (en) Method and system for ram cache coalescing
CN115756312A (en) Data access system, data access method, and storage medium
US9298610B2 (en) Data writing method, memory control circuit unit and memory storage apparatus
KR101626218B1 (en) Block based page mapping method
CN103645995B (en) Write the method and device of data
CN110688323A (en) System controller and system garbage recycling method
CN117234434B (en) Operation control method and device of storage device
CN110955609B (en) Evolved automatic flow tracking (EAST) for multi-flow, open channel storage devices
CN116974481A (en) Idle physical block water line adjusting method and storage device
Rahiman et al. Cleaning Process with Efficient Allocation Scheme Improves Flash Memory Performance.
JP2013156974A (en) Memory block allocation device and method taking into account file attributes

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant