A method, apparatus, and electronic device for processing storage resources
By inserting new hard disks into RAID and replacing logical blocks, the problem of handling RAID storage resources without affecting existing services and increasing disk bandwidth overhead is solved, and fast and convenient capacity expansion and fault repair are achieved.
Patent Information
- Application Number
- CN202210350128.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-02
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2042-04-02
AI Technical Summary
How to quickly and conveniently handle RAID storage resources without affecting the operation of existing services and without adding additional disk bandwidth overhead, especially when RAID usage status changes, such as capacity expansion or hard disk failure repair.
By inserting a new hard disk into the target RAID and replacing the logical blocks to be replaced in the pending strip with the logical blocks in the pending strip, the logical blocks of each pending strip belong to a different hard disk respectively to ensure that the data writing operation is normal.
It realizes the rapid and convenient processing of RAID storage resources without affecting the operation of existing services and without adding additional disk bandwidth overhead, ensuring the smooth progress of data writing and increasing storage space during capacity expansion.
Smart Images

Figure CN114691048B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and particularly to a method and apparatus for processing storage resources and an electronic device. Background Art
[0002] With the continuous development of RAID (Redundant Arrays of Independent Disks) technology and EC (Erasure Coding) technology, based on the fact that RAID technology supports dividing hard disks into several logical blocks (trunks), in combination with EC technology, any combination of the number (N) of data blocks and the number (M) of parity blocks included in each stripe in RAID can be achieved, where N≥M and N>1. In this way, the redundancy and security of RAID can be improved.
[0003] Among them, each data block and each parity block included in each stripe in RAID come from different hard disks respectively. For example, different hard disks on the same storage node or different hard disks on different storage nodes. For example, according to the number of slots in the device and the requirements of RAID, N+M hard disks for creating RAID are determined. Then, each hard disk is divided into several virtual logical blocks (trunks). Then, one logical block (trunk) included in each hard disk is used to create a stripe including N data blocks and M parity blocks, obtaining multiple stripes, and each stripe includes N+M logical blocks (trunks), and these storage blocks come from N+M different hard disks respectively. Among them, the so-called slot is: a card slot for inserting a hard disk to install the hard disk on the device.
[0004] However, in many cases, due to the change in the usage status of RAID, it is necessary to process the storage resources of RAID to ensure the normal use of RAID. For example, due to reasons such as the continuous development of business, users often need to expand the existing RAID; for another example, the hard disk used to create RAID fails, resulting in a faulty logical block (trunk) in the stripe, reducing the security of the data stored in the stripe.
[0005] Based on this, how to achieve fast and convenient processing of the storage resources of RAID without affecting the operation of existing services and without increasing additional disk bandwidth overhead has become an urgent problem to be solved currently. Summary of the Invention
[0006] The objective of the embodiments of the present invention is to provide a RAID expansion method, device, and a RAID driver, which can achieve fast and convenient processing of the storage resources of the RAID without affecting the operation of existing services and without increasing additional disk bandwidth overhead. The specific technical solutions are as follows:
[0007] In a first aspect, the embodiments of the present invention provide a method for processing storage resources. The method includes: determining a target RAID to be processed; where the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks, and the sizes of the logical blocks belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of the multiple initial hard disks; determining each strip to be processed from the multiple initial strips included in the target RAID; using the logical blocks for replacement in the target hard disk to replace the logical blocks to be replaced in each strip to be processed, so that the multiple logical blocks included in each processed strip belong to different hard disks respectively; where the target hard disk is a newly added hard disk, and the sizes of the logical blocks for replacement in the target hard disk are the same as the sizes of the logical blocks in each initial hard disk.
[0008] In a second aspect, the embodiments of the present invention provide a device for processing storage resources. The device includes: a RAID determination module, configured to determine a target RAID to be processed; where the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks, and the sizes of the logical blocks belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of the multiple initial hard disks; a stripe determination module, configured to determine each strip to be processed from the multiple initial strips included in the target RAID; a stripe processing module, configured to use the logical blocks for replacement in the target hard disk to replace the logical blocks to be replaced in each strip to be processed, so that the multiple logical blocks included in each processed strip belong to different hard disks respectively; where the target hard disk is a newly added hard disk, and the sizes of the logical blocks for replacement in the target hard disk are the same as the sizes of the logical blocks in each initial hard disk.
[0009] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; the memory is used for storing a computer program; when the processor executes the program stored on the memory, the steps of any of the storage resource processing methods provided in the first aspect are implemented.
[0010] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the storage resource processing methods provided in the first aspect are implemented.
[0011] In a fifth aspect, an embodiment of the present invention provides a computer program product containing instructions, which when running on a computer, causes the computer to execute the steps of any of the storage resource processing methods provided in the first aspect.
[0012] Advantageous effects of the embodiments of the present invention:
[0013] As can be seen above, by applying the solution provided by the embodiment of the present invention, first, a target RAID to be processed is determined. The target RAID includes multiple initial hard disks, and each initial hard disk is divided into multiple logical blocks (trunks), and the sizes of the logical blocks (trunks) belonging to different initial hard disks are the same. Among them, when constructing the target RAID, the number of data blocks (Data block) and the number of parity blocks (Parityblock) included in each initial stripe in the target RAID are set, and the sum of the above data block (Data block) number and parity block (Parity block) number is a first number, and the first number is not greater than the number of the above multiple initial hard disks. Thus, each initial stripe can include the first number of logical blocks (trunks) belonging to the first number of initial hard disks. Then, when performing storage resource processing on the above target RAID, new hard disks can be inserted first on the devices where the respective initial hard disks included in the target RAID are located, and each new hard disk is divided into multiple logical blocks (trunks), and the sizes of the logical blocks (trunks) in each new hard disk are the same as the sizes of the logical blocks (trunks) in each initial hard disk.
[0014] In this way, when processing the storage resources of the above-mentioned target RAID, a target hard disk for processing the storage resources of the above-mentioned target RAID can be selected from the above-mentioned newly added hard disks, and each stripe to be processed can be determined from the multiple initial stripes included in the target RAID. Furthermore, the trunk for replacement in the target hard disk can be used to replace the trunk to be replaced in each stripe to be processed, so that the multiple trunks included in each stripe to be processed after replacement belong to different hard disks respectively, and the processed target RAID is obtained.
[0015] Based on this, when applying the solution provided by the embodiment of the present invention to process the storage resources of the target RAID, the trunk for replacement in the newly added target hard disk can be used to replace the trunk to be replaced in each stripe to be processed in the target RAID, and each stripe to be processed after replacement is obtained. Moreover, the multiple trunks included in each stripe to be processed after replacement belong to different hard disks respectively. During the above processing, for each stripe to be processed after replacement and each stripe in the target RAID except the stripe to be processed, various operations such as data writing operations can be normally executed. Thus, it is possible to ensure the normal operation of the existing service without stopping it; and since each stripe to be processed after replacement includes the trunk in the target hard disk, when a data writing operation is executed on the stripe to be processed after replacement, the data to be written can be successfully written into the target hard disk. Thus, it is possible to avoid adding additional disk bandwidth overhead. In this way, it is possible to achieve fast and convenient processing of the storage resources of the RAID without affecting the operation of the existing service and without adding additional disk bandwidth overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other embodiments according to these drawings.
[0017] Figure 1 It is a schematic diagram of multiple initial stripes included in a target RAID;
[0018] Figure 2 In Figure 1Schematic diagram of each logical block divided in a target hard disk based on the target RAID shown;
[0019] Figure 3 Flow schematic diagram of a storage resource processing method provided by an embodiment of the present invention;
[0020] Figure 4 Flow schematic diagram of another storage resource processing method provided by an embodiment of the present invention;
[0021] Figure 5 Flow schematic diagram of another storage resource processing method provided by an embodiment of the present invention;
[0022] Figures 6 - 8 In Figure 1 Based on the target RAID shown and Figure 2 Based on the target hard disk shown, Figure 5 Schematic diagram of an example of a specific implementation manner;
[0023] Figure 9 Schematic diagram of multiple initial stripes included in another target RAID;
[0024] Figures 10 - 12 In Figure 10 Based on the target RAID shown and Figure 2 Based on the target hard disk shown, Figure 1 Schematic diagram of an example of a specific implementation manner of S302 in;
[0025] Figure 13 Flow schematic diagram of another storage resource processing method provided by an embodiment of the present invention;
[0026] Figure 14 Structural schematic diagram of a storage resource processing device provided by an embodiment of the present invention;
[0027] Figure 15 Structural schematic diagram of an electronic device provided by an embodiment of the present invention. Specific implementation manner
[0028] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art based on this application belong to the scope of protection of the present invention.
[0029] For a RAID, due to the change in the usage status of the RAID, it is necessary to process the storage resources of the RAID to ensure the normal use of the RAID. Based on this, how to achieve fast and convenient processing of the storage resources of the RAID without affecting the operation of existing services and without increasing additional disk bandwidth overhead has become an urgent problem to be solved currently.
[0030] To solve the above technical problems, an embodiment of the present invention provides a method for processing storage resources.
[0031] Among them, the method for processing storage resources is applicable to any application scenario that needs to process the storage resources of an existing RAID. Exemplarily, in the field of video surveillance, expanding the capacity of a RAID used to store surveillance videos; repairing a RAID including a faulty hard disk, etc. Of course, it is not limited to this.
[0032] Moreover, the method for processing storage resources can be applied to various independent electronic devices or clusters of electronic devices provided with a functional module for processing the storage resources of a RAID. For example, laptops, desktop computers, servers, etc. Of course, it is not limited to this, and hereinafter it can be simply referred to as an electronic device; thus, the electronic device can execute each step of the method for processing storage resources by running the above functional module and complete the processing of the storage resources of the RAID.
[0033] Among them, the functional module can be a RAID driver or other modules that can implement the function of processing the storage resources of a RAID. In this regard, the embodiments of the present invention do not make specific actions.
[0034] For example, the method for processing storage resources can be applied to a laptop installed with a RAID driver. The laptop executes each step of the method for processing storage resources by running the installed RAID driver and completes the processing of the storage resources of the RAID.
[0035] The target RAID to be processed includes multiple initial hard disks. Moreover, each initial hard disk is divided into multiple logical blocks (trunks), and the sizes of the logical blocks (trunks) belonging to different initial hard disks are the same. Thus, when constructing the target RAID, the number of data blocks (Data block) and the number of parity blocks (Parity block) included in each stripe in the target RAID can be set. Moreover, the sum of the number of data blocks (Data block) and the number of parity blocks (Parity block) included in each stripe is a first number, and the first number is not greater than the number of the above multiple initial hard disks.
[0036] In this way, to ensure the security of the data written to each stripe, each trunk in each stripe included in the target RAID is located on a different hard disk. Therefore, one trunk can be selected from each of the first number of initial hard disks to form a stripe, and thus, multiple initial stripes in the target RAID can be obtained. That is, each initial stripe in the target RAID includes: the first number of trunks respectively belonging to the first number of initial hard disks. That is to say, each trunk included in each initial stripe belongs to a different initial hard disk.
[0037] For example, as Figure 1 shown, it is a schematic diagram of multiple initial stripes included in a target RAID. Among them, the first number is 20, and TK is the abbreviation of trunk. Thus, TKa1 - TKa20 are respectively the first to the 20th trunks belonging to the initial hard disk a, TKb1 - TKb20 are respectively the first to the 20th trunks belonging to the initial hard disk b, TKc1 - TKc20 are respectively the first to the 20th trunks belonging to the initial hard disk c, and so on. TKt1 - TKt20 are respectively the first to the 20th trunks belonging to the initial hard disk t. That is to say, in Figure 1 , trunks with the same letter identifier belong to the same initial hard disk, while trunks with different letter identifiers belong to different initial hard disks, and trunks with the same letter identifier and different number identifiers are different trunks belonging to the same initial hard disk. In this way, each stripe includes twenty trunks respectively belonging to the initial hard disk a to the initial hard disk t.
[0038] In addition, optionally, when the number of multiple initial hard disks included in the target RAID is greater than the above first number, the initial hard disks to which the trunks included in different initial stripes belong may not be completely the same.
[0039] Furthermore, when processing the storage resources of the above-mentioned target RAID, one or more additional hard disks can be inserted into the above-mentioned device according to the number of available slots of the devices where the above-mentioned respective initial hard disks are located and the data storage requirements of the current service. Moreover, each additional hard disk is also divided into multiple logical blocks (trunks), and the size of each logical block (trunk) in each additional hard disk is the same as the size of each logical block (trunk) in each initial hard disk.
[0040] Optionally, the device where the above-mentioned respective initial hard disks are located can be one, that is, the above-mentioned respective initial hard disks are located on the same device, and then the additional hard disks are also inserted into this device.
[0041] Optionally, the devices where the above-mentioned respective initial hard disks are located can be multiple, that is, the above-mentioned respective initial hard disks are scattered and installed on different devices. Then each additional hard disk can also be inserted into any one of the above-mentioned multiple devices. Moreover, when the number of inserted additional hard disks is multiple, the multiple inserted additional hard disks can be inserted into the same device or into different devices.
[0042] For example, when the target RAID is as Figure 1 shown, then a schematic diagram of each logical block (trunk) divided in one type of additional hard disk can be as Figure 2 shown. As Figure 2 shown, TK is the abbreviation of trunk, TKu represents the additional hard disk, and TKu1 - TKu20 are the 20 logical blocks (trunks) in the additional hard disk TKu obtained after dividing the additional hard disk TKu into logical blocks (trunks).
[0043] Among them, the size of the logical block (trunk) in each target hard disk and the size of the logical block (trunk) in each initial hard disk are determined according to data storage service requirements, hard disk capacity, etc. In this regard, the embodiments of the present invention do not make specific limitations.
[0044] In this way, when processing the storage resources of the above-mentioned target RAID, the target hard disk for processing the storage resources of the target RAID can be determined from the above-mentioned respective additional hard disks according to the hard disk information of each initial hard disk included in the target RAID and the data storage requirements of the current service.
[0045] Based on the above content, a storage resource processing method provided by the embodiments of the present invention includes the following steps:
[0046] Determine the target RAID to be processed; wherein, the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks, and the sizes of the logical blocks belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of the multiple initial hard disks.
[0047] Determine each strip to be processed from the multiple initial strips included in the target RAID.
[0048] Use the logical blocks for replacement in the target hard disk to replace the logical blocks to be replaced in each strip to be processed, so that the multiple logical blocks included in each processed strip belong to different hard disks respectively; wherein, the target hard disk is a newly added hard disk, and the sizes of the logical blocks for replacement in the target hard disk are the same as the sizes of the logical blocks in each initial hard disk.
[0049] As can be seen above, by applying the solution provided in the embodiments of the present invention, first determine the target RAID to be processed, which includes multiple initial hard disks. And each initial hard disk is divided into multiple logical blocks (trunks), and the sizes of the logical blocks (trunks) belonging to different initial hard disks are the same. Among them, when constructing the target RAID, the number of data blocks and the number of parity blocks included in each initial stripe in the target RAID are set, and the sum of the above-mentioned number of data blocks and the number of parity blocks is the first number, and the first number is not greater than the number of the multiple initial hard disks. Thus, each initial stripe can include the first number of logical blocks (trunks) respectively belonging to the first number of initial hard disks. Then, when performing storage resource processing on the above target RAID, a newly added hard disk can be inserted into the device where each initial hard disk included in the target RAID is located, and each newly added hard disk is divided into multiple logical blocks (trunks), and the sizes of the logical blocks (trunks) in each newly added hard disk are the same as the sizes of the logical blocks (trunks) in each initial hard disk.
[0050] In this way, when processing the storage resources of the above-mentioned target RAID, a target hard disk for processing the storage resources of the above-mentioned target RAID can be selected from the above-mentioned newly added hard disks, and each stripe to be processed can be determined from the multiple initial stripes included in the target RAID. Furthermore, the trunk for replacement in the target hard disk can be used to replace the trunk to be replaced in each stripe to be processed, so that the multiple trunks included in each stripe to be processed after replacement belong to different hard disks respectively, and the processed target RAID can be obtained.
[0051] Based on this, when applying the solution provided by the embodiments of the present invention to process the storage resources of a target RAID, the trunk for replacement in the newly added target hard disk can be used to replace the trunk to be replaced in each stripe to be processed in the target RAID, and each stripe to be processed after replacement can be obtained. Moreover, the multiple trunks included in each stripe to be processed after replacement belong to different hard disks respectively. During the above processing, for each stripe to be processed after replacement and each stripe in the target RAID other than the stripe to be processed, various operations such as data writing operations can be normally executed. Thus, it is possible to ensure the normal operation of the existing services without stopping them; and since each stripe to be processed after replacement includes the trunk in the target hard disk, when a data writing operation is performed on the stripe to be processed after replacement, the data to be written can be smoothly written into the target hard disk. Therefore, it is possible to achieve fast and convenient processing of the storage resources of the RAID without affecting the operation of the existing services and without increasing additional disk bandwidth overhead.
[0052] Next, with reference to the accompanying drawings, a method for processing storage resources provided by the embodiments of the present invention will be specifically described.
[0053] Figure 3 It is a schematic flowchart of a method for processing storage resources provided by the embodiments of the present invention. As Figure 3 shown, the method may include the following steps:
[0054] S301: Determine the target RAID to be processed;
[0055] Among them, the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks (trunks), and the sizes of the logical blocks (trunks) belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks (trunks) respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of multiple initial hard disks;
[0056] The electronic device can first determine the target RAID to be processed from the already constructed RAID.
[0057] For example, determine the RAID with insufficient storage space that needs to be expanded as the target RAID to be processed; for another example, determine the RAID with a faulty hard disk among the multiple included hard disks that needs to be repaired as the target RAID to be processed, etc. Currently, it is not limited to this.
[0058] Optionally, for the already constructed RAID, the electronic device can determine whether the RAID is the target RAID to be processed according to the usage status of the RAID.
[0059] For example, for the already constructed RAID, when the electronic device determines that the usage status of the RAID is the status to be expanded, it means that the storage space of the RAID cannot meet the service requirements and needs to be expanded. Therefore, the electronic device can determine the RAID as the target RAID to be processed;
[0060] For another example, for the already constructed RAID, when the electronic device determines that the usage status of the RAID is the status to be repaired, it means that there is a faulty hard disk among the multiple hard disks included in the RAID and needs to be repaired. Therefore, the electronic device can determine the RAID as the target RAID to be processed.
[0061] S302: Determine each strip to be processed from the multiple initial strips included in the target RAID;
[0062] After determining the target RAID to be processed, the electronic device can determine each strip to be processed from the multiple initial strips (stripes) of the target RAID.
[0063] For example, when it is necessary to expand the target RAID, the electronic device may determine the stripe that is currently writing data in the RAID as the stripe to be processed, or may also determine the stripe that has written data in the RAID as the stripe to be processed, etc. For another example, when it is necessary to repair the target RAID, the electronic device may determine the stripe with a fault in the RAID as the stripe to be processed.
[0064] Optionally, during the continuous operation of the current service, the electronic device may perform a data writing operation on the initial stripe in the above-mentioned target RAID. In this way, the electronic device may determine the initial stripe for which the data writing operation is to be currently performed as the stripe to be processed. Furthermore, after replacing the trunk to be replaced in the stripe to be processed, the data to be written corresponding to the data writing operation may then be written into the replaced stripe to be processed. And if data has been written in the stripe to be processed and the written data is about to expire or has expired, the data to be written corresponding to the data writing operation will overwrite the data that has been written in the stripe to be processed, without the need to migrate the data that has been written in the stripe to be processed to the target hard disk. In this way, the electronic device may synchronously complete the processing of the storage resources of the above-mentioned target RAID during the continuous operation of the current service, and without increasing additional disk bandwidth overhead.
[0065] For another example, when it is necessary to repair a stripe that includes a trunk belonging to a faulty hard disk, the electronic device may determine the stripe that includes a trunk belonging to a faulty hard disk as the target RAID to be processed.
[0066] For the sake of clarity in writing, the above step S302 will be illustrated with examples later.
[0067] S303: Use the replacement trunks in the target hard disk to replace the trunks to be replaced in each stripe to be processed, so that the multiple trunks included in each replaced stripe to be processed belong to different hard disks respectively;
[0068] Among them, the target hard disk is a newly added hard disk, and the size of each replacement trunk in the target hard disk is the same as the size of each trunk in each initial hard disk.
[0069] After determining the above-mentioned respective stripes to be processed, the target hard disks for performing storage resource processing on the target RAID can be determined in the newly added hard disks, where the above-mentioned target hard disks are newly added hard disks. Moreover, each target hard disk is also divided into multiple trunks, and the size of each trunk in each target hard disk is the same as the size of each trunk in each initial hard disk. Furthermore, after determining the trunks to be replaced in each stripe to be processed, the trunks for replacement in the target hard disks can be used to replace the trunks to be replaced in each stripe to be processed, so that the multiple trunks included in each stripe to be processed after replacement respectively belong to different hard disks.
[0070] Among them, when determining the trunks to be replaced in each stripe to be processed, it can be determined in various ways. For example, a third number of trunks to be replaced are randomly determined in each stripe to be processed; or for another example, the trunks belonging to the specified initial hard disk in each stripe to be processed are determined as the trunks to be replaced, etc.
[0071] For example, in some scenarios where asynchronous I / O (Input / Output) operations are running, there may be hot-spot hard disks among the respective initial hard disks included in the target RAID, that is, hard disks with excessive asynchronous I / O operations. Thus, the performance of the above-mentioned hot-spot hard disks can become a performance bottleneck of the target RAID, reducing the running performance of the target RAID. Therefore, the trunks belonging to the above-mentioned hot-spot hard disks included in each initial stripe of the target RAID can be replaced to optimize the overall running performance of the target RAID. Based on this, the trunks belonging to the hot-spot hard disks in each stripe to be processed can be determined as the trunks to be replaced.
[0072] In this regard, the embodiments of the present invention do not make specific limitations. And the above-mentioned step S303 can be executed in various ways. For the sake of clarity in writing, the above-mentioned step S303 and the ways of determining the trunks to be replaced in each stripe to be processed will be illustrated by examples later.
[0073] In addition, when performing storage resource processing on the above-mentioned target RAID, the target hard disks for performing storage resource processing on the target RAID can be first determined according to the hard disk information of the respective initial hard disks included in the target RAID and the data storage requirements of the current service.
[0074] Based on this, optionally, in a specific implementation manner, a storage resource processing method provided by an embodiment of the present invention may further include the following step 11:
[0075] Step 11: Determine a target hard disk among the newly added hard disks.
[0076] In this specific implementation manner, before replacing the trunk to be replaced in each stripe to be processed with the trunk for replacement in the target hard disk, the target hard disk may first be determined from among the newly added hard disks.
[0077] Optionally, in a specific implementation manner, the above step 11 may include the following step 111:
[0078] Step 111: For each stripe to be processed, determine a target hard disk from among the newly added hard disks based on the hard disk information of the newly added hard disks.
[0079] In this specific implementation manner, after determining each stripe to be processed, for each stripe to be processed, before processing the stripe to be processed, the target hard disk may first be determined from among the newly added hard disks based on the hard disk information of the newly added hard disks. Furthermore, the trunk in the determined target hard disk may be used to replace the trunk to be replaced in the stripe to be processed, so that the multiple trunks included in the stripe to be processed after replacement belong to different hard disks respectively.
[0080] For example, for each stripe to be processed, a target hard disk for replacing the trunk to be replaced in the stripe to be processed may be selected from among the newly added hard disks according to the hard disk information such as the total hard disk capacity, free capacity, and health value of the newly added hard disks.
[0081] Among them, optionally, the hard disk information of the newly added hard disks may include at least one of the hard disk information such as the total hard disk capacity, free capacity, and health value of the newly added hard disks;
[0082] Optionally, in the case where the above target RAID is composed of multiple initial hard disks located on multiple devices, the hard disk information of the newly added hard disks may include: the device identifier where the newly added hard disk is located.
[0083] Optionally, when there are multiple newly added hard disks, the above-mentioned target hard disk can be one or more. That is to say, all newly added hard disks can be determined as the target hard disk, or only some of the newly added hard disks can be determined as the target hard disk; moreover, for different to-be-processed stripes, the determined target hard disks can be the same or different.
[0084] Optionally, in a specific implementation manner, step 11 above may include the following step 112:
[0085] Step 112: Select a random number within a preset random number value range, and determine the newly added hard disk corresponding to the random value sub-interval to which the selected random number belongs as the target hard disk;
[0086] Among them, the random number value range is composed of random value sub-intervals corresponding to each newly added hard disk.
[0087] In this specific implementation manner, a random value sub-interval can be preset for each newly added hard disk, and the total value range composed of the random value sub-intervals corresponding to each newly added hard disk is determined. Furthermore, this total value range is used as the random number value range. In this way, when determining the target hard disk, a random number can be selected within the above-mentioned random number value range, and then, the random value sub-interval to which the selected random number belongs is determined, and the newly added hard disk corresponding to this random value sub-interval is determined as the target hard disk.
[0088] For example, when the resource levels of the inserted multiple newly added hard disks are the same, the same-sized random value sub-intervals can be set for each newly added hard disk, and the total value interval composed of the random value sub-intervals of all newly added hard disks is used as the value range of the random value. Thus, when determining the target hard disk, the second number of random values can be randomly selected within the above-mentioned total value interval, and the random value sub-interval to which each selected random value belongs is determined. For each selected random value, among the newly added hard disks, the newly added hard disk whose set random value sub-interval is the random value sub-interval where this random value is located is the determined target hard disk.
[0089] Exemplarily, there are two newly added hard disks with the same resource level. The random value sub-interval of the first newly added hard disk is 1 - 40, and the random value sub-interval of the second newly added hard disk is 41 - 80. Then the total value interval is 1 - 80. Furthermore, the second number is 1. Thus, when determining the target hard disk, a random value can be obtained within 1 - 80, and the random value 20 is obtained. Since the random value 20 belongs to the random value sub-interval of the first newly added hard disk, which is 1 - 40, the first hard disk can be determined as the target hard disk.
[0090] Among them, since the newly added hard disks can provide storage resources for the target RAID, and the capabilities of the newly added hard disks to provide storage resources for the target RAID may be different according to the devices where the newly added hard disks are installed, the total capacity, the free capacity, the health status, etc., the capabilities of the newly added hard disks to provide storage resources for the target RAID can be used as the resource levels of the newly added hard disks.
[0091] Furthermore, the newly added hard disks with the same resource level refer to the hard disks that meet at least one of the following conditions: the newly added hard disks installed in the same device, with the same total capacity, the same free capacity, and the same health value. For example, the newly added hard disks installed in the same device, with the same total capacity, the same free capacity, and the same health value can be determined as the newly added hard disks with the same resource level.
[0092] Among them, the health value is a parameter determined based on the various operating parameters of the hard disk and used to represent the operating state of the hard disk. The higher the health value, the better the operating state of the hard disk.
[0093] Optionally, in a specific implementation, step 11 above may include the following step 113:
[0094] Step 113: Select weights within a preset weight value range, and determine the newly added hard disks with the selected weights as the target hard disks;
[0095] Among them, the weight value range is composed of the weights of the newly added hard disks.
[0096] In this specific implementation, the weights can be preset for each newly added hard disk according to the hard disk information of each newly added hard disk, and the total weight range composed of the weights of the newly added hard disks can be determined. Furthermore, this total weight range can be used as the weight value range. In this way, when determining the target hard disks, weights can be selected within the above weight value range, and then the newly added hard disks with the selected weights can be determined and the newly added hard disks can be determined as the target hard disks.
[0097] For example, when the resource levels of the inserted multiple newly added hard disks are different, different weights can be set for each newly added hard disk according to the different resource levels of the newly added hard disks, and the weight value range composed of the weights of all the newly added hard disks can be used as the value range of the random values. Thus, when determining the target hard disks, a second number of random values can be randomly selected within the above value range of the random values, and the newly added hard disks with the weight values being the random values are the determined target hard disks.
[0098] In the above example, using random values to determine the target hard disks can discretize the composition of the new stripe, avoid the problem of regular loss of data after hard disk anomalies caused by regularly selecting target hard disks, and improve the security of the written data.
[0099] For another example, the total capacities of the newly added hard disks may not be the same. To ensure balanced usage of each hard disk, the newly added hard disks with larger total capacities can be determined as target hard disks more frequently and discontinuously. Therefore, the value range or weight of each newly added hard disk can be dynamically adjusted according to the proportion of the free capacity of each newly added hard disk. Herein, the statement that the newly added hard disks with larger total capacities are determined as target hard disks more frequently and discontinuously means that the newly added hard disks with larger total capacities are determined as target hard disks more times, and the newly added hard disks with larger total capacities are not continuously determined as target hard disks for multiple times. That is to say, the newly added hard disks with larger total capacities and other newly added hard disks are alternately determined as target hard disks, and among them, the newly added hard disks with larger total capacities are determined as target hard disks more times.
[0100] Exemplarily, there are two newly added hard disks. The total capacity of the first newly added hard disk is 4T, and the total capacity of the second newly added hard disk is 8T. The size of each logical block (trunk) divided in each newly added hard disk is 128K. Assuming that the available capacity of 1T is represented by the value 1, the capacity proportion of the newly added hard disk with a total capacity of 4T can be represented by the value 4, and the capacity proportion of the newly added hard disk with a total capacity of 8T can be represented by the value 8. Furthermore, according to the ratio of the capacity proportions of the above two newly added hard disks, the random value range of the newly added hard disk with a total capacity of 4T can be set as 1 - 40, and the random value range of the newly added hard disk with a total capacity of 8T can be set as 41 - 120. Then, the value range of the random value is 1 - 120. Furthermore, when determining the target hard disk, a random value can be obtained within 1 - 120. If the random value falls within the value range of a certain newly added hard disk, then this newly added hard disk is determined as the target hard disk. In this way, it can be ensured that the hard disk with a larger total capacity is determined as the target hard disk relatively more times, and it is also ensured that the situation of determining the newly added hard disk with a larger total capacity as the target hard disk is discretely distributed.
[0101] Exemplarily, the free capacity and the percentage of the total capacity of the newly added hard disk can also be used to determine the target hard disk. For the two newly added hard disks with a total capacity of 4T and a total capacity of 8T in the above example, when these two newly added hard disks are just inserted into the device, the value of free capacity / total capacity of these two newly added hard disks is 100%. Then, when determining the target hard disk, a random value can be taken within a certain value range, and then, calculate ((free capacity - random value) / total capacity) * 1000 times, and sort according to the size of the calculation result. Thus, the target hard disk is determined according to the sorting result. Among them, in the above calculation formula, the purpose of multiplying by 1000 to expand the value is to avoid that the random value is too small to be differentially recognized in operating systems such as the Linux system.
[0102] In addition, when determining the target hard disk, the distribution of the free capacity in all the initial hard disks and the newly added hard disks that can be used by the target RAID can be further considered. Thus, according to the distribution of the free capacity in all the initial hard disks and the newly added hard disks, the weights of each newly added hard disk can be dynamically adjusted, thereby improving the balance of the distribution of the free capacity in all the initial hard disks and the newly added hard disks.
[0103] It should be emphasized that the above examples are only illustrative of the method for determining the target hard disk from the newly added hard disks, rather than limitations. Any method capable of determining the target hard disk from the newly added hard disks belongs to the protection scope of the embodiments of the present invention.
[0104] Optionally, in a specific implementation manner, as Figure 4 shown, a storage resource processing method provided by an embodiment of the present invention may further include the following step S300:
[0105] S300: After detecting each newly added hard disk, perform logical block partitioning on each detected newly added hard disk.
[0106] In this specific implementation manner, the target hard disk for performing storage resource processing on the target RAID is determined from the newly added hard disks inserted in advance. Therefore, when performing storage resource processing on the above target RAID, the electronic device may first detect whether there are newly added hard disks, that is, whether new hard disks are inserted into the devices where each initial hard disk included in the above target RAID is located. In this way, when it is detected that there are newly added hard disks, since the electronic device can know the size of each logical block (trunk) in each initial hard disk, the electronic device can then perform logical block (trunk) partitioning on the detected newly added hard disks according to this size, so that the size of each logical block (trunk) obtained by partitioning the newly added hard disks is the same as the size of each logical block (trunk) in each initial hard disk.
[0107] Optionally, for each to-be-processed stripe, when there is a data writing operation for this to-be-processed stripe, after replacing the to-be-replaced logical block (trunk) in this to-be-processed stripe with the logical block (trunk) in the target hard disk, the above data writing operation may be executed for the replaced to-be-processed stripe, thereby writing the to-be-written data corresponding to the above data writing operation into the replaced to-be-processed stripe. And, a part of the to-be-written data corresponding to the above data writing operation, or a part of the check data of the to-be-written data corresponding to the above data writing operation will be written into the target hard disk.
[0108] As can be seen above, when processing the storage resources of the target RAID by applying the solution provided in the embodiment of the present invention, the logical blocks (trunks) in the newly added target hard disk can be used to replace the to-be-replaced logical blocks (trunks) in each to-be-processed stripe in the target RAID, so as to obtain each to-be-processed stripe after replacement. Moreover, the multiple logical blocks (trunks) included in each to-be-processed stripe after replacement belong to different hard disks respectively. During the above processing process, for each to-be-processed stripe after replacement and each stripe in the target RAID except the to-be-processed stripe, various operations such as data writing operations can be normally executed. Therefore, it is possible to ensure the normal operation of the existing services without stopping the existing services; and, since each to-be-processed stripe after replacement includes the logical blocks (trunks) in the target hard disk, when a data writing operation is performed on the to-be-processed stripe after replacement, the data to be written can be successfully written into the target hard disk. Therefore, it is possible to avoid adding additional disk bandwidth overhead. In this way, it is possible to quickly and conveniently process the storage resources of the RAID without affecting the operation of the existing services and without adding additional disk bandwidth overhead.
[0109] In many cases, due to reasons such as an increase in the amount of data to be stored, the storage space of the above target RAID will not be able to meet the requirements of data storage in actual applications. Therefore, the target hard disk can be used to expand the capacity of the above target RAID. That is, through logical block (trunk) replacement, the logical blocks (trunks) in the target hard disk are added to the initial stripe of the above target RAID. And since it is a replacement of logical blocks (trunks), the number of logical blocks (trunks) included in each stripe can be not changed, and new stripes can also be constructed based on the logical blocks (trunks) replaced from the initial hard disks in the initial stripe. Thus, by means of the logical blocks (trunks) in the target hard disk, the number of stripes included in the target RAID can be increased, and thus the storage space of the target RAID can be increased.
[0110] Based on this, optionally, in a specific implementation manner, as Figure 5 shown, a storage resource processing method provided in an embodiment of the present invention may further include the following step S304:
[0111] S304: Create a new stripe based on each to-be-replaced logical block that is replaced.
[0112] In this specific implementation, after replacing the trunk to be replaced in each stripe to be processed with the trunk in the target hard disk, the trunks to be replaced belonging to each initial hard disk that are replaced can be obtained. Thus, new stripes can be created based on the replaced trunks to be replaced. Moreover, the newly created stripes include: the first number of trunks belonging to the first number of hard disks respectively, and among the first number of trunks, there may or may not be trunks belonging to the target hard disk.
[0113] For example, the first number of trunks to be replaced belonging to different initial hard disks can be selected from the replaced trunks to be replaced, and the selected first number of trunks to be replaced can be constructed into a new stripe.
[0114] For example, several trunks to be replaced belonging to different initial hard disks can be selected from the replaced trunks to be replaced, and the number of the selected several trunks to be replaced is not less than the first difference between the first number and the second number of the target hard disk. Furthermore, the second difference between the first number and the number of the selected several trunks to be replaced is calculated. In this way, the second difference number of target hard disks can be selected from the target hard disk. Thus, the selected several trunks to be replaced and one trunk in each of the selected second difference number of target hard disks are constructed into a new stripe.
[0115] It should be emphasized that the above examples are only illustrative of the above step S304, rather than limiting. Any way that can implement the above step S304 belongs to the protection scope of the embodiments of the present invention.
[0116] For example, as Figures 6 - 8 shown, on the basis of the above target RAID as Figure 1 shown, and each trunk divided from the target hard disk as Figure 2 shown, assume that stripe 1 - 20 in the target RAID is the stripe to be processed, and each stripe to be processed includes 1 trunk to be replaced.
[0117] In this way, as Figure 6As shown, the trunk TKa1 in stripe 1 can be replaced with TK in the target hard disk. u 1; As Figure 7 shown, replace the trunk TKc2 in stripe 2 with TKu2 in the target hard disk. And so on, as Figure 8 shown, until each trunk in the target hard disk is used to replace one trunk to be replaced in stripes 1 - 20 in turn, obtaining 20 trunks to be replaced that respectively belong to different initial hard disks.
[0118] Among them, as Figure 8 shown, for each trunk in the target hard disk identified in the dashed box, the trunk to be replaced connected to this trunk by a dashed connection line with an arrow is the trunk to be replaced replaced by this trunk. Furthermore, based on the 20 trunks to be replaced that respectively belong to different initial hard disks, new stripes can be created, that is, the stripe 21 in Figure 8 is created, and this target stripe 21 is the new storage space obtained by capacity expansion.
[0119] In this specific implementation manner, after each new stripe is created, data writing can be immediately performed using this new stripe, that is, after each new stripe is created, a data writing operation can be immediately performed on this new stripe. That is to say, in this specific implementation manner, the capacity expansion of the target RAID is achieved by replacing the target trunk in the stripe to be processed, and the current data writing service can be carried out simultaneously.
[0120] Optionally, in a specific implementation manner, on the basis of the specific implementation manner shown in Figure 5 , a storage resource processing method provided by an embodiment of the present invention may further include the following step 21:
[0121] Step 21: After all new stripes are created, perform a data writing operation on each created new stripe in turn.
[0122] In this specific implementation, after each new stripe is created, the new stripe can be retained as a stripe available for data writing. Thus, when there is no logical block (trunk) available for replacement on the target hard disk, that is, after the expansion of the target RAID is completed, the data writing operation can be sequentially performed on each newly created stripe.
[0123] Optionally, when all the initial stripes in the above-mentioned target RAID are replaced as stripes to be processed and data writing operations have been performed on all the replaced initial stripes, when it is necessary to continue performing the data writing operation to write data to the expanded target RAID, all the newly created stripes can be used as currently available blank stripes. Thus, the data writing operation can be sequentially performed on each newly created stripe.
[0124] Optionally, when there is no logical block (trunk) available for replacement on the target hard disk and data writing operations have been performed on all the initial stripes replaced as stripes to be processed, if there are still initial stripes that do not require replacement of the logical block to be replaced, then when it is necessary to continue performing the data writing operation to write data to the expanded target RAID, the data writing operation can first be performed on the initial stripes that do not require replacement of the logical block to be replaced. After the data writing operation has been performed on all the initial stripes that do not require replacement of the logical block to be replaced, the data writing operation can be sequentially performed on each newly created stripe.
[0125] Optionally, when there is no logical block (trunk) available for replacement on the target hard disk, at this time, regardless of whether there are still initial stripes that do not require replacement of the logical block to be replaced, when it is necessary to continue performing the data writing operation to write data to the expanded target RAID, the data writing operation can first be sequentially performed on each newly created stripe. Furthermore, after the data writing operation has been performed on each newly created stripe, starting from the first stripe in the expanded target RAID, the data writing operation can be sequentially performed to overwrite the data written in each stripe in the expanded target RAID.
[0126] Among them, each of the above optional specific implementation manners is only an illustrative example of step 21 above, rather than a limitation. Any manner capable of implementing step 21 above belongs to the protection scope of this application.
[0127] Based on this, in the specific implementation manner shown in step 21 above, for each to-be-processed stripe after replacement, a data writing operation to be executed can be normally performed. Thus, there is no need to stop the existing services, ensuring the normal operation of the existing services. In addition, since the to-be-processed stripe after replacement includes a trunk in the target hard disk, by performing a data writing operation on the to-be-processed stripe after replacement, the data to be written corresponding to this data writing operation can be successfully written into the target hard disk, and there is no need to migrate the data written in the initial hard disk to the target hard disk. Thus, there is no need to increase additional disk bandwidth overhead. In this way, it is possible to achieve fast and convenient expansion of RAID without affecting the operation of the existing services and without increasing additional disk bandwidth overhead.
[0128] Next, an illustrative example of step S302 above, which determines each to-be-processed stripe from multiple initial stripes included in the target RAID, will be given.
[0129] Optionally, in a specific implementation manner, step S302 above may include the following step 31:
[0130] Step 31: If data has been written to all of the multiple initial stripes included in the above target RAID, then determine each of the multiple initial stripes as a to-be-processed stripe.
[0131] In this specific implementation manner, since there is no blank stripe in the above target RAID that has not been written with data, when a data writing operation is performed on the above target RAID again, the data to be written needs to overwrite the data that has been written in each initial stripe. Therefore, each of the multiple initial stripes included in the above target RAID can be determined as a to-be-processed stripe.
[0132] For example, it is possible to start from the first initial stripe among the multiple initial stripes included in the target RAID and sequentially determine each initial stripe as a to-be-processed stripe. Exemplarily, such as Figure 1As shown, in the case where there is no blank stripe in which no data is written in each of the initial stripes 1-20, each of the initial stripes 1-20 can be determined as the stripe to be processed in sequence from top to bottom.
[0133] Optionally, in another specific implementation manner, step S302 may include the following step 32:
[0134] Step 32: If there is a blank stripe among the multiple initial stripes included in the target RAID; then determine each of the initial stripes in which data is written, and / or, each of the blank stripes among the multiple initial stripes as the stripe to be processed.
[0135] In this specific implementation manner, considering that there are blank stripes in the target RAID in which no data is written, in order to ensure the security of the data written in the initial stripes in which data has been written in the target RAID, when performing a data writing operation on the target RAID again, the data to be written corresponding to the data writing operation can be written only into the blank stripes. Therefore, each of the blank stripes among the multiple initial stripes included in the target RAID can be determined as the stripe to be processed.
[0136] Correspondingly, in some cases, although there are blank stripes in the target RAID in which no data is written, however, considering that the data written in the initial stripes in which data has been written in the target RAID may have become invalid, when performing a data writing operation on the target RAID again, the data to be written corresponding to the data writing operation can be used to overwrite the data written in each of the initial stripes in which data has been written. Therefore, each of the initial stripes in which data has been written among the multiple initial stripes included in the target RAID can also be determined as the stripe to be processed.
[0137] In addition, in some cases, considering the blank stripes in the above-mentioned target RAID that have not been written with data, in order to ensure the security of the data written in the initial stripes in the above-mentioned target RAID that have already been written with data, when performing a data writing operation on the above-mentioned target RAID again, the blank stripe to which the data to be written corresponding to the data writing operation is to be written can be written first. Then, after all the blank stripes are written with data, in order to ensure that the data to be written corresponding to the subsequent data writing operation can be written into the above-mentioned target RAID, the data to be written corresponding to the subsequent data writing operation can be used to overwrite the data that has already been written in each initial stripe. Therefore, each blank stripe and each initial stripe that has been written with data in the multiple initial stripes included in the above-mentioned target RAID can also be determined as stripes to be processed, that is, all the multiple initial stripes included in the above-mentioned target RAID are determined as stripes to be processed.
[0138] For example, starting from the first initial stripe among the multiple initial stripes included in the target RAID, each initial stripe can be sequentially determined as a stripe to be processed. Exemplarily, as Figure 1 shown, in the case where data has been written in initial stripes 1-5 and initial stripes 6-20 are blank stripes without written data among each initial stripe 1-20, each initial stripe 1-20 can be sequentially determined as a stripe to be processed in the order from top to bottom.
[0139] Again, for example, starting from the first stripe among the blank stripes existing in the target RAID, each blank stripe can be sequentially determined as a stripe to be processed. Exemplarily, as Figure 1 shown, in the case where data has been written in initial stripes 1-5 and initial stripes 6-20 are blank stripes without written data among each initial stripe 1-20, each initial stripe 6-20 can be sequentially determined as a stripe to be processed in the order from top to bottom.
[0140] For another example, it is possible to start from the first stripe among the blank stripes existing in the target RAID, and sequentially determine each blank stripe as the stripe to be processed; after each blank stripe is determined as the stripe to be processed, starting from the first initial stripe among the multiple initial stripes, sequentially determine each initial stripe that has written data before determining the first initial stripe as the stripe to be processed. Exemplarily, as Figure 1 shown, among each of the initial stripes 1-20, if data has been written in the initial stripes 1-5 and the initial stripes 6-20 are blank stripes without written data, it is possible to first sequentially determine each of the initial stripes 6-20 as the stripe to be processed in the order from top to bottom, and then, again in the order from top to bottom, determine each of the initial stripes 1-5 as the stripe to be processed.
[0141] It should be emphasized that the above examples are merely illustrative of the above step S302 and not limiting. Any implementation manner of determining each stripe to be processed from the multiple initial stripes included in the target RAID falls within the protection scope of the embodiments of the present invention.
[0142] Exemplarily, assume that each initial stripe in the target RAID includes 10 logical blocks (trunks), and among the 10 logical blocks (trunks) there are: 8 data blocks and 2 parity blocks, and the size of each logical block (trunk) is 4K. Among them, each initial stripe in the target RAID can be called an 8+2 stripe.
[0143] In this way, when writing data, if the amount of data to be written is 4K. Accordingly:
[0144] In the first method, if data is written in stripes, at least 8 data volumes of 4K are required to fill an initial stripe. Therefore, when the data volume to be written is only 4K, the initial stripe to which the data to be written is to be written and the data blocks to be written in the initial stripe can be determined first. Thus, the data already written in the other 7 data blocks in the initial stripe can be read, and 2 parity data can be recalculated using the read data and the data to be written. Further, the read data, the data to be written, and the 2 recalculated parity data can be written into the initial stripe, or the data already written in the other 7 data blocks in the initial stripe can be kept unchanged, and the data to be written and the 2 recalculated parity data can be written into the initial stripe.
[0145] In the first method above, when preparing to write the data to be written and the 2 recalculated parity data into the initial stripe, the initial stripe can be determined as the stripe to be processed first. Then, the trunk to be replaced in the initial stripe can be directly replaced with the replacement logical block in the target hard disk, and after the replacement is completed, the data to be written and the 2 recalculated parity data can be written into the initial stripe after replacement.
[0146] Among them, all 8 + 2 logical blocks in the initial stripe can be replaced at most, or only the data block for storing the data to be written can be replaced, or only the data block for storing the data to be written and two parity blocks can be replaced. All of these are reasonable.
[0147] In the second method, in a scenario where the requirement for data consistency is low and the business I / O (Input / Output) is small, when data volume of 4K to be written is obtained each time, each data to be written can be successively written into an initial stripe. Thus, when the 8th data to be written is obtained, the 7 already written data to be written can be read out at one time. Then, 2 parity data can be calculated using the 7 already written data to be written and the 8th data to be written. Further, the 8th data to be written and the 2 calculated parity data can be continuously written.
[0148] In the second method, each time a 4k-sized data to be written is obtained and written into the initial stripe, the initial stripe can be first determined as a stripe to be processed, and then a replacement logic block in the target hard disk can be directly used to replace a logic block (trunk) in the initial stripe to which data is not written. After the replacement is completed, the obtained data to be written is written into the replaced logic block (trunk) belonging to the target hard disk.
[0149] It should be emphasized that the above two methods are the writing methods of the target RAID. In the embodiment of the present invention, the above two methods are only used to illustrate the specific implementation methods shown in the above steps 31 and 32, but not to limit the writing methods of the target RAID. Any writing method that can write data to the target RAID falls within the protection scope of the embodiment of the present invention.
[0150] Based on the above situation, in the specific implementation method shown in the above steps 31 and 32, when the initial stripe (stripe) of the written data included in the target RAID is determined as the stripe (stripe) to be processed, for the stripe (stripe), after writing the new data to be written, the replaced logical block (trunk) with the new data to be written replaces the old replaced logical block (trunk) with the data, and because the data in the old replaced logical block (trunk) with the data may be data that is about to expire or has expired, there is no need to migrate the data in the old replaced logical block (trunk) with the data to the target hard disk, thereby achieving the expansion of the target RAID without affecting the normal operation of the business and without increasing additional disk bandwidth.
[0151] The following is an example of how to determine the logic block (trunk) to be replaced in each stripe (stripe) to be processed.
[0152] Optionally, in a specific implementation, the method for determining the to-be-replaced logical blocks in each to-be-processed stripe may include the following steps 41-42:
[0153] Step 41: for each stripe to be processed, based on the hard disk information of the initial hard disk to which each logical block in the stripe to be processed belongs and the hard disk information of the target RAID, determine the replacement weight value of each logical block in the stripe to be processed;
[0154] Step 42: Determine the logical blocks to be replaced in each stripe to be processed based on the replacement weight values of the logical blocks in each stripe to be processed and the second quantity of the target hard disk.
[0155] In this specific implementation manner, for each stripe to be processed, the replacement weight value of each logical block (trunk) in the stripe to be processed can be determined first based on the hard disk information of the initial hard disk to which each logical block (trunk) in the stripe to be processed belongs and the hard disk information of the target RAID.
[0156] Among them, the so-called replacement weight value of each logical block (trunk) can represent: the possibility of each logical block (trunk) being replaced determined based on the resource processing target of the target RAID. For each logical block (trunk), if the replacement weight value of the logical block (trunk) is larger, the possibility of the logical block (trunk) being replaced is greater. Thus, after the logical block (trunk) is replaced, the contribution to achieving the resource processing target of the target RAID is greater; conversely, if the replacement weight value of the logical block (trunk) is smaller, the possibility of the logical block (trunk) being replaced is smaller. Thus, after the logical block (trunk) is replaced, the contribution to achieving the resource processing target of the target RAID is smaller.
[0157] For example, in a target RAID with high performance requirements, more emphasis is placed on the health value of the hard disks where the logical blocks (trunks) in the initial stripe are located. Thus, the replacement weight value of the logical block (trunk) with a higher health value of the hard disk where it is located can be smaller, that is, it is not desired to replace the logical block (trunk) with a higher health value of the hard disk where it is located.
[0158] That is to say, the calculation of the replacement weight value of each logical block (trunk) can be dynamically adjusted and optimized according to the product requirements, business requirements, etc. of the target RAID.
[0159] Optionally, the hard disk information of the above initial hard disk may include at least one of the hard disk total capacity, free capacity, health value, etc. of the initial hard disk; the hard disk information of the target RAID may include at least one of the hard disk total capacity, free capacity, health value, etc. of the target hard disk.
[0160] In addition, optionally, on the basis that the above first quantity is less than the quantity of the multiple initial hard disks included in the target RAID, when determining the replacement weight value of each logical block (trunk) in each stripe to be processed, it can be determined based on the hard disk information of each initial hard disk included in the target RAID and the hard disk information of the target RAID.
[0161] Furthermore, for each stripe to be processed, after determining the replacement weight values of each trunk in the stripe to be processed, the trunks to be replaced in the stripe to be processed can be further determined based on the replacement weight values of each trunk in the stripe to be processed and the second quantity of the target hard disk.
[0162] For example, for each stripe to be processed, arrange the replacement weight values of each trunk in the stripe to be processed from largest to smallest, and determine the trunks to be replaced in the top second quantity positions as the trunks to be replaced.
[0163] Optionally, in a specific implementation manner, step 22 above may include the following steps 421 and 422:
[0164] Step 421: For each stripe to be processed, determine each trunk whose replacement weight value meets a preset condition as a candidate trunk;
[0165] Among them, the preset condition includes: being within a preset weight range, or being greater than a preset weight threshold;
[0166] Step 422: If the third quantity of the determined candidate trunks is greater than the second quantity of the target hard disk, select the second quantity of trunks from the determined candidate trunks as the trunks to be replaced.
[0167] In this specific implementation manner, for each stripe to be processed, each trunk whose replacement weight value meets a preset condition can be first determined from each trunk included in the stripe to be processed as a candidate trunk.
[0168] For example, for each stripe to be processed, each trunk whose replacement weight value is within a preset weight range can be first determined from each trunk included in the stripe to be processed as a candidate trunk.
[0169] For another example, for each stripe to be processed, each trunk whose replacement weight value is greater than a preset weight threshold can be determined from the various trunks included in the stripe to be processed as a candidate trunk.
[0170] It should be emphasized that the above examples are merely illustrative examples of the implementation manner of determining each trunk whose replacement weight value meets the preset conditions included in each stripe to be processed as a candidate trunk, rather than limitations. Any manner that can determine the candidate trunks in each stripe to be processed belongs to the protection scope of the embodiments of the present invention.
[0171] Furthermore, for each stripe to be processed, if the third quantity of the determined candidate trunks is greater than the second quantity of the target hard disks, then the second quantity of trunks can be selected from the determined candidate trunks as the trunks to be replaced.
[0172] For example, for each stripe to be processed, if the third quantity of the determined candidate trunks is greater than the second quantity of the target hard disks, the second quantity of trunks can be randomly selected from the determined candidate trunks as the trunks to be replaced.
[0173] For another example, for each stripe to be processed, if the third quantity of the determined candidate trunks is greater than the second quantity of the target hard disks, then the trunks to be replaced ranked in the top second quantity positions are determined as the trunks to be replaced according to the replacement weight values of the candidate trunks from large to small.
[0174] Of course, other methods can also be used to implement step 422, and the embodiments of the present invention do not make specific limitations in this regard.
[0175] Optionally, in another specific implementation manner, step 42 may include the following steps 421 and 423:
[0176] Step 421: For each stripe to be processed, each trunk whose replacement weight value meets the preset conditions is determined as a candidate trunk;
[0177] Wherein, the preset conditions include: being within a preset weight range, or being greater than a preset weight threshold;
[0178] Step 423: If the third quantity of the determined candidate logical blocks (trunks) is not greater than the second quantity of the target hard disk, determine the determined candidate logical blocks (trunks) as the logical blocks (trunks) to be replaced.
[0179] In this specific implementation, for each stripe to be processed, first, from each logical block (trunk) included in the stripe to be processed, determine each logical block (trunk) whose replacement weight value meets the preset conditions as the candidate logical block (trunk). Furthermore, for each stripe to be processed, if the third quantity of the determined candidate logical blocks (trunks) is not greater than the second quantity of the target hard disk, then the determined candidate logical blocks (trunks) can be determined as the logical blocks (trunks) to be replaced.
[0180] That is to say, for each stripe to be processed, if the third quantity of the determined candidate logical blocks (trunks) is not greater than the second quantity of the target hard disk, since it is possible to replace one candidate logical block (trunk) in the stripe to be processed with one logical block (trunk) in the target hard disk respectively, therefore, all the candidate logical blocks (trunks) in the stripe to be processed can be determined as the logical blocks (trunks) to be replaced.
[0181] Optionally, in another specific implementation, the above step 42 may include the following steps 421 - 423:
[0182] Step 421: For each stripe to be processed, determine each logical block (trunk) whose included replacement weight value meets the preset conditions as the candidate logical block (trunk);
[0183] Among them, the preset conditions include: being within a preset weight range, or being greater than a preset weight threshold;
[0184] Step 422: If the third quantity of the determined candidate logical blocks (trunks) is greater than the second quantity of the target hard disk, select the second quantity of logical blocks (trunks) from the determined candidate logical blocks (trunks) as the logical blocks (trunks) to be replaced;
[0185] Step 423: If the third quantity of the determined candidate logical blocks (trunks) is not greater than the second quantity of the target hard disk, determine the determined candidate logical blocks (trunks) as the logical blocks (trunks) to be replaced.
[0186] Optionally, in a specific implementation, the method for determining the trunk to be replaced in each stripe to be processed may include the following step 43:
[0187] Step 43: Determine the logical blocks belonging to the hot hard disk in each stripe to be processed as the trunks to be replaced in each stripe to be processed.
[0188] In this specific implementation, there may be hot hard disks among the initial hard disks included in the target RAID. Thus, the performance of the above hot hard disks may become the performance bottleneck of the target RAID, reducing the running performance of the target RAID. Therefore, the logical blocks (trunks) belonging to the above hot hard disks included in each stripe to be processed can be replaced to optimize the overall running performance of the target RAID.
[0189] Based on this, the hot hard disks in each of the initial hard disks included in the target RAID can be determined first. Furthermore, the logical blocks (trunks) belonging to the hot hard disks in each stripe to be processed are determined as the trunks to be replaced.
[0190] Optionally, among the initial hard disks included in the target RAID, the initial hard disks with the number of asynchronous I / Os greater than the preset number threshold within a specified duration can be determined as hot hard disks.
[0191] Next, an example is given for replacing the trunks to be replaced in each stripe to be processed with the replacement logical blocks in the target hard disk in the above step S303.
[0192] Optionally, in a specific implementation, the above step S303 may include the following step 51:
[0193] Step 51: For each stripe to be processed, if the third quantity of the trunks to be replaced in this stripe to be processed is not less than the second quantity of the target hard disks, then use one replacement logical block in each target hard disk to replace one trunk to be replaced in each stripe to be processed.
[0194] In this specific implementation, for each determined stripe to be processed, the trunks to be replaced in this stripe to be processed can be determined first, and the third quantity of the trunks to be replaced is obtained. Thus, the numerical size relationship between the third quantity of the trunks to be replaced in this stripe to be processed and the second quantity of the determined target hard disks can be determined.
[0195] Among them, if the third quantity of the trunks to be replaced in the stripe to be processed is not less than the second quantity of the target hard disks, one replacement trunk in each target hard disk can be used to replace one trunk to be replaced in each stripe to be processed.
[0196] Optionally, for each stripe to be processed, if the third quantity of the trunks to be replaced in the stripe to be processed is equal to the second quantity of the target hard disks, step 51 above may include the following step 511:
[0197] Step 511: Use one replacement trunk in each target hard disk to replace one trunk to be replaced in each stripe to be processed.
[0198] For each stripe to be processed, if the third quantity of the trunks to be replaced in the stripe to be processed is equal to the second quantity of the target hard disks, then each trunk to be replaced in the stripe to be processed can be replaced by one trunk in a different hard disk respectively.
[0199] For example, as Figures 6 - 8 shown, on the basis of the above target RAID as Figure 1 shown, and each trunk divided from the target hard disks as Figure 2 shown, assume that stripe 1-20 in the target RAID is the stripe to be processed, and the third quantity of the trunks to be replaced in each stripe to be processed is 1, then the third quantity of the trunks to be replaced in each stripe to be processed is equal to the second quantity of the target hard disks.
[0200] In this way, as Figure 6 shown, the trunk TKa1 in stripe 1 can be replaced by TK u 1 in the target hard disk; as Figure 7 shown, the trunk TKc2 in stripe 2 can be replaced by TKu2 in the target hard disk. And so on, as Figure 8As shown, until each logical block (trunk) in the target hard disk is used to sequentially replace the logical blocks (trunks) to be replaced in stripes 1 - 20 respectively, to obtain the processed stripes after replacement, and the multiple logical blocks (trunks) included in each processed stripe after replacement belong to different hard disks.
[0201] Optionally, for each stripe to be processed, if the third quantity of the logical blocks (trunks) to be replaced in this stripe to be processed is greater than the second quantity of the target hard disk, then step 51 above may include the following step 512:
[0202] Step 512: Use the fourth quantity of logical blocks for replacement in the target hard disk to replace and obtain the fourth quantity of specified logical blocks from at least one initial stripe other than the stripe to be processed; and, use one logical block to be utilized to replace one logical block to be replaced in this stripe to be processed respectively;
[0203] Wherein, the fourth quantity is: the difference between the third quantity and the second quantity, the specified logical blocks do not belong to the initial hard disk included in this stripe to be processed, and the logical blocks to be utilized include: one logical block for replacement in each target hard disk and the fourth quantity of specified logical blocks.
[0204] For each stripe to be processed, if the third quantity of the logical blocks (trunks) to be replaced in this stripe to be processed is greater than the second quantity of the target hard disk, then after using one logical block (trunk) for replacement in each target hard disk to replace one logical block (trunk) to be replaced in this stripe to be processed respectively, there are still logical blocks (trunks) to be replaced that have not been replaced in this stripe to be processed.
[0205] For example, for a certain stripe to be processed, if the third quantity of the logical blocks (trunks) to be replaced included in this stripe to be processed is 3, and the second quantity of the target hard disk is 2, then after using two logical blocks (trunks) belonging to different target hard disks to replace two logical blocks (trunks) to be replaced in this stripe to be processed, there is still 1 logical block (trunk) to be replaced in this stripe to be processed.
[0206] Furthermore, in order to ensure that each trunk to be replaced in the stripe to be processed is replaced, and the multiple trunks included in the stripe to be processed after replacement belong to different hard disks respectively, trunks that do not belong to the initial hard disks included in the stripe to be processed can be used to replace the still-existing trunks to be replaced that have not been replaced.
[0207] Among them, the difference between the third quantity of the trunks to be replaced in the stripe to be processed and the second quantity of the target hard disks can be calculated first to obtain a fourth quantity. The fourth quantity is: after using one replaceable trunk in each target hard disk to replace one trunk to be replaced in the stripe to be processed respectively, the quantity of the still-existing trunks to be replaced that have not been replaced in the stripe to be processed.
[0208] Furthermore, considering that each trunk in each initial stripe included in the target RAID does not belong to the target hard disks, the fourth quantity of replaceable trunks in the target hard disks can be used to replace the fourth quantity of specified trunks from at least one initial stripe other than the stripe to be processed. Moreover, the fourth quantity of specified trunks obtained by replacement do not belong to the initial hard disks included in the stripe to be processed.
[0209] In this way, since the sum of the quantity of the target hard disks and the quantity of the specified trunks is equal to the quantity of the trunks to be replaced in the stripe to be processed, each replaceable trunk in each target hard disk and each specified trunk can be used to replace each trunk to be replaced in the stripe to be processed respectively. That is to say, each trunk to be replaced in the stripe to be processed can be replaced with a specified trunk or a trunk in a target hard disk.
[0210] That is to say, one replaceable trunk can be determined from each target hard disk to obtain the second quantity of trunks belonging to the target hard disks. Furthermore, the second quantity of trunks belonging to the target hard disks determined above and the fourth quantity of specified trunks obtained by replacement above can be used as the trunks to be utilized. Thus, each trunk to be replaced in the stripe to be processed can be replaced with one trunk to be utilized respectively.
[0211] Among them, in order to ensure that at least one initial stripe except the stripe to be processed after replacement is still a stripe available for data writing, therefore, in the obtained fourth quantity of designated trunks, the designated trunks belonging to the same initial stripe are respectively replaced with one trunk belonging to different target hard disks, so that each trunk included in at least one initial stripe except the stripe to be processed after replacement still belongs to different hard disks.
[0212] And, in order to ensure that the stripe to be processed after replacement is still a stripe available for data writing, since the above-mentioned respective designated trunks are used to replace the trunks to be replaced in the stripe to be processed, and the trunks in the stripe to be processed that are not replaced will be retained, therefore, the initial hard disks to which the respective designated trunks belong are all different from the initial hard disks to which the trunks in the stripe to be processed that are not replaced belong.
[0213] In this way, one trunk in each target hard disk and each designated trunk can be used to replace each trunk to be replaced included in the stripe to be processed respectively.
[0214] For example, as Figures 9 - 12 shown, among them, Figure 9 are three initial stripes in the target RAID. Furthermore, as Figure 10 shown, when the initial hard disk i and the initial hard disk j are faulty hard disks, in the order from top to bottom, the first initial stripe is an initial stripe that does not include a faulty trunk, the second initial stripe includes the faulty trunk TKi2, and the third initial stripe includes the faulty trunks TKi3 and TKj3. Then it can be determined that the second initial stripe and the third initial stripe are stripes to be processed, and the trunk to be replaced in the second initial stripe is the trunk TKi2, and the trunks to be replaced in the third initial stripe are the trunks TKi3 and TKj3.
[0215] Furthermore, when the target hard disk is as Figure 2 shown, as Figure 11 shown, for the above-mentioned second initial stripe, use the trunk TKu1 in the target hard disk to replace the trunk TKi2 to be replaced in this second initial stripe, obtaining the stripe to be processed after replacement; for the above-mentioned third initial stripe, use the trunk TKu2 in the target hard disk to replace the trunk TKi3 to be replaced in this third initial stripe.
[0216] After that, as Figure 12 shown, use the trunk TKu3 in the target hard disk to replace the trunk TKa1 in the above-mentioned first initial stripe, thereby obtaining the specified trunk TKa1 that is replaced. Furthermore, the specified trunk TKa1 can be used to replace the trunk TKj3 to be replaced in the third initial stripe.
[0217] As described above, in some cases, there may be a faulty hard disk among the multiple initial hard disks used to construct the above-mentioned target RAID. Thus, to ensure the integrity and security of the data written to the initial stripe including the trunk belonging to the faulty hard disk, the trunk belonging to the faulty hard disk in this initial stripe can be replaced with the trunk in the target hard disk.
[0218] Based on this, optionally, in a specific implementation manner, as Figure 13 shown, the above step S302 of determining each stripe to be processed from the multiple initial stripes included in the target RAID may include the following step S3021;
[0219] S3021: Determine, as each stripe to be processed, each stripe among the multiple initial stripes included in the target RAID that includes a faulty trunk;
[0220] Correspondingly, in this specific implementation manner, a storage resource processing method provided by an embodiment of the present invention may further include the following step S305:
[0221] S305: For each stripe to be processed, determine the faulty trunk included in this stripe to be processed as the trunk to be replaced in this faulty stripe.
[0222] In this specific implementation, the electronic device may first detect whether there is a faulty hard disk among the multiple initial hard disks included in the target RAID, and whether there is a faulty logical block (trunk) among the logical blocks (trunks) of each of the multiple initial hard disks included in the target RAID.
[0223] Among them, when there is a faulty hard disk among the multiple initial hard disks included in the target RAID, and / or there is a faulty logical block (trunk) among the logical blocks (trunks) of each of the multiple initial hard disks included in the target RAID, the faulty logical blocks (trunks), as well as the logical blocks (trunks) belonging to the faulty hard disk, can be determined as faulty logical blocks (trunks), and the number of faulty hard disks can be one or multiple.
[0224] Furthermore, the electronic device can then determine, from the multiple initial stripes in the target RAID, each initial stripe that includes a faulty logical block (trunk), and determine each of the determined stripes that include a faulty logical block (trunk) as each stripe to be processed. Each stripe to be processed may include at least one faulty logical block (trunk).
[0225] Optionally, in another specific implementation, step 52 may be included in step S303 as follows:
[0226] Step 52: For each stripe to be processed, if the third quantity is less than the second quantity, select the third quantity of hard disks from the target hard disks as the hard disks to be utilized, and respectively use one logical block in each of the selected hard disks to be utilized to replace one logical block to be replaced in each stripe to be processed.
[0227] In this specific implementation, for each stripe to be processed determined, the logical block (trunk) to be replaced in the stripe to be processed can be first determined, and the third quantity of the logical block (trunk) to be replaced can be obtained. Thus, the numerical size relationship between the third quantity of the logical block (trunk) to be replaced in the stripe to be processed and the second quantity of the determined target hard disks can be determined.
[0228] Among them, if the third quantity of the trunks to be replaced in the stripe to be processed is less than the second quantity of the target hard disks, the trunks to be replaced in the stripe to be processed can be replaced by using the trunks in some of the target hard disks. That is to say, there can be target hard disks that do not replace the trunks to be replaced in the stripe to be processed.
[0229] Based on this, three hard disks can be selected from the target hard disks as the hard disks to be utilized, and one trunk in each of the selected hard disks to be utilized is used to replace one trunk to be replaced in each stripe to be processed.
[0230] For example, for a certain stripe to be processed, if the third quantity of the trunks to be replaced included in the stripe to be processed is 2, and the second quantity of the target hard disks is 3, then two target hard disks can be selected from the three target hard disks as the hard disks to be utilized, and one trunk is determined from each of the selected target hard disks, and the two trunks determined from the selected target hard disks are used to replace the two trunks to be replaced in the stripe to be processed.
[0231] Among them, optionally, in a specific implementation manner, step 52 may include the following step 521:
[0232] Step 521: Select the third quantity of hard disks from the target hard disks as the hard disks to be utilized based on the hard disk information of each target hard disk;
[0233] Among them, the hard disk information of each target hard disk at least includes the total capacity of each target hard disk, the free capacity of each target hard disk, or the health value of each target hard disk.
[0234] In this specific implementation manner, when the third quantity of the trunks to be replaced in the stripe to be processed is less than the second quantity of the target hard disks, the hard disk information of each target hard disk can be determined, and based on the determined hard disk information, the third quantity of hard disks are selected from each of the target hard disks as the hard disks to be utilized.
[0235] Among them, the hard disk information of each target hard disk at least includes the total capacity of each target hard disk, the free capacity of each target hard disk, or the health value of each target hard disk.
[0236] That is to say, at least according to the total capacity of each target hard disk, the free capacity of each target hard disk, or the health value of each target hard disk, a third number of hard disks can be selected from each target hard disk as the hard disks to be utilized.
[0237] For example, sort by the health value from high to low, and select the target hard disks ranked in the top third number as the hard disks to be utilized. Another example is to sort by the free capacity from high to low and select the target hard disks ranked in the top third number as the hard disks to be utilized. Still another example is to sort by the percentage of the free capacity in the total capacity from high to low and select the target hard disks ranked in the top third number as the hard disks to be utilized, etc.
[0238] Another example is that when the resource levels of the inserted multiple new hard disks are the same, the same-sized random value range can be set for each new hard disk. Thus, when determining the second number of target hard disks, third number of random values can be selected within the value range formed by the random value ranges of the second number of target hard disks, and the random value range to which each selected random value belongs can be determined. For each selected random value, among the second number of target hard disks, the target hard disk with the set random value range being the random value range where the random value is located is the determined hard disk to be utilized.
[0239] Another example is that when the resource levels of the inserted multiple new hard disks are different, different weights can be set for each new hard disk according to the different resource levels of each new hard disk. Thus, when determining the second number of target hard disks, third number of random values can be randomly selected within the value range formed by the weight values of the second number of target hard disks, and the target hard disk with the weight value being the random value is the determined hard disk to be utilized.
[0240] In the above examples, using random values to determine the hard disks to be utilized can discretize the composition of new stripes, avoid the problem of regular data loss after hard disk anomalies caused by regular selection of the hard disks to be utilized, and improve the security of the written data.
[0241] Still another example is that the total capacities of each target hard disk may not be the same. To ensure the balanced use of each target hard disk, the target hard disks with larger total capacities can be determined as the hard disks to be utilized more frequently and discontinuously. Therefore, the value range or weight of each target hard disk can be dynamically adjusted according to the proportion of the free capacity of each target hard disk.
[0242] Exemplarily, there are two target hard disks. The total capacity of the first target hard disk is 4T, and the total capacity of the second target hard disk is 8T. The size of each logical block (trunk) divided in each target hard disk is 128K. Assuming that the available capacity of 1T is represented by the value 1, the capacity ratio of the target hard disk with a total capacity of 4T can be represented by the value 4, and the capacity ratio of the target hard disk with a total capacity of 8T can be represented by the value 8. Furthermore, according to the ratio of the capacity ratios of the above two newly added hard disks, the random value range for the target hard disk with a total capacity of 4T can be set as 1 - 40, and the random value range for the target hard disk with a total capacity of 8T can be set as 41 - 120. Then, the range of the random value is 1 - 120. Furthermore, when determining a hard disk to be utilized, a random value can be obtained within 1 - 120. If the random value falls within the value range of a certain target hard disk, then that target hard disk is determined as the hard disk to be utilized. In this way, it can ensure that the target with a larger total capacity is determined as the hard disk to be utilized relatively more times, and at the same time, it can ensure that the situation of determining the target hard disk with a larger total capacity as the hard disk to be utilized is discretely distributed.
[0243] In addition, when determining the hard disk to be utilized, the distribution of the free capacity in the target hard disk can be further considered. Thus, according to the distribution of the free capacity in the target hard disk, the weights of each target hard disk can be dynamically adjusted, so as to balance the distribution of the free capacity in the target hard disk.
[0244] It should be emphasized that the information types included in the above hard disk information, and the examples of selecting the hard disk to be utilized, are only examples for the above step 521. Any implementation method that can select the third number of hard disks from the target hard disks as the hard disk to be utilized based on the hard disk information of each target hard disk, and any hard disk information belonging to each target hard disk fall within the protection scope of the embodiments of the present invention.
[0245] Optionally, in another specific implementation manner, the above step S303 may include the following steps 51 and 52:
[0246] Step 51: For each strip to be processed, if the third number of logical blocks to be replaced in the strip to be processed is not less than the second number of the target hard disks, then one logical block in each target hard disk is used to replace one logical block to be replaced in each strip to be processed;
[0247] Step 52: For each strip to be processed, if the third number is less than the second number, then select the third number of hard disks from the target hard disks as the hard disks to be utilized, and use one logical block in each of the selected hard disks to be utilized to replace one logical block to be replaced in each strip to be processed.
[0248] In many cases, due to reasons such as the increase in the amount of data to be stored, the storage space of the above-mentioned target RAID will not be able to meet the requirements of data storage in actual applications. Therefore, the target hard disk can be used to expand the capacity of the above-mentioned target RAID. That is, through logical block (trunk) replacement, the logical blocks (trunks) in the target hard disk are added to the initial stripe of the above-mentioned target RAID, and new stripes can be constructed based on the logical blocks (trunks) replaced from the initial stripes and belonging to each initial hard disk. Thus, with the help of the logical blocks (trunks) in the target hard disk, the number of stripes included in the target RAID can be increased, and further, the storage space of the target RAID can be increased.
[0249] Among them, since the logical blocks (trunks) included in each stripe of the target RAID belong to different hard disks, each stripe to be processed can be grouped. Thus, when performing logical block (trunk) replacement, the replaced logical blocks (trunks) belonging to the same stripe group can belong to different initial hard disks respectively. Therefore, new stripes can be constructed using the replaced logical blocks (trunks) belonging to the same stripe group.
[0250] Based on this, optionally, in a specific implementation manner, every preset number of stripes to be processed are divided into a stripe group, and the replaced logical blocks (trunks) belonging to the same stripe group belong to different initial hard disks respectively.
[0251] In this specific implementation manner, the above-mentioned preset number can be determined according to the number of logical blocks (trunks) included in each stripe of the target RAID and the number of determined target hard disks. Then, according to this preset number, each stripe to be processed can be grouped, so that every preset number of stripes to be processed are divided into a stripe group. Furthermore, for each stripe group, the logical blocks (trunks) in the target hard disk can be used to replace the replaced logical blocks (trunks) in each stripe to be processed in this stripe group, and the replaced logical blocks (trunks) belonging to this stripe group belong to different initial hard disks respectively.
[0252] Among them, for each stripe group, for the first stripe to be processed in the stripe group, one trunk in each target hard disk or each hard disk to be utilized is respectively used to replace one trunk to be replaced in the stripe to be processed; then, for the second stripe to be processed in the stripe group, one trunk in each target hard disk or each hard disk to be utilized is respectively used to replace one trunk to be replaced in the stripe to be processed, and the trunk to be replaced replaced from the second stripe to be processed belongs to different initial hard disks from the trunks to be replaced replaced from each stripe to be processed that have been replaced previously; afterwards, for the third stripe to be processed in the stripe group, one trunk in each target hard disk or each hard disk to be utilized is respectively used to replace one trunk to be replaced in the stripe to be processed, and the trunk to be replaced replaced from the third stripe to be processed belongs to different initial hard disks from the trunks to be replaced replaced from each stripe to be processed that have been replaced previously; and so on, until for the preset number of stripes to be processed in the stripe group, one trunk in each target hard disk or each hard disk to be utilized is respectively used to replace one trunk to be replaced in the stripe to be processed, and the trunk to be replaced replaced from the preset number of specified stripes belongs to different initial hard disks from the trunks to be replaced replaced from each stripe to be processed that have been replaced previously. Thus, all the trunks to be replaced that are replaced from the preset number of stripes to be processed in the stripe group and belong to different initial hard disks can be obtained.
[0253] Furthermore, after completing the replacement of the to-be-replaced logical blocks (trunks) in the preset number of to-be-processed stripes in the above stripe group, for the preset number of to-be-processed stripes in the next stripe group that need to have their logical blocks (trunks) replaced, the above process can be looped again to obtain all the to-be-replaced logical blocks (trunks) that are replaced from different initial hard disks for the preset number of to-be-processed stripes in the next stripe group.
[0254] Optionally, in practical applications, the electronic device may not perform specific grouping actions on the to-be-processed stripe. Therefore, when replacing the to-be-replaced trunk in the to-be-processed stripe, for the first determined to-be-processed stripe, one trunk in each target hard disk or each to-be-utilized hard disk can be used to replace one to-be-replaced trunk in the to-be-processed stripe respectively; then, for the second determined to-be-processed stripe, one trunk in each target hard disk or each to-be-utilized hard disk can be used to replace one to-be-replaced trunk in the to-be-processed stripe respectively, and the to-be-replaced trunk replaced from the second to-be-processed stripe belongs to different initial hard disks from the to-be-replaced trunks replaced from each of the previously completed to-be-processed stripes; afterwards, for the third determined to-be-processed stripe, one trunk in each target hard disk or each to-be-utilized hard disk can be used to replace one to-be-replaced trunk in the to-be-processed stripe respectively, and the to-be-replaced trunk replaced from the third to-be-processed stripe belongs to different initial hard disks from the to-be-replaced trunks replaced from each of the previously completed to-be-processed stripes; and so on, until for the preset number of to-be-processed stripes, one trunk in each target hard disk or each to-be-utilized hard disk is used to replace one to-be-replaced trunk in the to-be-processed stripe respectively, and the to-be-replaced trunk replaced from the preset number of specified stripes belongs to different initial hard disks from the to-be-replaced trunks replaced from each of the previously completed to-be-processed stripes. Thus, all the to-be-replaced trunks replaced from the above preset number of to-be-processed stripes, which belong to different initial hard disks, can be obtained.
[0255] Furthermore, after replacing the trunks to be replaced in each preset number of stripes to be processed, for the next stripe to be processed for trunk replacement, it can be re-determined as the first stripe to be processed. Thus, by looping the above process, all the trunks to be replaced that are replaced from different initial hard disks for the next group of preset number of stripes to be processed can be obtained.
[0256] Among them, since the number of trunks to be replaced replaced by the trunks in the target hard disk in each stripe to be processed is not greater than the second number, and the number of trunks included in the newly created stripe is the first number, therefore, for each stripe group, the total number of trunks to be replaced is not greater than the first number; furthermore, considering that the newly created stripe based on each trunk to be replaced can include the trunks in the target hard disk, then, the difference between the first number and the total number of trunks to be replaced is not greater than the second number of the target hard disk.
[0257] That is to say, for each stripe group, the number of each trunk to be replaced belonging to the stripe group is not greater than the first number and not less than the difference between the first number and the second number.
[0258] Moreover, for each stripe group, if the third number of trunks to be replaced in each stripe to be processed is not less than the second number of the target hard disk, then the number of each trunk to be replaced belonging to the stripe group is: the product of the second number and the preset number. If the third number of trunks to be replaced in the stripe to be processed is less than the second number of the target hard disk, then the number of each trunk to be replaced belonging to the stripe group is: the product of the third number and the preset number.
[0259] For example, the first quantity of trunks included in each stripe is 20, the second quantity of target hard disks is 1, and the quantity of trunks to be replaced included in each stripe to be processed is 1. Then the above preset quantity can be 20, and the 20 trunks to be replaced included in the newly created stripe respectively belong to each initial hard disk;
[0260] For another example, the first quantity of trunks included in each stripe is 20, the second quantity of target hard disks is 1, and the quantity of trunks to be replaced included in each stripe to be processed is 1. Then the above preset quantity can be 19, and the newly created stripe includes 19 trunks to be replaced respectively belonging to one initial hard disk and one trunk belonging to the target hard disk.
[0261] Optionally, when determining each stripe to be processed, one stripe to be processed can be determined each time, and after replacing the trunks to be replaced in this stripe to be processed, the next stripe to be processed is determined until the quantity of the stripes to be processed replaced reaches the preset quantity.
[0262] Optionally, when determining each stripe to be processed, multiple stripes to be processed can be determined simultaneously each time, and after respectively replacing the trunks to be replaced in these multiple stripes to be processed, the next group of multiple stripes to be processed is determined until the quantity of the stripes to be processed replaced reaches the preset quantity.
[0263] Optionally, when determining each stripe to be processed, a preset quantity of stripes to be processed can be determined simultaneously each time, that is, a stripe group including a preset quantity of stripes to be processed is determined, and after respectively replacing the trunks to be replaced in each stripe to be processed in this stripe group, the next stripe group is determined.
[0264] Furthermore, when there is no available logical block (trunk) in the target hard disk, since the logical block (trunk) in the target hard disk cannot be used to replace the logical block (trunk) to be replaced in the stripe to be processed, thus, it is impossible to continue to process the resources of the target RAID by replacing the logical block (trunk) to be replaced in the stripe to be processed. Therefore, the resource processing of the above target RAID is completed.
[0265] That is to say, optionally, when multiple initial stripes included in the target RAID are used as stripes to be processed and are replaced, or when there is no available logical block (trunk) in the target hard disk, the resource processing of the above target RAID is completed.
[0266] As described above, by using the storage resource processing method provided by the embodiments of the present invention, the expansion and repair of the target RAID can be realized. Therefore, in practical applications, the storage resource processing method provided by the embodiments of the present invention can be used to expand or repair the target RAID respectively, or can be executed alternately to realize the expansion and repair of the target RAID.
[0267] That is to say, by using the storage resource processing method provided by the embodiments of the present invention, the target RAID can be only expanded; the target RAID can be only repaired; after the target RAID is expanded, if there are faulty logical blocks (trunks) in the expanded target RAID, the expanded target RAID can be further repaired; after the target RAID is repaired, the repaired target RAID can be further expanded. All of these are reasonable.
[0268] Corresponding to the above storage resource processing method provided by the embodiments of the present invention, the embodiments of the present invention also provide a storage resource processing device.
[0269] Figure 14 As shown in the structural schematic diagram of a storage resource processing device provided by the embodiments of the present invention, Figure 14 as shown, the device includes:
[0270] A RAID determination module 1401, configured to determine a target RAID to be processed; wherein, the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks, and the sizes of the logical blocks belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of the multiple initial hard disks;
[0271] A stripe determination module 1402, configured to determine each to-be-processed stripe from multiple initial stripes included in the target RAID;
[0272] A stripe processing module 1403, configured to use the logical blocks for replacement in the target hard disk to replace the to-be-replaced logical blocks in each to-be-processed stripe, so that multiple logical blocks included in each replaced to-be-processed stripe respectively belong to different hard disks; wherein, the target hard disk is a newly added hard disk, and the sizes of the logical blocks for replacement in the target hard disk are the same as the sizes of the logical blocks in each initial hard disk.
[0273] As can be seen above, when applying the solution provided in the embodiment of the present invention to process the storage resources of the target RAID, the logical blocks in the newly added target hard disk can be used to replace the to-be-replaced logical blocks in each to-be-processed stripe in the target RAID, so as to obtain each replaced to-be-processed stripe, and multiple logical blocks included in each replaced to-be-processed stripe respectively belong to different hard disks. In the above processing process, for each replaced to-be-processed stripe and each stripe in the target RAID except the to-be-processed stripe, various operations such as data writing operations can be normally executed, so that it is not necessary to stop the existing services and the normal operation of the existing services can be ensured; and, since each replaced to-be-processed stripe includes the logical blocks in the target hard disk, when a data writing operation is executed on the replaced to-be-processed stripe, the data to be written can be successfully written into the target hard disk, so that it is not necessary to increase additional disk bandwidth overhead. In this way, it is possible to quickly and conveniently process the storage resources of the RAID without affecting the operation of the existing services and without increasing additional disk bandwidth overhead.
[0274] Optionally, in a specific implementation manner, the stripe processing module 1403 includes:
[0275] A first processing sub-module, configured to, for each to-be-processed stripe, if the third quantity of the to-be-replaced logical blocks in the to-be-processed stripe is not less than the second quantity of the target hard disk, use one logical block for replacement in each target hard disk to replace one to-be-replaced logical block in the to-be-processed stripe; and / or,
[0276] A second processing sub-module, configured to, for each to-be-processed stripe, if the third quantity is less than the second quantity, select the third quantity of hard disks from the target hard disk as the to-be-utilized hard disks, and use one logical block for replacement in each of the selected to-be-utilized hard disks to replace one to-be-replaced logical block in the to-be-processed stripe.
[0277] Optionally, in a specific implementation, every preset number of to-be-processed stripes are divided into a stripe group, and each replaced to-be-replaced logical block belonging to the same stripe group belongs to a different initial hard disk respectively.
[0278] Optionally, in a specific implementation, the apparatus further includes:
[0279] A first determination module, configured to, for each to-be-processed stripe, determine a replacement weight value of each logical block in the to-be-processed stripe based on the hard disk information of the initial hard disks to which the logical blocks in the to-be-processed stripe belong and the hard disk information of the target RAID; determine the to-be-replaced logical blocks in each to-be-processed stripe based on the replacement weight values of the logical blocks in each to-be-processed stripe and the second quantity of the target hard disk; or determine the logical blocks belonging to the hot hard disks in each to-be-processed stripe as the to-be-replaced logical blocks in each to-be-processed stripe.
[0280] Optionally, in a specific implementation, the first determination module includes:
[0281] A candidate logical block determination sub-module, configured to, for each to-be-processed stripe, determine each logical block whose replacement weight value meets a preset condition as a candidate logical block; where the preset condition includes: being within a preset weight range, or being greater than a preset weight threshold.
[0282] A first determination sub-module, configured to, if the third quantity of the determined candidate logical blocks is greater than the second quantity of the target hard disk, select the second quantity of logical blocks from the determined candidate logical blocks as the to-be-replaced logical blocks; and / or, a second determination sub-module, configured to, if the third quantity of the determined candidate logical blocks is not greater than the second quantity of the target hard disk, determine the determined candidate logical blocks as the to-be-replaced logical blocks.
[0283] Optionally, in a specific implementation, the first determination sub-module is specifically configured to:
[0284] Based on the hard disk information of each target hard disk, select the third quantity of hard disks from the target hard disks as the to-be-utilized hard disks; where the hard disk information of each target hard disk includes at least the total capacity of each target hard disk, the free capacity of each target hard disk, or the health value of each target hard disk.
[0285] Optionally, in a specific implementation, the stripe determination module 1402 is specifically configured to:
[0286] If data has been written to all the multiple initial stripes, determine each of the multiple initial stripes as a to-be-processed stripe; or
[0287] If there are blank stripes among the multiple initial stripes, then each initial stripe that has been written with data and / or each blank stripe among the multiple initial stripes is determined as a stripe to be processed.
[0288] Optionally, in a specific implementation manner, if the third quantity is not less than the second quantity, the first processing sub-module is specifically configured to:
[0289] If the third quantity is equal to the second quantity, one replaceable logical block in each target hard disk is respectively used to replace one replaceable logical block in each stripe to be processed;
[0290] If the third quantity is greater than the second quantity, the fourth quantity of replaceable logical blocks in the target hard disk is used to replace and obtain the fourth quantity of specified logical blocks from at least one initial stripe other than the stripe to be processed; and one available logical block is respectively used to replace one replaceable logical block in the stripe to be processed; wherein, the fourth quantity is the difference between the third quantity and the second quantity, the specified logical block does not belong to the initial hard disk included in the stripe to be processed, and the available logical block includes: one replaceable logical block in each target hard disk and the fourth quantity of specified logical blocks.
[0291] Optionally, in a specific implementation manner, the stripe determination module 1402 is specifically configured to:
[0292] Among the multiple initial stripes included in the target RAID, each stripe including a faulty logical block is determined as each stripe to be processed;
[0293] The apparatus further includes:
[0294] A second determination module, configured to, for each stripe to be processed, determine the faulty logical block included in the stripe to be processed as the replaceable logical block in the faulty stripe.
[0295] Optionally, in a specific implementation manner, the apparatus further includes:
[0296] A stripe creation module, configured to create new stripes based on the replaced replaceable logical blocks.
[0297] Optionally, in a specific implementation manner, the apparatus further includes:
[0298] A hard disk determination module, configured to determine a target hard disk from each newly added hard disk.
[0299] Optionally, in a specific implementation manner, the hard disk determination module is specifically configured to:
[0300] For each strip to be processed, based on the hard disk information of each newly added hard disk, determine a target hard disk from each newly added hard disk; or,
[0301] Select a random number within a preset random number value range, and determine the newly added hard disk corresponding to the random value sub-range to which the selected random number belongs as the target hard disk; wherein, the random number value range is composed of the random value sub-ranges corresponding to each newly added hard disk; or,
[0302] Select a weight within a preset weight value range, and determine the newly added hard disk with the selected weight as the target hard disk; wherein, the weight value range is composed of the weights of each newly added hard disk.
[0303] Optionally, in a specific implementation manner, the device further includes:
[0304] A hard disk partitioning module, configured to perform logical block partitioning on each of the detected newly added hard disks after detecting each newly added hard disk.
[0305] Corresponding to the above-mentioned storage resource processing method provided by an embodiment of the present invention, an embodiment of the present invention further provides an electronic device, as Figure 15 shown, including a processor 1501, a communication interface 1502, a memory 1503, and a communication bus 1504, wherein the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504,
[0306] The memory 1503 is used to store a computer program;
[0307] The processor 1501, when executing the program stored on the memory 1503, implements the steps of any of the above-mentioned storage resource processing methods provided by the embodiments of the present invention.
[0308] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the above electronic device and other devices. The memory may include a Random Access Memory (RAM), and may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor. The above processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0309] In another embodiment provided by the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the RAID expansion methods provided by the above embodiments of the present invention are implemented.
[0310] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions, which when running on a computer, causes the computer to execute the steps of any of the RAID expansion methods provided by the above embodiments of the present invention.
[0311] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0312] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not expressly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0313] Each embodiment in this specification is described in a related manner. The same or similar parts among the embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the device embodiments, electronic device embodiments, computer-readable storage medium embodiments, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments.
[0314] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included within the protection scope of the present invention.
Claims
1. A method for processing storage resources, characterized in that, The method includes: Determine a target RAID to be processed; wherein, the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks, and the sizes of the logical blocks belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of the multiple initial hard disks; Determine each stripe to be processed from the multiple initial stripes included in the target RAID; Use the logical blocks for replacement in the target hard disk to replace the logical blocks to be replaced in each stripe to be processed, so that the multiple logical blocks included in each stripe to be processed after replacement respectively belong to different hard disks; wherein, the target hard disk is a newly added hard disk, and the sizes of the logical blocks for replacement in the target hard disk are the same as the sizes of the logical blocks in each initial hard disk.
2. The method according to claim 1, wherein The step of using the logical blocks for replacement in the target hard disk to replace the logical blocks to be replaced in each stripe to be processed includes: For each stripe to be processed, if the third number of the logical blocks to be replaced in this stripe to be processed is not less than the second number of the target hard disk, then use one logical block for replacement in each target hard disk to replace one logical block to be replaced in this stripe to be processed; and / or For each stripe to be processed, if the third number is less than the second number, select the third number of hard disks from the target hard disk as the hard disks to be utilized, and use one logical block for replacement in each of the selected hard disks to be utilized to replace one logical block to be replaced in this stripe to be processed.
3. The method according to claim 2, wherein Every preset number of stripes to be processed are divided into a stripe group, and the replaced logical blocks to be replaced belonging to the same stripe group respectively belong to different initial hard disks.
4. The method according to claim 3, wherein The determination method of the logical blocks to be replaced in each stripe to be processed includes: For each stripe to be processed, based on the hard disk information of the initial hard disks to which the logical blocks in this stripe to be processed belong and the hard disk information of the target RAID, determine the replacement weight values of the logical blocks in this stripe to be processed; based on the replacement weight values of the logical blocks in each stripe to be processed and the second number of the target hard disk, determine the logical blocks to be replaced in each stripe to be processed; or Determine the logical blocks belonging to the hot hard disk in each stripe to be processed as the logical blocks to be replaced in each stripe to be processed.
5. The method according to claim 4, wherein The step of determining the logical blocks to be replaced in each stripe to be processed based on the replacement weight values of the logical blocks in each stripe to be processed and the second number of the target hard disk includes: For each stripe to be processed, determine the logical blocks whose replacement weight values meet the preset conditions as candidate logical blocks; wherein, the preset conditions include: being within a preset weight range, or being greater than a preset weight threshold; If the third number of the determined candidate logical blocks is greater than the second number of the target hard disk, select the second number of logical blocks from the determined candidate logical blocks as the logical blocks to be replaced; and / or If the third quantity of the determined candidate logical blocks is not greater than the second quantity of the target hard disks, determine the determined candidate logical blocks as the logical blocks to be replaced.
6. The method according to any one of claims 2-5, characterized in that, The step of selecting the third quantity of hard disks from the target hard disks as the hard disks to be utilized includes: Based on the hard disk information of each target hard disk, select the third quantity of hard disks from the target hard disks as the hard disks to be utilized; Wherein, the hard disk information of each target hard disk includes at least the total capacity of each target hard disk, the free capacity of each target hard disk, or the health value of each target hard disk.
7. The method according to any one of claims 1-5, characterized in that, The step of determining each strip to be processed from the multiple initial strips included in the target RAID includes: If all of the multiple initial strips have been written with data, determine each of the multiple initial strips as a strip to be processed; Or, If there are blank strips among the multiple initial strips; then determine each of the initial strips that have been written with data and / or each of the blank strips among the multiple initial strips as strips to be processed.
8. The method according to claim 2, wherein The step of, if the third quantity is not less than the second quantity, respectively using one replacement logical block in each target hard disk to replace one logical block to be replaced in each strip to be processed includes: If the third quantity is equal to the second quantity, respectively use one replacement logical block in each target hard disk to replace one logical block to be replaced in each strip to be processed; If the third quantity is greater than the second quantity, use the fourth quantity of replacement logical blocks in the target hard disks to replace and obtain the fourth quantity of specified logical blocks from at least one initial strip other than the strip to be processed; and respectively use one logical block to be utilized to replace one logical block to be replaced in this strip to be processed; Wherein, the fourth quantity is: the difference between the third quantity and the second quantity, the specified logical block does not belong to the initial hard disks included in this strip to be processed, and the logical blocks to be utilized include: one replacement logical block in each target hard disk and the fourth quantity of specified logical blocks.
9. The method according to claim 1 or 8, characterized in that, The step of determining each strip to be processed from the multiple initial strips included in the target RAID includes: Determine each strip including a faulty logical block among the multiple initial strips included in the target RAID as each strip to be processed; The method further includes: For each strip to be processed, determine the faulty logical block included in this strip to be processed as the logical block to be replaced in the faulty strip.
10. The method according to any one of claims 1-5 and 8, characterized in that, The method further includes: Create new strips based on each replaced logical block to be replaced.
11. The method according to any one of claims 1-5 and 8, characterized in that, The method further includes: Determine target hard disks from each newly added hard disk.
12. The method according to claim 11, wherein The step of determining target hard disks from each newly added hard disk includes: For each strip to be processed, based on the hard disk information of each newly added hard disk, determine target hard disks from each newly added hard disk; Or, Select a random number within a preset random number value range, and determine the newly added hard disk corresponding to the sub-range of the random value to which the selected random number belongs as the target hard disk; wherein, the random number value range is composed of sub-ranges of random values corresponding to each newly added hard disk; Or, Select weights within a preset weight value range, and determine the newly added hard disk with the selected weights as the target hard disk; wherein, the weight value range is composed of the weights of each newly added hard disk.
13. The method according to any one of claims 1-5 and 8, characterized in that, The method further includes: After detecting each newly added hard disk, perform logical block partitioning on each detected newly added hard disk.
14. A storage resource processing device, characterized in that, The device includes: A RAID determination module, configured to determine a target RAID to be processed; wherein, the target RAID includes multiple initial hard disks, each initial hard disk is divided into multiple logical blocks, and the sizes of the logical blocks belonging to different initial hard disks are the same. Each initial stripe in the target RAID includes: the first number of logical blocks respectively belonging to the first number of initial hard disks, and the first number is not greater than the number of the multiple initial hard disks; A stripe determination module, configured to determine each stripe to be processed from the multiple initial stripes included in the target RAID; A stripe processing module, configured to use the logical blocks for replacement in the target hard disk to replace the logical blocks to be replaced in each stripe to be processed, so that the multiple logical blocks included in each stripe to be processed after replacement respectively belong to different hard disks; wherein, the target hard disk is a newly added hard disk, and the sizes of the logical blocks for replacement in the target hard disk are the same as the sizes of the logical blocks in each initial hard disk.
15. The device according to claim 14, wherein The stripe processing module includes: A first processing sub-module, configured to, for each stripe to be processed, if the third number of the logical blocks to be replaced in the stripe to be processed is not less than the second number of the target hard disk, use one logical block for replacement in each target hard disk to replace one logical block to be replaced in the stripe to be processed; and / or, a second processing sub-module, configured to, for each stripe to be processed, if the third number is less than the second number, select the third number of hard disks from the target hard disk as the hard disks to be utilized, and use one logical block for replacement in each selected hard disk to be utilized to replace one logical block to be replaced in the stripe to be processed; and / or, Every preset number of stripes to be processed are divided into a stripe group, and the logical blocks to be replaced belonging to the same stripe group respectively belong to different initial hard disks; and / or, The device further includes: a first determination module, configured to, for each stripe to be processed, based on the hard disk information of the initial hard disks to which the logical blocks in the stripe to be processed belong and the hard disk information of the target RAID, determine the replacement weight values of the logical blocks in the stripe to be processed; based on the replacement weight values of the logical blocks in each stripe to be processed and the second number of the target hard disk, determine the logical blocks to be replaced in each stripe to be processed; or, determine the logical blocks belonging to the hot hard disk in each stripe to be processed as the logical blocks to be replaced in each stripe to be processed; and / or, The first determination module includes: a candidate logical block determination sub-module, configured to, for each strip to be processed, determine each logical block whose included replacement weight value meets a preset condition as a candidate logical block; wherein, the preset condition includes: being within a preset weight range, or being greater than a preset weight threshold; a first determination sub-module, configured to, if the third quantity of the determined candidate logical blocks is greater than the second quantity of the target hard disks, select the second quantity of logical blocks from the determined candidate logical blocks as the logical blocks to be replaced; and / or, a second determination sub-module, configured to, if the third quantity of the determined candidate logical blocks is not greater than the second quantity of the target hard disks, determine the determined candidate logical blocks as the logical blocks to be replaced; and / or, The first determination sub-module is specifically configured to: based on the hard disk information of each target hard disk, select the third quantity of hard disks from the target hard disks as the hard disks to be utilized; wherein, the hard disk information of each target hard disk includes at least the total capacity of each target hard disk, the free capacity of each target hard disk, or the health value of each target hard disk; and / or, The strip determination module is specifically configured to: if all of the multiple initial strips have been written with data, determine each of the multiple initial strips as a strip to be processed; or, if there are blank strips among the multiple initial strips, determine each of the initial strips that have been written with data and / or each of the blank strips among the multiple initial strips as strips to be processed; and / or, If the third quantity is not less than the second quantity, the first processing sub-module is specifically configured to: if the third quantity is equal to the second quantity, respectively use one replacement logical block in each target hard disk to replace one logical block to be replaced in each strip to be processed; if the third quantity is greater than the second quantity, use the fourth quantity of replacement logical blocks in the target hard disks to replace the fourth quantity of specified logical blocks from at least one initial strip other than the strip to be processed; and, respectively use one logical block to be utilized to replace one logical block to be replaced in this strip to be processed; wherein, the fourth quantity is: the difference between the third quantity and the second quantity, the specified logical block does not belong to the initial hard disks included in this strip to be processed, and the logical blocks to be utilized include: one replacement logical block in each target hard disk and the fourth quantity of specified logical blocks; and / or, The strip determination module is specifically configured to: determine each of the strips including faulty logical blocks among the multiple initial strips included in the target RAID as each strip to be processed; the apparatus further includes: a second determination module, configured to, for each strip to be processed, determine the faulty logical blocks included in this strip to be processed as the logical blocks to be replaced in the faulty strip; and / or, The apparatus further includes: a strip creation module, configured to create new strips based on each of the replaced logical blocks to be replaced; and / or, The apparatus further includes: a hard disk determination module, configured to determine target hard disks from each of the newly added hard disks; and / or, The hard disk determination module is specifically configured to, for each strip to be processed, determine a target hard disk from each newly added hard disk based on the hard disk information of each newly added hard disk; alternatively, select a random number within a preset random number value range, and determine the newly added hard disk corresponding to the sub-range of the random value to which the selected random number belongs as the target hard disk; wherein, the random number value range is composed of the sub-ranges of random values corresponding to each newly added hard disk; or, select a weight within a preset weight value range, and determine the newly added hard disk with the selected weight as the target hard disk; wherein, the weight value range is composed of the weights of each newly added hard disk. and / or, The device further includes: a hard disk partitioning module, configured to perform logical block partitioning on each of the detected newly added hard disks after detecting each newly added hard disk.
16. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used for storing a computer program; The processor is configured to, when executing the program stored on the memory, implement the steps of the method according to any one of claims 1-13.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1-13.
Citation Information
Patent Citations
Method and device for processing bad blocks of redundant array of independent disk (RAID)
CN105468479A
Hard disk data recovery verifying method
CN105808386A