# Patent

## Title
Method for a storage device processing data and storage device

## Abstract

A method for managing data in a hierarchical storage device which includes primary storage disks and secondary storage disks. The primary storage disks have higher performance than the secondary storage disks. The storage device detects an access frequency of a data block stored in the secondary storage disks. Based on the access frequency of a data block, the storage device determines that the access frequency of the data block reaches an access threshold value. And then, based upon the determination, the storage device moves the data block to the primary storage disks. After that, the storage device divides the data block into a plurality of sub-blocks and detects an access frequency of each of the sub-blocks. Finally, the storage device moves one or more of the sub-blocks of which access frequencies are less than the access threshold value back to the secondary storage disks.

## Background
CROSS-REFERENCE TO RELATED APPLICATION
This application is a continuation of U.S. patent application Ser. No. 14/190,264, filed on Feb. 26, 2014, which is a continuation of International Application No. PCT/CN2012/086670, filed on Dec. 14, 2012. The International Application claims priority to Chinese Patent Application No. 201110460211.X, filed on Dec. 31, 2011. The afore-mentioned patent applications are hereby incorporated by reference in their entireties.


TECHNICAL FIELD
The present invention relates to storage technologies, and in particular, to a method for a storage device processing data and a storage device.
BACKGROUND
Tiered storage refers to setting an existing storage device as disk tiers and setting different types of disks onto different tiers so that data can be migrated between different tiers according to data access requirements. For example, a solid state disk (SSD) set comprises a plurality of SSDs. Each of the SSDs is a high-tier disk characterized by a high access speed, and a hard disk drive (HDD) set comprises a plurality of HDDs. Each of the HDDS is a low-tier disk characterized by a low access speed. In the practice of tiered storage, infrequently accessed data is stored into a disk tier characterized by a low access speed such as a HDD set, and frequently accessed data is stored into a disk tier characterized by a high access speed such as a SSD set, and therefore, in accessing frequently used data, the data access speed and the storage device access efficiency are enhanced.
A disk generally stores data in the form of data blocks. Multiple storage units of the same size are set in the disk, and each storage unit is configured to store one data block. When data is migrated between different tiers, the data block as a whole is migrated. Even if only a part of data (called “hot data”) in the data block has an access frequency rising to a set threshold and needs to be migrated to a high-tier disk set, the data block as a whole is actually migrated. That is, the “cold data” (data whose access frequency is still low) in the data block moves together with “hot data”. The data block is generally called a “migration unit”, indicating that the data block is a unit of migration. In addition, the storage device further includes metadata storage resources used to store metadata, where the metadata is information corresponding to a migration unit, for example, a storage address of the migration unit, and each migration unit has corresponding metadata, and therefore, the consumption amount of the metadata storage resources is proportional to the number of migration units.
Currently, the size of the “migration unit” is generally fixed, such as 256 megabytes (MB). However, the setting of the migration units of a fixed size brings the following problems: if the set size of the migration unit is large, few metadata storage resources are consumed, but the phenomenon that cold data moves together with the hot data will lead to waste of the storage space of the expensive high-tier storage medium and low usage of space; and, if the set size of the migration unit is small, the waste of the high-tier storage medium is reduced naturally, but more metadata storage resources are consumed.
SUMMARY
One aspect of the present invention provides a method for a storage device processing data to improve usage of storage media and control reasonableness of metadata storage resource consumption.
Another aspect of the present invention provides a data storage device to improve usage of storage media and control reasonableness of metadata storage resource consumption.
The method for a storage device processing data provided in the present invention includes obtaining an access frequency of a block of the second storage set; determining that the access frequency of the block achieves a first access threshold value; based upon the determination, moving the block to the first storage disk set; obtaining an access frequency of each of sub-blocks into which the block is divided; determining that an access frequency of at least one of the sub-blocks is less than a second access threshold value; and based upon the determination, moving the determined sub-block back to the second storage disk set.
The storage device provided in the present invention comprises a processor, a communication interface, and a communication bus, wherein the processor communicates with the communication interface through the communication bus and the processor is configured to obtain an access frequency of a block of a second storage set, wherein the second storage set includes a plurality of storage disks with low performance; determine that the access frequency of the block achieves a first access threshold value; based upon the determination, move the block to a first storage disk set, wherein the first storage disk set includes a plurality of storage disks with high performance; obtain an access frequency of each of sub-blocks into which the block is divided; determine that an access frequency of at least one of the sub-blocks is less than a second access threshold value; and based upon the determination, move the determined sub-block back to the second storage disk set.
Technical effects of the method for a storage device processing data in the present invention are, when a migration unit is migrated to a high-tier disk set, a data access frequency of each migration subunit is detected respectively so that hot data can be identified more easily; and when cold data is identified, the migration subunit corresponding to the cold data can be migrated to a low-tier disk set, thereby reducing waste of the storage space of the high-tier disk, so that the high-tier disk stores only hot data, and improving the usage of storage media; in addition, when all migration subunits are migrated to the low-tier disk set, integration can be performed by combining all the migration subunits into a migration unit, thereby reducing the number of migration units in time and controlling metadata storage resource consumption effectively.
Technical effects of the storage device in the present invention are, when a migration unit is migrated to a high-tier disk set, a data access frequency of each migration subunit is detected respectively so that hot data can be identified more easily; and when cold data is identified, the migration subunit corresponding to the cold data can be migrated to a low-tier disk set, thereby reducing waste of the storage space of the high-tier disk, so that the high-tier disk stores only hot data, and improving the usage of storage media; in addition, when all migration subunits are migrated to the low-tier disk set, integration can be performed by combining all the migration subunits into a migration unit, thereby reducing the number of migration units in time and controlling metadata storage resource consumption effectively.



