Patent Description:
A redundant array of independent disks (Redundant Array of Independent Disks, RAID) is a technology of combining multiple independent hard disks (physical hard disks) in different manners into a hard disk group (a logical hard disk). The RAID can provide higher storage performance and data backup performance than a single hard disk. Data in the RAID is distributed in a stripe (Stripe) form. A stripe may be understood as a group of location-related chunks in two or more partitions in the hard disk array. The chunk may also be referred to as a stripe unit (Stripe Unit, SU), that is, the stripe includes multiple stripe units. One stripe includes a stripe unit used to store data and a stripe unit used to store parity data of the data.

In a RAID including solid state disks (Solid State Disk, SSD), when data in a stripe needs to be modified, a redirect on write (Redirect On Write, ROW) manner is usually used, that is, new data is written to a new idle address, and correspondingly, data at an original address becomes invalid data. When an invalid data amount in the stripe reaches a specific threshold, garbage collection (Garbage Collection, GC) on the stripe is triggered.

In conventional technologies, when garbage collection is performed on a stripe, all valid data in the stripe first needs to be migrated to another idle stripe, and then the stripe is reclaimed. This leads to a large data migration amount, that is, increases write operations on a storage device, and causes relatively high performance overheads.

<CIT> discloses a method and system for service-aware parity placement in a storage system, including after receiving the service notification specifying a target SD. The method comprises: writing a RAID stripe to the persistent storage, where the parity block of the RAID stripe is stored on the target SD and none of the data blocks in the RAID stripe are stored on the target SD. The method further includes performing a modified garbage collection operation that includes identifying a live RAID stripe in the persistent storage, writing a new RAID stripe to a new location in the persistent storage, where the new RAID stripe includes a copy of at least a portion of data from the live RAID stripe and a parity block in the new RAID stripe is stored on the target SD, and issuing a removal notification when the modified garbage collection operation is completed.

Embodiments of the present invention provide a method for processing a stripe in a storage device and a storage device, so as to effectively reduce a data migration amount in a scenario of performing garbage collection on a stripe, thereby reducing write operations and lowering performance overheads. Advantageous features are defined in the dependent claims.

A first aspect provides a method for processing a stripe in a storage device, where the method includes:.

In this application, in a scenario of performing garbage collection on a stripe, the stripe units that are in the at least two stripes and do not require garbage collection are constructed into the new stripe, and garbage collection processing is not performed on the new stripe. Correspondingly, there is no data migration operation. Therefore, in the scenario of performing garbage collection on a stripe, according to this application, a data migration amount can be effectively reduced, thereby reducing write operations on the storage device, and lowering performance overheads of the storage device.

In addition, in this application, parity data of data in the stripe units that are in the at least two stripes and do not require garbage collection is written to the first idle stripe unit, so that the first stripe unit and the stripe units not requiring garbage collection are constructed into the new stripe, instead of performing a large quantity of extra write operations to migrate data in the original stripe units to an idle stripe unit to construct the new stripe. Therefore, storage space utilization of the storage device can be improved to some extent.

In the foregoing implementation, the stripe unit not requiring garbage collection is a stripe unit whose invalid data amount is less than a first preset threshold in the stripe; correspondingly, the stripe unit requiring garbage collection is a stripe unit whose invalid data amount is greater than or equal to the first preset threshold in the stripe. Alternatively, the stripe unit not requiring garbage collection may be a stripe unit whose valid data amount is greater than a second preset threshold in the stripe; correspondingly, the stripe unit requiring garbage collection is a stripe unit whose valid data amount is less than or equal to the second preset threshold in the stripe. It should be understood that, different stripes may have same or different preset thresholds (the first preset threshold or the second preset threshold) used to determine whether a stripe unit requires garbage collection. The invalid data amount used to determine whether a stripe unit requires garbage collection may indicate a proportion of a size of invalid data in the stripe unit to a size of all data in the stripe unit, or may directly indicate the size of the invalid data in the stripe unit. The valid data amount used to determine whether a stripe unit requires garbage collection may indicate a proportion of a size of valid data in the stripe unit to a size of all data in the stripe unit, or may directly indicate the size of the valid data in the stripe unit.

