A storage resource allocation method, device and electronic device based on a tree structure

The tree-based storage resource allocation method addresses storage fragmentation and system instability by dynamically managing storage particles using state markers, ensuring efficient and stable data storage.

CN117608475BActive Publication Date: 2025-07-15YUSUR TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311578602.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-24
Publication Date
2025-07-15
Estimated Expiration
2043-11-24

AI Technical Summary

Technical Problem

In the existing data storage architecture, it is impossible to efficiently manage the state of storage particles, resulting in storage fragmentation, affecting system stability and possibly causing system crash.

Method used

The storage resource allocation method based on the tree structure is adopted to manage storage particles through a multi-layer tree structure, record the particle and node status using status marks, and dynamic management is carried out according to the marks to achieve dynamic storage strategy adjustment.

Benefits of technology

It improves the stability and efficiency of the storage system, avoids the impact of storage fragments on system performance, ensures efficient utilization and rapid retrieval of storage particles, and solves the problems of data storage errors and system crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117608475B_ABST
    Figure CN117608475B_ABST
Patent Text Reader

Abstract

The present invention discloses a storage resource allocation method, device and electronic device based on a tree structure. First, a multi-layer tree structure is used to manage storage particles hierarchically, avoiding the impact of storage fragmentation on the overall performance of the storage system and improving the stability of the entire storage system. Secondly, status markers are used to record the status of storage particles and nodes, and the storage particles are dynamically managed according to the status markers, so that the usage situation of each storage particle can be quickly retrieved, fully realizing dynamic management, improving the usage efficiency of storage particles, being simple and efficient. That is to say, the present invention can adjust the storage strategy in real time according to the storage space and the status of rough particles, solving the problems of data storage errors and system crashes caused by the inability to perceive the status of storage particles in a complex data storage architecture, and is applicable to network processors and security devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data communication and network processors, and particularly relates to a storage resource allocation method, device and electronic device based on a tree structure. Background Art

[0002] With the continuous improvement of communication technology, the explosive growth of data volume has been brought about, stimulating the rapid development of storage chips and computer technology. The communication between devices is increasingly tending to develop in the directions of multi-threading, multi-core, multi-dimensional, etc. In the existing data storage architecture, a small-particle storage method is generally adopted to store large-flow data. While this method efficiently uses the storage space, it also brings the complexity of storage particle management and cannot monitor and manage the storage space efficiently and simply.

[0003] In the traditional data storage process, the storage space is divided into multiple storage particles. When needed, the storage particles are applied for and allocated, and after use, the storage particles are released and recycled. However, as the system runs over time, there will be storage particle fragments, which will affect the stability of the system. However, this solution will reduce the management difficulty of the storage space, improve the management efficiency of the storage space, improve the utilization efficiency of the storage space, and the stability of the entire storage system. Summary of the Invention

[0004] In view of this, the present invention provides a storage resource allocation method, device and electronic device based on a tree structure, which can solve the problems of data storage errors and system crashes caused by the inability to perceive the state of storage particles in a complex data storage architecture during long-term operation.

[0005] In a first aspect, a storage resource allocation method based on a tree structure, the storage resources include a plurality of storage particles; each storage particle is divided into multiple groups, and each group of storage particles is respectively mounted on a leaf node; each leaf node is divided into multiple groups, and each group of leaf nodes is respectively mounted on an intermediate node as a child node; each intermediate node is mounted on a root node as a child node; wherein, a status flag indicating its own free state or used state is set for each of the storage particle, leaf node, intermediate node and root node, and for each node, only when the storage particles or child nodes mounted on itself are all in the used state, its own status is in the used state;

[0006] The method includes:

[0007] Determine whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node. If so, poll the intermediate nodes, and determine whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node. If so, poll the leaf nodes mounted on the current intermediate node, and determine whether the storage resources mounted on the current leaf node meet the storage requirements of the current message to be stored according to the status flag of the leaf node. If so, schedule the idle storage granules mounted on the current leaf node to store the current message to be stored.

[0008] Further, a storage resource allocation method based on a tree structure further includes:

[0009] After the storage granules that meet the storage requirements of the current message to be stored store the current message to be stored, modify the status flag of the storage granules that store the current message to be stored to the used state, and backtrack through the levels of nodes starting from the storage granules with the modified status flag, so as to modify the corresponding status flags of each node, and complete the status update of the tree structure composed of leaf nodes, intermediate nodes, and the root node.

[0010] Further, a storage resource allocation method based on a tree structure further includes:

