Virtual disk state management method, system, terminal and storage medium

CN116893881BActive Publication Date: 2026-10-30INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310903177.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-21
Publication Date
2026-10-30
Estimated Expiration
2043-07-21

AI Technical Summary

Benefits of technology

[0021]本发明的有益效果在于,本发明提供的虚拟磁盘状态管理方法、系统、终端及存储介质,采用一个构建状态机来实现虚拟磁盘复杂状态变更的管理,根据设置的输入回调函数获取虚拟磁盘当前状态,最后通过一个统一的状态处理接口来实现对各种场景的状态变更处理及相关事件流的发起;由此可保证复杂业务状态处理的稳定性与统一性,也可提升业务处理的安定性,以防止在一些繁杂的业务情景中因状态匹配错乱而导致的业务失败问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116893881B_ABST
    Figure CN116893881B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of servers, and specifically provides a virtual disk state management method, a system, a terminal and a storage medium, which comprises the following steps: creating a state machine, and taking a virtual disk state change as a trigger condition for state machine operation; obtaining a latest virtual disk state output after state machine operation; matching a corresponding disk processing instruction set for the latest virtual disk state based on a preset corresponding relationship between a disk state and a disk processing instruction set; and executing the corresponding disk processing instruction set on the corresponding disk. The application can guarantee the stability and uniformity of complex business state processing, and can improve the stability of business processing to prevent business failure caused by state matching disorder in some complex business scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of server technology, and specifically to a virtual disk status management method, system, terminal, and storage medium. Background Technology

[0002] A virtual disk is a disk on a remote computer that is displayed on the local computer. It appears as if it were a hard drive on the local machine, even though it's not actually located on the local machine. Network virtual disks (iSCSI) increase the hard drive capacity of internet cafe client computers, offering high speed, security, and stability. iSCSI Cake is primarily used for shared hard drive services in internet cafes. Virtual disks utilize the technology of creating one or more virtual disks in memory. Like virtual memory, memory is much faster than a hard drive; by leveraging this, creating one or more virtual disks in memory can accelerate data exchange, thereby improving computer performance.

[0003] Due to the large number of virtual disks, periodically querying each virtual disk through system commands consumes a significant amount of server computing resources. Furthermore, executing the corresponding processing flow only after detecting changes in the virtual disk status leads to a relative delay in processing. When handling complex business states, stability and consistency cannot be guaranteed, which can result in business failures due to mismatched statuses in some complex business scenarios. Summary of the Invention

[0004] To address the problems of existing technologies that cannot guarantee the stability and consistency of status monitoring and status processing, this invention provides a virtual disk status management method, system, terminal, and storage medium to solve the aforementioned technical problems.

[0005] In a first aspect, the present invention provides a virtual disk status management method, comprising: Create a state machine and use virtual disk state changes as the trigger condition for the state machine to run; Obtain the latest state of the virtual disk output after the state machine has run; Based on the preset correspondence between disk status and disk processing instruction set, the corresponding disk processing instruction set is matched for the latest status of the virtual disk; Execute the corresponding set of disk processing instructions on the corresponding disk.

[0006] In an optional implementation, a state machine is created, and virtual disk state changes are used as trigger conditions for the state machine's execution, including: Construct the state machine object data structure; Configure the virtual disk control status; Create a state machine object, allocate memory for the temporary storage space for state processing of the state machine object, and register the state change handling function; Create a virtual disk internal state data storage object, which is used to store the internal state data of the virtual disk; The external states of the virtual disk module are used to populate the input state list of the state machine; Set up a status acquisition callback function and a status write callback function. The status acquisition callback function is used to acquire the virtual disk status, and the status write callback function does not include an external status write function.

[0007] In one optional implementation, the state machine object data structure includes: The list includes: an input state linked list, a function linked list for obtaining input state data, a temporary storage space for state processing, a state change processing function, and a function linked list for writing state data.

[0008] In an optional implementation, the virtual disk control state includes: The status of virtual disk existence, pause request status, clear request status, whether virtual disk is recognized, whether pause or clear request is being processed, whether pause or clear request has been completed, and the status of clear request execution. The existence status of the virtual disk, the pause request status, and the clear request status belong to the external status of the module; the status of whether the virtual disk is recognized, whether a pause or clear request is being processed, whether a pause or clear request has been completed, and whether a clear request is being executed belong to the internal status of the module.

[0009] In one optional implementation, obtaining the latest state of the virtual disk output after the state machine runs includes: The latest state of the virtual disk is read from the state processing temporary storage space of the state machine. After any state change in the input state chain, the state machine calls the state acquisition callback function to read the state information of all virtual disks and temporarily stores the latest read state information into the state processing temporary storage space.