In the foregoing implementations, the garbage collection condition means a condition that a stripe in the storage device needs to satisfy when garbage collection is performed on the stripe. Specifically, the garbage collection condition may mean that an invalid data amount in a stripe reaches a garbage collection threshold, or the garbage collection condition may mean that one or more stripe units in a stripe become abnormal, for example, there is a lack of a corresponding physical hard disk data block.

It should be understood that, when the garbage collection condition is that one or more stripe units in a stripe become abnormal, the stripe unit requiring garbage collection is an abnormal stripe unit, and the stripe unit not requiring garbage collection is a normal stripe unit.

With reference to the first aspect, in a first possible implementation of the first aspect, the method further includes:.

In this application, for the stripe unit requiring garbage collection, when the stripe unit includes valid data, the valid data is first migrated to an idle stripe unit, and then the stripe unit is reclaimed; when the stripe unit includes no valid data, the stripe unit can be directly reclaimed.

With reference to the first aspect or the first possible implementation of the first aspect, in a second possible implementation of the first aspect, a size of the new stripe is the same as a size of each of the at least two stripes; or a size of the new stripe is the same as a size of at least one of the at least two stripes; or a size of the new stripe is different from a size of each of the at least two stripes.

With reference to the first aspect or the first or second possible implementation of the first aspect, in a third possible implementation of the first aspect, the new stripe is a stripe generated by using a redundant array of independent disks RAID technology.

With reference to the first aspect or the first or second possible implementation of the first aspect, in a fourth possible implementation of the first aspect, the new stripe is a stripe generated by using an erasure coding technology.

With reference to the first possible implementation of the first aspect, in a fifth possible implementation of the first aspect, the method further includes:
releasing a mapping relationship between a logical unit number LUN and the stripe unit requiring garbage collection.

It should be understood that, when the stripe unit requiring garbage collection includes valid data, the method further includes:
establishing a mapping relationship between the LUN and the second stripe unit.

A second aspect provides a storage device, where the storage device is configured to perform the method in the first aspect or any possible implementation of the first aspect.

Specifically, the storage device may include modules configured to perform the method in the first aspect or any possible implementation of the first aspect.

A third aspect provides a storage device, where the storage device includes a controller and multiple stripes, and the controller is configured to:.

With reference to the third aspect, in a first possible implementation of the third aspect, the controller is further configured to: when the stripe unit requiring garbage collection includes valid data, migrate the valid data in the stripe unit requiring garbage collection to a second idle stripe unit in the storage device, erase data in the stripe unit requiring garbage collection, and reclaim the stripe unit requiring garbage collection; and
when the stripe unit requiring garbage collection includes no valid data, erase data in the stripe unit requiring garbage collection, and reclaim the stripe unit requiring garbage collection.

Specifically, in implementations of the third aspect, the controller specifically includes a processor and a memory, and the processor executes a computer instruction in the memory to implement the implementations (operations) of the third aspect. A person skilled in the art may know that, another implementation may also implement the implementations (operations) of the controller in the embodiments of the present invention. For example, a field-programmable gate array (Field Programmable Gate Array, FPGA) or other hardware is used to perform all the implementations (operations) of the controller in the embodiments of the present invention, or the processor and an FPGA or other hardware separately perform some implementations (operations) of the controller in the embodiments of the present invention, to implement the implementations (operations) of the controller described in the embodiments of the present invention.

In the implementations of the third aspect, a stripe is a result of striping management on storage space in the storage device by the controller.

Correspondingly, a fourth aspect provides a non-volatile storage medium, where the non-volatile storage medium stores a computer instruction, and the processor in the implementations of the third aspect executes the computer instruction, to implement the implementations (operations) of the third aspect.