[0011] The storage granules are unevenly divided into multiple groups, and starting from the leftmost leaf node of the tree structure composed of leaf nodes, intermediate nodes, and the root node, the groups of storage granules are sequentially mounted on each leaf node in descending order of quantity.

[0012] Further, a storage resource allocation method based on a tree structure further includes:

[0013] The method for determining the polling direction is as follows:

[0014] Denote the number of groups of storage granules as N, and obtain the number of granules in a single group when the storage granules are evenly divided according to the number of groups N;

[0015] Determine the polling direction according to the size relationship between the storage requirements of the current message to be stored and the number of granules in a single group. Among them, if the storage requirements of the current message to be stored are not less than the number of granules in a single group, poll starting from the leftmost intermediate node; if the storage requirements of the current message to be stored are less than the number of granules in a single group, poll starting from the rightmost intermediate node.

[0016] Further, a storage resource allocation method based on a tree structure further includes:

[0017] When the storage requirement of the current message to be stored is greater than the number of storage grains in the group with the largest number of grains in the current idle state, the current message to be stored is split into two sub-messages. If the sizes of the two sub-messages are equal, either of the two sub-messages is polled starting from the leftmost intermediate node, and at the same time, the other message is polled starting from the rightmost intermediate node; if the sizes of the two sub-messages are not equal, the larger sub-message is polled starting from the leftmost intermediate node, and at the same time, the smaller sub-message is polled starting from the rightmost intermediate node.

[0018] Further, a storage resource allocation method based on a tree structure further includes:

[0019] The method for splitting the current message to be stored into two sub-messages is as follows:

[0020] Obtain the leaf nodes in the current idle state according to the status flags of each node;

[0021] Split the current message to be stored according to the number of idle storage grains mounted on the leaf nodes in the current idle state. Among them, the sizes of the two sub-messages obtained by splitting are the same as the number of grains of any two groups of idle storage grains in the current idle state, or the sizes of the two sub-messages obtained by splitting are not greater than the number of grains of the two groups of idle storage grains in the current idle state that are currently selected.

[0022] Further, a storage resource allocation method based on a tree structure further includes:

[0023] When the storage grains, leaf nodes, intermediate nodes, and root nodes are in the idle state, their status flags are set to 0; when the storage grains, leaf nodes, intermediate nodes, and root nodes are in the used state, their status flags are set to 1.

[0024] Further, the tree structure composed of leaf nodes, intermediate nodes, and root nodes is a binary tree. Among them, the leaf nodes are associated with the root node through multiple levels of intermediate nodes, and each intermediate node has two child nodes.

[0025] In a second aspect, a storage resource allocation device based on a tree structure, the storage resources include multiple storage grains; each storage grain is divided into multiple groups, and each group of storage grains is respectively mounted on a leaf node; each leaf node is divided into multiple groups, and each group of leaf nodes is respectively mounted on an intermediate node as a child node; each intermediate node is mounted on the root node as a child node; among them, status flags indicating whether the storage grains, leaf nodes, intermediate nodes, and root nodes are in the idle state or the used state are set, and for each node, only when the storage grains or child nodes mounted on itself are all in the used state, its own state is in the used state;

[0026] The device includes:

[0027] A first judgment module, configured to judge whether the storage resource meets the storage requirement of the current message to be stored according to the status flag of the root node;

[0028] A second judgment module, configured to poll intermediate nodes when the judgment result of the first judgment module is yes, and judge whether the storage resource mounted on the current intermediate node meets the storage requirement of the current message to be stored according to the status flag of the intermediate node;

[0029] A third judgment module, configured to poll the leaf nodes mounted on the current intermediate node when the judgment result of the second judgment module is yes, and judge whether the storage resource mounted on the current leaf node meets the storage requirement of the current message to be stored according to the status flag of the leaf node;

[0030] A scheduling module, configured to schedule the idle storage particles mounted on the current leaf node to store the current message to be stored when the judgment result of the third judgment module is yes.

[0031] In a third aspect, an electronic device includes a memory and a processor;

[0032] The storage resources of the memory include multiple storage particles; each storage particle is divided into multiple groups, and each group of storage particles is respectively mounted on a leaf node; each leaf node is divided into multiple groups, and each group of leaf nodes is respectively mounted on an intermediate node as a child node; each intermediate node is mounted on the root node as a child node; wherein, the storage particles, leaf nodes, intermediate nodes and root nodes are all provided with status flags indicating their own idle state or used state, and for each node, only when the storage particles or child nodes mounted on itself are all in the used state, its own state is in the used state;