[0010] In an optional implementation, the correspondence between disk status and disk processing instruction set includes: When a virtual disk exists but is not recognized, it means that the virtual disk has just been created. The corresponding processing instruction set includes the process of initiating a virtual disk creation event. The virtual disk is in a read-write state. After completion, known is set to true. When a disk does not exist and is recognized, it means that the virtual disk has just been deleted. The corresponding processing instruction set includes the virtual disk deletion event related process. After completion, known is set to false. When the pause request is in a pause request state and there is no pause or clear request being processed or clear request being executed, the pause request event flow is triggered. The corresponding processing instruction set includes the virtual disk being in a stopped service state. When triggered, the status of whether a pause or clear request is being processed is set to yes. After the process is completed, the status of whether the pause or clear request has been processed is set to the completed state. When a pause request is in progress, no pause or clear request is being processed, or a clear request is being executed, an event flow for processing the clear request is triggered. The corresponding processing instruction set includes setting the status of whether a pause or clear request is being processed to "yes" and setting the status of whether the pause or clear request has been processed to "completed" after the process is completed. When a virtual disk exists, a pause or clear request has been processed, is not in a pause request state, or is not in the process of a clear request, a non-pause event flow is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been processed to incomplete, and after the process is completed, setting the status of whether the pause or clear request is being processed to not being in that state, and the virtual disk is restored to a readable and writable state. When a virtual disk exists, a pause or clear request has been completed, it is not in a pause request state, or a pause or clear request is being processed, an event flow for a non-clear request is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been completed to no, and after the process is completed, setting the status of whether the clear request is being executed to no, and setting the status of whether the pause or clear request is being processed to no, and the virtual disk is restored to a readable and writable state. When the virtual disk does not exist and the status of processing a pause or clear request is in progress, it means that the virtual disk was deleted during the pause request processing process. At this time, the status of whether the pause or clear request is being processed, whether the pause or clear request has been completed, and whether the clear request is being executed are all set to no. If there is no corresponding set of processing instructions for a state combination, the current state machine operation will end directly.

[0011] In an optional implementation, after executing the corresponding disk processing instruction set on the corresponding disk, the method further includes: The virtual disk is named in advance based on the physical disk to which it belongs; Set the virtual disk that has completed the pause or clear request as the target disk; The target physical disk is obtained based on the name of the target disk, and all virtual disks other than the target disk whose names contain the target physical disk are marked as candidate disks; Obtain the remaining space of the candidate disks, and select the candidate disk with the largest remaining space as the target virtual disk; Reconstruct the target disk using the target virtual disk; The pre-naming of the virtual disk based on the physical disk to which the virtual disk belongs includes: Number the physical disks in the storage pool sequentially; The index numbers of the virtual disks after each physical disk is partitioned are sequentially labeled; When creating each LUN in sequence, the physical disks in the storage pool are selected according to the physical disk number order, and the corresponding virtual disks are selected according to the index number of the virtual disks on each physical disk. Create LUNs from the selected virtual disks. Each created LUN has its own sequence number. In addition, a portion of space is reserved at the end of each physical disk as space for a hot spare virtual disk.

[0012] In a second aspect, the present invention provides a virtual disk status management system, comprising: The status monitoring module is used to create state machines and use virtual disk status changes as trigger conditions for the state machine to run. The state acquisition module is used to acquire the latest state of the virtual disk after the state machine has run; The instruction matching module is used to match the latest state of the virtual disk with the corresponding disk processing instruction set based on the preset correspondence between disk state and disk processing instruction set. The instruction execution module is used to execute the corresponding disk processing instruction set on the corresponding disk.

[0013] In one optional implementation, the status monitoring module includes: Data construction unit, used to construct the data structure of state machine objects; The status setting unit is used to set the virtual disk control status; The memory allocation unit is used to create state machine objects, allocate memory for the temporary storage space of state machine objects for state processing, and register state change handling functions. An object creation unit is used to create a virtual disk internal state data storage object, which is used to store various internal state data of the virtual disk. A linked list construction unit is used to populate the state machine input state linked list with the module's external state from the virtual disk; The function setting unit is used to set the status acquisition callback function and the status writing callback function. The status acquisition callback function is used to acquire the virtual disk status, and the status writing callback function does not include the external status writing function.

[0014] In one optional implementation, the state machine object data structure includes: The list includes: an input state linked list, a function linked list for obtaining input state data, a temporary storage space for state processing, a state change processing function, and a function linked list for writing state data.

[0015] In one optional implementation, the virtual disk control state includes: The status of virtual disk existence, pause request status, clear request status, whether virtual disk is recognized, whether pause or clear request is being processed, whether pause or clear request has been completed, and the status of clear request execution. The existence status of the virtual disk, the pause request status, and the clear request status belong to the external status of the module; the status of whether the virtual disk is recognized, whether a pause or clear request is being processed, whether a pause or clear request has been completed, and whether a clear request is being executed belong to the internal status of the module.