Based on the foregoing implementations, in this application, in a scenario of performing garbage collection on a stripe, the stripe units that are in the at least two stripes and do not require garbage collection are constructed into the new stripe, and garbage collection processing is not performed on the new stripe. Correspondingly, there is no data migration operation. Therefore, in the scenario of performing garbage collection on a stripe, according to this application, a data migration amount can be effectively reduced, thereby reducing write operations on the storage device, and lowering performance overheads of the storage device.

To describe the technical solutions in the embodiments of the present invention more clearly, the following briefly describes the accompanying drawings required for describing the embodiments or the prior art.

The following clearly describes the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention.

A method for processing a stripe (Stripe) in a storage device provided in the embodiments of the present invention may be applied to a storage device that performs stripe-based management, for example, a storage array including solid state disks (Solid State Disk, SSD), or an SSD, or a storage array including shingled magnetic recording (Shingled Magneting Recording, SMR) disks.

Striping is a method for combining multiple hard disks (or multiple storage media in a single disk) into one volume. A stripe may be understood as a group of location-related chunks in two or more partitions in a hard disk array (or a hard disk). The chunk may also be referred to as an SU, that is, the stripe includes multiple SUs. The stripe is a result of striping management on storage space. For details, refer to an understanding of the stripe by a person skilled in the art. Each SU corresponds to a block (Block) in a hard disk. For example, as shown in <FIG>, a stripe <NUM> includes three SUs, and the three SUs respectively correspond to a data block (Block) in a hard disk a, a data block in a hard disk b, and a parity data block in a hard disk that are in a row denoted by <NUM> in <FIG>. A stripe <NUM> includes three SUs, and the three SUs respectively correspond to a data block in the hard disk a, a parity data block in the hard disk b, and a data block in the hard disk c that are in a row denoted by <NUM> in <FIG>. A stripe <NUM> includes three SUs, and the three SUs respectively correspond to a data block in the hard disk a, a data block in the hard disk b, and a parity data block in the hard disk c that are in a row denoted by <NUM> in <FIG>.

The stripe <NUM> includes three SUs, and the three SUs respectively correspond to a parity data block in the hard disk a, a data block in the hard disk b, and a data block in the hard disk c that are in a row denoted by <NUM> in <FIG>.

Storage device shown in <FIG> is, for example, an SSD storage array. For example, the hard disks a, b, and c shown in <FIG> are all SSDs. For ease of understanding and description, the following is described by using an example in which the embodiments of the present invention are applied to an SSD-based storage device. However, according to instructions in the embodiments of the present invention, a person skilled in the art may clearly understand that, the method in the embodiments of the present invention may also be applied to another storage device that performs stripe-based management, and such applications all fall within the protection scope of the present invention.

The SSD is a new storage system that uses a flash memory as a storage medium. The flash memory does not have a mechanical part like a magnetic head, and has equivalent overheads in a random access mode and a sequential access mode. Therefore, the SSD has a large performance advantage over a conventional hard disk. The flash memory has to be erased before being written. For example, when data in the flash memory needs to be updated, before an old value of the data is erased, a new value of the data cannot be written to a physical address at which the old value of the data is located, that is, the old value of the data needs to be erased first, and the new value of the data can be then written to the physical address at which the old value of the data is located. However, the flash memory has another characteristic: A page is used as a unit for read and write operations, and a block (including multiple pages) is used as a unit for an erase operation. In other words, when the new value of the data needs to be written to the physical address at which the old value of the data is located, data in an entire block (usually <NUM> or <NUM>) in which the old value of the data is located needs to be erased, and the new value of the data can be then written to the block that is in an erased state. However, first, block erasure is much costly, because although a block in the flash memory can be erased repeatedly, each block has a limited quantity of erasing times, and a service life of the flash memory is calculated according to the quantity of erasing times. For example, a multi-level cell (Multi-Level Cell, MLC) flash memory generally has a service life of <NUM>,<NUM> to <NUM>,<NUM> times, and a single-level cell (Single-Level Cell, SLC) flash memory has a service life of about <NUM>,<NUM> times. Second, when a to-be-erased block further includes valid data, before the block is erased, the valid data first needs to be read and then written to a new block address. Such a process is referred to as data migration. Data migration causes write amplification (Write amplification, WA), that is, an amount of data actually written is greater than an amount of data that needs to be written to the SSD. Write amplification is an unwanted phenomenon. To resolve the foregoing problems, in the prior art, a redirect-on-write (Redirect On Write, ROW) manner is usually used, that is, in a case of data overwriting, to-be-written data is redirected and written to a new idle address, and correspondingly, data at an original address becomes invalid data.