[0033] The processor is configured to judge whether the storage resource meets the storage requirement of the current message to be stored according to the status flag of the root node. If so, poll the intermediate nodes, and judge whether the storage resource mounted on the current intermediate node meets the storage requirement of the current message to be stored according to the status flag of the intermediate node. If so, poll the leaf nodes mounted on the current intermediate node, and judge whether the storage resource mounted on the current leaf node meets the storage requirement of the current message to be stored according to the status flag of the leaf node. If so, schedule the idle storage particles mounted on the current leaf node to store the current message to be stored. Beneficial effects:

[0034] 1. The present invention provides a storage resource allocation method based on a tree structure. First, a multi-layer tree structure is used to manage storage granules hierarchically, avoiding the impact of storage fragmentation on the overall performance of the storage system and enhancing the stability of the entire storage system. Second, status tags are used to record the status of storage granules and nodes, and the storage granules are dynamically managed based on the status tags. As a result, the usage situation of each storage granule can be quickly retrieved, fully realizing dynamic management, improving the usage efficiency of storage granules, and being simple and efficient. That is to say, the present invention can adjust the storage strategy in real time according to the storage space and the status of rough granules, solving the problems of data storage errors and system crashes caused by the inability to perceive the status of storage granules in a complex data storage architecture, and is applicable to network processors and security devices.

[0035] 2. The present invention provides a storage resource allocation method based on a tree structure. The storage granules are divided according to actual storage requirements. The group with a larger number of storage granules is mounted on the left side of the tree structure, and the group with a smaller number of storage granules is mounted on the right side of the tree structure, facilitating the determination of the polling direction according to the storage requirements of the to-be-stored packets later and improving the usage efficiency of storage granules.

[0036] 3. The present invention provides a storage resource allocation method based on a tree structure. The to-be-stored packets are split according to the idle status of the remaining storage granules, which can improve the storage rate of the packets and the utilization rate of storage granules.

[0037] 4. The present invention provides a storage resource allocation method based on a tree structure. The tree structure is simplified into a binary tree, thereby simplifying the hierarchical storage logic of storage granules and making the management of hardware storage granules more efficient and simple.

[0038] 5. The present invention provides a storage resource allocation device based on a tree structure. First, a multi-layer tree structure is used to manage storage granules hierarchically, avoiding the impact of storage fragmentation on the overall performance of the storage system and enhancing the stability of the entire storage system. Second, status tags are used to record the status of storage granules and nodes, and the storage granules are dynamically managed based on the status tags. As a result, the usage situation of each storage granule can be quickly retrieved, fully realizing dynamic management, improving the usage efficiency of storage granules, and being simple and efficient. That is to say, the present invention can adjust the storage strategy in real time according to the storage space and the status of rough granules, solving the problems of data storage errors and system crashes caused by the inability to perceive the status of storage granules in a complex data storage architecture.

[0039] 6. The present invention provides an electronic device, including a memory and a processor. First, a multi-layer tree structure is used to manage storage particles hierarchically, avoiding the impact of storage fragmentation on the overall performance of the storage system and improving the stability of the entire storage system. Second, status tags are used to record the status of storage particles and nodes, and the storage particles are dynamically managed according to the status tags, so that the usage of each storage particle can be quickly retrieved, fully realizing dynamic management, improving the usage efficiency of storage particles, which is simple and efficient. That is to say, the present invention can adjust the storage strategy in real time according to the storage space and the status of rough particles, solving the problems of data storage errors and system crashes caused by the inability to perceive the status of storage particles in a complex data storage architecture. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 FIG. is a schematic diagram of the corresponding relationship between the status of storage particles and the status of the last-level nodes in the tree structure provided by the present invention.

[0041] Figure 2 FIG. is a flowchart of a storage resource allocation method based on a tree structure provided by the present invention.

[0042] Figure 3 FIG. is a schematic diagram of the corresponding relationship between the status of the parent node and the child node in the tree structure provided by the present invention.

[0043] Figure 4 FIG. is a schematic diagram of the structure of a storage resource allocation device based on a tree structure provided by the present invention.

[0044] Figure 5 FIG. is a schematic diagram of the structure of an electronic device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0045] The present invention will be described in detail below with reference to the accompanying drawings and examples.

[0046] It should be noted that if the usage of each storage particle cannot be globally grasped, abnormal problems such as the repeated use and multiple releases of a certain storage particle will occur, leading to data loss and chaos, and further causing the collapse of the entire storage system. For example: a certain storage particle is not being used, but an external module sends a storage particle release signal. Once this signal is adopted by the storage space, this particle will appear multiple times in the resource pool, inevitably causing data overwriting and resulting in data loss.