[0016] In one optional implementation, obtaining the latest state of the virtual disk output after the state machine runs includes: The latest state of the virtual disk is read from the state processing temporary storage space of the state machine. After any state change in the input state chain, the state machine calls the state acquisition callback function to read the state information of all virtual disks and temporarily stores the latest read state information into the state processing temporary storage space.

[0017] In an optional implementation, the correspondence between disk status and disk processing instruction set includes: When a virtual disk exists but is not recognized, it means that the virtual disk has just been created. The corresponding processing instruction set includes the process of initiating a virtual disk creation event. The virtual disk is in a read-write state. After completion, known is set to true. When the disk does not exist and is recognized, it means that the virtual disk has just been deleted. The corresponding processing instruction set includes the virtual disk deletion event related process. After completion, known is set to false. When the pause request is in a pause request state and there is no pause or clear request being processed or clear request being executed, the pause request event flow is triggered. The corresponding processing instruction set includes the virtual disk being in a stopped service state. When triggered, the status of whether a pause or clear request is being processed is set to yes. After the process is completed, the status of whether the pause or clear request has been processed is set to the completed state. When a pause request is in progress, no pause or clear request is being processed, or a clear request is being executed, an event flow for processing the clear request is triggered. The corresponding processing instruction set includes setting the status of whether a pause or clear request is being processed to "yes" and setting the status of whether the pause or clear request has been processed to "completed" after the process is completed. When a virtual disk exists, a pause or clear request has been processed, is not in a pause request state, or is not in the process of a clear request, a non-pause event flow is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been processed to incomplete, and after the process is completed, setting the status of whether the pause or clear request is being processed to not being in that state, and the virtual disk is restored to a readable and writable state. When a virtual disk exists, a pause or clear request has been completed, it is not in a pause request state, or a pause or clear request is being processed, an event flow for a non-clear request is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been completed to no, and after the process is completed, setting the status of whether the clear request is being executed to no, and setting the status of whether the pause or clear request is being processed to no, and the virtual disk is restored to a readable and writable state. When the virtual disk does not exist and the status of processing a pause or clear request is in progress, it means that the virtual disk was deleted during the pause request processing process. At this time, the status of whether the pause or clear request is being processed, whether the pause or clear request has been completed, and whether the clear request is being executed are all set to no. If there is no corresponding set of processing instructions for a state combination, the current state machine operation will end directly.

[0018] In an optional implementation, the system further includes: The naming setting module is used to pre-name the virtual disk based on the physical disk to which the virtual disk belongs; The target locking module is used to set a virtual disk that has completed a pause or clear request as the target disk; The disk selection module is used to obtain the target physical disk based on the name of the target disk, and mark all virtual disks other than the target disk whose names contain the target physical disk as candidate disks; The space filtering module is used to obtain the remaining space of candidate disks and filter out the candidate disk with the largest remaining space as the target virtual disk. The disk reconstruction module is used to reconstruct the target disk using the target virtual disk; The naming settings module is specifically used for: Number the physical disks in the storage pool sequentially; The index numbers of the virtual disks after each physical disk is partitioned are sequentially labeled; When creating each LUN in sequence, the physical disks in the storage pool are selected according to the physical disk number order, and the corresponding virtual disks are selected according to the index number of the virtual disks on each physical disk. Create LUNs from the selected virtual disks. Each created LUN has its own sequence number. In addition, a portion of space is reserved at the end of each physical disk as space for a hot spare virtual disk.

[0019] Thirdly, a terminal is provided, including: Processor, memory, among which, This memory is used to store computer programs. The processor is used to retrieve and run the computer program from memory, causing the terminal to perform the terminal method described above.

[0020] Fourthly, a computer storage medium is provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform the methods described in the above aspects.

[0021] The beneficial effects of this invention are that the virtual disk state management method, system, terminal, and storage medium provided by this invention adopt a state machine to manage complex state changes of the virtual disk, obtain the current state of the virtual disk according to the set input callback function, and finally realize the state change processing and related event stream initiation for various scenarios through a unified state processing interface. This can ensure the stability and uniformity of complex business state processing, and also improve the stability of business processing, so as to prevent business failures caused by state matching errors in some complex business scenarios.

[0022] This invention pre-sets corresponding processing instruction sets for various status monitoring results. These processing instruction sets are used to execute the processing flow corresponding to various status monitoring results, thereby organically combining virtual disk status monitoring and status processing. This can improve the stability of business processing and effectively avoid business failures caused by virtual disk status mismatch.

[0023] This invention improves reconstruction efficiency by pre-naming virtual disks based on the physical disk to which they belong, and then reconstructing the damaged virtual disk using a virtual disk located on the same physical disk as the damaged virtual disk after the virtual disk is damaged.

[0024] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1This is a schematic flowchart of a method according to an embodiment of the present invention.

[0027] Figure 2 This is another illustrative flowchart of a method according to an embodiment of the present invention.

[0028] Figure 3 This is a schematic block diagram of a system according to an embodiment of the present invention.

