Storage space allocation method and device, electronic equipment and storage medium

By allocating cache pools for virtual disks and obtaining segments from multiple shard groups, the problem of unbalanced write IO load in distributed storage systems is solved, and the balance of write performance and storage space allocation is improved.

CN119440379APending Publication Date: 2025-02-14RUIJIE NETWORKS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310943107.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-28
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When a distributed storage system writes data in CKG units, it cannot guarantee the load balancing of the write IO, resulting in poor write bandwidth.

Method used

By allocating a segment for each virtual disk, the segments obtained by splitting the shard group are cached. If there are no available segments in the segment allocation cache pool, the target segment is determined from the preset multiple shard groups, obtain the preset number of segments caches into the segment allocation cache pool, and determine the target segment as virtual. Disk allocated storage space.

Benefits of technology

By dividing the shard group into segments, the problem of large space occupancy of the shard group is solved, ensuring as much physical disk participation as possible, so that the written data is evenly dropped on different disks, and improving write concurrency and performance ensure balanced storage space allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440379A_ABST
    Figure CN119440379A_ABST
Patent Text Reader

Abstract

The invention provides a storage space allocation method and device, electronic equipment and a storage medium. The method comprises the following steps: in response to a storage space allocation instruction for a virtual disk, determining a segment allocation cache pool corresponding to the virtual disk; wherein the segment allocation cache pool is used for caching segments obtained by segmentation of a fragment group, the fragment group is composed of fragments from at least two physical disks, and the fragments are local parts of the physical disks; if it is determined that there is no available segment in the segment allocation cache pool, determining a target fragment group from at least two preset fragment groups; determining a preset number of segments from the target fragment group, and caching the preset number of segments into a segment allocation cache pool; and determining a target segment from the segment allocation cache pool as a storage space allocated to the virtual disk. Through the method provided by the invention, the balance of IO loads of different disks can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to computer technology, and in particular to a storage space allocation method, device, electronic device and storage medium. Background Art

[0002] In the face of massive data explosion, a distributed storage system can be used for storage. A distributed storage system can use the disk space on multiple storage servers and form a virtual disk with these scattered storage resources for users to use.

[0003] In order to achieve optimal storage performance, the distributed storage system forms CKG (Chunk Group) to allocate storage space for virtual disks to write data. However, when writing data in units of CKG, the load balancing of write IO (Input / Output) cannot be guaranteed, and the write bandwidth is poor. Therefore, how to allocate storage space and give full play to the performance of physical disks on different storage servers has become an important issue that needs to be solved in this field. Summary of the invention

[0004] The present application provides a storage space allocation method, device, electronic device and storage medium to improve the balance of storage space allocation.

[0005] In a first aspect, the present application provides a method for allocating storage space, comprising:

[0006] In response to a storage space allocation instruction for a virtual disk, a segment allocation buffer pool corresponding to the virtual disk is determined; wherein the segment allocation buffer pool is used to cache segments obtained by segmentation of a shard group, wherein the shard group is composed of shards from at least two physical disks, and the shard is a part of a physical disk;

[0007] If it is determined that there are no available segments in the segment allocation buffer pool, determining a target shard group from at least two preset shard groups;

[0008] Determine a preset number of segments from the target shard group, and cache the preset number of segments in the segment allocation cache pool;

[0009] A target segment is determined from the segment allocation buffer pool, which is a storage space allocated to the virtual disk.

[0010] In a second aspect, the present application provides a storage space allocation device, comprising:

[0011] An instruction response module is used to respond to a storage space allocation instruction for a virtual disk and determine a segment allocation buffer pool corresponding to the virtual disk; wherein the segment allocation buffer pool is used to cache segments obtained by segmentation of a shard group, wherein the shard group is composed of shards from at least two physical disks, and the shard is a part of a physical disk;

[0012] A first determination module, configured to determine a target shard group from at least two preset shard groups if it is determined that there are no available segments in the segment allocation buffer pool;

[0013] A second determination module is used to determine a preset number of segments from the target shard group, and cache the preset number of segments into the segment allocation cache pool;

[0014] The space allocation module is used to determine a target segment from the segment allocation buffer pool, which is a storage space allocated to the virtual disk.

[0015] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0016] The memory stores computer-executable instructions;

[0017] The processor executes the computer-executable instructions stored in the memory to implement the storage space allocation method as described in the first aspect of the present application.

[0018] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer execution instructions, and when the computer execution instructions are executed by a processor, they are used to implement the storage space allocation method as described in the first aspect of the present application.

[0019] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the storage space allocation method described in the first aspect of the present application.

[0020] The present application provides a storage space allocation method, device, electronic device and storage medium. A virtual disk can be used to store write data, and each virtual disk corresponds to a segment allocation buffer pool. After responding to the storage space allocation instruction for the virtual disk, the segment allocation buffer pool corresponding to the virtual disk is determined. The segment allocation buffer pool can cache segments obtained by segmentation of a shard group. The shard group is composed of shards from at least two physical disks, and the shard is a part of the physical disk. There are multiple shard groups preset, and a shard group can be divided into multiple segments. If it is determined that there are no available segments in the segment allocation buffer pool, a target shard group can be determined from the preset multiple shard groups, and a preset number of segments are determined from the target shard group and cached in the segment allocation buffer pool. Then a target segment is determined from the segment allocation buffer pool and allocated to the virtual disk for data writing and storage. By dividing the shard group into segments, the problem of large space occupied by the shard group is solved. When allocating storage space, it ensures that as many physical disks as possible participate, so that the written data falls evenly on different disks, improving write concurrency, thereby improving write performance and ensuring the balance of storage space allocation. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] Figure 1 A schematic diagram of a flow chart of a storage space allocation method provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram of a slice of a physical disk provided in an embodiment of the present application;

[0024] Figure 3 A schematic diagram of a flow chart of a storage space allocation method provided in an embodiment of the present application;

[0025] Figure 4 A structural block diagram of a storage space allocation device provided in an embodiment of the present application;

[0026] Figure 5 A structural block diagram of a storage space allocation device provided in an embodiment of the present application;

[0027] Figure 6 A structural block diagram of an electronic device provided in an embodiment of the present application;

[0028] Figure 7 A structural block diagram of an electronic device provided in an embodiment of the present application.

[0029] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0030] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0031] It should be clear that the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0032] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0033] In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0034] It should be noted that due to space limitations, this application specification does not list all optional implementation methods. After reading this application specification, those skilled in the art should be able to think that as long as the technical features do not contradict each other, any combination of technical features can constitute an optional implementation method. Each embodiment is described in detail below.