[0047] Based on this, the present invention provides a storage resource allocation method based on a tree structure, as Figure 1As shown in the figure, the storage resources include multiple storage particles; each storage particle is divided into multiple groups, and each group of storage particles is respectively mounted on a last-level node; each last-level node is divided into multiple groups, and each group of last-level nodes, as child nodes, is respectively mounted on an intermediate node; each intermediate node is mounted on the root node as a child node; among them, the storage particles, last-level nodes, intermediate nodes, and root nodes are all provided with status flags indicating their own free or used status, and for each node, only when the storage particles or child nodes mounted on itself are all in the used status, its own status is in the used status. Thus, the last-level nodes, intermediate nodes, and root nodes form a tree structure.

[0048] It should be noted that when the storage particles, last-level nodes, intermediate nodes, and root nodes are in the free state, their status flags are set to 0; when the storage particles, last-level nodes, intermediate nodes, and root nodes are in the used state, their status flags are set to 1. Optionally, the status flags of the storage particles and nodes can be expressed as follows:

[0049] Status Identifier Idle 1’b0 In use 1’b1

[0050] It should be noted that each storage particle can be evenly divided into multiple groups or unevenly divided into multiple groups. When using the uneven grouping method, starting from the leftmost last-level node of the tree structure composed of the last-level nodes, intermediate nodes, and root nodes, each group of storage particles can be mounted on each last-level node in the order of decreasing quantity. That is to say, the corresponding relationship between the storage particles and the last-level nodes can be adjusted. For example, 8 storage particles are mounted on a last-level node; the corresponding relationship between the parent node and the child node also supports adjustment; below, taking 8 storage particles corresponding to a last-level node and 8 child nodes corresponding to a parent node as an example, the tree structure of the present invention will be elaborated in detail.

[0051] The corresponding relationship between the status of the storage particles and the status of the last-level nodes is as Figure 1 shown. Among them, S0 to S7 are storage particles, and the status flags of the storage particles S0 to S7 are respectively 0 or 1. L3_0 is the last-level node 0, and the last-level node 0 is responsible for managing and recording the status L3_0 of the storage particles mounted on itself as follows:

[0052] L3_0 = S0 & S1 & S2 & S3 & S4 & S5 & S6 & S7

[0053] Among them, & represents logical AND.

[0054] Thus, it can be seen that when the storage particle S0 is free, its status flag is 0; when the storage particles S1 to S7 are all in the used state, its status flag is 1. Then, the status of the last-level node L3_0 is free, indicating that there are free particles among its subordinate storage particles:

[0055] L3_0 = 0&1&1&1&1&1&1&1 = 0

[0056] It should be noted that when the last - level node L3_0 is an idle node, the corresponding used child nodes and idle nodes can be queried according to its status flag bits. For example, define an identifier with a width of 8 bits, and each bit corresponds to a storage granule. When the last - level node L3_0 is idle, the corresponding idle storage granules can be queried. For example, the identifier 01111111 indicates that the storage granule S0 is in an idle state, and the storage granules S1 to S7 are in a used state. At this time, the idle storage granules can be scheduled according to the flag bits.

[0057] When all the storage granules S0 - S7 are idle, their status flag is 0. Then, the status of the last - level node L3_0 being idle means that there are no used storage granules among its subordinate storage granules:

[0058] L3_0 = 0&0&0&0&0&0&0&0 = 0

[0059] At this time, all the storage granules mounted on the last - level node L3_0 can be scheduled for use.

[0060] For another example, the correspondence between the status of the parent node and the status of the child nodes is as Figure 3 shown. L2_0 - L2_7 are the last - level nodes and also the child nodes of the intermediate node L1_0. At the same time, the intermediate node L1_0 also serves as the parent node of the last - level nodes L2_0 - L2_7. The status flags of the last - level nodes L2_0 - L2_7 are 0 or 1 respectively. L1_0 is the parent node and is responsible for managing the status of its mounted child nodes as follows:

[0061] L1_0 = L2_0&L2_1&L2_2&L2_3&L2_4&L2_5&L2_6&L2_7

[0062] It can be seen that when the child node L2_0 is idle, its status flag is 0; when all the child nodes L2_1 - L2_7 are in use, its status flag is 1. Then, the status of the parent node L1_0 being idle means that there are idle nodes among its child nodes:

[0063] L1_0 = 0&1&1&1&1&1&1&1 = 0