[0029] Figure 4 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present invention. Detailed Implementation

[0030] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.

[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

[0032] The virtual disk status management method provided in this embodiment of the invention is executed by a computer device, and correspondingly, the virtual disk status management system runs in the computer device.

[0033] Figure 1 This is a schematic flowchart illustrating a method according to an embodiment of the present invention. Wherein, Figure 1 The executing entity can be a virtual disk state management system. Depending on different requirements, the order of the steps in this flowchart can be changed, and some can be omitted.

[0034] like Figure 1 As shown, the method includes: Step 110: Create a state machine and use the virtual disk state change as the trigger condition for the state machine to run; Step 120: Obtain the latest state of the virtual disk output after the state machine runs; Step 130: Based on the preset correspondence between disk status and disk processing instruction set, match the corresponding disk processing instruction set for the latest status of the virtual disk; Step 140: Execute the corresponding disk processing instruction set on the corresponding disk.

[0035] To facilitate understanding of the present invention, the following description further illustrates the virtual disk state management method provided by the present invention, based on the principle of the virtual disk state management method and the process of managing the virtual disk state in the embodiments.

[0036] For details, please refer to Figure 2 The virtual disk status management method includes: S1. Create a state machine and use the virtual disk state change as the trigger condition for the state machine to run.

[0037] S101 constructs the state machine object data structure.

[0038] Construct the state machine object data structure, including: an input state list (input_status_list), a list of functions for retrieving input state data (read_input_data_fn_list), a temporary storage space for state processing (context), state change handling functions (status_handle_fn), a list of functions for writing state data (write_output_data_fn_list), and other necessary components.

[0039] S102 sets the virtual disk control status.

[0040] Virtual disk control status includes: The virtual disk's existence status exists (external state of the module, corresponding to whether the virtual disk exists or not, provided by the module that created the virtual disk); The pause request status is pause_req (external module status, paused request, when other modules request it); Clear the request status discard_req(module external status, clears the request, which is initiated when other modules request it); The virtual disk is recognized (known, internal module status, whether the virtual disk is recognized by this module). The status of whether a pause or clear request is being processed (internal module status, whether a pause or clear request is being processed); The status of whether the pause or clear request has been processed (paused, internal module status, pause or clear request processing completed); The discarding state during request execution (internal module state, whether the request is being discarded) is cleared.

[0041] A pause request must precede any request to clean up virtual disk data via a cleanup request.

[0042] S103 creates a state machine object, allocates memory for the state machine object's state processing temporary storage space, and registers state change handling functions.

[0043] Create a state machine object, allocate context memory space according to the actual scenario data size, and register the state change handling function (status_handle_fn).

[0044] S104 Creates a virtual disk internal state data storage object, which is used to store the internal state data of the virtual disk.

[0045] Create a virtual disk internal state data storage object to store the internal state data of the virtual disk.

[0046] S105 uses the external state of the virtual disk module to populate the state machine input state list.

[0047] Populate the state machine input_status_list; here you only need to add exists, paused, pause_req, and discard_req.

[0048] S106 sets a status acquisition callback function and a status write callback function. The status acquisition callback function is used to acquire the virtual disk status, and the status write callback function does not include an external status write function.

[0049] Set the state retrieval callback function (read_input_data_fn_list) and the state write callback function (write_output_data_fn_list, excluding the external state write function).

[0050] S2. Obtain the latest state of the virtual disk output after the state machine runs.

[0051] When any state in `input_status_list` changes, the state machine is triggered. Once triggered, the state machine first calls all functions in `read_input_data_fn_list` to read all current state information. The read state information is then temporarily stored in the `contest` field of the state machine object.

[0052] The latest state of the virtual disk can be read from the state processing temporary space of the state machine.

[0053] S3. Based on the preset correspondence between disk status and disk processing instruction set, match the corresponding disk processing instruction set for the latest status of the virtual disk.

[0054] The correspondence between disk status and disk processing instruction sets includes: When a virtual disk exists but is not recognized, it means that the virtual disk has just been created. The corresponding processing instruction set includes initiating the virtual disk creation event related process, the virtual disk is in a read-write state, and known is set to true after completion. Specifically, when exists is true and known is false, it means that the virtual disk has just been created. This module initiates the virtual disk creation event related process, the virtual disk is in a read-write state, and known is set to true after completion.

[0055] When a disk does not exist and is recognized, it means that the virtual disk has just been deleted. The corresponding processing instruction set includes the virtual disk deletion event related process. After completion, known is set to false. Specifically, when exists is false and known is true, it means that the virtual disk has just been deleted. This module initiates the virtual disk deletion event related process. After completion, known is set to false.

[0056] When a pause request is in a pause request state and no pause or clear request is being processed, nor is a clear request being executed, the pause request event flow is triggered. The corresponding processing instruction set includes the virtual disk being in a stopped service state. When triggered, the status of whether a pause or clear request is being processed is set to yes. After the process is completed, the status of whether the pause or clear request has been processed is set to complete. Specifically, the pause event flow is triggered when pause_req is true, pausing is false, and discarding (here, the same as discard_req) is false. The virtual disk is in a stopped service state. When triggered, pausing is set to true. After the process is completed, paused is set to true.

[0057] When a pause request is in progress, no pause or clear request is being processed, or a clear request is being executed, an event flow for processing the clear request is triggered. The corresponding processing instruction set includes setting the status of whether a pause or clear request is being processed to "yes" and setting the status of whether the pause or clear request has been processed to "completed" after the process is completed. Specifically, when pause_req is true, pausing is false, and discarding (which is the same as discard_req) is true, the discard event flow is triggered. The virtual disk is in a cleanup state. When triggered, pausing is set to true, and paused is set to true after the process is completed.

[0058] The non-pause event flow is triggered when the virtual disk exists, a pause or clear request has been completed, the virtual disk is not in a pause request state, or the clear request is not in progress. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been completed to incomplete, and setting the status of whether the pause or clear request is being processed to no state after the flow is completed, and the virtual disk is restored to a read-write state. Specifically, the unpause event flow is triggered when exists is true, paused is true, pause_req is false, and discarding is false. When triggered, paused is set to false, discarding is set to false, and pausing is set to false after the flow is completed, and the virtual disk is restored to a read-write state.

[0059] The non-clearing request event flow is triggered when a virtual disk exists, a pause or clearing request has been completed, it is not in a pause request state, or a pause or clearing request is being processed. The corresponding processing instruction set when triggered includes setting the status of whether the pause or clearing request has been completed to no, and after the process is completed, setting the status of whether a clearing request is being executed to no, and setting the status of whether a pause or clearing request is being processed to no, and the virtual disk is restored to a read-write state. Specifically, the undiscard event flow is triggered when exists is true, paused is true, pause_req is false, and discarding is true. When triggered, paused is set to false, and after the process is completed, discarding is set to false, pausing is set to false, and the virtual disk is restored to a read-write state.

[0060] When the virtual disk does not exist and the process is in the state of processing a pause or clear request, it means that the virtual disk was deleted during the pause request process. At this time, the states of whether the pause or clear request is being processed, whether the pause or clear request has been completed, and whether the clear request is in the process of execution are all set to no. Specifically, when pausing is true and exists is false, it means that the virtual disk was deleted during the pause process. At this time, pausing, paused, and discarding are all set to false.

[0061] If there is no corresponding processing instruction set for a state combination, the current state machine operation will end directly; that is, if other state combinations indicate that there is no corresponding event, the current state machine operation will end directly.

[0062] The above correspondence is related to the needs of the business scenario and can be customized according to the needs of the business scenario.

[0063] S4. Execute the corresponding disk processing instruction set on the corresponding disk.

[0064] After obtaining the latest status of each virtual disk, the processing function status_handle_fn is called to execute the corresponding set of processing instructions for each virtual disk based on the latest status of each virtual disk.

[0065] After processing is complete, update the current state in the context of the state machine object; call the function in write_output_data_fn_list to write the state information in the context to the corresponding position; Update the paused status in input_status_list.

[0066] If the virtual disk state changes, the above method will be executed repeatedly to process it accordingly.

[0067] S5. Reconstruct the cleared virtual disk.

[0068] The physical disks in the storage pool are sequentially numbered; the index numbers of the virtual disks partitioned from each physical disk are sequentially labeled; when creating each LUN in sequence, the physical disks in the storage pool are selected according to their numbering order, and the corresponding virtual disks are selected according to their index numbers on each physical disk; LUNs are created for the selected virtual disks, and each created LUN has its own sequence number; furthermore, a portion of space is reserved at the end of each physical disk as space for a hot spare virtual disk. This achieves naming the virtual disks based on the physical disk to which they belong. The virtual disk that has completed a pause or clear request is set as the target disk. The target physical disk is obtained based on its name. All virtual disks other than the target disk whose names contain the target physical disk are marked as candidate disks. The remaining space of the candidate disks is obtained, and the candidate disk with the largest remaining space is selected as the target virtual disk. The target virtual disk is then used to reconstruct the target disk. In other words, from the virtual disks mounted on the physical disk to which the damaged virtual disk to be deleted belongs, the virtual disk with the most remaining space is selected as the target disk, and the damaged virtual disk is reconstructed using the target disk. This reduces the actual amount of data interaction and improves reconstruction efficiency.

[0069] This method employs a state machine to manage complex state changes of the virtual disk. It obtains the current state of the virtual disk based on a set input callback function, and finally uses a unified state processing interface to handle state changes and initiate related event streams for various scenarios. This ensures the stability and consistency of complex business state processing and improves the security of business processing, preventing business failures caused by state mismatch in complex business scenarios.

[0070] In some embodiments, the virtual disk state management system 300 may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the virtual disk state management system 300 may be stored in the memory of a computer device and executed by at least one processor to perform (see details). Figure 1 (Description) Functionality of virtual disk status management.

[0071] In this embodiment, the virtual disk status management system 300 can be divided into multiple functional modules according to its functions, such as... Figure 3 As shown. The functional modules may include: a status monitoring module 310, a status acquisition module 320, an instruction matching module 330, and an instruction execution module 340. The module referred to in this invention is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and which are stored in memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0072] The status monitoring module is used to create state machines and use virtual disk status changes as trigger conditions for the state machine to run. The state acquisition module is used to acquire the latest state of the virtual disk after the state machine has run; The instruction matching module is used to match the corresponding disk processing instruction set for the latest state of the virtual disk based on a preset correspondence between disk state and disk processing instruction set; The instruction execution module is used to execute the corresponding disk processing instruction set on the corresponding disk.