As shown in <FIG>, a storage array including SSDs has a controller and SSDs (it is assumed that hard disks shown in <FIG> are all SSDs) connected to the controller. The controller is configured to divide the SSDs into multiple stripes (for example, the stripe <NUM>, the stripe <NUM>, the stripe <NUM>, and the stripe <NUM> shown in <FIG>), and then provide logical unit numbers (Logic Unit Number, LUN) for a host by using the stripes. The LUN may be considered as a logical hard disk accessible to the host, may also be referred to as a logical space unit, and is also space in which a user can read and write. As shown in <FIG>, one stripe includes multiple SUs, and each SU corresponds to a block (Block). It should be understood that, when the host performs a write operation in the LUN, corresponding data is written to an SU, and is correspondingly written to a corresponding block. When garbage collection is performed on the stripe, a corresponding block is also reclaimed, that is, the corresponding block is erased, and storage space of the block is released. Specifically, the controller shown in <FIG> is, for example, a RAID controller, and the stripe <NUM>, the stripe <NUM>, the stripe <NUM>, and the stripe <NUM> shown in <FIG> are all stripes constructed based on a RAID technology.

<FIG> is a schematic diagram of a garbage collection method for a storage device according to an embodiment of the present invention.

Determine two stripes: a stripe <NUM> and a stripe <NUM> in the storage device that satisfy a garbage collection condition. The stripe <NUM> and the stripe <NUM> each include an SU (for example, an SU <NUM> and an SU <NUM> in the stripe <NUM>, and an SU <NUM> and an SU <NUM> in the stripe <NUM>) requiring garbage collection and an SU (for example, an SU <NUM> and an SU <NUM> in the stripe <NUM>, and an SU <NUM> and an SU <NUM> in the stripe <NUM>) not requiring garbage collection.

Specifically, for example, invalid data is generated in the stripe <NUM> and the stripe <NUM> due to a data overwriting operation. For example, a user needs to update data stored in the SU <NUM> of the stripe <NUM>, and writes updated data of the data stored in the SU <NUM> to another blank address; as a result, the data stored in the SU <NUM> becomes invalid data. When an invalid data amount in each of the stripe <NUM> and the stripe <NUM> reaches a garbage collection threshold, a garbage collection operation on the stripe <NUM> and the stripe <NUM> is triggered. As shown in <FIG>, invalid data amounts of the SUs in the stripe <NUM> and the stripe <NUM> are unbalanced, the SU <NUM> and the SU <NUM> in the stripe <NUM> are determined as SUs requiring garbage collection, the SU <NUM> and the SU <NUM> in the stripe <NUM> are determined as SUs not requiring garbage collection, the SU <NUM> and the SU <NUM> in the stripe <NUM> are determined as SUs requiring garbage collection, and the SU <NUM> and the SU <NUM> in the stripe <NUM> are determined as SUs not requiring garbage collection.

Construct the SU <NUM> and the SU <NUM> in the stripe <NUM> that do not require garbage collection and the SU <NUM> and the SU <NUM> in the stripe <NUM> that do not require garbage collection into a new stripe (for example, a stripe <NUM> shown in <FIG>).

Specifically, parity data of data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> is computed, and the parity data is stored into an idle SU (the SU storing the parity data is not shown in <FIG>), so that the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> together with the SU storing the parity data are constructed into the new stripe stripe <NUM> (the stripe unit, storing the parity data, in the stripe <NUM> is not shown in <FIG>).