[0035] Facing the massive data explosion, the traditional centralized storage system is no longer the best choice. Currently, more distributed storage systems are used to store massive data. Distributed storage systems use the disk space on multiple storage servers through the network and form virtual disks with these dispersed storage resources for users to use.

[0036] In order to achieve optimal storage performance, the distributed system needs to allow multiple storage servers to provide performance support at the same time. Therefore, the distributed storage system needs to consider the balanced use of each physical disk when building the CKG. Each CKG built comes from different disks of different server nodes. In order to improve the efficiency of CKG building, the space granularity occupied by CKG is relatively large. If data is written directly in units of CKG, only a small number of nodes and disks will participate each time data is written, which seriously affects the write bandwidth and causes unbalanced IO load. Therefore, it is necessary to further divide the CKG into segments with smaller granularity to allow more CKGs to participate in writing. How to allocate segments to ensure that as many disks as possible participate and give full play to the performance of each disk has become an important issue that needs to be solved in this field.

[0037] The present application provides a storage space allocation method, device, electronic device and storage medium, aiming to solve the above technical problems in the prior art.

[0038] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0039] Figure 1 FIG. 1 is a flow chart of a storage space allocation method provided according to an embodiment of the present application, and the method can be executed by a storage space allocation device. Figure 1 As shown, the method comprises the following steps:

[0040] S101. In response to a storage space allocation instruction for a virtual disk, determine a segment allocation buffer pool corresponding to the virtual disk; wherein the segment allocation buffer pool is used to cache segments obtained by segmentation from a shard group, a shard group is composed of shards from at least two physical disks, and a shard is a part of a physical disk.

[0041] Exemplarily, a virtual disk is provided to a user as a virtual storage device, which can be used to write and store data. For example, a user can issue a data storage instruction through an upper-layer application, respond to the data storage instruction, obtain the data input by the user, and write the data into the storage space of the virtual disk for storage. The storage space of the virtual disk can come from different physical disks in different computer nodes. For example, in a distributed system, there are multiple computer nodes, and each computer node can have one or more physical disks. These distributed storage resources are used to form multiple virtual disks. In this embodiment, the storage space of the physical disk in the centralized multi-disk system can also be allocated to the virtual disk.

[0042] When data is stored through a virtual disk, storage space needs to be allocated for the data to be stored. After responding to the user's data storage instruction, the upper-layer application can issue a storage space allocation instruction for the virtual disk, and the storage space allocation instruction can be used to determine the storage space allocated to the virtual disk for data storage. In this embodiment, the allocation of storage space can be applied to scenarios such as erasure coding or replica types.

[0043] Each virtual disk may correspond to a segment allocation buffer pool. After responding to the storage space allocation instruction for the virtual disk, the segment allocation buffer pool corresponding to the virtual disk may be obtained. For example, the segment allocation buffer pool corresponding to the virtual disk may be determined based on the association relationship between the virtual disk and the segment allocation buffer pool. The segment allocation buffer pool may be used to cache one or more segments, and the segment is obtained by segmenting the CKG. The CKG is composed of chunks from at least two physical disks, and a chunk is a part of a physical disk. That is, a part of the storage space in the physical disk may be divided into a chunk, and the chunks divided from different physical disks may be formed into a CKG, and then a CKG may be divided into multiple segments. One or more segments may be placed in the segment allocation buffer pool for use by the virtual disk. The association relationship between the virtual disk and the segment allocation buffer pool may be preset, and the segment allocation buffer pool corresponding to the virtual disk may be found based on the preset association relationship.

[0044] In this embodiment, the method also includes: dividing at least two physical disks into slices of a preset first size, obtaining a slice from each of the at least two physical disks to form a slice group; dividing the slices in the slice group into strips of a preset second size; and forming a segment with at least two stripes; wherein the stripes in the segment come from different slices in the slice group.

[0045] Specifically, at least two physical disks are sliced ​​to obtain multiple segments. At least two physical disks can come from the same computer node or from different computer nodes. Each physical disk is divided into chunks of a fixed size. For example, each physical disk can be divided into multiple chunks of a preset first size. A chunk is obtained from each physical disk to form a CKG. That is, the chunks in a CKG can come from different physical disks. Each chunk in the CKG is then divided into a finer granularity. For example, the chunks in the CKG are cut into strips of a preset second size. Strips from different chunks in the CKG are combined into a segment.

[0046] Figure 2 A schematic diagram of a physical disk slice. Figure 2 There are three physical disks, A, B, and C. Physical disk A can be divided into three chunks, represented by a; physical disk B can be divided into three chunks, represented by b; physical disk C can be divided into three chunks, represented by c. Get one a, one b, and one c respectively to form a CKG. Split the chunk in a CKG again, and one chunk can be divided into three strips. The three strips divided from a are three xs, the three strips divided from b are three ys, and the three strips divided from c are three zs. Get one x, one y, and one z respectively to form a segment, that is, a CKG can be divided into three segments. Among them, the strips in a segment are all from the same CKG.

[0047] The beneficial effect of this setting is that a segment can come from different physical disks of different computer nodes, which realizes the consideration of the use balance of each disk when forming CKG, so as to ensure that as many disks as possible participate and give full play to the performance of each disk. It ensures that the written data falls evenly on different disks of different computer nodes, improves write concurrency, and thus improves write performance.

[0048] S102: If it is determined that there are no available segments in the segment allocation buffer pool, determine a target shard group from at least two preset shard groups.

[0049] Exemplarily, a virtual disk needs to obtain storage space from a segment allocation buffer pool, and a segment may or may not exist in the segment allocation buffer pool. After determining the segment allocation buffer pool corresponding to the virtual disk, determine whether the segment allocation buffer pool is empty, that is, determine whether there is a segment in the segment allocation buffer pool. If it is determined that there is a segment in the segment allocation buffer pool, it can also be determined whether the segment is available, for example, it can be determined whether there is free storage space in the segment.

[0050] In this embodiment, determining that there are no available segments in the segment allocation buffer pool includes: if it is determined that there are no segments in the segment allocation buffer pool, then determining that there are no available segments in the segment allocation buffer pool; or if it is determined that there are no segments with free storage space in the segment allocation buffer pool, then determining that there are no available segments in the segment allocation buffer pool.