[0064] At this time, regardless of whether there are idle child nodes mounted on the intermediate node L1_0, whether there are idle storage particles mounted on the child nodes in the used state, the storage particles indirectly mounted on the last-level node L3_0 cannot be scheduled for use. It should be noted that when the parent node L1_0 is an idle node, the corresponding used child nodes and idle nodes can be queried according to its status flag bit. For example, define an identifier with a width of 8 bits, and each bit corresponds to a child node. When the status of the parent node is idle, the corresponding idle child nodes can be queried. For example, the identifier 01111111 indicates that the child node L2_0 is in the idle state, and the child nodes L2_1 to L2_7 are in the used state. At this time, the idle child nodes can be scheduled according to the flag bit.

[0065] When all of the child nodes L2_0 to L2_7 are idle, their status flags are marked as 0. Then, the status of the parent node L1_0 being idle indicates that there are no nodes in the used state among its child nodes:

[0066] L1_0 = 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 = 0

[0067] At this time, all the storage particles indirectly mounted on the intermediate node L1_0 can be scheduled for use.

[0068] Furthermore, a storage resource allocation method based on a tree structure provided by the present invention includes:

[0069] Judge whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node. If so, poll the intermediate nodes, and judge whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node. If so, poll the last-level nodes mounted on the current intermediate node, and judge whether the storage resources mounted on the current last-level node meet the storage requirements of the current message to be stored according to the status flag of the last-level node. If so, schedule the idle storage particles mounted on the current last-level node to store the current message to be stored.

[0070] After the storage particles that meet the storage requirements of the current message to be stored store the current message to be stored, modify the status flag of the storage particles that store the current message to be stored to the used state, and backtrack through the levels of nodes starting from the storage particles with the modified status flag, so as to modify the corresponding status flags of each node, and complete the status update of the tree structure composed of the last-level node, the intermediate node, and the root node.

[0071] For example, as Figure 2 shown, the specific process of a storage resource allocation based on a tree structure provided by the present invention is as follows:

[0072] Step A: In the initial power-on state, initialize the storage blocks and the states of each node, and record each initial state as 1’b0;

[0073] Step B: When a storage space application instruction is received, first start from the root node and select appropriate nodes layer by layer downward. When the state of the root node is 1, it means that all child nodes of the current memory are in use, and at this time, resource scheduling is not supported; when the state of the root node is 0, it means that there are idle states among all child nodes of the current memory. Select a certain idle child node according to the identification bit;

[0074] Step C: After the parent node completes the selection of the child node, similarly to step B, enter the last-level node in turn, and complete the storage space scheduling according to the state of the storage granule;

[0075] Step D: After selecting the final resource, set the corresponding node state flag to 1, and determine whether the parent node needs to be updated. If so, update it layer by layer upward;

[0076] Step E: When recycling, directly calculate the node position and clear it, and decide whether the parent node needs to be updated according to the situation of the same-level nodes. If so, update it layer by layer upward.

[0077] It should be noted that when the storage granules adopt a uniform grouping method, since the number of storage granules mounted on each last-level node is the same, whether polling starts from the leftmost last-level node or the rightmost last-level node in the tree structure, the speed of finding the storage granule for storing the current message to be stored is not much different; however, when the storage granules adopt a non-uniform grouping method, for example, the number of granules in the nth group of storage granules is 2 n , and the storage granules of each group have been mounted on each last-level node in the order of the number from more to less and from the left to the right of the tree structure. Since there are differences in the number of storage granules mounted on the leftmost and rightmost last-level nodes in the tree structure, in the case of non-uniform storage granules, in order to obtain the storage granule that matches the storage requirement of the current message to be stored more quickly, it is necessary to determine the polling direction according to the storage requirement of the current message to be stored, as follows:

[0078] Record the number of groups of storage granules as N, and obtain the number of granules in a single group when the storage granules are evenly divided according to the number of groups N;

[0079] Determine the polling direction according to the size of the storage requirement of the current message to be stored and the number of granules in a single group. Among them, if the storage requirement of the current message to be stored is not less than the number of granules in a single group, poll starting from the leftmost middle node; if the storage requirement of the current message to be stored is less than the number of granules in a single group, poll starting from the rightmost middle node.

[0080] For example, assume that the storage requirement of the current message to be stored is 33 bits, the number of single-group particles when the storage particles are evenly divided is 16, the storage particle groups with more than 16 particles are mounted on the last-level nodes on the left side of the tree structure, and the storage particle groups with less than 16 particles are mounted on the last-level nodes on the right side of the tree structure. At this time, it is obvious that polling starts from the last-level node on the left side of the tree structure, and an idle storage particle group that meets the storage requirement of the current message to be stored can be found more quickly.