Optionally, in this embodiment of the present invention, the constructed new stripe (the stripe <NUM>) is a stripe generated by using a RAID technology or an erasure coding (Erasure Coding, EC) technology.

It should be understood that the stripe generated by using the RAID technology means that an SU storing data and an SU storing parity data in the stripe conform to a particular RAID level relationship, for example, a RAID <NUM>, a RAID <NUM>, or a RAID <NUM> is formed. The stripe generated by using the EC technology means that the parity data stored in the stripe is obtained by computing data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> by using a particular EC algorithm, so that the SU storing the parity data, the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> are constructed into the new stripe.

Migrate valid data in the SU <NUM>, requiring garbage collection, in the stripe <NUM> to an idle stripe (for example, a stripe <NUM> shown in <FIG>). It should be understood that the idle stripe may be a stripe not written with data, or may be a stripe not fully written with data.

Erase data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>, and then release storage space of the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>, that is, reclaim the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>.

Therefore, in this embodiment of the present invention, in a scenario of performing garbage collection on a stripe, the stripe units that are in the at least two stripes and do not require garbage collection are constructed into the new stripe, and the new stripe is not reclaimed, so that a data migration amount can be reduced, thereby reducing write operations on the storage device, and lowering performance overheads of the storage device. In addition, parity data of data in the stripe units that are in the at least two stripes and do not require garbage collection is written to a first idle stripe unit, so that the first stripe unit and the stripe units not requiring garbage collection are constructed into the new stripe, instead of performing a large quantity of extra write operations to migrate data in the original stripe units to an idle stripe unit to construct the new stripe. Therefore, storage space utilization of the storage device can be improved to some extent.

Specifically, in S21, the stripe <NUM> and the stripe <NUM> in the storage device that satisfy the garbage collection condition are determined. The garbage collection condition may mean that an invalid data amount in a stripe reaches a garbage collection threshold. For example, when a proportion of an invalid data amount in the stripe <NUM> shown in <FIG> in a total data amount in the stripe <NUM> reaches <NUM>% (it is assumed that the garbage collection threshold is <NUM>%), garbage collection processing on the stripe <NUM> is triggered.

When the garbage collection condition is that an invalid data amount in a stripe reaches a garbage collection threshold, an SU requiring garbage collection is an SU whose invalid data amount is greater than or equal to the preset threshold in the stripe; and an SU not requiring garbage collection is an SU whose invalid data amount is less than the preset threshold in the stripe. Different stripes may have same or different preset thresholds used to determine whether an SU requires garbage collection.

Optionally, the garbage collection condition may mean that one or more stripe units in a stripe become abnormal, for example, there is a lack of a corresponding physical hard disk data block. When a disk in which a block corresponding to an SU in a stripe is located is faulty, or a block corresponding to an SU in a stripe is unavailable, this stripe satisfies the garbage collection condition, and requires garbage collection.

When the garbage collection condition indicates that one or more stripe units in a stripe become abnormal, an SU requiring garbage collection is the abnormal SU, and an SU not requiring garbage collection is a normal SU.

Therefore, in this embodiment of the present invention, only the abnormal stripe unit in the stripe is reclaimed, and the normal stripe unit in the stripe and a normal stripe unit in another stripe are constructed into a new stripe, so that a data migration amount is reduced, thereby effectively reducing write operations on the storage device, and lowering performance overheads of the storage device.

In S22, the SU <NUM> and the SU <NUM>, not requiring garbage collection, in the stripe <NUM>, and the SU <NUM> and the SU <NUM>, not requiring garbage collection, in the stripe <NUM> are constructed into the new stripe (for example, the stripe <NUM> shown in <FIG>). Optionally, in this embodiment of the present invention, a size of the new stripe is the same as a size of the stripe <NUM> or the stripe <NUM>; or a size of the new stripe is the same as a size of one of the stripe <NUM> and the stripe <NUM>; or a size of the new stripe is different from a size of each of the stripe <NUM> and the stripe <NUM>.

It should be understood that a size of a stripe is a sum of capacities of data that can be written by an array (for example, a RAID shown in <FIG>) to a group of parallel hard disks.