[0051] If it is determined that there is no segment in the segment allocation buffer pool, that is, it is determined that the virtual disk currently has no allocable storage space, then one or more segments need to be placed in the segment allocation buffer pool. The segment is obtained by dividing the CKG. Therefore, to determine the segment to be placed in the segment allocation buffer pool, it is necessary to determine a CKG as the target CKG, so as to place the segment in the target CKG in the segment allocation buffer pool. Multiple CKGs are generated in advance, and the target CKG is determined from the preset multiple CKGs. For example, a target CKG can be randomly determined, or the first CKG can be determined as the target CKG according to the physical address order of the CKG.

[0052] When determining the target CKG, each CKG may be screened before determining the target CKG. For example, a CKG with free space may be determined from multiple CKGs. Then a CKG with free space may be randomly selected from the CKGs as the target CKG. In this embodiment, the first selected target CKG may be randomly selected, or the first one may be selected according to the identification order of the CKGs. If it is not the first time, a CKG may be determined based on the result of the last selection based on a preset round-robin algorithm, and then it is determined whether the CKG meets the preset conditions.

[0053] In this embodiment, the method further includes: if it is determined that there are available segments in the segment allocation buffer pool, determining a target segment from the segment allocation buffer pool as the storage space allocated to the virtual disk.

[0054] Specifically, if it is determined that the segment allocation buffer pool is not empty, that is, there are segments in the segment allocation buffer pool and the segments are available, a segment can be directly determined from the segment allocation buffer pool as the target segment. The target segment is used as storage space allocated to the virtual disk to store data written by the user.

[0055] If there are multiple segments in the segment allocation buffer pool, a segment can be randomly selected as the target segment. Each segment has its own physical address, and an optimal segment can be selected based on the physical address of the segment in the segment allocation buffer pool. For example, based on the size of the segment's physical address, the segments are sorted from small to large, and the first segment is determined as the target segment.

[0056] The beneficial effect of this setting is that the optimal segment is selected according to the order of physical addresses, which ensures the optimal write bandwidth, improves the effectiveness of storage space allocation, and further improves write performance.

[0057] S103: Determine a preset number of segments from the target shard group, and cache the preset number of segments into a segment allocation cache pool.

[0058] Exemplarily, a CKG includes multiple segments, that is, a target CKG includes multiple segments. One or more segments can be determined from the target CKG and placed in the segment allocation buffer pool. The number of segments can be preset, and the preset number of segments can be cached in the segment allocation buffer pool. For example, a preset number of segments can be randomly obtained from the segments of the target CKG.

[0059] In this embodiment, an ideal value of the random read and write number is determined based on a predetermined maximum disk write bandwidth value and an average seek time; wherein the ideal value of the random read and write number is the product of the maximum disk write bandwidth value and the average seek time; a preset number is determined based on the ideal value of the random read and write number and the size of a stripe in a preset segment; wherein the preset number is the division result of the ideal value of the random read and write number and the size of a stripe in a preset segment.

[0060] Specifically, the number of segments added to the segment allocation buffer pool can be preset according to the actual performance of the hard disk. A physical disk is divided into multiple CKGs. If only one segment is added from the CKG at a time, the randomness of the disk write data will increase, affecting the performance. If too many segments are added, the balance of the write data will be affected. For mechanical hard disks, due to the influence of seek time, the bandwidth of random IO will not increase as the IO size increases. When the write delay and the average seek time are equal, the bandwidth of random IO is the largest. Therefore, the ideal random IO size is equal to the maximum write bandwidth of the disk multiplied by the average seek time. The number of preset segments can be determined according to the ideal random IO size. The preset number can be equal to the ideal random IO size divided by the stripe size of the segment, which can ensure the optimal performance of a single disk. The optimal preset number of segments can also be found through testing. For example, the performance of adding 1 segment from the CKG, the performance of adding 2 segments, and the performance of adding the entire CKG segment can be obtained through testing. According to the test results, the preset number of segments with the best performance is found.

[0061] In this embodiment, determining a preset number of segments from the target shard group includes: determining segments with free storage space in the target shard group; and determining the preset number of segments according to the physical address order of the segments with free storage space in the target shard group.

[0062] Specifically, the physical disk corresponds to its own physical address, and the physical disk is divided, and the obtained segments also correspond to their own physical addresses. According to the physical address of the segment, a preset number of segments can be obtained. For example, the physical addresses of the segments in the target CKG can be sorted from small to large. According to the sorting result, a preset number of segments are obtained. For example, if the preset number is 2, the first two segments can be obtained. In this embodiment, the segments with free storage space can be preferentially determined from the target CKG, and then the preset number of segments can be determined according to the order of the physical addresses of the segments with free storage space. That is, whether the segment is free can be used as the first condition, and the physical address can be used as the second condition.

[0063] The beneficial effect of this setting is that a preset number of segments are selected from the CKG each time according to the physical address order of the disk, ensuring the optimal random write bandwidth of a single disk and further improving the write performance.

[0064] In this embodiment, the method also includes: determining an ideal value of the random read and write number based on a predetermined maximum disk write bandwidth and an average seek time; wherein the ideal value of the random read and write number is the product of the maximum disk write bandwidth and the average seek time; determining a preset number based on the ideal value of the random read and write number and the size of a stripe in a preset segment; wherein the preset number is the division result of the ideal value of the random read and write number and the size of a stripe in a preset segment.

[0065] Specifically, if only one segment is added from the target CKG each time a segment is added, the randomness of the disk write data will increase, affecting performance. If too many segments are added, the balance of the write data will be affected. Therefore, it is necessary to predetermine the number of segments to be added to the segment allocation buffer pool. The optimal number of free segments is obtained from the target CKG in the order of the location of the disk physical address, and added to the segment allocation buffer pool. The optimal number is the preset number that needs to be determined. For mechanical hard disks, due to the influence of seek time, the bandwidth of random IO will not increase as the IO size increases. When the write delay and the average seek time are equal, the bandwidth of random IO is the largest. Therefore, the ideal random IO size is equal to the maximum write bandwidth of the disk multiplied by the average seek time, that is, the preset number of free segments added each time is equal to the ideal random IO size divided by the stripe size of the segment, so as to ensure the optimal performance of a single disk.

[0066] In this embodiment, the optimal preset number of segments can also be found through testing. For example, the performance of adding one segment from the target CKG each time, the performance of adding two segments each time, and so on until the performance of adding all segments in the target CKG each time can be obtained through testing. According to the test results, the preset number of segments with optimal performance is found.

[0067] S104: Determine a target segment from the segment allocation buffer pool as storage space allocated to the virtual disk.