BRIEF DESCRIPTION OF DRAWINGS
FIG. 1 is a schematic flowchart of an embodiment of a method for a storage device processing data according to the present invention;
FIG. 2 is a schematic principle diagram of another embodiment of a method for a storage device processing data according to the present invention; and
FIG. 3 is a schematic structural diagram of an embodiment of an apparatus for tiered storage processing of data according to the present invention.



DESCRIPTION OF EMBODIMENTS
Embodiment 1
FIG. 1 is a schematic flowchart of an embodiment of a method for a storage device processing data according to the present invention. As shown in FIG. 1, the method in this embodiment may include the following steps.
101. When a migration unit of a low-tier disk set is migrated to a high-tier disk, the storage device splits the migration unit into multiple migration subunits, and detects a data access frequency of each migration subunit respectively.
The low-tier disk set comprises a plurality of low-tier disks. Each of the low-tier disks is characterized by a low access speed, such as an HDD; and the high-tier disk set comprises a plurality of high-tier disks. Each of the high-tier disks is characterized by a high access speed, such as an SSD, that is, the high-tier disk provides a better performance and a higher speed than the low-tier disk.
The migration unit and the migration subunit refer to data blocks stored in the disk and migrated as an integral unit. The migration unit of a low-tier disk generally refers to a migration unit of a large size such as 256 MB; and, when the migration unit becomes hot and is migrated to a high-tier disk, the migration unit is split into multiple migration subunits of a smaller size such as 32 MB. In this embodiment, the number of migration subunits obtained after the splitting is not limited. For example, a migration unit may be split into four migration subunits or eight migration subunits. In addition, the size of the migration subunits obtained after the splitting is user-definable.
Optionally, after the migration unit is split into multiple migration subunits, storage address information of the multiple migration subunits is recorded respectively to ensure correct data access subsequently. For example, assuming that the migration unit is split into four migration subunits, the specific physical storage addresses of the four migration subunits in the high-tier disk need to be recorded respectively.
102. The storage device migrates the migration subunit to the low-tier disk when detecting that the data access frequency of the migration subunit is lower than a set threshold.
If the data access frequency of the migration subunit is lower than a set threshold, it indicates that the access frequency of the migration subunit is low. That means the migration subunit is infrequently accessed. It is also called “cold data.” Therefore, the migration subunit is migrated to the low-tier disk in this embodiment.
In this embodiment, in order to improve usage of storage space of the high-tier disks, a large-sized migration unit is split into small-sized migration subunits. Therefore, hot data in the migration unit can be identified more precisely, and the cold data can be migrated back to the low-tier disk set. Therefore, it prevents the cold data from wastefully occupying the expensive storage space in the high-tier disk set, and the disk usage is improved.
103. The storage device combines the multiple migration subunits into the migration unit when detecting that the multiple migration subunits are all migrated to the low-tier disk.
When detecting that all migration subunits obtained after the split migration unit migrated to the high-tier disk in 101 are migrated back to the low-tier disk, the migration subunits are re-integrated into a large-sized migration unit in this embodiment, because that means all of the migration subunits become cold again.
The low-tier disk integrates migration subunits into a migration unit in time, thereby reducing the number of migration units and controlling the metadata storage resource consumption effectively.
In the method for a storage device processing data in this embodiment, when a migration unit is migrated to a high-tier disk set, a data access frequency of each migration subunit is detected respectively so that hot data can be identified more easily. When cold data is identified, the migration subunit corresponding to the cold data can be migrated to a low-tier disk, thereby reducing waste of the storage space of the high-tier disks. Accordingly, the high-tier disks store only hot data, and the usage of storage media is improved. In addition, when all migration subunits are migrated to the low-tier disk set, integration can be performed by combining all the migration subunits into a migration unit, thereby reducing the number of migration units in time and controlling metadata storage resource consumption effectively.
Embodiment 2
FIG. 2 is a schematic principle diagram of another embodiment of a method for a storage device processing data according to the present invention. In this embodiment, assuming that the low-tier disk is an HDD and the high-tier disk is an SSD, the method for a storage device processing data in the present invention is described in detail. The HDD and the SSD may be disks that are set on two different tiers in a storage device, where the storage device further includes a relevant controlling unit that is configured to control migration of data between the two tiers of disks, for example, a hotness identifying unit configured to detect the data access frequency, or a migration controlling unit configured to control data migration, or the like.
As shown in FIG. 2, the storage space in the HDDs and the SSDs is divided into multiple storage units at a large size granularity first. For example, the storage unit may be configured to store a migration unit 11 of a 256 MB size. The migration unit 11 is a data block that is stored and migrated as a whole.
After the storage space is divided into multiple storage units, a mapping relationship is created between each storage unit in the HDDs and the SSDs and a logical block address (LBA) of the storage device respectively. For example, the storage device includes HDDs and SSDs that are tiered, and logical block address information is maintained in the storage device. Data is stored in a physical storage address in the HDDs and the SSDs. However, when a read or write operation is performed for the data, the operation information carries LBA information. Then, according to the mapping relationship between the LBA in the storage device and the physical storage address, the physical storage address of the data is searched out, and the data is found. Therefore, a mapping relationship between each storage unit and the LBA is created in the storage device. Further, each storage unit has a corresponding storage identifier, that is, a physical storage address, where the migration unit also has a data block identifier. The mapping relationship records the data block identifier, the LBA of the data block, and mapping relationship information between the physical storage addresses, so as to identify the storage location of the data block in the disk and ensure the correctness of data reading and writing.
The hotness identifying unit in the storage device may detect the data access frequency of the migration unit 11 in each storage unit, for example, detect Input/Output (IO) statistic information of the migration unit. In addition, an access frequency threshold may be set. If the data access frequency of the migration unit is greater than the threshold, it indicates that the migration unit is frequently accessed and has become “hot data”; if the data access frequency of the migration unit is less than the threshold, it indicates that the migration unit is infrequently accessed and is “cold data”.
After the migration unit becomes hot, the migration controlling unit in the storage device may control the migration unit to migrate to the SSDs; and, after the migration to the SSDs, the hotness identifying unit in the storage device in this embodiment may detect the data access frequency of each migration subunit in the migration unit respectively.
The storage device may preset a size such as 32 MB for the migration subunit. Assuming that the size of the migration unit is 256 MB, the migration unit actually includes 8 migration subunits. After the migration unit is migrated to the SSDs, the hotness identifying unit may detect the data access frequency of the 8 migration subunits respectively rather than detect the data access frequency of the entire migration unit as a whole just like the beginning, and therefore, hot data can be identified more easily. For example, only 64 MB data in the 256 MB migration unit becomes hot and the remaining is still cold data, but because the migration unit as a whole is a unit in the statistics of IO information, the migration unit is still regarded as hot and migrated to an upper tier; and then the IO information of each migration subunit in the migration unit is detected respectively to identify precisely 2 migration subunits that become hot and the remaining 6 migration subunits that are still cold data. In this way, the identification of hot data is more precise.
Optionally, the IO statistics for each migration subunit may be performed before the splitting of the migration unit, that is, when the migration unit is still a whole without being split, and the hot data of each internal migration subunit is identified beforehand; if all the migration subunits are detected as hot data, the migration unit may remain as a whole without being split, and is stored in the large-sized storage unit of the SSDs; and, if some are detected as cold data, the migration unit is controlled to split according to the preset size of migration subunits.
Alternatively, optionally, if no idle large storage unit corresponding to the size of the migration unit exists in the SSDs, the migration unit may be split into multiple migration subunits first, and the migration subunits are migrated to the small storage unit of a corresponding size in the SSDs, and then the IO statistics are detected respectively. That is, before the migration unit is split, the storage unit configured to store the migration unit is a storage space of a large size granularity; and, after the migration unit is split, the storage space is also split into multiple storage spaces of a small size granularity to store the multiple migration subunits after the splitting. Therefore, the order between the hotness identification and the migration unit splitting is not limited strictly, and any order is appropriate as long as the IO statistic information of each migration subunit of the migration unit in the SSDs can be detected and the hot data can be identified.
Assuming that it is already identified that the migration unit includes migration subunits corresponding to cold data, the migration unit 11 is split into multiple migration subunits 12 such as 32 MB; and the migration controlling unit controls the migration subunits corresponding to the cold data to migrate back to the HDDs so that the cold data no longer occupies the expensive storage space in the SSDs, which improves usage of the SSDs' storage space. In addition, the hot data identification is performed in the SSDs all along, that is, the IO statistic information of each migration subunit is detected respectively, and, once it is found that hot data changes to cold data, the cold data is migrated back to the HDDs.
In this embodiment, after the migration unit 11 is split into multiple migration subunits 12, to ensure data access correctness, the mapping relationship information needs to be updated. That is, in this case, the physical storage address of the migration unit 11 on the disk has changed, and the migration unit has been split into multiple migration subunits 12, where the multiple migration subunits 12 may be stored in various addresses in a distributed manner. Therefore, the mapping relationship between the migration unit and the multiple migration subunits needs to be recorded, and the current physical storage addresses of the multiple migration subunits need to be recorded. For example, the mapping relationship between the data block identifier of the migration unit 11 and the LBA of the data block remains unchanged. In searching for the migration unit 11 according to the LBA, the multiple migration subunits 12 obtained after the split migration unit 11 can be found. Some of the migration subunits 12 are stored in the physical storage addresses a1, a2, . . . , in the SSDs, and other migration subunits 12 are stored in the physical storage addresses b1, b2, . . . , in the HDDs. In specific implementation, addressing may be performed by means of arrays, and an array member points to a migration subunit in the HDDs and the SSDs respectively.
Optionally, when the migration unit in the HDDs is migrated to the SSDs, the idle large-sized storage unit corresponding to the size of the migration unit in the SSDs is preferred. When a cold migration subunit in the SSDs is migrated to the HDDs, the idle small-sized storage unit corresponding to the size of the migration unit in the HDDs is preferred. When the cold migration subunit in the HDDs becomes hot again, the migration subunit is preferably migrated to the idle small-sized storage unit corresponding to the size of the migration subunit in the SSDs.
In this embodiment, the migration subunit migrated back to the HDDs undergoes IO statistics using the migration subunit as a unit. The storage device maintains a count value for each migration unit which is used to obtain the number (which may be referred to as a first number) of migration subunits in the SSDs, or obtain the number (which may be referred to as a second number) of migration subunits in the HDDs. If the first number is zero or the second number is equal to the number of migration subunits after the splitting, it is determined that all the multiple migration subunits are migrated to the HDDs. For example, if the migration unit is split into four migration subunits, the number of migration subunits obtained after the split migration unit and currently located in the SSDs may be recorded. If the number is 4 at the beginning, when the data becomes cold, one of the migration subunits is migrated back to the HDDs, the number decreases by 1. When the number becomes zero, it indicates that all the four migration subunits obtained after the split migration unit have become cold and migrated down to the HDDs.
When all the migration subunits are migrated down to the HDDs, an integration process is triggered so that the multiple migration subunits are re-integrated into a migration unit. It is assumed that, when the migration unit is split into migration subunits and migrated down to the HDDs, the initial large-sized storage unit of the HDDs is split into small-sized storage subunits for storing the migration subunits. For example, a storage unit is split into four storage subunits, and one migration subunit migrated down is stored in one of the storage subunits; and the subsequent three migration subunits migrated down may be stored in other storage subunits obtained after the split storage unit of the HDDs, each migration subunit occupies a part of metadata storage resources, and the IO statistics are performed using the migration subunit as a unit. When it is detected that all the four migration subunits are migrated down, the migration subunits will be re-integrated into a migration unit. That is, the four storage subunits are also re-integrated into a large-sized storage unit. In this case, due to decrease of the number of migration units, the consumption of metadata storage resources decreases, and the consumption of the metadata storage resources is controlled, and the IO statistics begin to be performed using the integrated migration unit as a unit. In addition, the storage address information of each migration subunit, which is recorded when the migration unit is in a split state, changes back to the storage address information of the migration unit, and the resources occupied by the maintained count value of the migration subunits obtained after the split migration unit are released and the count value is not maintained any longer.
In the method for a storage device processing data in this embodiment, when a migration unit is migrated to a high-tier disk set, a data access frequency of each migration subunit is detected respectively so that hot data can be identified more easily. When cold data is identified, the migration subunit corresponding to the cold data can be migrated to a low-tier disk, thereby reducing waste of the storage space of the high-tier disks. Accordingly, the high-tier disks store only hot data, and the usage of storage media is improved. In addition, when all migration subunits are migrated to the low-tier disk set, integration can be performed by combining all the migration subunits into a migration unit, thereby reducing the number of migration units in time and controlling metadata storage resource consumption effectively.
Embodiment 3
FIG. 3 is a schematic structural diagram of an embodiment of an apparatus for tiered storage processing of data according to the present invention. The apparatus can perform the method for a storage device processing data according to any embodiment of the present invention. This embodiment only gives a brief description about the structure of the apparatus. For detailed working principles of the apparatus, reference may be made to the description in the method embodiment.
As shown in FIG. 3, the apparatus may include a resource adjusting unit 31, a hotness identifying unit 32, a migration controlling unit 33, and an address recording unit 34.
The resource adjusting unit 31 is configured to split a migration unit into multiple migration subunits, and combine the multiple migration subunits into the migration unit.
The hotness identifying unit 32 is configured to detect a data access frequency of each migration subunit respectively.
The migration controlling unit 33 is configured to migrate a migration unit in low-tier disks to high-tier disks; migrate the migration subunit to the low-tier disks when the hotness identifying unit detects that the data access frequency of the migration subunit is lower than a set threshold; and, detect whether the multiple migration subunits are all migrated to the low-tier disks.
The apparatus may further include an address recording unit 34, which is configured to, after the migration unit is split into multiple migration subunits and before the multiple migration subunits are combined into the migration unit, record storage address information of the multiple migration subunits respectively, for example, record a mapping relationship between the migration unit and the multiple migration subunits; and record current physical storage addresses of the multiple migration subunits.
The migration controlling unit 33 is further configured to detect whether a storage unit corresponding to a size of the migration unit exists in the high-tier disks and, if a result of the detection is yes, migrate the migration unit to the storage unit; and the resource adjusting unit 31 is further configured to split the migration unit into multiple migration subunits if a migration subunit exists whose data access frequency is lower than a set threshold.
Further, the migration controlling unit 33 is configured to detect whether a storage unit corresponding to a size of the migration unit exists in the high-tier disks, and the resource adjusting unit 31 is configured to split the migration unit into multiple migration subunits if a result of the detection of the migration controlling unit is no.
Further, the migration controlling unit 33 includes a counting subunit 331 and a state detecting subunit 332. The counting subunit 331 is configured to obtain a first number of the migration subunits in the high-tier disks, or obtain a second number of the migration subunits in the low-tier disks, and the state detecting subunit 332 is configured to determine that the multiple migration subunits are all migrated to the low-tier disks if the first number is zero or the second number is equal to the number of migration subunits obtained after the split migration unit.
With the apparatus for tiered storage processing of data in this embodiment, when a migration unit is migrated to high-tier disks, a data access frequency of each migration subunit is detected respectively so that hot data can be identified more easily, and when cold data is identified, the migration subunit corresponding to the cold data can be migrated to low-tier disks, thereby reducing waste of the storage space of the high-tier disks, so that the high-tier disks store only hot data, and improving the usage of storage media; in addition, when all migration subunits are migrated to the low-tier disks, integration can be performed by combining all the migration subunits into a migration unit, thereby reducing the number of migration units in time and controlling metadata storage resource consumption effectively.
Embodiment 4
The present invention provides a storage device, where the device includes low-tier disks and high-tier disks, and further includes an apparatus for tiered storage processing of data provided in any embodiment of the present invention, where the apparatus for tiered storage processing of data is connected to the low-tier disks and the high-tier disks respectively.
With the apparatus for tiered storage processing of data in the storage device, when a migration unit is migrated to high-tier disks, a data access frequency of each migration subunit is detected respectively, and when cold data is identified, the migration subunit corresponding to the cold data can be migrated to low-tier disks, thereby reducing waste of the storage space of the high-tier disks, so that the high-tier disks stores only hot data, and improving the usage of storage media; in addition, when all migration subunits are migrated to the low-tier disks, integration can be performed by combining all the migration subunits into a migration unit, thereby reducing the number of migration units in time and controlling metadata storage resource consumption effectively.
Persons of ordinary skill in the art may understand that, all or a part of the steps of the foregoing method embodiments may be implemented by a program instructing relevant hardware. The foregoing programs may be stored in a computer readable storage medium. When the program runs, the steps of the forgoing method embodiments are performed. The foregoing storage medium includes various mediums capable of storing program codes, such as a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that the foregoing embodiments are merely intended for describing the technical solutions of the present invention, rather than limiting the present invention. Although the present invention is described in detail with reference to the foregoing embodiments, persons of ordinary skill in the art should understand that they may still make modifications to the technical solutions described in the foregoing embodiments, or make equivalent replacements to some or all the technical features thereof, as long as the modifications and replacements do not cause the essence of corresponding technical solutions to depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