It should be understood that steps S23 and S24 may be collectively referred to as a process of performing garbage collection on a stripe unit requiring garbage collection.

Optionally, in this embodiment of the present invention, when the stripe unit requiring garbage collection includes valid data, the valid data in the stripe unit requiring garbage collection is migrated to a second idle stripe unit in the storage device, data in the stripe unit requiring garbage collection is erased, and the stripe unit requiring garbage collection is reclaimed; or
when the stripe unit requiring garbage collection includes no valid data, data in the stripe unit requiring garbage collection is erased, and the stripe unit requiring garbage collection is reclaimed.

Specifically, for example, in a scenario shown in <FIG>, because the SU <NUM>, requiring garbage collection, in the stripe <NUM> includes valid data, before the SU <NUM> is reclaimed, the valid data in the SU <NUM> first needs to be migrated to another idle stripe (for example, the stripe3 shown in <FIG>), and the SU <NUM> can be then reclaimed, that is, data in the SU <NUM> is erased, and storage space corresponding to the SU <NUM> is released. The SU <NUM>, requiring garbage collection, in the stripe <NUM>, and the SU <NUM> and the SU <NUM>, requiring garbage collection, in the stripe <NUM> include no valid data, and all data is invalid data. Therefore, the SU <NUM>, the SU <NUM>, and the SU <NUM> can be directly reclaimed. That is, data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> is erased, and storage space corresponding to the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> is released. In other words, for the SU <NUM> requiring garbage collection, both steps S23 and S24 need to be performed; however, for the SU <NUM>, the SU <NUM>, and the SU <NUM> requiring garbage collection, S23 does not need to be performed, and S24 is directly performed.

Optionally, in S23, valid data in an SU, whose invalid data amount is greater than a first threshold, in the stripe <NUM> and the stripe <NUM> is migrated to an idle SU. The idle SU may be an SU not written with data, or may be an SU not full written with data.

Optionally, in this embodiment of the present invention, a valid data amount and an invalid data amount in an SU may be determined according to a bitmap of the SU, so as to determine whether the SU requires garbage collection. It should be understood that the bitmap of the SU is used to identify which data in the SU is valid. For example, if the SU has a space size of <NUM>, and a minimum management granularity of the SU (that is, a data address granularity of the SU) is <NUM>, the bitmap of the SU includes <NUM>/<NUM>=<NUM> bits. For example, a bit corresponding to invalid data is set to "<NUM>", and a bit corresponding to valid data is set to "<NUM>". In this way, which data in the SU is valid and which data in the SU is invalid can be distinguished by using bit information in the bitmap of the SU, and the valid data amount and the invalid data amount in the SU can be determined.

Specifically, in S22, according to a disk ID bound to an ID of the SU <NUM> in the stripe <NUM>, the ID of the SU <NUM> is added to a linked list of a disk corresponding to the disk ID, and a similar action is performed for each to-be-reconstructed stripe unit. A disk ID bound to an ID of the SU storing the parity data of the data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM> is added to a linked list corresponding to the disk ID. A new stripe ID (that is, the stripe <NUM>) is allocated to the SU <NUM>, the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU that stores the parity data of the data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>, and a binding relationship between the new stripe ID and SU IDs in these linked lists of different disks is established.

It should be understood that a size of a stripe is a quantity of SUs included in the stripe, and may be a fixed value, or may be a variable in accordance with a policy of the storage device. For example, for a stripe generated by using the RAID technology, the stripe may include different quantities of SUs according to different RAID levels.

It should be further understood that, when a LUN includes the stripe <NUM> and the stripe <NUM>, after the storage device performs migration processing and reconstruction processing, the storage device releases a previous mapping relationship between the LUN and each of the SU <NUM> and the SU <NUM> in the stripe <NUM> and the SU <NUM> and the SU <NUM> in the stripe <NUM>, and establishes a mapping between the LUN and the SU that stores the parity data of the data in the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>.