[0068] Exemplarily, after the segment of the target CKG is placed in the segment allocation buffer pool, the segment exists in the segment allocation buffer pool. A segment can be determined from the segment allocation buffer pool as the target segment, and the target segment is determined as the storage space allocated to the virtual disk to store the data written by the user. If there are multiple segments in the segment allocation buffer pool, a segment can be randomly selected as the target segment.

[0069] Each segment has its own physical address, and an optimal segment can be selected based on the segment's physical address. For example, the segments are sorted from small to large based on the size of the segment's physical address, and the first-ranked segment is determined as the target segment.

[0070] The embodiment of the present application provides a method for allocating storage space, in which a virtual disk can be used to store write data, and each virtual disk corresponds to a segment allocation buffer pool. After responding to the storage space allocation instruction for the virtual disk, the segment allocation buffer pool corresponding to the virtual disk is determined. The segment allocation buffer pool can cache segments obtained by segmentation of a shard group, and the shard group is composed of shards from at least two physical disks, and the shard is a part of a physical disk. There are multiple shard groups preset, and a shard group can be divided into multiple segments. If it is determined that the segment allocation buffer pool is empty, a target shard group can be determined from the preset multiple shard groups, and a preset number of segments are determined from the target shard group and cached in the segment allocation buffer pool. Then, according to the physical address sequence of the segments in the segment allocation buffer pool, a target segment is determined and allocated to the virtual disk for data writing and storage. By dividing the shard group into segments, the problem of large space occupied by the shard group is solved. When allocating storage space, it ensures that as many physical disks as possible participate, so that the written data falls evenly on different disks, improving write concurrency, thereby improving write performance and ensuring the balance of storage space allocation.

[0071] Figure 3A flowchart of a method for allocating storage space provided in an embodiment of the present application is provided. This embodiment is an optional embodiment based on the above embodiment.

[0072] In this embodiment, if it is determined that there are no available segments in the segment allocation buffer pool, a target shard group is determined from at least two preset shard groups, which can be further refined as follows: if it is determined that there are no available segments in the segment allocation buffer pool, a parameter initialization is performed on the number of selections; wherein the number of selections is used to indicate the number of selections made from at least two preset shard groups after responding to the storage space allocation instruction; according to the number of selections, based on a preset round-robin algorithm, one shard group is selected from at least two preset shard groups as the target shard group.

[0073] like Figure 3 The method comprises the following steps:

[0074] S301. In response to a storage space allocation instruction for a virtual disk, determine a segment allocation buffer pool corresponding to the virtual disk; wherein the segment allocation buffer pool is used to cache segments obtained by segmentation from a shard group, a shard group is composed of shards from at least two physical disks, and a shard is a part of a physical disk.

[0075] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.

[0076] S302: If it is determined that there is no available segment in the segment allocation buffer pool, initialize the number of selection parameters; wherein the number of selections is used to indicate the number of selections made in at least two preset shard groups after responding to the storage space allocation instruction.

[0077] Exemplarily, if it is determined that the segment allocation buffer pool is empty, that is, there is no segment in the segment allocation buffer pool, or there is no free storage space for the segment in the segment allocation buffer pool, then it is necessary to determine a target CKG from at least two preset CKGs. You can select from multiple CKGs, set a parameter for the number of selections, and the number of selections can be increased by one for each selection. The number of selections can be used to indicate the number of selections made from at least two preset shard groups after responding to the current storage space allocation instruction. Each time a storage space allocation instruction is responded to and it is determined that there is no segment in the segment allocation buffer pool, the number of selections can be initialized, and the initialization can be to return the number of selections to 0.

[0078] After determining that there is no segment in the segment allocation buffer pool, the selection count is initialized to 0. When determining the target CKG, multiple selections may be required. For example, if a faulty CKG is selected in the first selection, the selection count can be increased by one, updated to 1, and the selection can be repeated.

[0079] S303: According to the number of selections and based on a preset round-robin algorithm, select a shard group from at least two preset shard groups as the target shard group.

[0080] Exemplarily, a round-robin algorithm is preset, and the number of selections may be a parameter applied in the round-robin algorithm. Through the number of selections and the round-robin algorithm, a CKG may be cyclically selected from multiple CKGs, and it may be determined whether the selected CKG can be used as the target CKG. A threshold for the number of selections may be preset, and the maximum number of selections made by the round-robin algorithm may be the selection number threshold. A confirmation condition for the target CKG may be preset in the round-robin algorithm. If a CKG that meets the confirmation condition is found within the selection number threshold, it is determined that the target CKG is found; if the target CKG is still not found after executing the selection within the selection number threshold, it is determined that the confirmation of the target CKG of this round has failed, and storage space cannot be allocated for the virtual disk.

[0081] In this embodiment, the round-robin algorithm is not specifically limited. For example, the round-robin algorithm can randomly select a CKG each time, and then determine whether the selected CKG has free space. If so, the CKG is determined to be the target CKG; if not, the number of selections is increased by one, and the selection continues until the number of selections reaches the selection number threshold.

[0082] In this embodiment, according to the number of selections and based on a preset round-robin algorithm, a shard group is selected from at least two preset shard groups as a target shard group, including: obtaining the current number of selections and a historical round-robin index; wherein the historical round-robin index is used to indicate the number of times the round-robin algorithm has been selected from at least two preset shard groups since the initial startup; if the current number of selections is less than a preset number of selections threshold, then the remainder of the historical round-robin index and the number of shard groups is taken, and a candidate shard group is determined from at least two shard groups according to the remainder; if it is determined that the candidate shard group meets the preset working conditions, then the candidate shard group is determined as the target shard group, and the historical round-robin index is updated.

[0083] Specifically, if it is determined that the candidate shard group meets the preset working conditions, the candidate shard group is determined to be the target shard group, and the historical rotation index is updated, which may include: if the candidate shard group meets the preset working conditions, the load coefficient of the candidate shard group is determined; wherein the load coefficient is used to indicate the busyness of the candidate shard group; if the load coefficient of the candidate shard group is less than a preset load coefficient threshold, the candidate shard group is determined to be the target shard group, and the historical rotation index is updated.

[0084] When the round-robin algorithm is running, the current number of selections can be determined, and the number of selections can change from 0 to a preset number of selections threshold. The current number of selections and the historical round-robin index are obtained. The historical round-robin index can be used to indicate the number of selections made in the preset at least two shard groups since the round-robin algorithm was first started. That is, the historical round-robin index is not initialized each time the round-robin algorithm is started, but indicates the total number of selections from the first time the round-robin algorithm was run to the current time.

