Data balancing method and device and computer equipment
By migrating data based on access heat and capacity differences in SSD storage systems, the problem of load imbalance between hard disks is solved, and read and write performance and system stability are improved.
Patent Information
- Application Number
- CN202311846668.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2025-07-01
AI Technical Summary
In the prior art, unbalanced load between hard disks in SSD storage systems leads to fast life consumption of some disks, and the stability of the storage system cannot be guaranteed. The existing data balance method only considers capacity usage, which affects read and write performance.
By determining the access popularity and used capacity differences of hard disk data blocks, data migration is determined based on the access popularity and the hard disk is migrated, and data migration is carried out on the basis of considering the access popularity, so as to achieve data and capacity balance between hard disks.
Improves the read and write performance of the hard disk, avoids reading hotspots, and improves the stability and overall performance of the storage system.
Smart Images

Figure CN120233936A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and in particular, to a data balancing method, apparatus, and computer device. Background Art
[0002] An SSD (Solid State Drive) is a storage medium using flash chips. Compared with traditional mechanical hard disks, an SSD has higher read and write performance. In a storage system using SSDs, if the load among hard disks is unbalanced and the load of some disks is relatively high, it will cause the disks to consume their lifespan quickly and the stability of the storage system cannot be guaranteed. Therefore, data balancing needs to be performed in an all-flash storage system.
[0003] In related technologies, data balancing is achieved by detecting the capacity usage of each hard disk in a storage system. If it is determined that there is an uneven capacity usage among hard disks, the data in the disk with a higher capacity usage rate is moved to the disk with a lower capacity usage rate to achieve capacity balance. However, the above data balancing method only considers the difference in capacity usage, which is relatively one-sided and causes a greater impact on the read and write performance of the storage system. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a data balancing method, apparatus, and computer device that can improve the read and write performance of the system.
[0005] In a first aspect, the present application provides a data balancing method applied to a system. The system includes multiple hard disks, and each hard disk includes multiple data blocks. The method includes:
[0006] Determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of the data blocks included in each hard disk;
[0007] Based on each hard disk to be migrated in, obtain a sequence of hard disks to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out to obtain a sequence of data blocks to be migrated out;
[0008] Traverse the sequence of hard disks to be migrated in. For each hard disk to be migrated in, determine a target data block to be migrated out that matches the hard disk to be migrated in in the sequence of data blocks to be migrated out, and determine a target data block in the hard disk to be migrated in. Perform data migration based on the target data block to be migrated out and the target data block.
[0009] In this embodiment, data balancing among hard disks can be performed considering the access heat among hard disks and the difference in the used capacity among hard disks. The read traffic can be evenly directed to each hard disk. Therefore, using the access heat of data as the basis for balancing can greatly improve the read and write performance of the hard disks.
[0010] In one embodiment, the determining the data blocks to be migrated corresponding to each hard disk to be migrated out to obtain a sequence of data blocks to be migrated out includes:
[0011] For each hard disk to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, determining the data blocks to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out;
[0012] Sorting the multiple data blocks to be migrated out corresponding to each of the hard disks to be migrated out according to the first sorting order of access heat, to obtain a sequence of data blocks to be migrated out, where the first sorting order is the order from large to small of the access heat of each of the data blocks to be migrated out.
[0013] In this embodiment, the terminal can determine the data blocks to be migrated out in each hard disk to be migrated out based on the access heat of the data blocks, ensuring the convenience of data migration in the data balancing process.
[0014] In one embodiment, the obtaining a sequence of hard disks to be migrated in based on each of the hard disks to be migrated in includes:
[0015] Sorting the hard disks to be migrated in according to the second target order of the insufficient access heat value of each of the hard disks to be migrated in, to obtain a sequence of hard disks to be migrated in, where the second target order is the order from large to small of the insufficient access heat value of each of the hard disks to be migrated in.
[0016] In this embodiment, by sorting each of the hard disks to be migrated in according to the difference between the total access heat of the hard disk and the average heat of the hard disk, the convenience of data block migration and the efficiency of data balancing during data migration can be improved.
[0017] In one embodiment, the for each of the hard disks to be migrated in, determining a target data block to be migrated out that matches the hard disk to be migrated in in the sequence of data blocks to be migrated out, and determining a target data block in the hard disk to be migrated in, and performing data migration based on the target data block to be migrated out and the target data block includes:
[0018] For each of the hard disks to be migrated in, determining a target data block to be migrated out that matches the insufficient access heat value of the hard disk to be migrated in in the sequence of data blocks to be migrated out;
[0019] Among the multiple data blocks included in the hard disk to be migrated in, according to the order from small to large of the access heat of each of the data blocks, taking the previous target number of data blocks as the target data blocks that match the target data block to be migrated out;
[0020] Migrate the target data block to be migrated out to the data block to be migrated in, and respectively migrate each target data block to the hard disk to be migrated out where each target data block is located in ascending order of the access popularity of each target data block.
[0021] In this embodiment, data balancing among various hard disks can be performed considering the differences in access popularity and used capacity among various hard disks. The read traffic can be evenly directed to each hard disk, so that the access popularity of data can be used as the basis for balancing, and the read and write performance of the hard disk can be improved to a great extent.
[0022] In one embodiment, determining the hard disk to be migrated out and the hard disk to be migrated in based on the access popularity of the data blocks included in each hard disk includes:
[0023] For each hard disk included in the system, calculate the total access popularity of the hard disk based on the access popularity of the multiple data blocks included in the hard disk;
[0024] Based on the total access popularity of each hard disk, calculate the average hard disk popularity, and respectively calculate the access popularity difference of each hard disk based on the total access popularity of each hard disk and the average hard disk popularity;
[0025] If the access popularity difference of the hard disk is greater than the preset value, determine that the hard disk is the hard disk to be migrated out, and the excessive access popularity value of the hard disk to be migrated out is the excessive access popularity value; if the access popularity difference of the hard disk is less than the preset value, determine that the hard disk is the hard disk to be migrated in, and the access popularity difference of the hard disk to be migrated in is the insufficient access popularity value.
[0026] In this embodiment, by determining each hard disk as the hard disk to be migrated out or the hard disk to be migrated in based on the relationship between the access popularity of each hard disk and the average hard disk popularity, data balancing among multiple hard disks can be achieved based on the access popularity, and the effect of migrating data blocks from the hard disk with high access popularity and migrating data blocks to the hard disk with low access popularity can be achieved, balancing the performance among each hard disk.
[0027] In one embodiment, determining the data block to be migrated out corresponding to the excessive access popularity value of the hard disk to be migrated out among the multiple data blocks included in each hard disk to be migrated out includes:
[0028] For each hard disk to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, use the data block whose sum value of access popularity is close to the excessive access popularity value of the hard disk to be migrated out as the data block to be migrated out of the hard disk to be migrated out.
[0029] In this embodiment, by determining the data blocks whose sum value of access heat is close to the excessive access heat value of the hard disk to be migrated out, the data blocks with higher heat can be accurately determined, which is convenient for the subsequent flow of data blocks among various hard disks and realizes the balance of read traffic on each hard disk.
[0030] In one embodiment, determining the target data block to be migrated out that matches the insufficient access heat value of the hard disk to be migrated into in the sequence of data blocks to be migrated out includes:
[0031] In the sequence of data blocks to be migrated out, determine the target number of target data blocks to be migrated out whose sum value of access heat is close to the difference value of access heat of the hard disk to be migrated into.
[0032] In this embodiment, by allocating data blocks on each hard disk based on the access heat of the data blocks, heat balance is achieved, the occurrence of read hotspots is avoided, and the overall performance of the system is improved.
[0033] In one embodiment, for each hard disk to be migrated into, determining the target data block to be migrated out that matches the hard disk to be migrated into in the sequence of data blocks to be migrated out, and determining the target data block in the hard disk to be migrated into, and performing data migration based on the target data block to be migrated out and the target data block includes:
[0034] For the currently traversed hard disk to be migrated into, in the current sequence of data blocks to be migrated out, use the first data block to be migrated out as the target data block to be migrated out whose insufficient access heat value is close to that of the hard disk to be migrated into, migrate the target data block to be migrated out to the hard disk to be migrated into, and in the hard disk to be migrated into, migrate the first data block to the hard disk to be migrated out where the target data block to be migrated out is located in ascending order of the access heat of the data blocks;
[0035] If the access heat of the first data block to be migrated out is less than or equal to the insufficient access heat value of the hard disk to be migrated into, update the insufficient access heat value of the hard disk to be migrated into, and re - execute the step of using the first data block to be migrated out as the target data block to be migrated out whose insufficient access heat value is close to that of the first hard disk to be migrated into until the access heat of the first data block to be migrated out is greater than the insufficient access heat value of the hard disk to be migrated into, and traverse the next hard disk to be migrated into of the currently traversed hard disk to be migrated into.
[0036] In this embodiment, the heat information of each data block is calculated through the statistical results of read I / O, and then the heat data of each hard disk in the system is obtained. Based on the heat data and capacity information of the hard disk, data migration is performed to evenly direct the read traffic to each hard disk, thereby achieving balance in read operations and giving full play to the disk read performance of the system.
[0037] In one embodiment, the data balancing method further includes:
[0038] In response to a data reading request, determining access heat information of a data block corresponding to the data reading request, where the access heat information includes a current access heat of the data block and a previous access time of the data block;
[0039] Updating the current access heat of the data block by using the current time and the previous access time to obtain the updated current access heat of the data block, and determining the current time as the updated previous access time of the data block.
[0040] In this embodiment, continuously updating the access heat of the data block by using the previous access time and the current time can ensure the timeliness of the access heat of the data block.
[0041] In one embodiment, the updating the current access heat of the data block by using the current time and the previous access time to obtain the updated current access heat of the data block includes:
[0042] When the previous access time of the data block is a target parameter, determining a target value as the updated current access heat of the data block, where the target parameter indicates that the data block has not been accessed;
[0043] When the previous access time of the data block is not the target parameter, calculating a time difference between the previous access time and the current time;
[0044] When the time difference is less than or equal to a preset time difference threshold, calculating a sum value of the target value and the access heat of the data block, and determining the sum value as the updated current access heat of the data block; when the time difference is greater than the preset time difference threshold, calculating a ratio of the access of the data block to the time difference, and calculating the updated current access heat of the data block based on the ratio and the target value.
[0045] In this embodiment, the current access heat of the data block is updated in real time by using the time difference between the previous access time and the current time of the data block, which can achieve the effect that the access heat of the data block increases as the number of data accesses increases, and can also achieve the effect that the heat value gradually decreases when the data has not been accessed for a period of time.
[0046] In one embodiment, the data balancing method further includes:
[0047] When a preset time interval is reached, based on the current time and the last access time of each data block, the access heat of each data block is respectively corrected to obtain the corrected current access heat of each data block.
[0048] In this embodiment, by periodically correcting the current access heat of the data block based on the last access time of the data block, the accuracy of the current access heat calculation can be ensured, and the situation that the heat information cannot be updated and is misestimated due to updating the current access heat based on the read request can be avoided, providing a reliable data basis for subsequent data balancing. And by performing heat correction through background timed tasks, resource conflicts between data and balanced migration can be avoided, and the consumption of computing resources can be reduced.
[0049] In one of the embodiments, the correcting the access heat of each data block based on the current time and the last access time of each data block to obtain the corrected current access heat of each data block includes:
[0050] For each data block, calculate a first time difference between the current time and the last access time of the data block;
[0051] If the first time difference is greater than a preset time difference threshold, calculate a ratio of the access heat of the data block to the first time difference, and determine the ratio as the corrected current access heat of the data block.
[0052] In this embodiment, by periodically correcting the current access heat of the data block based on the last access time of the data block and the preset time difference threshold, the operation of updating the heat of the data block can be realized without read operation, ensuring the timeliness of the current access heat of each data block.
[0053] In a second aspect, the present application further provides a data balancing device applied to a system. The system includes multiple hard disks, and each hard disk includes multiple data blocks. The device includes:
[0054] A first determination module, configured to determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of the data blocks included in each hard disk;
[0055] A second determination module, configured to obtain a sequence of hard disks to be migrated in based on each hard disk to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out to obtain a sequence of data blocks to be migrated out;
[0056] A third determination module, configured to traverse the hard disk sequence to be migrated, and for each hard disk to be migrated, determine a target data block to be migrated that matches the hard disk to be migrated in the data block sequence to be migrated, and determine a target data block in the hard disk to be migrated, and perform data migration based on the target data block to be migrated and the target data block.
[0057] In one embodiment, the second determination module is specifically configured to: for each hard disk to be migrated, determine, among the multiple data blocks included in the hard disk to be migrated, the data block to be migrated corresponding to the over-access heat value of the hard disk to be migrated;
[0058] Sort the multiple data blocks to be migrated respectively corresponding to each hard disk to be migrated according to the first sorting order of access heat, where the first sorting order is the order from large to small of the access heat of each data block to be migrated, to obtain a data block sequence to be migrated.
[0059] In one embodiment, the second determination module is specifically configured to: sort each hard disk to be migrated according to the second target order of the under-access heat value of each hard disk to be migrated, where the second target order is the order from large to small of the under-access heat value of each hard disk to be migrated, to obtain a hard disk sequence to be migrated.
[0060] In one embodiment, the third determination module is specifically configured to: for each hard disk to be migrated, determine, in the data block sequence to be migrated, a target data block to be migrated that matches the under-access heat value of the hard disk to be migrated;
[0061] Among the multiple data blocks included in the hard disk to be migrated, in the order from small to large of the access heat of each data block, use the previous target number of data blocks as the target data blocks that match the target data block to be migrated;
[0062] Migrate the target data block to be migrated to the target data block, and respectively migrate each target data block to the hard disk to be migrated where each target data block to be migrated is located in the order from small to large of the access heat of each target data block.
[0063] In one embodiment, the first determination module is specifically configured to:
[0064] For each hard disk included in the system, calculate the total access heat of the hard disk based on the access heat of the multiple data blocks included in the hard disk;
[0065] Calculate the average hard disk heat based on the total access heat of each hard disk, and calculate the access heat difference of each hard disk respectively based on the total access heat of each hard disk and the average hard disk heat;
[0066] If the access heat difference of the hard disk is greater than a preset value, determine that the hard disk is a hard disk to be migrated out, and the excess access heat value of the hard disk to be migrated out is the excess access heat value; if the access heat difference of the hard disk is less than the preset value, determine that the hard disk is a hard disk to be migrated in, and the access heat difference of the hard disk to be migrated in is the deficit access heat value.
[0067] In one embodiment, the second determining module is specifically configured to:
[0068] For each of the hard disks to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, use the data blocks whose sum value of access heat is close to the excess access heat value of the hard disk to be migrated out as the data blocks to be migrated out of the hard disk to be migrated out.
[0069] In one embodiment, the third determining module is specifically configured to:
[0070] In the sequence of data blocks to be migrated out, determine the first target number of target data blocks to be migrated out whose sum value of access heat is close to the access heat difference of the hard disk to be migrated in; among the multiple data blocks included in the hard disk to be migrated in, in ascending order of the access heat of each data block, use the first target number of data blocks as the target data blocks matching the target data blocks to be migrated out; in ascending order of the access heat of each target data block, migrate each target data block to the hard disk to be migrated out where each target data block to be migrated out is located.
[0071] In one embodiment, the third determining module is specifically configured to: for the currently traversed hard disk to be migrated in, in the current sequence of data blocks to be migrated out, use the first data block to be migrated out as the target data block to be migrated out whose deficit access heat value is close to the hard disk to be migrated in, migrate the target data block to be migrated out to the hard disk to be migrated in, and in the hard disk to be migrated in, in ascending order of the access heat of the data blocks, migrate the first data block to the hard disk to be migrated out where the target data block to be migrated out is located;
[0072] If the access heat of the first data block to be migrated out is less than or equal to the deficit access heat value of the hard disk to be migrated in, update the deficit access heat value of the hard disk to be migrated in, and re - execute the step of using the first data block to be migrated out as the target data block to be migrated out whose deficit access heat value is close to the first hard disk to be migrated in until the access heat of the first data block to be migrated out is greater than the deficit access heat value of the hard disk to be migrated in, and traverse the next hard disk to be migrated in of the currently traversed hard disk to be migrated in.
[0073] In one embodiment, the data balancing device further includes:
[0074] A fourth determination module, configured to determine access heat information of a data block corresponding to the data reading request in response to the data reading request, where the access heat information includes the current access heat of the data block and the previous access time of the data block;
[0075] A first update module, configured to update the current access heat of the data block by using the current time and the previous access time to obtain the updated current access heat of the data block, and determine the current time as the updated previous access time of the data block.
[0076] In one embodiment, the first update module is specifically configured to:
[0077] When the previous access time of the data block is a target parameter, determine a target value as the updated current access heat of the data block, where the target parameter indicates that the data block has not been accessed;
[0078] When the previous access time of the data block is not the target parameter, calculate a time difference between the previous access time and the current time;
[0079] When the time difference is less than or equal to a preset time difference threshold, calculate a sum value of the target value and the access heat of the data block, and determine the sum value as the updated current access heat of the data block; when the time difference is greater than the preset time difference threshold, calculate a ratio of the access of the data block to the time difference, and calculate the updated current access heat of the data block based on the ratio and the target value.
[0080] In one embodiment, the data balancing device further includes:
[0081] A correction module, configured to perform a correction process on the access heat of each data block based on the current time and the previous access time of each data block when a preset time interval is reached, to obtain the corrected current access heat of each data block.
[0082] In one embodiment, the correction module is specifically configured to:
[0083] For each data block, calculate a first time difference between the current time and the previous access time of the data block;
[0084] If the first time difference is greater than the preset time difference threshold, calculate a ratio of the access heat of the data block to the first time difference, and determine the ratio as the corrected current access heat of the data block.
[0085] In a third aspect, the present application also provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0086] Determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of data blocks included in each hard disk;
[0087] Based on each hard disk to be migrated in, obtain a sequence of hard disks to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out;
[0088] Traverse the sequence of hard disks to be migrated in. For each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine a target data block to be migrated out that matches the hard disk to be migrated in, and determine a target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block.
[0089] In a fourth aspect, the present application also provides a computer-readable storage medium. On the computer-readable storage medium, a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0090] Determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of data blocks included in each hard disk;
[0091] Based on each hard disk to be migrated in, obtain a sequence of hard disks to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out;
[0092] Traverse the sequence of hard disks to be migrated in. For each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine a target data block to be migrated out that matches the hard disk to be migrated in, and determine a target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block.
[0093] In a fifth aspect, the present application also provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0094] Determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of data blocks included in each hard disk;
[0095] Based on each hard disk to be migrated in, obtain a sequence of hard disks to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out;
[0096] Traverse the hard disk sequence to be migrated. For each hard disk to be migrated, in the sequence of data blocks to be migrated out, determine the target data block to be migrated out that matches the hard disk to be migrated, and determine the target data block in the hard disk to be migrated. Perform data migration based on the target data block to be migrated out and the target data block.
[0097] The above data balancing method, device and computer device, wherein the method includes: determining the hard disk to be migrated out and the hard disk to be migrated in based on the access heat of the data blocks contained in each hard disk; obtaining the hard disk sequence to be migrated in based on each hard disk to be migrated in; and respectively determining the data blocks to be migrated out corresponding to each hard disk to be migrated out to obtain the sequence of data blocks to be migrated out; traverse the hard disk sequence to be migrated in. For each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine the target data block to be migrated out that matches the hard disk to be migrated in, and determine the target data block in the hard disk to be migrated in. Perform data migration based on the target data block to be migrated out and the target data block. By adopting this method, data balancing and capacity balancing between hard disks can be performed on the basis of considering the access heat between each hard disk, and the read traffic can be evenly directed to each hard disk. Therefore, taking the access heat of the data as the basis for balancing can greatly improve the read and write performance of the hard disk. Description of the Drawings
[0098] Figure 1 It is a schematic flowchart of the data balancing method in an embodiment;
[0099] Figure 2 It is a schematic flowchart of the step of determining the hard disk sequence to be migrated in an embodiment;
[0100] Figure 3 It is a schematic flowchart of the step of performing data migration in an embodiment;
[0101] Figure 4 It is a schematic flowchart of the step of determining the hard disk to be migrated out and the hard disk to be migrated in an embodiment;
[0102] Figure 5 It is a schematic flowchart of the step of performing data migration in another embodiment;
[0103] Figure 6 It is a schematic flowchart of the step of updating the current access heat in an embodiment;
[0104] Figure 7 It is a schematic flowchart of the step of updating the current access heat in an embodiment;
[0105] Figure 8 It is a schematic flowchart of the step of correcting the current access heat in an embodiment;
[0106] Figure 9Schematic flowchart of the data balancing method in another embodiment;
[0107] Figure 10 Structural block diagram of the data balancing device in one embodiment;
[0108] Figure 11 Internal structure diagram of a computer device in one embodiment. Detailed implementation manners
[0109] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0110] In one embodiment, a data balancing method is provided. In this embodiment, the application of this method to a terminal is taken as an example for illustration. It can be understood that this method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. The above terminal can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, etc. The server can be implemented by an independent server or a server cluster composed of multiple servers. The data balancing method provided in this embodiment can be applied to the terminal where the system is located. The system includes multiple hard disks, each hard disk includes multiple data blocks, and the access heat of each hard disk can be determined based on the access heat of the multiple data blocks included in the hard disk; as Figure 1 shown, the data balancing method includes the following steps:
[0111] Step 102, determine the hard disk to be migrated out and the hard disk to be migrated in based on the access heat of the data blocks included in each hard disk.
[0112] Among them, the system can be a storage system. The storage system can include multiple hard disks. Each hard disk can include multiple data blocks. The access heat can be an access heat value determined based on the access time of the data block, and is used to represent the access frequency of the data block; the hard disk to be migrated out is the hard disk with a higher total access heat, and high-heat data blocks need to be migrated out to other hard disks to achieve heat balance; the hard disk to be migrated in is the hard disk with a lower total access heat, and high-heat data blocks need to be migrated in from other hard disks to achieve heat balance; the hard disk to be migrated out can be the hard disk with a total access heat higher than the average heat of the hard disks, and the hard disk to be migrated in can be the hard disk with a total access heat lower than the average heat of the hard disks. The average heat of the hard disks can be calculated based on the total access heat corresponding to each hard disk included in the storage system.
[0113] Specifically, for each hard disk included in the system, the terminal can obtain the access heat of each data block included in the hard disk, and classify each hard disk into a migration type based on the access heat of each data block included in the hard disk. For example, the hard disks can be classified into hard disks to be migrated out and hard disks to be migrated in respectively.
[0114] Step 104: Based on each hard disk to be migrated in, obtain a sequence of hard disks to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out.
[0115] Among them, the sequence of hard disks to be migrated in can be arranged based on the difference between the total access heat of each hard disk to be migrated in and the average hard disk heat. The average hard disk heat can be calculated as the average of the total access heat of each hard disk included in the system.
[0116] Specifically, the terminal can obtain the difference between the total access heat of each hard disk to be migrated in and the average hard disk heat, and arrange each hard disk to be migrated in based on the differences of each hard disk to be migrated in, to obtain a sequence of hard disks to be migrated in. The terminal can screen among the data blocks included in multiple hard disks to be migrated out to obtain one or multiple data blocks to be migrated out respectively corresponding to each hard disk to be migrated out; in this way, the terminal can arrange each data block to be migrated out based on the access heat of each data block to be migrated out, to obtain a sequence of data blocks to be migrated out. Among them, the arrangement order of the sequence of hard disks to be migrated in corresponds to the arrangement order of the sequence of data blocks to be migrated out. For example, if the sequence of data blocks to be migrated out is arranged in descending order, then the sequence of hard disks to be migrated in is also arranged in descending order.
[0117] Step 106: Traverse the sequence of hard disks to be migrated in. For each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine the target data block to be migrated out that matches the hard disk to be migrated in, and determine the target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block.
[0118] Specifically, the terminal can traverse each hard disk to be migrated in included in the sequence of hard disks to be migrated in according to the arrangement order of the sequence of hard disks to be migrated in. For each hard disk to be migrated in, the terminal can determine one or multiple target data blocks to be migrated out whose access heat matches the hard disk to be migrated in in the pre-determined sequence of data blocks to be migrated out; correspondingly, the terminal can determine the target data blocks respectively corresponding to each target data block to be migrated out in the multiple data blocks included in the hard disk to be migrated in. Based on this, the terminal can migrate the target data block to be migrated out to the hard disk to be migrated in, and correspondingly, the terminal can migrate each target data block in the hard disk to be migrated in to the hard disk to be migrated out where the target data block to which the target data block corresponds is located, to achieve the balance of access heat and the balance of the used capacity.
[0119] The above data balancing method determines the hard disk to be migrated out and the hard disk to be migrated in based on the access heat of the data blocks contained in each hard disk; obtains a sequence of hard disks to be migrated in based on each hard disk to be migrated in; and respectively determines the data blocks to be migrated out corresponding to each hard disk to be migrated out to obtain a sequence of data blocks to be migrated out; traverses the sequence of hard disks to be migrated in, and for each hard disk to be migrated in, determines a target data block to be migrated out that matches the hard disk to be migrated in in the sequence of data blocks to be migrated out, and determines a target data block in the hard disk to be migrated in, and performs data migration based on the target data block to be migrated out and the target data block. By adopting this method, data balancing and capacity balancing can be performed among hard disks on the basis of considering the access heat among hard disks, and the read traffic can be evenly directed to each hard disk, so that the access heat of the data can be used as the basis for balancing, and the read and write performance of the hard disks can be greatly improved.
[0120] In one embodiment, as Figure 2 shown, the specific processing process of step 104 "respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out to obtain a sequence of data blocks to be migrated out" includes:
[0121] Step 202, for each hard disk to be migrated out, among the multiple data blocks contained in the hard disk to be migrated out, determine the data block to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out.
[0122] Among them, the excessive access heat value of the hard disk to be migrated out is determined based on the total access heat of the hard disk to be migrated out and the average hard disk heat value, and can be the heat value by which the hard disk to be migrated out exceeds the average hard disk heat value.
[0123] Specifically, for each hard disk to be migrated out, the terminal can determine one data block to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out, or multiple data blocks to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out among the multiple data blocks contained in the hard disk to be migrated out; the data block to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out can be one or more data blocks whose access heat is closest to the excessive access heat value.
[0124] Step 204, sort the multiple data blocks to be migrated out corresponding to each hard disk to be migrated out in the first sorting order of access heat to obtain a sequence of data blocks to be migrated out.
[0125] Among them, the first sorting order is the order from large to small of the access heat of each data block to be migrated out, and the sequence of data blocks to be migrated out contains multiple data blocks to be migrated out arranged in the order from large to small of the access heat value.
[0126] Specifically, after determining the data blocks to be migrated out corresponding to each hard disk to be migrated out, the terminal may sort all the data blocks to be migrated out corresponding to each hard disk in descending order of the access popularity of each data block to be migrated out to generate a sequence of data blocks to be migrated out.
[0127] In this embodiment, the terminal may determine the data blocks to be migrated out in each hard disk to be migrated out based on the access popularity of the data blocks, ensuring the convenience of data migration in the data balancing process.
[0128] In one embodiment, the specific processing procedure of step 104, "obtaining a sequence of hard disks to be migrated in based on each hard disk to be migrated in", includes:
[0129] Sort the hard disks to be migrated in according to the second target order of the shortage access popularity values of each hard disk to be migrated in, where the second target order is the order from large to small of the shortage access popularity values of each hard disk to be migrated in, to obtain a sequence of hard disks to be migrated in.
[0130] Specifically, for each hard disk to be migrated in, the terminal may calculate the access popularity difference between the total access popularity of the hard disk to be migrated in and the average hard disk popularity, and use the absolute value of the access popularity difference as the shortage access popularity value of the hard disk to be migrated in. The terminal may arrange all the hard disks to be migrated in in descending order of the shortage access popularity values of each hard disk to be migrated in to obtain a sequence of hard disks to be migrated in.
[0131] In this embodiment, by sorting each hard disk to be migrated in according to the difference between the total access popularity of each hard disk to be migrated in and the average hard disk popularity, the convenience of data block transfer during data migration and the efficiency of data balancing can be improved.
[0132] In one embodiment, as Figure 3 shown, the specific processing procedure of step 106, "for each hard disk to be migrated in, determine the target data block to be migrated out that matches the hard disk to be migrated in in the sequence of data blocks to be migrated out, and determine the target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block", includes:
[0133] Step 302, for each hard disk to be migrated in, determine the target data block to be migrated out that matches the shortage access popularity value of the hard disk to be migrated in in the sequence of data blocks to be migrated out.
[0134] Among them, the shortage access popularity value of the hard disk to be migrated in is determined based on the total access popularity of the hard disk to be migrated in and the average hard disk popularity. For example, it may be the popularity value in the total access popularity of the hard disk to be migrated in that is less than the average hard disk popularity. The sequence of hard disks to be migrated in includes multiple hard disks to be migrated in arranged in descending order of the shortage access popularity values.
[0135] Specifically, the terminal can traverse each hard disk to be migrated in the sequence of hard disks to be migrated according to the arrangement order. For each hard disk to be migrated, the terminal can determine one target data block to be migrated out or multiple target data blocks to be migrated out in the sequence of data blocks to be migrated out determined in advance, whose access heat is matched with the insufficient access heat of the hard disk to be migrated.
[0136] Step 304, among the multiple data blocks included in the hard disk to be migrated, according to the ascending order of the access heat of each data block, take the first target number of data blocks as the target data blocks matched with the target data blocks to be migrated out.
[0137] Specifically, the terminal can, among the multiple data blocks included in the hard disk to be migrated, according to the ascending order of the access heat of each data block, determine the target data blocks respectively corresponding to each target data block to be migrated out by taking the first target number of data blocks.
[0138] Step 306, migrate the target data block to be migrated out to the data block to be migrated in, and respectively migrate each target data block to the hard disk to be migrated out where the target data block to be migrated out is located according to the ascending order of the access heat of each target data block.
[0139] Specifically, the terminal can migrate the target data block to be migrated out to the hard disk to be migrated in. Correspondingly, the terminal can respectively migrate each target data block in the hard disk to be migrated in to the hard disk to be migrated out where the target data block to which the target data block corresponds is located, so as to achieve the balance based on the access heat and the balance of the used capacity situation.
[0140] In this embodiment, data balance among hard disks can be performed considering the differences in access heat among hard disks and the used capacity among hard disks, and the read traffic can be evenly directed to each hard disk. Therefore, taking the access heat of data as the basis for balance can greatly improve the read and write performance of hard disks.
[0141] In one embodiment, as Figure 4 shown, the specific processing process of step 102 "determine the hard disk to be migrated out and the hard disk to be migrated in based on the access heat of data blocks included in each hard disk" includes:
[0142] Step 402, for each hard disk included in the system, calculate the total access heat of the hard disk based on the access heat of multiple data blocks included in the hard disk.
[0143] Among them, the access heat of the data block can be the current access heat of the data block.
[0144] Specifically, for each hard disk included in the storage system, the terminal can determine each data block included in the hard disk, respectively obtain the current access heat of each data block in the current situation, calculate the sum value of the current access heat of each data block in the current situation, and determine the sum value as the total access heat of the hard disk.
[0145] Step 404: Based on the total access heat of each hard disk, calculate the average hard disk heat, and based on the total access heat of each hard disk and the average hard disk heat, calculate the access heat difference of each hard disk respectively.
[0146] Among them, the access heat difference of the hard disk can be the excessive access heat value of the hard disk to be migrated out, and the access heat difference of the hard disk can also be the insufficient access heat value of the hard disk to be migrated in.
[0147] Specifically, after the terminal determines the total access heat of each hard disk included in the storage system, it can obtain the number of hard disks included in the storage system, and calculate the average hard disk heat based on the total access heat of each hard disk included in the storage system and the number of hard disks included in the storage system. In one example, the terminal can calculate the heat sum of the total access heat of each hard disk, and calculate the ratio between the heat sum and the number of hard disks, and determine the ratio as the average hard disk heat of the storage system. For each hard disk, the terminal can calculate the heat difference value between the total access heat of the hard disk and the average hard disk heat, and determine the calculated heat difference value as the access heat difference corresponding to the hard disk. In one example, the terminal can calculate the difference between the total access heat of the hard disk and the average hard disk heat, and determine the difference as the access heat difference of the hard disk.
[0148] Step 406: If the access heat difference of the hard disk is greater than the preset value, determine the hard disk as the hard disk to be migrated out; if the access heat difference of the hard disk is less than the preset value, determine the hard disk as the hard disk to be migrated in.
[0149] Among them, the excessive access heat value of the hard disk to be migrated out is the excessive access heat value, and the access heat difference of the hard disk to be migrated in is the insufficient access heat value; the preset value can be a parameter for classifying the migration type of the hard disk. The migration type can include the type to be migrated out and the type to be migrated in. Correspondingly, the hard disk can include the hard disk to be migrated out and the hard disk to be migrated in; In one example, the preset value can be 0.
[0150] Specifically, if the access heat difference of the hard disk is greater than the preset value, determine that the hard disk is a hard disk of the type to be migrated in, that is, the hard disk to be migrated out. In this way, the terminal can determine that the access heat difference of the hard disk to be migrated out is the excessive access heat value. If the access heat difference of the hard disk is less than the preset value, determine that the hard disk is a hard disk of the type to be migrated in, that is, the hard disk to be migrated in, and the access heat difference of the hard disk to be migrated in is the insufficient access heat value.
[0151] In one example, the terminal can determine each hard disk included in the storage system and the access heat of each data block included in each hard disk. The terminal can determine the migration type corresponding to the hard disk in the current situation based on the access heat of each data block included in each hard disk. The migration type can include a type to be migrated out and a type to be migrated in. In one example, the terminal can determine the total access heat of each hard disk included in the storage system, and calculate the average hard disk heat based on the total access heat of each hard disk and the number of hard disks. For each hard disk, the terminal can compare the total access heat of the hard disk with the calculated average hard disk heat to obtain a comparison result, and determine the migration type to which the hard disk belongs based on the comparison result. When it is determined that the total access heat is greater than the average hard disk heat, the terminal can determine that the hard disk is a hard disk to be migrated out. When it is determined that the total access heat is less than the average hard disk heat, the terminal can determine that the hard disk is a hard disk to be migrated in.
[0152] In another example, the terminal can determine the migration type of the hard disk based on the total access heat of each hard disk included in the storage system respectively and a preset access threshold. For example, for each hard disk, the terminal can compare the total access heat of the hard disk with the preset access threshold to obtain a comparison result, and determine the migration type to which the hard disk belongs based on the comparison result. When it is determined that the total access heat is greater than the preset access threshold, the terminal can determine that the hard disk is a hard disk to be migrated out. When it is determined that the total access heat is less than the preset access threshold, the terminal can determine that the hard disk is a hard disk to be migrated in. The preset access threshold can be determined based on the access heat of each hard disk in the target time period, or can be pre-configured in the storage system. The present disclosure does not specifically limit the specific value of the preset access threshold, and those skilled in the art can specifically determine it based on the actual application scenario.
[0153] In this embodiment, by determining whether each hard disk is a hard disk to be migrated out or a hard disk to be migrated in based on the relationship between the access heat of each hard disk and the average hard disk heat, data balance among multiple hard disks can be achieved based on the access heat, and the effect of migrating data blocks from a hard disk with high access heat and migrating data blocks to a hard disk with low access heat can be achieved, balancing the performance among each hard disk.
[0154] In one embodiment, the specific processing procedure of step 104, "respectively determine the data blocks to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out among the multiple data blocks included in each hard disk to be migrated out", includes:
[0155] For each hard disk to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, the data block whose sum value of access heat is close to the excessive access heat value of the hard disk to be migrated out is used as the data block to be migrated out of the hard disk to be migrated out.
[0156] Among them, the sum value of access heat can be the access heat value of a data block in the hard disk to be migrated out, or it can also be the sum value of the access heats of multiple data blocks in the hard disk to be migrated out; the sum value of the access heat being close to the excessive access heat value of the hard disk to be migrated out can mean that the sum value of the access heat is the same as the excessive access heat value, or the difference between the sum value of the access heat and the excessive access heat value is less than a preset threshold, etc.
[0157] Specifically, for each hard disk to be migrated out among the multiple hard disks to be migrated out included in the storage system, the terminal will determine the access heat corresponding to each data block included in the hard disk to be migrated out, and perform screening based on the access heat of each data block, and extract the data block whose sum value of the access heat is closest to the excessive access heat value of the hard disk to be migrated out as the data block to be migrated out of the hard disk to be migrated out.
[0158] In one example, the terminal can perform screening on each data block based on the excessive access heat value of the hard disk to be migrated out. If there is a data block whose access heat is the same as the excessive access heat value of the hard disk to be migrated out, the terminal can determine this data block as the data block to be migrated out of the hard disk to be migrated out. In another example, if there is no data block whose access heat is the same as the excessive access heat value of the hard disk to be migrated out, the terminal can obtain the first data block with the highest access heat in the hard disk to be migrated out, calculate the difference between the access heat of the first data block and the excessive access heat value, and query the second data block whose access heat is the same as this difference. In this way, the terminal can determine both the first data block and the second data block as the data blocks to be migrated out of the hard disk to be migrated out.
[0159] Optionally, the set of hard disks to be migrated out included in the storage system Regarding this, the terminal can determine that in there are some data blocks whose sum of heat values is closest to the excessive access heat value of the i-th hard disk to be migrated out In this way, the terminal can determine that these are the data that needs to be migrated out, that is, the data blocks to be migrated out; the terminal can also record the data volume corresponding to each data block to be migrated out in the disk Among them, for each data block to be migrated out
[0160] In this embodiment, by determining the data block to be migrated out based on the data block whose sum value of the access heat is close to the excessive access heat value of the hard disk to be migrated out, the data block with a relatively high heat can be accurately determined, which is convenient for the subsequent flow of data blocks among various hard disks and realizes the balance of read traffic on each hard disk.
[0161] In one embodiment, the specific processing procedure of step 106, "determine the target data block to be migrated out in the sequence of data blocks to be migrated out that matches the access heat value shortage of the hard disk to be migrated in", includes:
[0162] In the sequence of data blocks to be migrated out, determine the top target number of target data blocks to be migrated out whose sum of access heat values is close to the access heat value difference of the hard disk to be migrated in.
[0163] Specifically, the terminal can sort the multiple data blocks to be migrated out corresponding to the multiple hard disks to be migrated out in descending order of the access heat values of the data blocks to be migrated out to obtain the sequence of data blocks to be migrated out corresponding to the storage system. Correspondingly, the terminal can also arrange the hard disks to be migrated in in descending order of the access heat value shortage of each hard disk to be migrated in to obtain the sequence of hard disks to be migrated in. The terminal can traverse the sequence of hard disks to be migrated in. For each hard disk to be migrated in, the terminal can obtain the access heat value shortage of the hard disk to be migrated in, and screen in the sequence of data blocks to be migrated out based on the access heat value shortage of the hard disk to be migrated in to determine that the data block to be migrated out with the access heat value closest to the access heat value shortage is the target data block to be migrated out, or the top target number of data blocks to be migrated out whose sum of access heat values is closest to the access heat value shortage is the target data block to be migrated out.
[0164] In one example, the sequence of data blocks to be migrated out contains multiple data blocks to be migrated out arranged in descending order of access heat value. For each hard disk to be migrated in, the terminal can obtain the top target number of data blocks to be migrated out that meet the preset proximity condition with the access heat value shortage, and determine the top target number of data blocks to be migrated out as the target data block to be migrated out; the target number can be 1, and the target number can also be any value greater than 1; for example, the terminal can obtain the first data block to be migrated out in the sequence of data blocks to be migrated out in the current situation, and determine whether the first data block to be migrated out meets the preset proximity condition with the access heat value shortage. If it meets the preset proximity condition, then determine the first data block to be migrated out as the target data block to be migrated out. If it does not meet the preset proximity condition, then determine whether the sum of the first 2 data blocks to be migrated out meets the preset proximity condition with the access heat value shortage of the hard disk to be migrated in, until it is determined that the top target number of data blocks to be migrated out meets the preset proximity condition. At this time, the top target number of data blocks to be migrated out in the sequence of data blocks to be migrated out can be determined as the target data block to be migrated out. Optionally, the preset proximity condition can be the same value, or the difference value is less than the preset threshold, etc.
[0165] Based on this, the specific processing procedure of the above step "determine the target data block in the hard disk to be migrated in" includes:
[0166] Among the multiple data blocks included in the hard disk to be migrated, the first target number of data blocks are used as the target data blocks matching the target data blocks to be migrated out in ascending order of the access heat of each data block.
[0167] Specifically, after the terminal determines the target number of target data blocks to be migrated out corresponding to the hard disk to be migrated, it can arrange the multiple data blocks included in the hard disk to be migrated in ascending order of access heat, and determine the first target number of data blocks as the target data blocks matching the target data blocks to be migrated out.
[0168] The specific processing process of the step "migrate the target data blocks to the hard disk to be migrated out where the target data blocks to be migrated out are located" includes:
[0169] Respectively migrate each target data block to the hard disk to be migrated out where each target data block to be migrated out is located in ascending order of the access heat of each target data block.
[0170] Specifically, the terminal determines the first target number of data blocks to be migrated out in the data block sequence to be migrated out as the target data blocks to be migrated out, and also determines the first target number of target data blocks in the multiple data blocks included in the hard disk to be migrated in ascending order of access heat. Based on this, the terminal can migrate the first target number of data blocks to be migrated out to the hard disk to be migrated, and migrate the first target number of target data blocks, and migrate each target data block to the hard disk to be migrated out where the first target number of target data blocks to be migrated out are located in turn, completing the data block balance between the hard disk to be migrated and the hard disk to be migrated out.
[0171] In this embodiment, data blocks are allocated to each hard disk based on the access heat of the data blocks, achieving heat balance, avoiding the occurrence of read hotspots, and improving the overall performance of the storage system.
[0172] In one embodiment, as Figure 5 shown, the specific processing process of step 106 "for each hard disk to be migrated, determine the target data blocks to be migrated out matching the hard disk to be migrated in the data block sequence to be migrated out, and determine the target data blocks in the hard disk to be migrated, and perform data migration based on the target data blocks to be migrated out and the target data blocks" includes:
[0173] Step 502, for the currently traversed hard disk to be migrated, in the current data block sequence to be migrated out, use the first data block to be migrated out as the target data block to be migrated out matching the under-amount access heat value of the hard disk to be migrated, migrate the target data block to be migrated out to the hard disk to be migrated, and in the hard disk to be migrated, migrate the first data block to the hard disk to be migrated out where the target data block to be migrated out is located in ascending order of the access heat of the data blocks.
[0174] Specifically, the terminal can traverse the hard disk sequence to be migrated. For the currently traversed hard disk to be migrated, the terminal can determine the first data block to be migrated out in the sequence of data blocks to be migrated out in the current situation as the target data block to be migrated out that matches the under-quota access heat value of the hard disk to be migrated. The terminal can migrate the target data block to be migrated out (i.e., the first data block to be migrated out) to the hard disk to be migrated. Correspondingly, the terminal can arrange the multiple data blocks included in the hard disk to be migrated in ascending order of access heat, and determine the first data block as the target data block corresponding to the target data block to be migrated out, and migrate the target data block (the first data block) to the hard disk to be migrated out where the target data block to be migrated out is located.
[0175] Step 504, if the access heat of the first data block to be migrated out is less than or equal to the under-quota access heat value of the hard disk to be migrated, update the under-quota access heat value of the hard disk to be migrated, and re-execute the step of taking the first data block to be migrated out as the target data block to be migrated out that is close to the under-quota access heat value of the first hard disk to be migrated until the access heat of the first data block to be migrated out is greater than the under-quota access heat value of the hard disk to be migrated, and traverse the next hard disk to be migrated in the currently traversed hard disks to be migrated.
[0176] Specifically, if the access heat of the first data block to be migrated out is less than or equal to the under-quota access heat value of the hard disk to be migrated, the terminal can determine that data blocks continue to be migrated to the hard disk to be migrated currently. The terminal can update the under-quota access heat value of the hard disk to be migrated based on the total access heat of the hard disk to be migrated in the current situation. Based on the updated under-quota access heat value, the terminal can re-execute the above step of taking the first data block to be migrated out as the target data block to be migrated out that matches the under-quota access heat value of the hard disk to be migrated in the current sequence of data blocks to be migrated out, and migrating the target data block to be migrated out to the hard disk to be migrated until the access heat of the first data block to be migrated out is greater than the under-quota access heat value of the hard disk to be migrated. The terminal can determine that the processing of the hard disk to be migrated is completed and can traverse the next hard disk to be migrated in the currently traversed hard disks to be migrated.
[0177] In one example, the terminal can traverse the hard disk sequence to be migrated. For the currently traversed hard disk to be migrated, the terminal can, in the sequence of data blocks to be migrated in the current situation, migrate the first data block to be migrated in the current sequence of data blocks to be migrated to the hard disk to be migrated, and migrate the first data block of the hard disk to be migrated to the hard disk to be migrated where the first data block to be migrated is located, and determine whether the access heat of the first data block to be migrated (the data block to be migrated that has been migrated to the hard disk to be migrated, that is, the target data block to be migrated) is greater than the under-amount access heat value of the hard disk to be migrated; if the terminal determines that the access heat of the data block to be migrated that has been migrated to the hard disk to be migrated is greater than or equal to the under-amount access heat value of the hard disk to be migrated, the terminal can update the under-amount access heat value of the hard disk to be migrated based on the access heat of each data block included in the current hard disk to be migrated, and complete the traversal of the current hard disk to be migrated.
[0178] If the terminal determines that the access heat of the data block to be migrated that has been migrated to the hard disk to be migrated is less than the under-amount access heat value of the hard disk to be migrated, the terminal continues to migrate the first data block to be migrated in the current sequence of data blocks to be migrated in the current situation to the hard disk to be migrated until the access heat of the data block to be migrated that has been migrated to the hard disk to be migrated is greater than or equal to the under-amount access heat value of the hard disk to be migrated, complete the traversal of the current hard disk to be migrated, and traverse the next hard disk to be migrated of the hard disk to be migrated until the traversal of the hard disk sequence to be migrated is completed.
[0179] In this embodiment, the heat information of each data block is calculated through the statistical results of read I / O, and then the heat data of each hard disk in the system is obtained. Based on the heat data and capacity information of the hard disk, data migration is performed to evenly direct the read traffic to each hard disk, so as to achieve balance in read operations and give full play to the disk read performance of the system.
[0180] In one embodiment, as Figure 6 shown, the data balancing method further includes:
[0181] Step 602, in response to a data read request, determine the access heat information of the data block corresponding to the data read request.
[0182] Among them, the access heat information includes the current access heat of the data block (which can be denoted as H) and the previous access time of the data block. The data read request can be a read I / O request, for example, it can be a read I / O initiated by a user terminal. The previous access time of the data block is the time when the data block was last accessed (which can be denoted as T last )
[0183] Specifically, after receiving a data reading request, the terminal can determine the data block requested by the data reading request and obtain the access heat information of the data block in the current situation. The terminal can obtain the current access heat of the data block and the previous access time of the data block.
[0184] Step 604: Update the current access heat of the data block based on the current time and the previous access time to obtain the updated current access heat of the data block, and determine the current time as the updated previous access time of the data block.
[0185] Specifically, the terminal can obtain the current time and update the current access heat of the data block based on the current time and the previous access time of the data block to obtain the updated current access heat of the data block; in one example, after calculating the current access heat of the data block, the terminal can store the current time as the updated previous access time of the data block. In one example, the terminal can continuously update the current access heat of each data block through a scheduled task.
[0186] In this embodiment, continuously updating the access heat of the data block through the previous access time and the current time can ensure the timeliness of the access heat of the data block.
[0187] In one embodiment, as Figure 7 shown, the specific processing process of the step "Update the current access heat of the data block based on the current time and the previous access time to obtain the updated current access heat of the data block" includes:
[0188] Step 702: When the previous access time of the data block is the target parameter, determine the target value as the updated current access heat of the data block.
[0189] Wherein, the target parameter indicates that the data block has not been accessed, and the target parameter can also indicate that the previous access time of the data block is empty. For example, the target parameter can be 0, etc., and the target value can be 1, etc.
[0190] Specifically, the terminal can update the current access heat of the data block based on the matching relationship between the previous access time of the data block and the target parameter. If the terminal determines that the data block has no previous access time, that is, it can determine that the previous access time of the data block is the target parameter, then the terminal can update the current access heat of the data block based on the target value to obtain the updated current access heat of the data block. In one example, the terminal can determine the target value as the updated current access heat of the data block.
[0191] Step 704, when the previous access time of the data block is not the target parameter, calculate the time difference between the current time and the previous access time.
[0192] Specifically, if the terminal can query the previous access time of the data block, the terminal can calculate the time difference between the previous access time of the data block and the currently obtained current time. In this way, the terminal can update the current access popularity of the data block based on the calculated time difference and a preset time difference threshold to obtain the updated current access popularity of the data block.
[0193] Step 706, when the time difference is less than or equal to the preset time difference threshold, calculate the sum of the target value and the current access popularity of the data block, and determine the sum as the updated current access popularity of the data block. When the time difference is greater than the preset time difference threshold, calculate the ratio of the current access popularity of the data block to the time difference, and calculate the updated current access popularity of the data block based on the ratio and the target value.
[0194] Among them, the preset time difference threshold can be a threshold determined based on the actual application scenario. For example, it can be 5 minutes, etc. The present disclosure does not limit the specific value of the preset time difference threshold.
[0195] Specifically, the terminal can compare the time difference corresponding to the data block with the preset time difference threshold. If the time difference is less than or equal to the preset time difference threshold, the terminal can calculate the sum of the target value and the access popularity of the data block, and determine the sum as the updated current access popularity of the data block. If the terminal determines that the time difference is greater than the preset time difference threshold, the terminal can calculate the ratio of the access of the data block to the time difference, and calculate the sum of the ratio and the target value, and determine the calculated sum as the updated current access popularity of the data block.
[0196] In this embodiment, by using the time difference between the previous access time and the current time of the data block to update the current access popularity of the data block in real time, it is possible to achieve the effect that the access popularity of the data block increases as the number of data accesses increases, and it is also possible to achieve the effect that the popularity value gradually decreases when the data has not been accessed for more than a certain period of time.
[0197] In one embodiment, the data balancing method further includes:
[0198] When a preset time interval is reached, based on the current time and the previous access time of each data block, perform correction processing on the access popularity of each data block to obtain the corrected current access popularity of each data block.
[0199] Among them, the preset time interval can be the update period configured in the background of the storage system or the timing period, etc.
[0200] Specifically, the terminal can obtain the current time and the previous access time of each data block at intervals of the preset time interval, calculate the time difference between the current time and the previous access time of each data block respectively, and correct the current access heat of the data block based on the time difference corresponding to each data block and the preset time difference threshold to obtain the corrected current access heat of each data block.
[0201] In this embodiment, by periodically correcting the current access heat of the data block based on the previous access time of the data block, the accuracy of the current access heat calculation can be ensured, and the situation that the heat information cannot be updated and is misestimated due to updating the current access heat based on the read request can be avoided, providing a reliable data basis for subsequent data balancing. Moreover, by performing heat correction through background timing tasks, resource conflicts between data and balanced migration can be avoided, and the consumption of computing resources can be reduced.
[0202] In one embodiment, as Figure 8 shown, the specific processing process of the step "Based on the current time and the previous access time of each data block, respectively correct the access heat of each data block to obtain the corrected current access heat of each data block" includes:
[0203] Step 802, for each data block, calculate the first time difference between the current time and the previous access time of the data block.
[0204] Specifically, for each data block, after obtaining the current time, the terminal can calculate the first time difference between the current time and the previous access time of the data block.
[0205] Step 804, if the first time difference is greater than the preset time difference threshold, calculate the ratio of the current access heat of the data block to the first time difference, and determine the ratio as the corrected current access heat of the data block.
[0206] Specifically, the terminal can compare the calculated first time difference with the preset time difference threshold. If the terminal determines that the first time difference is greater than the preset time difference threshold, the terminal can calculate the ratio between the current access heat of the data block and the first time difference, and determine the ratio as the corrected current access heat of the data block; if the terminal determines that the first time difference is less than or equal to the preset time difference threshold, the terminal does not perform update processing on the current access heat of the data block, and still uses the original current access heat as the current access heat of the data block.
[0207] In this embodiment, by periodically correcting the current access popularity of data blocks based on the previous access time of the data blocks and a preset time difference threshold, the operation of updating the popularity of data blocks can be achieved without read operations, ensuring the timeliness of the current access popularity of each data block.
[0208] The following describes the specific execution process of the above data balancing method in detail in combination with a specific embodiment:
[0209] A data balancing method provided by an embodiment of the present application includes the calculation of the current access popularity (read popularity) of data blocks and the process of balanced migration based on the total read popularity of each hard disk. Among them, the calculation of read popularity may include the process of updating in response to the read IO process and automatically correcting the current access popularity of each data block through a timing task.
[0210] Specifically, the terminal can calculate and update the popularity of the data read in response to a data read request. For example, the terminal can count the data read situation based on the access time and the number of accesses. As Figure 9 shown, the terminal periodically detects the data popularity of each hard disk, corrects the popularity information, determines whether there is imbalance, and calculates the disk and data to be migrated out and performs a zigzag migration operation in the case of imbalance. If there is no imbalance, the data balancing is directly ended.
[0211] In an example, the newer the data access time and the more frequent the access, the higher the popularity of the data. The terminal can calculate the popularity of the data based on the LFU (Least Frequently Used) algorithm. The calculation of data popularity includes the calculation of read popularity, which may include the process of updating the popularity in response to the read IO process and automatically correcting the current access popularity of each data block through a timing task.
[0212] The update of the popularity in response to the read IO process includes: when the data is accessed, the data popularity is counted for a data block on a disk in granularities such as 512B / 4K / 1M. When a read IO request arrives, first obtain the corresponding popularity information through the target data block. The popularity information includes the time T when the current data was last accessed last , and the popularity value H of the data block. The popularity value can also be calculated based on the current time T curr , and a popularity correction threshold (preset time difference threshold, which can be denoted as Th). For example, the current access popularity of the data block (which can be denoted as H) can be calculated by the following formula:
[0213]
[0214] Among them, it can be ensured that the heat value of the data block increases as the number of data accesses increases. If the data has not been accessed for a period of time, the heat value will gradually decrease. After the terminal completes the update of the current access heat of the data block, the T of the data block can be updated based on the current time last 。
[0215] The heat calculation in the background timed task includes: Since the heat calculation in the read IO process is triggered by the read request, if a certain data block has been frequently accessed for a period of time and then there is no request to access the data block, its heat information cannot be updated and always remains at a high level, which will cause the balancing task to misevaluate the read traffic of each hard disk and affect the final balancing result. Therefore, it is also necessary to supplement and correct the data heat. The data balancing method provided in the embodiments of the present application places the heat correction in the background timed task, and before performing the calculation related to balancing, the data heat is corrected first. The correction formula is as follows:
[0216]
[0217] The process of performance balancing includes: The terminal can, based on the calculated heat data, statistically identify the heat differences between each hard disk. If there is imbalance, a data migration operation is performed to exchange the data between the hard disk with a heat higher than the average level and the hard disk with a heat lower than the average level, so as to achieve relative balance of the heat between each hard disk.
[0218] For the hard disk D in the storage system, the hard disk D includes a plurality of data blocks {d1, d2,..., d n}, and the heat corresponding to each data block is {H1, H2,..., H n}, then the total heat of the hard disk D (which can be denoted as Dh) is calculated by the following formula:
[0219] Dh = d1 + d2 +... + d n 。
[0220] For all the hard disks {D1, D2,..., D n} included in the storage system, their heat information {Dh1, Dh2,..., Dh n} is calculated respectively, and based on this, the average heat of each hard disk in the system (the average value of the hard disk heat, which can be denoted as Dh avg ) is calculated:
[0221] Dh avg = (Dh1 + Dh2 +... + Dh n ) / n
[0222] Among them, n represents the total number of hard disks included in the storage system.
[0223] The terminal can use the total heat of hard disk D (which can be denoted as Dh) and the average heat of each hard disk Dh avg The difference in heat values between them (the access heat difference, which can be denoted as ΔDh):
[0224] ΔDh = Dh - Dh avg
[0225] For hard disk D, if Dh is greater than Dh avg , then ΔDh > 0. According to the balancing strategy, it is necessary to migrate some high-heat data blocks from hard disk D and migrate some low-heat data blocks to hard disk D to reduce the disk heat. Conversely, if Dh is less than or equal to Dh avg , then ΔDh < 0. It is necessary to migrate some high-heat data blocks to hard disk D and migrate some low-heat data blocks from hard disk D to increase the disk heat.
[0226] For all hard disks {D1, D2,..., D n} included in the storage system, the corresponding access heat differences {ΔDh1, ΔDh2,..., ΔDh n} of each hard disk are used to classify each hard disk, that is, to obtain whether the access heat difference is an excessive access heat value or an insufficient access heat value, that is, to obtain the hard disk to be migrated (L out ) and the hard disk to be migrated to (L in ).
[0227]
[0228] For the elements in L out , the corresponding disk is Traverse all the disks in and calculate and obtain the data blocks to be migrated. Taking as an example , There are some data blocks in whose sum of heat values is closest to . Select as the data to be migrated from the disk and record the data volume of the data blocks migrated from the disk
[0229] For all the data blocks to be migrated from the hard disks in L out , sort them in descending order based on the heat values. The sorting result is The corresponding heat value is
[0230] Take the absolute value of the elements in L in and sort them in descending order. The sorting result is The corresponding disk is
[0231] based on and These two sets of data, calculate and select the source data block The calculation process of the migration target disk is as follows:
[0232] Traverse the two sets of data from front to back, that is, from and Start processing;
[0233] For the traversed data and The corresponding data block is Belong to hard disk The corresponding hard disk is During the heat balance migration process, the data blocks need to be From Hard Drive Migrate to Hard Drive Use hard disk Excess heat to compensate for the hard disk Insufficient heat. In addition, in order to balance capacity, it is also necessary to Take a data block Migrate to hard disk for Choices include:
[0234] Hard disk The data blocks in are sorted in ascending order of popularity, and the data block with the lowest current popularity is selected as the data block to be migrated back. Exchange completed and data and update the hard disk and After the heat information is obtained, the migration process is completed. At this time, there are two situations:
[0235] but The corresponding data block Not enough to fill Corresponding hard disk The heat gap continues to be filled with subsequent data blocks. The heat gap, that is, use and Continue to perform the above migration operations;
[0236] but The corresponding data block Enough to fill The corresponding hard disk 's heat gap, for the hard disk 's processing has ended. Select the subsequent hard disk as the next processing object, that is, use and Continue to execute the above migration operation;
[0237] Before continuing to execute the subsequent migration operation, it is necessary to first update the value of based on the heat data change brought by this migration until the traversal of the hard disk sequence to be migrated is completed.
[0238] A data balancing method provided by an embodiment of the present application can obtain the migrated-out blocks and migrated-in blocks for balanced migration. By performing data migration, it is possible to achieve both capacity balance and heat balance between disks. Specifically, the heat information of each data block can be calculated based on the statistical results of read IOs, and then the heat data of each hard disk in the system can be obtained. Through data migration, the read traffic can be evenly directed to each hard disk, thereby achieving balance in read operations and making more full use of the disk read performance of the system.
[0239] A data balancing method provided by an embodiment of the present application can use the statistically obtained data heat as the basis for balancing the data of each hard disk, and then balance the read traffic between each hard disk, try to avoid the occurrence of hot hard disks, make full use of the disk read performance of the entire cluster, and can ensure capacity balance and performance balance, that is, try to balance the read traffic between each hard disk and be able to reach a higher performance ceiling.
[0240] It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence according to the arrows, these steps do not necessarily have to be executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps does not have a strict order limit, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these steps or stages does not necessarily have to be sequential, but can be executed alternately or in turn with at least some of the steps or stages in other steps or other steps.
[0241] Based on the same inventive concept, an embodiment of the present application also provides a data balancing device for implementing the above-mentioned data balancing method. The implementation solution provided by this device to solve problems is similar to the implementation solution described in the above method. Therefore, the specific limitations in one or more embodiments of the data balancing device provided below can refer to the limitations on the data balancing method in the above text and will not be repeated here.
[0242] In one embodiment, as Figure 10 shown, a data balancing device 1000 is provided, which is applied to a storage system. The storage system includes multiple hard disks, and each hard disk includes multiple data blocks. The device includes:
[0243] A first determination module 1002, configured to determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of the data blocks included in each hard disk;
[0244] A second determination module 1004, configured to obtain a sequence of hard disks to be migrated in based on each hard disk to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out;
[0245] A third determination module 1006, configured to traverse the sequence of hard disks to be migrated in, and for each hard disk to be migrated in, determine a target data block to be migrated out that matches the hard disk to be migrated in from the sequence of data blocks to be migrated out, and determine a target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block.
[0246] In one of the embodiments, the second determination module is specifically configured to: for each hard disk to be migrated out, determine the data block to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out from the multiple data blocks included in the hard disk to be migrated out;
[0247] Sort the multiple data blocks to be migrated out corresponding to each hard disk to be migrated out according to the first sorting order of the access heat, to obtain a sequence of data blocks to be migrated out, and the first sorting order is the order from large to small of the access heat of each data block to be migrated out.
[0248] In one of the embodiments, the second determination module is specifically configured to: sort the hard disks to be migrated in according to the second target order of the insufficient access heat value of each hard disk to be migrated in, to obtain a sequence of hard disks to be migrated in, and the second target order is the order from large to small of the insufficient access heat value of each hard disk to be migrated in.
[0249] In one of the embodiments, the third determination module is specifically configured to: for each hard disk to be migrated in, determine the target data block to be migrated out that matches the insufficient access heat value of the hard disk to be migrated in from the sequence of data blocks to be migrated out;
[0250] In the multiple data blocks included in the hard disk to be migrated in, take the first target number of data blocks in the order from small to large of the access heat of each data block as the target data blocks that match the target data block to be migrated out;
[0251] Migrate the target data block to be migrated out to the target data block to be migrated in, and respectively migrate each target data block to the hard disk to be migrated out where each target data block to be migrated out is located in the order from small to large of the access heat of each target data block.
[0252] In one embodiment, the first determination module is specifically configured to:
[0253] For each hard disk included in the storage system, based on the access heat of multiple data blocks included in the hard disk, calculate the total access heat of the hard disk;
[0254] Based on the total access heat of each hard disk, calculate the average hard disk heat, and based on the total access heat of each hard disk and the average hard disk heat, calculate the access heat difference of each hard disk respectively;
[0255] If the access heat difference of the hard disk is greater than the preset value, determine that the hard disk is a hard disk to be migrated out, and the excess access heat value of the hard disk to be migrated out is the excess access heat value; if the access heat difference of the hard disk is less than the preset value, determine that the hard disk is a hard disk to be migrated in, and the access heat difference of the hard disk to be migrated in is the shortage access heat value.
[0256] In one embodiment, the second determination module is specifically configured to:
[0257] For each hard disk to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, use the data blocks whose sum of access heat is close to the excess access heat value of the hard disk to be migrated out as the data blocks to be migrated out of the hard disk to be migrated out.
[0258] In one embodiment, the third determination module is specifically configured to:
[0259] In the sequence of data blocks to be migrated out, determine the first target number of target data blocks to be migrated out whose sum of access heat is close to the access heat difference of the hard disk to be migrated in; among the multiple data blocks included in the hard disk to be migrated in, in the ascending order of the access heat of each data block, use the first target number of data blocks as the target data blocks matching the target data blocks to be migrated out; in the ascending order of the access heat of each target data block, migrate each target data block to the hard disk to be migrated out where the target data block to be migrated out is located respectively.
[0260] In one embodiment, the third determination module is specifically configured to: for the currently traversed hard disk to be migrated in, in the current sequence of data blocks to be migrated out, use the first data block to be migrated out as the target data block to be migrated out whose shortage access heat value is close to the hard disk to be migrated in, migrate the target data block to be migrated out to the hard disk to be migrated in, and in the hard disk to be migrated in, in the ascending order of the access heat of the data blocks, migrate the first data block to the hard disk to be migrated out where the target data block to be migrated out is located;
[0261] If the access heat of the first data block to be migrated out is less than or equal to the deficit access heat value of the hard disk to be migrated in, update the deficit access heat value of the hard disk to be migrated in, and re - execute the step of taking the first data block to be migrated out as the target data block to be migrated out close to the deficit access heat value of the first hard disk to be migrated in until the access heat of the first data block to be migrated out is greater than the deficit access heat value of the hard disk to be migrated in, and then traverse the next hard disk to be migrated in among the currently traversed hard disks to be migrated in.
[0262] In one embodiment, the data balancing device further includes:
[0263] A fourth determination module, configured to determine the access heat information of the data block corresponding to the data read request in response to the data read request, where the access heat information includes the current access heat of the data block and the previous access time of the data block;
[0264] A first update module, configured to update the current access heat of the data block through the current time and the previous access time to obtain the updated current access heat of the data block, and determine the current time as the updated previous access time of the data block.
[0265] In one embodiment, the first update module is specifically configured to:
[0266] When the previous access time of the data block is a target parameter, determine the target value as the updated current access heat of the data block, where the target parameter indicates that the data block has not been accessed;
[0267] When the previous access time of the data block is not the target parameter, calculate the time difference between the previous access time and the current time;
[0268] When the time difference is less than or equal to the preset time difference threshold, calculate the sum value of the target value and the access heat of the data block, and determine the sum value as the updated current access heat of the data block; when the time difference is greater than the preset time difference threshold, calculate the ratio of the access of the data block to the time difference, and calculate the updated current access heat of the data block based on the ratio and the target value.
[0269] In one embodiment, the data balancing device further includes:
[0270] A correction module, configured to, when the preset time interval is reached, respectively perform correction processing on the access heat of each data block based on the current time and the previous access time of each data block to obtain the corrected current access heat of each data block.
[0271] In one embodiment, the correction module is specifically configured to:
[0272] For each data block, calculate a first time difference between the current time and the previous access time of the data block;
[0273] If the first time difference is greater than a preset time difference threshold, calculate a ratio of the access heat of the data block to the first time difference, and determine the ratio as the corrected current access heat of the data block.
[0274] Each module in the above data balancing device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0275] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 11 shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store hard disk data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a data balancing method.
[0276] Those skilled in the art can understand that Figure 11 the structure shown in
[0277] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0278] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the steps in each of the above method embodiments.
[0279] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, it implements the steps in each of the above method embodiments.
[0280] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0281] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0282] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.
[0283] The above embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation to the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A data balancing method, characterized in that, Applied to a system, the system includes a plurality of hard disks, and each hard disk includes a plurality of data blocks. The method includes: Determine a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of the data blocks included in each hard disk; Based on each of the hard disks to be migrated in, obtain a sequence of hard disks to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out; Traverse the sequence of hard disks to be migrated in. For each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine a target data block to be migrated out that matches the hard disk to be migrated in, and determine a target data block in the hard disk to be migrated in. Perform data migration based on the target data block to be migrated out and the target data block.
2. The method according to claim 1, characterized in that, The step of respectively determining the data blocks to be migrated out corresponding to each hard disk to be migrated out, to obtain a sequence of data blocks to be migrated out, includes: For each hard disk to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, determine the data block to be migrated out corresponding to the excessive access heat value of the hard disk to be migrated out; Sort the multiple data blocks to be migrated out corresponding to each hard disk to be migrated out according to the first sorting order of access heat, where the first sorting order is the order from largest to smallest of the access heat of each data block to be migrated out, to obtain a sequence of data blocks to be migrated out.
3. The method according to claim 1, characterized in that The step of obtaining a sequence of hard disks to be migrated in based on each of the hard disks to be migrated in includes: Sort the hard disks to be migrated in according to the second target order of the insufficient access heat value of each hard disk to be migrated in, where the second target order is the order from largest to smallest of the insufficient access heat value of each hard disk to be migrated in, to obtain a sequence of hard disks to be migrated in.
4. The method according to claim 1, characterized in that The step of, for each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine a target data block to be migrated out that matches the hard disk to be migrated in, and determine a target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block includes: For each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine a target data block to be migrated out that matches the insufficient access heat value of the hard disk to be migrated in; Among the multiple data blocks included in the hard disk to be migrated in, in the order from smallest to largest of the access heat of each data block, use the previous target number of data blocks as the target data blocks that match the target data block to be migrated out; Migrate the target data block to be migrated out to the target data block, and respectively migrate each target data block to the hard disk to be migrated out where the target data block to be migrated out is located, in the order from smallest to largest of the access heat of each target data block.
5. The method according to claim 1, characterized in that, The step of determining a hard disk to be migrated out and a hard disk to be migrated in based on the access heat of the data blocks included in each hard disk includes: For each hard disk included in the system, based on the access heat of the multiple data blocks included in the hard disk, calculate the total access heat of the hard disk; Based on the total access heat of each hard disk, calculate the average hard disk heat, and based on the total access heat of each hard disk and the average hard disk heat, respectively calculate the access heat difference of each hard disk; If the access heat difference of the hard disk is greater than a preset value, determine that the hard disk is a hard disk to be migrated out, and the access heat difference of the hard disk to be migrated out is the excess access heat value; if the access heat difference of the hard disk is less than the preset value, determine that the hard disk is a hard disk to be migrated in, and the access heat difference of the hard disk to be migrated in is the deficit access heat value.
6. The method according to claim 2, wherein Determining, in the multiple data blocks included in each of the hard disks to be migrated out, a data block to be migrated out corresponding to the excess access heat value of the hard disk to be migrated out includes: For each hard disk to be migrated out, among the multiple data blocks included in the hard disk to be migrated out, use the data block whose sum value of access heat is close to the excess access heat value of the hard disk to be migrated out as the data block to be migrated out of the hard disk to be migrated out.
7. The method according to claim 4, wherein Determining, in the sequence of data blocks to be migrated out, a target data block to be migrated out that matches the deficit access heat value of the hard disk to be migrated in includes: In the sequence of data blocks to be migrated out, determine the first target number of target data blocks to be migrated out whose sum value of access heat is close to the access heat difference of the hard disk to be migrated in.
8. The method according to claim 1, characterized in that, For each hard disk to be migrated in, determining, in the sequence of data blocks to be migrated out, a target data block to be migrated out that matches the hard disk to be migrated in, and determining a target data block in the hard disk to be migrated in, and performing data migration based on the target data block to be migrated out and the target data block includes: For the currently traversed hard disk to be migrated in, in the current sequence of data blocks to be migrated out, use the first data block to be migrated out as the target data block to be migrated out that matches the deficit access heat value of the hard disk to be migrated in, migrate the target data block to be migrated out to the hard disk to be migrated in, and in the hard disk to be migrated in, migrate the first data block to the hard disk to be migrated out where the target data block to be migrated out is located in ascending order of the access heat of the data blocks. If the access heat of the first data block to be migrated out is less than or equal to the deficit access heat value of the hard disk to be migrated in, update the deficit access heat value of the hard disk to be migrated in, and re - execute the step of using the first data block to be migrated out as the target data block to be migrated out that is close to the deficit access heat value of the first hard disk to be migrated in until the access heat of the first data block to be migrated out is greater than the deficit access heat value of the hard disk to be migrated in, and traverse the next hard disk to be migrated in of the currently traversed hard disk to be migrated in.
9. The method according to claim 1, wherein The method further includes: In response to a data read request, determine the access heat information of the data block corresponding to the data read request, where the access heat information includes the current access heat of the data block and the previous access time of the data block; Update the current access heat of the data block through the current time and the previous access time to obtain the updated current access heat of the data block, and determine the current time as the updated previous access time of the data block.
10. The method according to claim 9, characterized in that, Updating the current access heat of the data block through the current time and the previous access time to obtain the updated current access heat of the data block includes: When the previous access time of the data block is the target parameter, determine the target value as the updated current access popularity of the data block, where the target parameter indicates that the data block has not been accessed; When the previous access time of the data block is not the target parameter, calculate the time difference between the current time and the previous access time; When the time difference is less than or equal to the preset time difference threshold, calculate the sum of the target value and the current access popularity of the data block, and determine the sum as the updated current access popularity of the data block; when the time difference is greater than the preset time difference threshold, calculate the ratio of the current access popularity of the data block to the time difference, and calculate the updated current access popularity of the data block based on the ratio and the target value.
11. The method according to claim 9, wherein The method further includes: When a preset time interval is reached, based on the current time and the previous access time of each data block, respectively perform correction processing on the current access popularity of each data block to obtain the corrected current access popularity of each data block.
12. The method according to claim 11, wherein The performing correction processing on the current access popularity of each data block based on the current time and the previous access time of each data block to obtain the corrected current access popularity of each data block includes: For each data block, calculate the first time difference between the current time and the previous access time of the data block; If the first time difference is greater than the preset time difference threshold, calculate the ratio of the current access popularity of the data block to the first time difference, and determine the ratio as the corrected current access popularity of the data block.
13. A data balancing device, characterized in that, Applied to a system, the system includes multiple hard disks, each hard disk includes multiple data blocks, and the device includes: A first determination module, configured to determine a hard disk to be migrated out and a hard disk to be migrated in based on the access popularity of the data blocks included in each hard disk; A second determination module, configured to obtain a sequence of hard disks to be migrated in based on each hard disk to be migrated in; and respectively determine the data blocks to be migrated out corresponding to each hard disk to be migrated out to obtain a sequence of data blocks to be migrated out; A third determination module, configured to traverse the sequence of hard disks to be migrated in, and for each hard disk to be migrated in, in the sequence of data blocks to be migrated out, determine a target data block to be migrated out that matches the hard disk to be migrated in, and determine a target data block in the hard disk to be migrated in, and perform data migration based on the target data block to be migrated out and the target data block.
14. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.
Citation Information
Cited By
Heat processing method and device, computer equipment, storage medium and program product
CN121680726A