It should be further understood that, after the storage device performs garbage collection on the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>, new data can be written to the SU <NUM>, the SU <NUM>, the SU <NUM>, and the SU <NUM>.

Therefore, in this embodiment of the present invention, in a scenario of performing garbage collection on a stripe, the stripe units, not requiring garbage collection, in the at least two stripes are constructed into the new stripe, instead of migrating valid data in each stripe unit in the stripes, so that data migration is reduced, and performance overheads of the storage device are lowered. In addition, parity data of data in the stripe units that are in the at least two stripes and do not require garbage collection is written to the first idle stripe unit, so that the first stripe unit and the stripe units not requiring garbage collection are constructed into the new stripe, instead of performing a large quantity of extra write operations to migrate data in the original stripe units to an idle stripe unit to construct the new stripe. Therefore, storage space utilization of the storage device can be improved to some extent. <FIG> shows a case in which two stripes satisfying the garbage collection condition are processed. This embodiment of the present invention is not limited thereto. For example, three or more stripes satisfying the garbage collection condition may be processed by using the method provided in this embodiment of the present invention.

With reference to <FIG>, a redirect-on-write storage system is used above as an example to describe the method for processing a stripe in a storage device provided in this embodiment of the present invention. It should be understood that the application scope of the method for processing a stripe in a storage device provided in this embodiment of the present invention is not limited only to a scenario in which invalid data is caused due to redirect-on-write. The method for processing a stripe in a storage device provided in this embodiment of the present invention can be applied, provided that invalid data is produced in a stripe and requires garbage collection.

<FIG> is a schematic block diagram of a storage device <NUM> according to an embodiment of the present invention. The storage device <NUM> includes:.

Therefore, in this embodiment of the present invention, in this application, in a scenario of performing garbage collection on a stripe, the stripe units that are in the at least two stripes and do not require garbage collection are constructed into the new stripe, and garbage collection processing is not performed on the new stripe. Correspondingly, there is no data migration operation. Therefore, in the scenario of performing garbage collection on a stripe, according to this application, a data migration amount can be effectively reduced, thereby reducing write operations on the storage device, and lowering performance overheads of the storage device.

In this embodiment of the present invention, the device <NUM> further includes:
a stripe reclaiming module <NUM>, configured to: when the stripe unit requiring garbage collection includes valid data, migrate the valid data in the stripe unit requiring garbage collection to a second idle stripe unit in the storage device, and reclaim the stripe unit requiring garbage collection.

The stripe reclaiming module <NUM> is further configured to: when the stripe unit requiring garbage collection includes no valid data, reclaim the stripe unit requiring garbage collection.

In this embodiment of the present invention, for the stripe unit requiring garbage collection, when the stripe unit includes valid data, the valid data is first migrated to an idle stripe unit, and then the stripe unit requiring garbage collection is reclaimed; when the stripe unit includes no valid data, the stripe unit can be directly reclaimed.

Optionally, in this embodiment of the present invention, the new stripe is a stripe generated by using a redundant array of hard disks RAID technology.

Optionally, in this embodiment of the present invention, the new stripe is a stripe generated by using an erasure coding technology.

It should be understood that the foregoing and other operations and/or functions of the modules in the device <NUM> for processing invalid data according to this embodiment of the present invention are separately used to implement corresponding procedures of the method shown in <FIG>. For brevity, details are not described herein again.

As shown in <FIG>, an embodiment of the present invention further provides a storage device <NUM>. The storage device <NUM> includes a controller <NUM> and multiple stripes <NUM>. Specifically, the controller <NUM> includes a processor <NUM>, a memory <NUM>, and a bus system <NUM>. The processor <NUM> is connected to the memory <NUM> by using the bus system <NUM>. The memory <NUM> is configured to store a computer instruction. The processor <NUM> is configured to execute the computer instruction stored in the memory <NUM>. The following operations performed by the controller <NUM> are implemented by executing the computer instruction stored in the memory <NUM>. A person skilled in the art may know that the controller <NUM> in this embodiment of the present invention may be implemented in another implementation. For example, a field programmable gate array (Field Programmable Gate Array, FPGA) or other hardware is used to perform all operations of the controller <NUM> in this embodiment of the present invention, or the processor <NUM> and an FPGA or other hardware separately perform some operations of the controller <NUM> in this embodiment of the present invention, to implement the operations of the controller <NUM> described in this embodiment of the present invention. The controller <NUM> is configured to:.