[0085] A selection number threshold is pre-set, and the current selection number is compared with the selection number threshold to determine whether the current selection number reaches the selection number threshold. If it is determined that the current selection number is less than the preset selection number threshold, that is, the current selection number does not reach the selection number threshold, then the historical rotation index and the number of shard groups are modulo each other. The historical rotation index can be divided by the number of shard groups to obtain a remainder after the division. For example, if the number of shard groups is 500 and the historical rotation index is 501, then the remainder can be 1. A candidate CKG can be determined from at least two CKGs based on the remainder. For example, each CKG corresponds to a preset identifier, and the association relationship between different identifiers and remainders is pre-set. Based on the preset association relationship, the candidate CKG is determined.

[0086] The working conditions are set in advance. The working conditions may refer to the conditions that allow the candidate CKG to be determined as the target CKG. For example, the working conditions may be to determine whether there is free storage space or whether there is a faulty disk, etc. If it is determined that the candidate CKG meets the preset working conditions, for example, the candidate CKG has free storage space and no faulty disk, the candidate CKG can be determined as the target CKG. After determining that the candidate CKG meets the preset working conditions, the load factor of the candidate CKG may be further determined. The load factor may be used to indicate the busyness of the CKG. The method for determining the load factor may be set in advance, and the load factor of the candidate CKG may be determined according to the method for determining the load factor.

[0087] In this embodiment, the load factor can be related to the sum of the number of disk flight IOs in the CKG, or to the average response time of all disk IOs in the CKG. According to the hardware queue depth of the physical disk, the sum of the number of disk flight reads and writes in the shard group is determined; wherein the hardware queue depth of the physical disk is related to the hardware condition of the physical disk, and the sum of the number of disk flight reads and writes in the shard group is in direct proportion to the hardware queue depth of the physical disk; or, the number of written reads and writes of the physical disk is divided by the number of read and write operations performed per second by the physical disk to determine the average response time of disk reads and writes in the shard group; wherein the number of read and write operations performed per second by the physical disk is related to the hardware condition of the physical disk.

[0088] The sum of the number of disk in-flight IOs in the candidate CKG, or the average response time of all disk IOs in the candidate CKG, can be obtained as the load factor of the candidate CKG. The disk here refers to the physical disk, where the number of disk in-flight IOs refers to the amount of data written to the disk that has not yet fallen into the disk. The load factor can be any indicator used to measure the actual busyness of the CKG, which is different from the traditional solution that uses the amount of data written per unit time as the disk load. Because different models of disks have different write capabilities, the amount of data written per unit time cannot accurately measure the disk load. For example, the amount of data written per unit time on a fast disk is definitely more than that on a slow disk, but it does not mean that the fast disk is busier.

[0089] A load factor threshold is set in advance, and the load factor threshold can be determined by the hardware's own conditions and can be set dynamically. After obtaining the load factor of the candidate CKG, the load factor of the candidate CKG is compared with the load factor threshold. If the load factor of the candidate CKG is less than the preset load factor threshold, the candidate CKG can be determined as the target CKG, and the historical rotation index can be updated. That is, the historical rotation index can be increased by one. After obtaining the target CKG, it means that the rotation algorithm of this round can be completed, so there is no need to increase the number of selections by one.

[0090] The beneficial effect of this setting is that by selecting CKG through the round-robin algorithm, it can ensure that the virtual disk allocates segments from different CKGs each time. Since different CKGs are divided by different nodes and disks, it can ensure that the written data falls evenly on different disks of different nodes, improving write concurrency and thus improving write performance.

[0091] In this embodiment, determining a candidate shard group from at least two shard groups according to a remainder includes: determining, from at least two shard groups, a shard group whose preset shard group identifier is a remainder as a candidate shard group; wherein the shard group identifier is to mark the shard groups according to the number of shard groups.

[0092] Specifically, a plurality of CKGs are pre-divided, and a shard group identifier is assigned to the CKG according to the number of CKGs. For example, if there are 500 CKGs, the shard group identifier can be 0 to 499. The remainder of the historical rotation index divided by the number of shard groups is one of the shard group identifiers. For example, if the historical rotation index is 501 and the number of shard groups is 500, it can be determined that the remainder is 1.

[0093] According to the determined remainder, a candidate CKG can be determined from multiple CKGs. The fragment group identifier of the candidate CKG is the same as the determined remainder, for example, the fragment group identifier can be 0 to 499, and the remainder is 1, then the CKG with the fragment group identifier of 1 can be determined as the candidate CKG, that is, the second CKG is determined as the candidate CKG.

[0094] The beneficial effect of such a setting is that by determining the candidate CKG through the remainder and the number of the shard group identifier, it can be ensured that each CKG is determined as a candidate CKG in turn, improving the balance of storage space allocation and further improving the write performance of the virtual disk.

[0095] In this embodiment, the method further includes: if the current number of selections is equal to or greater than a preset number of selections threshold, issuing a prompt message indicating that storage space allocation has failed; wherein the prompt message indicating that storage space allocation has failed is used to prompt the user that there is currently no available storage space.

[0096] Specifically, the current number of selections is compared with a preset number of selections threshold. If the current number of selections is less than the preset number of selections threshold, the modulus of the historical rotation index and the number of shard groups is taken, and a candidate CKG is determined from at least two CKGs based on the remainder.

[0097] If it is determined that the current number of selections is equal to or greater than the preset number of selections threshold, it is determined that the number of selections in this round has reached the upper limit. That is, no available target CKG is found in all the number of selections in this round. A prompt message indicating that storage space allocation failed can be sent to the upper-layer application, prompting the user that there is currently no available storage space and the written data cannot be stored.

[0098] The beneficial effect of such a setting is that if the number of selections is greater than the preset selection number threshold, the selection is determined to have failed, and the selection is stopped, thus avoiding a continuous cycle of the selection process, improving the efficiency of storage space allocation, and enhancing the user experience.

[0099] In this embodiment, the method further includes: if the candidate shard group does not meet the preset working conditions, updating the number of selections and the historical rotation index; and re-executing to obtain the current number of selections and the historical rotation index.

[0100] Specifically, it is determined whether the candidate CKG meets the preset working conditions. If yes, the load factor of the candidate CKG can be determined; if no, it means that the selection process of the current selection number is over and needs to be selected again. The selection number and the historical rotation index can be updated, for example, the selection number and the historical rotation index are increased by one respectively.