[0081] It should be noted that during the actual storage process, the storage particles mounted on any remaining idle last-level node may not meet the storage requirement of the current message to be stored. That is to say, if the storage requirement of the current message to be stored is greater than the number of particles in the group of storage particles with the largest number in the current idle state, the current message to be stored is split into two sub-messages. If the two sub-messages are of equal size, either of the two sub-messages is polled starting from the middle node on the leftmost side, and the other message is polled starting from the middle node on the rightmost side; if the two sub-messages are of unequal size, the larger sub-message is polled starting from the middle node on the leftmost side, and the smaller sub-message is polled starting from the middle node on the rightmost side.

[0082] Furthermore, the method for splitting the current message to be stored into two sub-messages is as follows:

[0083] Obtain the last-level nodes with the current state being idle according to the status marks of each node;

[0084] Split the current message to be stored according to the number of storage particles mounted on the last-level nodes with the current state being idle. Among them, the sizes of the two sub-messages obtained by splitting are the same as the number of particles in any two groups of storage particles with the current state being idle, or the sizes of the two sub-messages obtained by splitting are not greater than the number of particles in the two groups of storage particles with the current state being idle that are currently selected.

[0085] It should be noted that as the storage particles are occupied, the remaining idle storage particles will become fewer and fewer. If the current message to be stored is only split into two sub-messages, and the storage particles mounted on any remaining idle last-level node still do not meet the storage requirements of the two sub-messages, the current message to be stored can be split into multiple sub-messages until there are storage particles mounted on the currently still idle last-level nodes that meet the storage requirements of the multiple sub-messages obtained by the current split; after the split is completed, the polling direction corresponding to each sub-message and the splitting method of the sub-message are similar to the processing method when splitting into two sub-messages at one time, and the present invention will not elaborate on this.

[0086] For example, assume that the storage requirement of the current message to be stored is 33 bits, and the maximum number of storage particles mounted on the last-level node in the idle state is 32. Obviously, 32 bits do not meet the storage requirement of the current message to be stored, which is 33 bits. Then, the current message to be stored can be split into two sub-messages of 32 bits and 1 bit, and two polling requests are generated accordingly. The 32-bit sub-message is polled starting from the middle node on the leftmost side, and the 1-bit sub-message is polled starting from the middle node on the rightmost side;

[0087] It should be noted that assume that the maximum number of idle storage particles mounted on the last-level node in the previous idle state is 10. If the storage requirement of the current message to be stored, which is 33 bits, is only split into two sub-messages, it obviously does not meet the storage requirement. The storage requirement of the current message to be stored, which is 33 bits, can be split into four sub-messages of 10 bits, 8 bits, 8 bits, and 7 bits; It should be noted that the specific splitting method can be determined according to the actual number of storage particles mounted on the last-level node that is currently in the idle state. After splitting the storage requirement of the current message to be stored, which is 33 bits, into four sub-messages, four polling requests are generated accordingly. Since the tree structure has only two directions, the left entrance and the right entrance, only two polling requests can be processed simultaneously.

[0088] Thus, it can be seen that the present invention needs to determine the status of each node in real time according to the status marks of each node, and update the status marks of each node and the status marks of each storage particle in real time, and obtain the information of the current idle storage particles from the status marks, so as to provide a basis for the division of the current message to be stored. That is to say, the present invention needs to record the status of each storage particle: idle or in use; and also needs to perform dynamic management for each node, and determine the next status of the node according to the current status of the storage particle and the node and the application operation, solving the problem that in a complex data storage architecture, the status of the storage particle cannot be perceived, resulting in data storage errors and further leading to system crashes during long-term operation.

[0089] Further, a binary tree is the simplest tree in the tree structure. To speed up the polling speed of sibling nodes, the tree structure can be designed as a binary tree structure. At this time, the intermediate nodes will be divided into multiple levels of intermediate nodes, such as the first-level intermediate node, the second-level intermediate node, and the third-level intermediate node. The last-level nodes are then associated with the root node through multiple levels of intermediate nodes, and each intermediate node has two child nodes.

[0090] The above is the description of the method embodiment of the present invention. Next, the device for implementing the above method will be introduced.

[0091] See Figure 4 , which is a schematic structural diagram of a storage resource allocation device based on a tree structure provided by the present invention.

[0092] The storage resources include multiple storage particles; each storage particle is divided into multiple groups, and each group of storage particles is respectively mounted on a leaf node; each leaf node is divided into multiple groups, and each group of leaf nodes is respectively mounted on an intermediate node as child nodes; each intermediate node is mounted on the root node as a child node; wherein, the storage particles, leaf nodes, intermediate nodes, and the root node are all provided with status flags indicating whether they are in an idle state or a used state, and for each node, only when the storage particles or child nodes mounted on itself are all in an idle state, its own state is in an idle state;