[0073] Optionally, as an embodiment of the present invention, the status monitoring module includes: Data construction unit, used to construct the data structure of state machine objects; The status setting unit is used to set the virtual disk control status; The memory allocation unit is used to create state machine objects, allocate memory for the temporary storage space of state machine objects for state processing, and register state change handling functions. An object creation unit is used to create a virtual disk internal state data storage object, which is used to store various internal state data of the virtual disk. A linked list construction unit is used to populate the state machine input state linked list with the module's external state from the virtual disk; The function setting unit is used to set the status acquisition callback function and the status writing callback function. The status acquisition callback function is used to acquire the virtual disk status, and the status writing callback function does not include the external status writing function.

[0074] Optionally, as an embodiment of the present invention, the state machine object data structure includes: The list includes: an input state linked list, a function linked list for obtaining input state data, a temporary storage space for state processing, a state change processing function, and a function linked list for writing state data.

[0075] Optionally, as an embodiment of the present invention, the virtual disk control state includes: The status of virtual disk existence, pause request status, clear request status, whether virtual disk is recognized, whether pause or clear request is being processed, whether pause or clear request has been completed, and the status of clear request execution. The existence status of the virtual disk, the pause request status, and the clear request status belong to the external status of the module; the status of whether the virtual disk is recognized, whether a pause or clear request is being processed, whether a pause or clear request has been completed, and whether a clear request is being executed belong to the internal status of the module.