## Claims

1. A method for managing data in a hierarchical storage device which includes primary storage disks and secondary storage disks, wherein the primary storage disks have higher performance than the secondary storage disks, the method performed by the storage device comprising:
detecting an access frequency of a data block stored in the secondary storage disks;
determining that the access frequency of the data block reaches an access threshold value;
moving the data block to the primary storage disks based upon determining that the access frequency of the data block reaches the access threshold value;
dividing the data block in the primary storage disks into a plurality of sub-blocks, wherein the sub-blocks are independently accessible, and wherein each of the sub-blocks has a respective access frequency separate from access frequencies of other sub-blocks;
detecting the access frequencies of the sub-blocks; and
moving a sub-block back to the secondary storage disks when an access frequency of the sub-block is less than the access threshold value.

2. The method according to claim 1, further comprising recording a relationship between the data block and each of the sub-blocks.

3. A hierarchical storage device comprising:
primary storage disks for storing data;
secondary storage disks for storing data, wherein the primary storage disks have higher performance than the secondary storage disks; and
a processor connected to the primary storage disks and the secondary storage disks, and configured to:
detect an access frequency of a data block stored in the secondary storage disks;
determine that the access frequency of the data block reaches an access threshold value;
move the data block to the primary storage disks based upon determining that he access frequency of the data block reaches the access threshold value;
divide the data block in the primary storage disks into a plurality of sub-blocks, wherein the sub-blocks are independently accessible, and wherein each of the sub-blocks has a respective access frequency separate from access frequencies of other sub-blocks;
detect the access frequencies of the sub-blocks; and
move a sub-block back to the secondary storage disks when an access frequency of the sub-block is less than the access threshold value.

4. The device according to claim 3, wherein the processor is further configured to record a relationship between the data block and each of the sub-blocks.