[0093] The device includes:

[0094] A first judgment module 401, configured to judge whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node;

[0095] A second judgment module 402, configured to poll the intermediate nodes when the judgment result of the first judgment module is yes, and judge whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node;

[0096] A third judgment module 403, configured to poll the leaf nodes mounted on the current intermediate node when the judgment result of the second judgment module is yes, and judge whether the storage resources mounted on the current leaf node meet the storage requirements of the current message to be stored according to the status flag of the leaf node;

[0097] A scheduling module 404, configured to schedule the idle storage particles mounted on the current leaf node to store the current message to be stored when the judgment result of the third judgment module is yes.

[0098] The device solves the problem that in a complex data storage architecture, the status of storage particles cannot be perceived, resulting in data storage errors and further causing the system to crash during long-term operation.

[0099] See Figure 5 , which is a schematic structural diagram of an electronic device provided by the present invention.

[0100] The electronic device, such as a computer, may include a memory 501 and a processor 502.

[0101] The storage resources of the memory 501 include multiple memory dies; each memory die is divided into multiple groups, and each group of memory dies is respectively mounted on a last-level node; each last-level node is divided into multiple groups, and each group of last-level nodes is respectively mounted on an intermediate node as child nodes; each intermediate node is mounted on the root node as a child node; wherein, the memory dies, last-level nodes, intermediate nodes, and root node are all provided with status flags indicating whether they are in an idle state or a used state, and for each node, only when the memory dies or child nodes mounted on itself are all in an idle state, its own state is in an idle state;

[0102] The processor 502 is configured to determine whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node. If so, it polls the intermediate nodes, and determines whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node. If so, it polls the last-level nodes mounted on the current intermediate node, and determines whether the storage resources mounted on the current last-level node meet the storage requirements of the current message to be stored according to the status flag of the last-level node. If so, it schedules the idle memory die mounted on the current last-level node to store the current message to be stored.

[0103] This electronic device solves the problem that in a complex data storage architecture, the status of memory dies cannot be perceived, resulting in data storage errors and further causing the system to crash during long-term operation.

[0104] In several embodiments provided by the present invention, it should be understood that the disclosed methods, apparatuses, and electronic devices can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0105] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0106] In summary, 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 shall be included in the protection scope of the present invention.

Claims

1. A storage resource allocation method based on a tree structure, characterized in that The storage resources include multiple storage particles; each storage particle is divided into multiple groups, and each group of storage particles is respectively mounted on a last-level node; each last-level node is divided into multiple groups, and each group of last-level nodes is respectively mounted on an intermediate node as a child node; each intermediate node is mounted on the root node as a child node; wherein, status flags indicating whether the storage particle, the last-level node, the intermediate node, and the root node are in an idle state or a used state are set, and for each node, its status is in the used state only when the storage particles or child nodes mounted on itself are all in the used state; The method includes: Judging whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node. If so, polling the intermediate nodes, and judging whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node. If so, polling the last-level nodes mounted on the current intermediate node, and judging whether the storage resources mounted on the current last-level node meet the storage requirements of the current message to be stored according to the status flag of the last-level node. If so, scheduling the idle storage particles mounted on the current last-level node to store the current message to be stored; It also includes: The storage particles are unevenly divided into multiple groups, and starting from the leftmost last-level node of the tree structure composed of the last-level nodes, intermediate nodes, and the root node, each group of storage particles is mounted on each last-level node in descending order of quantity.

2. The storage resource allocation method based on a tree structure according to claim 1, wherein, It also includes: After the storage particles that meet the storage requirements of the current message to be stored store the current message to be stored, modifying the status flag of the storage particles that store the current message to be stored to the used state, and backtracking each level of nodes starting from the storage particles with the modified status flag, so as to modify the corresponding status flags of each node and complete the status update of the tree structure composed of the last-level nodes, intermediate nodes, and the root node.

3. The storage resource allocation method based on a tree structure according to claim 1, characterized in that, It also includes: The method for determining the polling direction is: Denote the number of groups of storage particles as N, and obtain the number of particles in a single group when the storage particles are evenly divided according to the number of groups N; Determine the polling direction according to the size relationship between the storage requirements of the current message to be stored and the number of particles in a single group. Among them, if the storage requirements of the current message to be stored are not less than the number of particles in a single group, polling starts from the leftmost intermediate node; if the storage requirements of the current message to be stored are less than the number of particles in a single group, polling starts from the rightmost intermediate node.