[0076] Optionally, as an embodiment of the present invention, obtaining the latest state of the virtual disk output after the state machine has run includes: The latest state of the virtual disk is read from the state processing temporary storage space of the state machine. After any state change in the input state chain, the state machine calls the state acquisition callback function to read the state information of all virtual disks and temporarily stores the latest read state information into the state processing temporary storage space.

[0077] Optionally, as an embodiment of the present invention, the correspondence between disk status and disk processing instruction set includes: When a virtual disk exists but is not recognized, it means that the virtual disk has just been created. The corresponding processing instruction set includes the process of initiating a virtual disk creation event. The virtual disk is in a read-write state. After completion, known is set to true. When the disk does not exist and is recognized, it means that the virtual disk has just been deleted. The corresponding processing instruction set includes the virtual disk deletion event related process. After completion, known is set to false. When the pause request is in a pause request state and there is no pause or clear request being processed or clear request being executed, the pause request event flow is triggered. The corresponding processing instruction set includes the virtual disk being in a stopped service state. When triggered, the status of whether a pause or clear request is being processed is set to yes. After the process is completed, the status of whether the pause or clear request has been processed is set to the completed state. When a pause request is in progress, no pause or clear request is being processed, or a clear request is being executed, an event flow for processing the clear request is triggered. The corresponding processing instruction set includes setting the status of whether a pause or clear request is being processed to "yes" and setting the status of whether the pause or clear request has been processed to "completed" after the process is completed. When a virtual disk exists, a pause or clear request has been processed, is not in a pause request state, or is not in the process of a clear request, a non-pause event flow is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been processed to incomplete, and after the process is completed, setting the status of whether the pause or clear request is being processed to not being in that state, and the virtual disk is restored to a readable and writable state. When a virtual disk exists, a pause or clear request has been completed, it is not in a pause request state, or a pause or clear request is being processed, an event flow for a non-clear request is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been completed to no, and after the process is completed, setting the status of whether the clear request is being executed to no, and setting the status of whether the pause or clear request is being processed to no, and the virtual disk is restored to a readable and writable state. When the virtual disk does not exist and the status of processing a pause or clear request is in progress, it means that the virtual disk was deleted during the pause request processing process. At this time, the status of whether the pause or clear request is being processed, whether the pause or clear request has been completed, and whether the clear request is being executed are all set to no. If there is no corresponding set of processing instructions for a state combination, the current state machine operation will end directly.