[0101] After updating the number of selections and the historical rotation index, obtain the current number of selections and the historical rotation index again. The number of selections and the historical rotation index at this time are different from the previous number of selections and the historical rotation index. For example, when making the first selection, the current number of selections is 0, the first selection fails, and the second selection is made. Then, when making the second selection, the current number of selections is 1. Continue to determine whether the current number of selections is less than the preset number of selections threshold. If so, take the remainder of the historical rotation index and the number of shard groups, and determine the candidate CKG from at least two CKGs based on the remainder. If the candidate CKG meets the preset working conditions, determine the load factor of the candidate CKG. If the load factor of the candidate CKG is less than the preset load factor threshold, determine the candidate CKG as the target CKG, and update the historical rotation index.

[0102] The beneficial effect of this setting is that if the candidate CKG does not meet the basic working conditions, the number of selections and the historical rotation index are increased, and the selection is automatically cycled to improve the efficiency and success rate of storage space allocation.

[0103] In this embodiment, the method further includes: if the load factor of the candidate shard group is equal to or greater than a preset load factor threshold, updating the number of selections and the historical rotation index; and re-executing to obtain the current number of selections and the historical rotation index.

[0104] Specifically, the load factor of the candidate CKG is compared with a preset load factor threshold. If the load factor of the candidate CKG is less than the preset load factor threshold, the candidate CKG is determined to be the target CKG, and the historical rotation index is updated; if the load factor of the candidate CKG is equal to or greater than the preset load factor threshold, it means that the candidate CKG is not the target CKG, the selection process of the current selection number is ended, and it is necessary to select again. The selection number and the historical rotation index can be updated, for example, the selection number and the historical rotation index are respectively increased by one.

[0105] After updating the number of selections and the historical rotation index, obtain the current number of selections and the historical rotation index again. The number of selections and the historical rotation index at this time are different from the number of selections and the historical rotation index of the previous time. For example, when making the first selection, the current number of selections is 0, the first selection fails, and the second selection is made. Then, when making the second selection, the current number of selections is 1. Continue to determine whether the current number of selections is less than the preset number of selections threshold. If so, take the remainder of the historical rotation index and the number of shard groups, and determine the candidate CKG from at least two CKGs based on the remainder. If the candidate CKG meets the preset working conditions, determine the load factor of the candidate CKG. If the load factor of the candidate CKG is less than the preset load factor threshold, determine the candidate CKG as the target CKG, and update the historical rotation index.

[0106] The beneficial effect of this setting is that if the load factor of the candidate CKG is greater than the load factor threshold, the number of selections and the historical rotation index are increased, and the selection is automatically cycled to improve the efficiency and success rate of storage space allocation. And by controlling the selection of the target CKG through the real-time load of the disk, it can avoid some slow disks from slowing down the writing performance of the entire virtual disk, improve load balancing, and thus improve the writing performance of the entire virtual disk.

[0107] S304: Determine a preset number of segments from the target shard group, and cache the preset number of segments into a segment allocation cache pool.

[0108] Exemplarily, this step may refer to the above-mentioned step S103 and will not be described in detail.

[0109] S305: Determine a target segment from the segment allocation buffer pool, which is a storage space allocated to the virtual disk.

[0110] Exemplarily, this step may refer to the above-mentioned step S104 and will not be described in detail.

[0111] The embodiment of the present application provides a method for allocating storage space, in which a virtual disk can be used to store write data, and each virtual disk corresponds to a segment allocation buffer pool. After responding to the storage space allocation instruction for the virtual disk, the segment allocation buffer pool corresponding to the virtual disk is determined. The segment allocation buffer pool can cache segments obtained by segmentation of a shard group, and the shard group is composed of shards from at least two physical disks, and the shard is a part of a physical disk. There are multiple shard groups preset, and a shard group can be divided into multiple segments. If it is determined that the segment allocation buffer pool is empty, a target shard group can be determined from the preset multiple shard groups, and a preset number of segments are determined from the target shard group and cached in the segment allocation buffer pool. Then, according to the physical address sequence of the segments in the segment allocation buffer pool, a target segment is determined and allocated to the virtual disk for data writing and storage. By dividing the shard group into segments, the problem of large space occupied by the shard group is solved. When allocating storage space, it ensures that as many physical disks as possible participate, so that the written data falls evenly on different disks, improving write concurrency, thereby improving write performance and ensuring the balance of storage space allocation.

[0112] Figure 4 This is a structural block diagram of a storage space allocation device provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 4 The device includes: an instruction response module 401, a first determination module 402, a second determination module 403 and a space allocation module 404.

[0113] The instruction response module 401 is used to determine the segment allocation buffer pool corresponding to the virtual disk in response to the storage space allocation instruction of the virtual disk; wherein the segment allocation buffer pool is used to cache the segments obtained by segmentation of the shard group, the shard group is composed of shards from at least two physical disks, and the shard is a part of the physical disk;

[0114] A first determination module 402 is configured to determine a target shard group from at least two preset shard groups if it is determined that there are no available segments in the segment allocation buffer pool;

[0115] A second determination module 403 is used to determine a preset number of segments from the target shard group, and cache the preset number of segments into the segment allocation cache pool;

[0116] The space allocation module 404 is used to determine a target segment from the segment allocation buffer pool, which is the storage space allocated to the virtual disk.

[0117] In one example, the first determining module 402 is specifically configured to:

[0118] If it is determined that there is no segment in the segment allocation buffer pool, then it is determined that there is no available segment in the segment allocation buffer pool; or,

[0119] If it is determined that there is no segment with free storage space in the segment allocation buffer pool, it is determined that there is no available segment in the segment allocation buffer pool.

[0120] Figure 5 A structural block diagram of a storage space allocation device provided in an embodiment of the present application, in Figure 4 Based on the embodiment shown, Figure 5 As shown, the first determination module 402 includes an initialization unit 4021 and a rotation unit 4022 .

[0121] The initialization unit 4021 is used to initialize the number of selections if it is determined that there is no available segment in the segment allocation buffer pool; wherein the number of selections is used to indicate the number of selections made in at least two preset shard groups after responding to the storage space allocation instruction;

[0122] The rotation unit 4022 is used to select a shard group from at least two preset shard groups as the target shard group according to the number of selections and based on a preset rotation algorithm.

[0123] In one example, the rotation unit 4022 includes:

[0124] An acquisition subunit, used to acquire the current number of selections and a historical round-robin index; wherein the historical round-robin index is used to indicate the number of selections made by the round-robin algorithm in at least two preset shard groups since the initial startup;

[0125] A remainder subunit, configured to take the remainder of the historical rotation index and the number of shard groups if the current number of selections is less than a preset number of selections threshold, and determine a candidate shard group from at least two shard groups according to the remainder;