It should be understood that the multiple stripes <NUM> may correspond to multiple stripes (the stripe <NUM>, the stripe <NUM>, the stripe <NUM>, and the stripe <NUM>) in a resource pool shown in <FIG>.

The stripe is a result of striping management on storage space in the storage device by the controller. For details, refer to an understanding of the stripe by a person skilled in the art.

In this embodiment of the present invention, in a scenario of performing garbage collection on a stripe, the stripe units that are in the at least two stripes and do not require garbage collection are constructed into the new stripe, and garbage collection processing is not performed on the new stripe. Correspondingly, there is no data migration operation. Therefore, in the scenario of performing garbage collection on a stripe, according to this application, a data migration amount can be effectively reduced, thereby reducing write operations on the storage device, and lowering performance overheads of the storage device.

In addition, in this embodiment of the present invention, parity data of data in the stripe units that are in the at least two stripes and do not require garbage collection is written to the first idle stripe unit, so that the first stripe unit and the stripe units not requiring garbage collection are constructed into the new stripe, instead of performing a large quantity of extra write operations to migrate data in the original stripe units to an idle stripe unit to construct the new stripe. Therefore, storage space utilization of the storage device can be improved to some extent.

In this embodiment of the present invention, the processor <NUM> is further configured to: when the stripe unit requiring garbage collection includes valid data, migrate the valid data in the stripe unit requiring garbage collection to a second idle stripe unit in the storage device, erase data in the stripe unit requiring garbage collection, and reclaim the stripe unit requiring garbage collection; and
when the stripe unit requiring garbage collection includes no valid data, erase data in the stripe unit requiring garbage collection, and reclaim the stripe unit requiring garbage collection.

Optionally, in this embodiment of the present invention, the stripe in the storage device <NUM> is generated based on a redundant array of hard disks RAID technology or an erasure coding EC technology.

Therefore, in this embodiment of the present invention, in a scenario of performing garbage collection on a stripe, the stripe units that are in the at least two stripes and do not require garbage collection are constructed into the new stripe, and garbage collection processing is not performed on the new stripe. Correspondingly, there is no data migration operation. Therefore, in the scenario of performing garbage collection on a stripe, according to this application, a data migration amount can be effectively reduced, thereby reducing write operations on the storage device, and lowering performance overheads of the storage device.

It should be understood that the storage device <NUM> according to this embodiment of the present invention corresponds to the storage device <NUM> provided in the foregoing embodiment of the present invention, and the storage device <NUM> is configured to implement corresponding procedures of the method shown in <FIG>. For brevity, details are not described herein again.

It should be understood that sequence numbers of the foregoing processes do not mean execution sequences in various embodiments of the present invention. The execution sequences of the processes should be determined according to functions and internal logic of the processes, and should not be construed as any limitation on the implementation processes of the embodiments of the present invention.

Claim 1:
A garbage collection method, implemented by a storage device comprising a plurality of stripes, wherein the method comprises:
determining at least two stripes in the storage device that satisfy a garbage collection condition, wherein each of the at least two stripes comprises a stripe unit requiring garbage collection and a stripe unit not requiring garbage collection;
determining (S21) stripe units not requiring garbage collection and stripe units requiring garbage collection from the determined stripes;
computing parity data of data in the stripe units not requiring garbage collection from the determined stripes;
storing the parity data into a first idle stripe unit;
linking (S22) the first idle stripe unit and the stripe units not requiring garbage collection in the determined stripes to a new stripe in the storage device using a linked list without performing garbage collection on the new stripe to migrate the data of the stripe units not requiring garbage collection; and
reclaiming the stripe units requiring garbage collection in the determined stripes.