[0078] Optionally, as an embodiment of the present invention, the system further includes: The naming setting module is used to pre-name the virtual disk based on the physical disk to which the virtual disk belongs; The target locking module is used to set a virtual disk that has completed a pause or clear request as the target disk; The disk selection module is used to obtain the target physical disk based on the name of the target disk, and mark all virtual disks other than the target disk whose names contain the target physical disk as candidate disks; The space filtering module is used to obtain the remaining space of candidate disks and filter out the candidate disk with the largest remaining space as the target virtual disk. The disk reconstruction module is used to reconstruct the target disk using the target virtual disk; The naming settings module is specifically used for: Number the physical disks in the storage pool sequentially; The index numbers of the virtual disks after each physical disk is partitioned are sequentially labeled; When creating each LUN in sequence, the physical disks in the storage pool are selected according to the physical disk number order, and the corresponding virtual disks are selected according to the index number of the virtual disks on each physical disk. Create LUNs from the selected virtual disks. Each created LUN has its own sequence number. In addition, a portion of space is reserved at the end of each physical disk as space for a hot spare virtual disk.

[0079] Figure 4 This is a schematic diagram of the structure of a terminal 400 provided in an embodiment of the present invention. The terminal 400 can be used to execute the virtual disk status management method provided in the embodiment of the present invention.

[0080] The terminal 400 may include a processor 410, a memory 420, and a communication module 430. These components communicate via one or more buses. Those skilled in the art will understand that the server structure shown in the figure does not constitute a limitation of the present invention. It may be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0081] The memory 420 can be used to store the execution instructions of the processor 410. The memory 420 can be implemented by any type of volatile or non-volatile storage terminal 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 storage, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 420 are executed by the processor 410, the terminal 400 is able to perform some or all of the steps in the above method embodiments.

[0082] The processor 410 serves as the control center of the storage terminal, connecting various parts of the electronic terminal via various interfaces and lines. It executes software programs and / or modules stored in the memory 420, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 410 may consist only of a central processing unit (CPU). In this embodiment of the invention, the CPU may have a single processing core or include multiple processing cores.

[0083] The communication module 430 is used to establish a communication channel, enabling the storage terminal to communicate with other terminals. It receives user data sent by other terminals or sends user data to other terminals.

[0084] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, which, when executed, may include some or all of the steps provided in the embodiments of the present invention. The storage medium may be a magnetic disk, an optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0085] Therefore, this invention employs a state machine to manage complex state changes of the virtual disk. It obtains the current state of the virtual disk based on a set input callback function, and finally uses a unified state processing interface to handle state changes in various scenarios and initiate related event streams. This ensures the stability and consistency of complex business state processing and improves the security of business processing, preventing business failures caused by state mismatches in complex business scenarios. The technical effects achieved by this embodiment can be found in the description above, and will not be repeated here.

[0086] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or other media capable of storing program code. It includes several instructions to cause a computer terminal (which may be a personal computer, server, or a second terminal, network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0087] The same or similar parts between the various embodiments in this specification can be referred to mutually. In particular, the terminal embodiments are basically similar to the method embodiments, so the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.

[0088] In the embodiments provided by this invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or modules may be electrical, mechanical, or other forms.

[0089] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0090] In addition, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0091] Although the present invention has been described in detail with reference to the accompanying drawings and preferred embodiments, the invention is not limited thereto. Various equivalent modifications or substitutions can be made to the embodiments of the invention by those skilled in the art without departing from the spirit and essence of the invention, and such modifications or substitutions should all be within the scope of the invention. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the invention should also be covered within the protection scope of the invention. Therefore, the protection scope of the invention should be determined by the scope of the claims.

Claims

1. A method for managing the status of a virtual disk, characterized in that, include: Create a state machine and use virtual disk state changes as the trigger condition for the state machine to run; Obtain the latest state of the virtual disk output after the state machine has run; Based on the preset correspondence between disk status and disk processing instruction set, the corresponding disk processing instruction set is matched for the latest status of the virtual disk; Execute the corresponding disk processing instruction set on the corresponding disk; Create a state machine and use virtual disk state changes as trigger conditions for the state machine's execution, including: Construct the state machine object data structure; Configure the virtual disk control status; Create a state machine object, allocate memory for the temporary storage space for state processing of the state machine object, and register the state change handling function; Create a virtual disk internal state data storage object, which is used to store the internal state data of the virtual disk; The external states of the virtual disk module are used to populate the input state list of the state machine; Set a status acquisition callback function and a status write callback function. The status acquisition callback function is used to acquire the virtual disk status. The status write callback function does not include an external status write function. After executing the corresponding disk processing instruction set on the corresponding disk, it also includes: The virtual disk is named in advance based on the physical disk to which it belongs; Set the virtual disk that has completed the pause or clear request as the target disk; The target physical disk is obtained based on the name of the target disk, and all virtual disks other than the target disk whose names contain the target physical disk are marked as candidate disks; Obtain the remaining space of the candidate disks, and select the candidate disk with the largest remaining space as the target virtual disk; Reconstruct the target disk using the target virtual disk.