[0126] The condition judgment subunit is used to determine that the candidate shard group meets the preset working condition, then determine that the candidate shard group is the target shard group, and update the historical rotation index.

[0127] In one example, the condition judgment subunit includes:

[0128] A coefficient determination slave unit, used for determining a load coefficient of the candidate shard group if the candidate shard group meets a preset working condition; wherein the load coefficient is used to indicate the busyness of the shard group;

[0129] The coefficient judgment slave unit is used to determine that the candidate shard group is the target shard group if the load coefficient of the candidate shard group is less than a preset load coefficient threshold, and to update the historical rotation index.

[0130] In one example, the remainder subunit is specifically used for:

[0131] From at least two shard groups, determine a shard group whose preset shard group identifier is the remainder as the candidate shard group; wherein the shard group identifier is a labeling of the shard groups according to the number of the shard groups.

[0132] In one example, the device further includes:

[0133] an allocation failure module, configured to issue a prompt message indicating that storage space allocation has failed if the current number of selections is equal to or greater than a preset number of selections threshold; wherein the prompt message indicating that storage space allocation has failed is used to prompt the user that there is currently no available storage space; and / or,

[0134] A first loop module, configured to update the number of selections and the historical rotation index if the candidate shard group does not meet a preset working condition;

[0135] Re-execute to obtain the current number of selections and the historical rotation index.

[0136] In one example, the device further includes:

[0137] The condition determination module is used to determine that the candidate shard group meets the preset working condition if there is free storage space in the candidate shard group and / or there is no preset disk failure in the candidate shard group.

[0138] In one example, the load factor is related to the sum of the number of disk in-flight reads and writes in the shard group, or is related to the average response time of the disk reads and writes in the shard group.

[0139] In one example, the device further includes:

[0140] A condition setting module, used to determine the sum of the number of disk in-flight reads and writes in the slice group according to the hardware queue depth of the physical disk; wherein the hardware queue depth of the physical disk is related to the hardware condition of the physical disk, and the sum of the number of disk in-flight reads and writes in the slice group is in direct proportion to the hardware queue depth of the physical disk; or,

[0141] The number of written reads and writes of the physical disk is divided by the number of read and write operations performed per second by the physical disk to determine the average response time of disk reads and writes in the shard group; wherein the number of read and write operations performed per second by the physical disk is related to the hardware conditions of the physical disk.

[0142] In one example, the second determining module 403 is specifically configured to:

[0143] Determine a segment with free storage space in the target shard group;

[0144] A preset number of segments is determined according to the physical address sequence of the segments with free storage space in the target slice group.

[0145] In one example, the device further includes:

[0146] An ideal value determination module is used to determine an ideal value of the random read / write number according to a predetermined maximum disk write bandwidth and an average seek time; wherein the ideal value of the random read / write number is a product of the maximum disk write bandwidth and the average seek time;

[0147] A preset number determination module is used to determine the preset number according to the ideal value of the random read / write number and the size of the stripe in the preset segment; wherein the preset number is the division result of the ideal value of the random read / write number and the size of the stripe in the preset segment.

[0148] In one example, the device further includes:

[0149] The target segment determination module is used to determine the target segment from the segment allocation buffer pool if it is determined that there are available segments in the segment allocation buffer pool, which is the storage space allocated to the virtual disk.

[0150] In one example, the device further includes:

[0151] The segment selection module is used to determine the target segment from the segment allocation buffer pool according to the physical address order of the segments in the segment allocation buffer pool.

[0152] In one example, the device further includes:

[0153] A disk slicing module, used for slicing at least two physical disks into slices of a preset first size, and obtaining a slice from each of the at least two physical disks to form the slice group;

[0154] A stripe determination module, used for dividing the slices in the slice group into stripes of a preset second size;

[0155] The segment composition module is used to compose at least two stripes into a segment; wherein the stripes in the segment come from different slices in the slice group.

[0156] Figure 6 This is a structural block diagram of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device includes: a memory 61, a processor 62; the memory 61; and a memory for storing instructions executable by the processor 62.

[0157] The processor 62 is configured to execute the method provided in the above embodiment.

[0158] The electronic device further includes a receiver 63 and a transmitter 64. The receiver 63 is used to receive instructions and data sent by other devices, and the transmitter 64 is used to send instructions and data to external devices.

[0159] Figure 7 It is a structural block diagram of an electronic device according to an exemplary embodiment. The device may be a mobile phone, a computer, a digital broadcast terminal, a message transceiver, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant or a robot, etc.

[0160] Device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .

[0161] The processing component 702 generally controls the overall operation of the device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.

[0162] The memory 704 is configured to store various types of data to support operations on the device 700. Examples of such data include instructions for any application or method operating on the device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0163] The power supply component 706 provides power to the various components of the device 700. The power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device 700.

[0164] The multimedia component 708 includes a screen that provides an output interface between the device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0165] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the device 700 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.

[0166] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0167] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the device 700. For example, the sensor assembly 714 can detect the open / closed state of the device 700, the relative positioning of components, such as the display and keypad of the device 700, and the sensor assembly 714 can also detect the position change of the device 700 or a component of the device 700, the presence or absence of user contact with the device 700, the orientation or acceleration / deceleration of the device 700, and the temperature change of the device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0168] The communication component 716 is configured to facilitate wired or wireless communication between the device 700 and other devices. The device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0169] In an exemplary embodiment, the device 700 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0170] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by the processor 720 of the device 700 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0171] A non-temporary computer-readable storage medium, when instructions in the storage medium are executed by a processor of a terminal device, enables the terminal device to execute the above-mentioned method for allocating storage space of the terminal device.

[0172] The present application also discloses a computer program product, including a computer program, which implements the method described in this embodiment when executed by a processor.

[0173] Various embodiments of the systems and techniques described above in the present application can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, which can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor, which can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0174] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or electronic device.

[0175] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0176] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0177] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data electronic device), or a computing system that includes middleware components (e.g., an application electronic device), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0178] The computer system may include a client and an electronic device. The client and the electronic device are generally far away from each other and usually interact through a communication network. The relationship between the client and the electronic device is generated by computer programs running on corresponding computers and having a client-electronic device relationship with each other. The electronic device may be a cloud electronic device, also known as a cloud computing electronic device or a cloud host, which is a host product in a cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The electronic device may also be an electronic device of a distributed system, or an electronic device combined with a blockchain. It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solution disclosed in this application can be achieved, and this document is not limited here.