4. A storage resource allocation method based on a tree structure according to claim 1, characterized in that It also includes: If the storage requirements of the current message to be stored are greater than the number of particles in the group with the largest number of particles in the current idle state, split the current message to be stored into two sub-messages. If the sizes of the two sub-messages are equal, randomly select one of the sub-messages to start polling from the leftmost intermediate node, and at the same time, the other message starts polling from the rightmost intermediate node; if the sizes of the two sub-messages are not equal, select the larger sub-message to start polling from the leftmost intermediate node, and at the same time, the smaller sub-message starts polling from the rightmost intermediate node.

5. The method for allocating storage resources based on a tree structure according to claim 4, wherein, It also includes: The method for splitting the current message to be stored into two sub-messages is: Obtain the last-level nodes that are currently in the idle state according to the status flags of each node; Split the current message to be stored according to the number of free storage particles mounted on the leaf nodes in the idle state, where the sizes of the two sub-messages obtained by splitting are the same as the number of particles in any two groups of free storage particles in the idle state, or the sizes of the two sub-messages obtained by splitting are not greater than the number of particles in the two groups of free storage particles in the idle state currently selected.

6. A storage resource allocation method based on a tree structure according to any one of claims 1 to 5, characterized in that, It also includes: When the storage particles, leaf nodes, intermediate nodes, and root nodes are in the idle state, their status flags are set to 0; when the storage particles, leaf nodes, intermediate nodes, and root nodes are in the used state, their status flags are set to 1.

7. A storage resource allocation method based on a tree structure according to any one of claims 1 to 5, characterized in that, The tree structure composed of leaf nodes, intermediate nodes, and root nodes is a binary tree, where the leaf nodes are associated with the root node through multiple levels of intermediate nodes, and each intermediate node has two child nodes.

8. A storage resource allocation device based on a tree structure, characterized in that, The storage resources include multiple storage particles; the storage particles are divided into multiple groups, and each group of storage particles is respectively mounted on a leaf node; the leaf nodes are divided into multiple groups, and each group of leaf nodes is respectively mounted on an intermediate node as a child node; each intermediate node is mounted on the root node as a child node; among them, status flags indicating whether the storage particles, leaf nodes, intermediate nodes, and root nodes are in the idle state or the used state are set, and for each node, its status is only in the used state when all the storage particles or child nodes mounted on itself are in the used state; The device includes: A first judgment module for judging whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node; A second judgment module for polling the intermediate nodes when the judgment result of the first judgment module is yes, and judging whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node; A third judgment module for polling the leaf nodes mounted on the current intermediate node when the judgment result of the second judgment module is yes, and judging whether the storage resources mounted on the current leaf node meet the storage requirements of the current message to be stored according to the status flag of the leaf node; A scheduling module for scheduling the free storage particles mounted on the current leaf node to store the current message to be stored when the judgment result of the third judgment module is yes; Among them, the storage particles are unevenly divided into multiple groups, and starting from the leftmost leaf node of the tree structure composed of leaf nodes, intermediate nodes, and root nodes, each group of storage particles is mounted on each leaf node in the order of decreasing quantity.

9. An electronic device, characterized in that, It includes a memory and a processor; The storage resources of the memory include multiple memory grains; each memory grain is divided into multiple groups, and each group of memory grains is respectively mounted on a last-level node; each last-level node is divided into multiple groups, and each group of last-level nodes is respectively mounted on an intermediate node as a child node; each intermediate node is mounted on the root node as a child node; wherein, the memory grains, last-level nodes, intermediate nodes, and root nodes are all provided with status flags indicating whether they are in an idle state or a used state, and for each node, only when the memory grains or child nodes mounted on itself are all in the used state, its own state is in the used state; The processor is configured to determine whether the storage resources meet the storage requirements of the current message to be stored according to the status flag of the root node. If so, it polls the intermediate nodes, and determines whether the storage resources mounted on the current intermediate node meet the storage requirements of the current message to be stored according to the status flag of the intermediate node. If so, it polls the last-level nodes mounted on the current intermediate node, and determines whether the storage resources mounted on the current last-level node meet the storage requirements of the current message to be stored according to the status flag of the last-level node. If so, it schedules the idle memory grains mounted on the current last-level node to store the current message to be stored; Among them, the memory grains are unevenly divided into multiple groups, and starting from the leftmost last-level node of the tree structure composed of last-level nodes, intermediate nodes, and root nodes, each group of memory grains is mounted on each last-level node in descending order of quantity.

Citation Information

Patent Citations

  • Magnetic disk space management and managing system

    CN101030165A

  • Distributed speed limit queue implementation method and device

    CN114035924A