2. The method according to claim 1, characterized in that, The state machine object data structure includes: The list includes: an input state linked list, a function linked list for obtaining input state data, a temporary storage space for state processing, a state change processing function, and a function linked list for writing state data.

3. The method according to claim 1, characterized in that, The virtual disk control status includes: The status of virtual disk existence, pause request status, clear request status, whether virtual disk is recognized, whether pause or clear request is being processed, whether pause or clear request has been completed, and the status of clear request execution. The existence status of the virtual disk, the pause request status, and the clear request status belong to the external status of the module; the status of whether the virtual disk is recognized, whether a pause or clear request is being processed, whether a pause or clear request has been completed, and whether a clear request is being executed belong to the internal status of the module.

4. The method according to claim 1, characterized in that, Obtain the latest state of the virtual disk output after the state machine has run, including: The latest state of the virtual disk is read from the state processing temporary storage space of the state machine. After any state change in the input state chain, the state machine calls the state acquisition callback function to read the state information of all virtual disks and temporarily stores the latest read state information into the state processing temporary storage space.

5. The method according to claim 1, characterized in that, The correspondence between disk status and disk processing instruction sets includes: When a virtual disk exists but is not recognized, it means that the virtual disk has just been created. The corresponding processing instruction set includes the process of initiating a virtual disk creation event. The virtual disk is in a read-write state. After completion, known is set to true. When a disk does not exist and is recognized, it means that the virtual disk has just been deleted. The corresponding processing instruction set includes the virtual disk deletion event related process. After completion, known is set to false. When the pause request is in a pause request state and there is no pause or clear request being processed or clear request being executed, the pause request event flow is triggered. The corresponding processing instruction set includes the virtual disk being in a stopped service state. When triggered, the status of whether a pause or clear request is being processed is set to yes. After the process is completed, the status of whether the pause or clear request has been processed is set to the completed state. When a pause request is in progress, no pause or clear request is being processed, or a clear request is being executed, an event flow for processing the clear request is triggered. The corresponding processing instruction set includes setting the status of whether a pause or clear request is being processed to "yes" and setting the status of whether the pause or clear request has been processed to "completed" after the process is completed. When a virtual disk exists, a pause or clear request has been processed, is not in a pause request state, or is not in the process of a clear request, a non-pause event flow is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been processed to incomplete, and after the process is completed, setting the status of whether the pause or clear request is being processed to not being in that state, and the virtual disk is restored to a readable and writable state. When a virtual disk exists, a pause or clear request has been completed, it is not in a pause request state, or a pause or clear request is being processed, an event flow for a non-clear request is triggered. When triggered, the corresponding processing instruction set includes setting the status of whether the pause or clear request has been completed to no, and after the process is completed, setting the status of whether the clear request is being executed to no, and setting the status of whether the pause or clear request is being processed to no, and the virtual disk is restored to a readable and writable state. When the virtual disk does not exist and the status of processing a pause or clear request is in progress, it means that the virtual disk was deleted during the pause request processing process. At this time, the status of whether the pause or clear request is being processed, whether the pause or clear request has been completed, and whether the clear request is being executed are all set to no. If there is no corresponding set of processing instructions for a state combination, the current state machine operation will end directly.

6. The method according to claim 1, characterized in that, The pre-naming of the virtual disk based on the physical disk to which the virtual disk belongs includes: Number the physical disks in the storage pool sequentially; The index numbers of the virtual disks after each physical disk is partitioned are sequentially labeled; When creating each LUN in sequence, the physical disks in the storage pool are selected according to the physical disk number order, and the corresponding virtual disks are selected according to the index number of the virtual disks on each physical disk. Create LUNs from the selected virtual disks. Each created LUN has its own sequence number. In addition, a portion of space is reserved at the end of each physical disk as space for a hot spare virtual disk.

7. A virtual disk status management system, characterized in that, The system for implementing the method as described in any one of claims 1-6 includes: The status monitoring module is used to create state machines and use virtual disk status changes as trigger conditions for the state machine to run. The state acquisition module is used to acquire the latest state of the virtual disk after the state machine has run; The instruction matching module is used to match the latest state of the virtual disk with the corresponding disk processing instruction set based on the preset correspondence between disk state and disk processing instruction set. The instruction execution module is used to execute the corresponding disk processing instruction set on the corresponding disk.

8. A terminal, characterized in that, include: The memory is used to store the virtual disk status management program; A processor, configured to implement the steps of the virtual disk state management method as described in any one of claims 1-6 when executing the virtual disk state management program.

9. A computer-readable storage medium storing a computer program, characterized in that, The readable storage medium stores a virtual disk state management program, which, when executed by a processor, implements the steps of the virtual disk state management method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Finite state machine-based storage virtualization management system and method

    CN104102529A