[0179] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0180] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for allocating storage space, characterized in that: include: In response to a storage space allocation instruction for a virtual disk, a segment allocation buffer pool corresponding to the virtual disk is determined; wherein the segment allocation buffer pool is used to cache segments obtained by segmentation of a shard group, wherein the shard group is composed of shards from at least two physical disks, and the shard is a part of a physical disk; If it is determined that there are no available segments in the segment allocation buffer pool, determining a target shard group from at least two preset shard groups; Determine a preset number of segments from the target shard group, and cache the preset number of segments in the segment allocation cache pool; A target segment is determined from the segment allocation buffer pool as storage space allocated to the virtual disk.

2. The method according to claim 1, characterized in that Determining that there is no available segment in the segment allocation buffer pool includes: If it is determined that there is no segment in the segment allocation buffer pool, then it is determined that there is no available segment in the segment allocation buffer pool; or, If it is determined that there is no segment with free storage space in the segment allocation buffer pool, it is determined that there is no available segment in the segment allocation buffer pool.

3. The method according to claim 1, characterized in that If it is determined that there are no available segments in the segment allocation buffer pool, determining a target shard group from at least two preset shard groups includes: If it is determined that there is no available segment in the segment allocation buffer pool, a parameter is initialized for the number of selections; wherein the number of selections is used to indicate the number of selections made in at least two preset shard groups after responding to the storage space allocation instruction; According to the number of selections, based on a preset round-robin algorithm, a shard group is selected from at least two preset shard groups as the target shard group.

4. The method according to claim 3, characterized in that According to the number of selections, based on a preset round-robin algorithm, a shard group is selected from at least two preset shard groups as the target shard group, including: Obtaining the current number of selections and a historical round-robin index; wherein the historical round-robin index is used to indicate the number of times the round-robin algorithm has been selected in at least two preset shard groups since the initial startup; If the current number of selections is less than a preset number of selections threshold, taking the remainder of the historical rotation index and the number of shard groups, and determining a candidate shard group from at least two shard groups according to the remainder; If it is determined that the candidate shard group meets the preset working condition, the candidate shard group is determined to be the target shard group, and the historical rotation index is updated.

5. The method according to claim 4, characterized in that If it is determined that the candidate shard group meets the preset working condition, the candidate shard group is determined to be the target shard group, and the historical rotation index is updated, including: If the candidate shard group meets the preset working conditions, the load factor of the candidate shard group is determined; wherein the load factor is used to indicate the busyness of the candidate shard group; If the load factor of the candidate shard group is less than a preset load factor threshold, the candidate shard group is determined to be the target shard group, and the historical rotation index is updated.

6. The method according to claim 4, characterized in that Determining a candidate shard group from at least two shard groups according to the remainder includes: From the at least two shard groups, determine a shard group whose preset shard group identifier is the remainder as the candidate shard group; wherein the shard group identifier is a labeling of the shard groups according to the number of the shard groups.

7. The method according to claim 4, characterized in that The method further comprises: If the current number of selections is equal to or greater than a preset number of selections threshold, a prompt message indicating that storage space allocation has failed is issued; wherein the prompt message indicating that storage space allocation has failed is used to prompt the user that there is currently no available storage space; and / or, If the candidate shard group does not meet the preset working conditions, the selection times and the historical rotation index are updated; Re-execute to obtain the current number of selections and the historical rotation index.

8. The method according to claim 5 or 7, characterized in that: The method comprises: If there is free storage space in the candidate shard group, and / or there is no preset disk failure in the candidate shard group, it is determined that the candidate shard group meets the preset working condition.

9. The method according to claim 5, characterized in that The load factor is related to the sum of the number of disk in-flight reads and writes in the shard group, or to the average response time of the disk reads and writes in the shard group.

10. The method according to claim 9, characterized in that The method comprises: Determine the sum of the in-flight read and write numbers of the disks in the slice group according to the hardware queue depth of the physical disk; wherein the hardware queue depth of the physical disk is related to the hardware condition of the physical disk, and the sum of the in-flight read and write numbers of the disks in the slice group is in direct proportion to the hardware queue depth of the physical disk; or, The number of written reads and writes of the physical disk is divided by the number of read and write operations performed per second by the physical disk to determine the average response time of disk reads and writes in the shard group; wherein the number of read and write operations performed per second by the physical disk is related to the hardware conditions of the physical disk.

11. The method according to claim 1, characterized in that: Determining a preset number of segments from the target shard group includes: Determine a segment with free storage space in the target shard group; The preset number of segments is determined according to the physical address order of the segments with free storage space in the target slice group.

12. The method according to claim 11, characterized in that The method further comprises: Determine an ideal value of the random read / write number according to a predetermined maximum disk write bandwidth and an average seek time; wherein the ideal value of the random read / write number is a product of the maximum disk write bandwidth and the average seek time; The preset number is determined according to the ideal value of the random read / write number and the size of the stripe in the preset segment; wherein the preset number is the division result of the ideal value of the random read / write number and the size of the stripe in the preset segment.

13. The method according to claim 1, characterized in that The method further comprises: If it is determined that there are available segments in the segment allocation buffer pool, a target segment is determined from the segment allocation buffer pool as the storage space allocated to the virtual disk.

14. The method according to claim 1 or 13, characterized in that: Determining a target segment from the segment allocation buffer pool includes: According to the physical address order of the segments in the segment allocation buffer pool, a target segment is determined from the segment allocation buffer pool.

15. The method according to claim 1, characterized in that The method further comprises: Dividing at least two physical disks into slices of a preset first size, obtaining a slice from each of the at least two physical disks to form the slice group; Splitting the slices in the slice group into strips of a preset second size; At least two stripes are grouped into a segment; wherein the stripes in the segment are from different shards in the shard group.

16. A storage space allocation device, characterized in that: include: An instruction response module is used to respond to a storage space allocation instruction for a virtual disk and determine a segment allocation buffer pool corresponding to the virtual disk; wherein the segment allocation buffer pool is used to cache segments obtained by segmentation of a shard group, wherein the shard group is composed of shards from at least two physical disks, and the shard is a part of a physical disk; A first determination module, configured to determine a target shard group from at least two preset shard groups if it is determined that there are no available segments in the segment allocation buffer pool; A second determination module is used to determine a preset number of segments from the target shard group, and cache the preset number of segments into the segment allocation cache pool; The space allocation module is used to determine a target segment from the segment allocation buffer pool, which is a storage space allocated to the virtual disk.

17. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the storage space allocation method according to any one of claims 1-15.

18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the storage space allocation method according to any one of claims 1 to 15.

19. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the storage space allocation method described in any one of claims 1 to 15.