Block device hot plug method and device, intelligent network card and storage medium

By using execution flags and timing processing tasks in a polling drive environment, the hot-swap process of slicing and chunking equipment is realized, the coordinated processing of software and hardware is reduced, and the impact on data IO is improved and processing efficiency is improved.

CN119621629APending Publication Date: 2025-03-14MAIPU COMM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311192364.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-14
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

In a polling-driven environment, the hot-swap process of block devices is time-consuming, so how to avoid affecting the processing of data IO is a difficult problem.

Method used

By setting execution flags and creating timing processing tasks, hot-swap processing is divided into several subprocesses, and the parallel execution of timing processing tasks is used to reduce the consumption of CPU resources.

Benefits of technology

The impact of hot-swap processing of block equipment on data IO processing is reduced, the coordinated processing of software and hardware is realized, and the processing efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621629A_ABST
    Figure CN119621629A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of cloud computing and intelligent network cards, and provides a block device hot plug method and device, an intelligent network card and a storage medium, which are applied to the intelligent network card, the intelligent network card is in communication connection with a server, the intelligent network card is in network connection with a storage device, the storage device pre-creates a cloud disk, and the intelligent network card is pre-configured with a block device. A block device communicates with a cloud disk, a server accesses the cloud disk through the block device, and the method comprises the following steps: receiving a configuration instruction for performing hot plugging on the block device; creating a timing processing task based on the configuration instruction, and setting an initial value of an execution mark; when the timing processing task is awakened, corresponding operation is executed according to the value of the execution mark so as to achieve hot plugging of the block device, and the value of the execution mark is updated when the corresponding operation is completed. According to the invention, the influence of hot plug processing of the block device on data IO processing can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud computing and smart network cards, and in particular to a block device hot-plugging method, device, smart network card and storage medium. Background Art

[0002] With the development of cloud computing, more and more enterprise users use cloud servers or BMS (Bare Metal Server) provided by cloud service providers to deploy their businesses. BMS is a dedicated computing service that can be elastically expanded. It has the same computing performance and security isolation as traditional physical machines. It can meet the high performance, security and stability requirements of key business of enterprises. Such products are required to provide minute-level delivery capabilities.

[0003] The host of the bare metal server is controlled by the user. In order to provide the elastic expansion and minute-level delivery required by cloud services, independent computing components must be used to provide such functions, among which smart network cards are a common choice. Smart network cards provide BMS with cloud disk access and management functions through their storage offload function.

[0004] In the host machine, the smart network card simulates the storage block device through the PCIE (Peripheral Component Interconnect Express, PCIE) bus, implements the virtio_blk backend through the hardware logic firmware in the smart network card, performs storage protocol conversion through the CPU storage offload system software, communicates with various types of remote storage servers, and provides cloud storage access functions for the server. In order to achieve high efficiency, the CPU storage offload system generally adopts the user-mode polling method to implement the driver.

[0005] When the host machine supports hot-plugging of PCIE, you can use hot-plugging of block devices on the smart network card to implement the cloud disk mounting and unmounting functions. Hot-plugging of block devices in smart network cards requires the cooperation of hardware and software. The hot-plugging process of a block device is a time-consuming process. How to minimize the impact on data IO processing in a polling-driven environment is a difficult problem that needs to be solved. Summary of the invention

[0006] The object of the present invention is to provide a block device hot plugging method, device, intelligent network card and storage medium, which can reduce the impact of block device hot plugging processing on data IO processing.

[0007] The embodiments of the present invention can be implemented as follows:

[0008] In a first aspect, the present invention provides a block device hot-swap method, which is applied to a smart network card, wherein the smart network card is communicatively connected to a server, the smart network card is network-connected to a storage device, a cloud disk is pre-created on the storage device, the smart network card is pre-configured with a block device, the block device communicates with the cloud disk, and the server accesses the cloud disk through the block device. The method comprises:

[0009] Receiving a configuration instruction for hot-plugging the block device;

[0010] Setting an initial value of an execution flag based on the configuration instruction and creating a scheduled processing task;

[0011] When the timed processing task is awakened, a corresponding operation is performed according to the value of the execution flag to implement hot plugging of the block device, and the value of the execution flag is updated when the corresponding operation is completed.

[0012] In an optional implementation, the configuration instruction is an instruction for hot-plugging the block device, the smart network card pre-creates an operation handle corresponding to the cloud disk, the smart network card accesses the cloud disk through the operation handle, the smart network card also includes hardware logic firmware, and when the timed processing task is awakened, the corresponding operation is performed according to the value of the execution flag to implement the step of hot-plugging the block device, including:

[0013] When the timed processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to perform hot-insertion preprocessing, and the execution flag is set to the second preset value, and then the processing task is terminated, and the hardware logic firmware completes the underlying hot-insertion preprocessing operation in parallel;

[0014] When the timed processing task is awakened, if the execution flag is the second preset value, hot plugging is performed, and the execution flag is set to the third preset value, and then the processing task is terminated, and the hardware logic firmware completes the underlying hot plugging operation in parallel;

[0015] When the scheduled processing task is awakened, if the execution flag is the third preset value, the scheduled processing task is cancelled, and the complete hot insertion process of the block device is ended.

[0016] In an optional implementation, the hardware logic firmware includes a hardware register, and the step of performing hot insertion processing includes:

[0017] Obtaining the size of the block device and writing it to the hardware register;

[0018] The hardware logic firmware is notified to insert the block device.

[0019] In an optional implementation, the configuration instruction is an instruction for hot-plugging the block device, the smart network card further includes hardware logic firmware, and when the timed processing task is awakened, the step of performing a corresponding operation according to the value of the execution flag to implement hot-plugging of the block device further includes:

[0020] When the scheduled processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to unplug the block device, and the execution flag is set to the second preset value, and then the processing task is terminated;

[0021] When the scheduled processing task is awakened, if the execution flag is the second preset value, check whether the hardware logic firmware has completed unplugging the block device, if it is detected that it is completed, set the execution flag to the third preset value, and then end the processing task; if it is detected that it is not completed, do not change the execution flag, and directly end the processing task;

[0022] When the scheduled processing task is awakened, if the execution flag is the third preset value, the software unplugging process is performed, and it is checked whether the software unplugging of the block device is completed. If it is detected that it is completed, the execution flag is set to the fourth preset value, and then the processing task is terminated; if it is detected that it is not completed, the execution flag is not changed, and the processing task is directly terminated;

[0023] When the scheduled processing task is awakened, if the execution flag is the fourth preset value, the scheduled processing task is cancelled, and the complete hot unplugging process of the block device is ended.

[0024] In an optional implementation manner, the smart network card pre-creates an operation handle corresponding to the cloud disk, and the smart network card accesses the cloud disk through the operation handle, and the step of performing software unplugging processing includes:

[0025] If the software unplugging condition is met, the operation handle is released; the hardware logic firmware is notified to perform block device reset processing; check whether the hardware reset is completed, if completed, determine that the software unplugging processing is completed, otherwise, directly exit the software unplugging processing and continue checking in the next cycle.

[0026] In an optional implementation, the configuration instruction is an instruction for hot-inserting the block device, the smart network card further includes a preset port, and the step of creating a scheduled processing task based on the configuration instruction includes:

[0027] Creating an operation handle corresponding to the cloud disk;

[0028] The operation handle is bound to the preset port, and a data communication channel of the operation handle is opened.

[0029] In an optional implementation, the configuration instruction is an instruction to hot-plug the block device, the smart network card further includes a preset port, the smart network card pre-creates an operation handle corresponding to the cloud disk, the smart network card accesses the cloud disk through the operation handle, the operation handle and the preset port are pre-bound, and before the step of creating a scheduled processing task based on the configuration instruction, the step further includes:

[0030] The binding relationship between the operation handle and the preset port is released.

[0031] In a second aspect, the present invention provides a block device hot-swap device, which is applied to a smart network card, wherein the smart network card is connected to a server for communication, the smart network card is connected to a storage device network, the storage device has a cloud disk created in advance, the smart network card is pre-configured with a block device, the block device communicates with the cloud disk, and the server accesses the cloud disk through the block device, and the device comprises:

[0032] A receiving module, used for receiving a configuration instruction for hot-plugging the block device;

[0033] A creation module, used to set an initial value of an execution flag based on the configuration instruction and create a scheduled processing task;

[0034] The execution module is used to execute a corresponding operation according to the value of the execution flag when the scheduled processing task is awakened, so as to realize the hot plugging of the block device, and the value of the execution flag is updated when the corresponding operation is completed.

[0035] In a third aspect, the present invention provides an intelligent network card, comprising a central processing unit and a memory, wherein the memory is used to store a program, and the central processing unit is used to implement the block device hot plug method described in any one of the aforementioned embodiments when executing the program.

[0036] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the block device hot-plugging method described in any one of the aforementioned implementations.

[0037] Compared with the prior art, the block device hot-plug method, device, intelligent network card and storage medium provided in this embodiment divide the time-consuming hot-plug processing into several sub-processes by setting the execution flag and creating a scheduled processing task, and the timing of each sub-process is guaranteed by setting the value of the execution flag. In the scheduled processing task, the corresponding sub-process processing is executed according to the value of the execution flag. In the sub-process of the scheduled processing task, the hardware or software is notified to perform the corresponding operation, and the hardware or software background performs the related processing in parallel. In the scheduled processing task, it is detected whether the previous step of the operation is completed. If the previous step of the operation is completed, the value of the execution flag is updated to execute the next sub-process. This method changes the time-consuming processing that requires the cooperation of software and hardware in serial execution to parallel execution of software and hardware. In this way, the effect of releasing the CPU processing power during hardware execution is achieved without changing the timing and the final effect. Therefore, by reducing the occupation of CPU resources during the hot-plug processing process, the impact of the hot-plug processing of block devices on data IO processing is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0039] Figure 1 This is an example diagram of an application scenario provided by this embodiment.

[0040] Figure 2 This is a block diagram of an example of a smart network card provided in this embodiment.

[0041] Figure 3 This is an example flowchart of the block device hot plugging method provided in this embodiment.

[0042] Figure 4 This is a block diagram of an example of a hot-swap device for a block device provided in this embodiment.

[0043] Icons: 10 - smart network card; 11 - CPU; 12 - hardware logic firmware; 13 - PCIE bus; 20 - server; 30 - storage device; 100 - block device hot-swap device; 110 - receiving module; 120 - creation module; 130 - execution module. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0045] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0047] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0048] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0049] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0050] Please refer to Figure 1 , Figure 1 This is an example diagram of an application scenario provided in this embodiment. Figure 1 In the embodiment, the smart network card 10 is connected to the server 20 for communication. One communication connection mode may be that the smart network card 10 is inserted into the server 20, and the smart network card 10 communicates with various types of remote storage devices 30 through the network.

[0051] The smart network card 10 is a network card with an independent computing unit that can complete specific infrastructure functional operations. It can not only realize the connection function of the network card, but also usually offload some CPU processing tasks, such as network acceleration, security acceleration, storage offloading, storage acceleration, cloud platform management and other tasks. In the storage offloading scenario, the smart network card 10 simulates the storage block device through the PCIE bus 13, implements the back end of the virtual block device in the smart network card 10, and converts the communication protocol and storage protocol through software, communicates with various types of remote storage devices 30, and provides cloud storage access functions for the server 20. The storage offloading function of the smart network card 10 enables the server 20 to use the storage resources on the remote storage device 30 without perceiving the specific type of the remote storage device 30 and the physical type of the storage component of the storage device 30.

[0052] The server 20 may be an independent computer device or a physical server. The server 20 is also called a host machine or a bare metal server.

[0053] The storage device 30 may be a storage device such as an IPSAN (IP Storage Area Network), CEPH, etc.

[0054] The storage device 30 has a cloud disk created in advance, the smart network card 10 is configured with a block device, the block device of the smart network card 10 communicates with the cloud disk of the storage device 30, and the server accesses the cloud disk through the block device of the smart network card 10. As an implementation method, the smart network card 10 has an operation handle corresponding to the cloud disk created in advance, and the smart network card 10 accesses the cloud disk through the operation handle.

[0055] based on Figure 1 This embodiment also provides a block diagram of the smart network card 10, please refer to Figure 2 , Figure 2 This is a block diagram of an example of a smart network card provided in this embodiment. The smart network card 10 includes a CPU 11 and a hardware logic firmware 12. In some scenarios, the smart network card 10 also includes a memory for storing a computer program executed by the CPU 11.

[0056] The hardware logic firmware 12 is connected to the server 20 through the PCIE bus 13, the CPU 11 and the hardware logic firmware 12 can be electrically connected or connected through the PCIE bus, and the CPU 11 is connected to the storage device 30 through the network.

[0057] The hardware logic firmware 12 may be a FPGA (Field Programmable Gate Array), an ASIC (Application Specific Integrated Circuit), a DPU (Data Processing Unit), or the like.

[0058] When the server 20 supports hot plugging of PCIE, the hot plugging of block devices can be used on the smart network card 10 to realize the mounting and unloading functions of the cloud disk. The hot plugging process of the storage block device in the smart network card 10 is a time-consuming process, and the CPU resources occupied by the hot plugging process will affect the processing of data IO. Since the hot plugging process requires the cooperation of hardware and software, and the hardware processing is more time-consuming, the software will still occupy CPU resources while waiting for the hardware processing to be completed, thereby affecting the processing of data IO. According to this processing feature, the embodiment of the present invention provides a block device hot plugging method, device, smart network card and storage medium, and its core improvement point is that the time-consuming processing that requires the serial execution of software and hardware is changed to parallel execution of software and hardware. The part of the cross-processing of software and hardware and the time-consuming processing part in the hot plugging process are processed by the timed processing task mode. The timed processing task will not occupy the CPU during the timing period, and the time-consuming processing of the hardware can be continued by waiting for a certain time before continuing the next process. Therefore, the block device hot plugging method provided in this embodiment will not occupy redundant CPU resources, but also can achieve the purpose of collaborative software and hardware processing, which will be described in detail below.

[0059] based on Figure 1 and Figure 2 This embodiment also provides an application in Figure 1 and Figure 2 For the hot-swap method of the block device of the smart network card 10, please refer to Figure 3 , Figure 3 The following is an example flow chart of a method for hot plugging a block device provided in this embodiment, wherein the method comprises the following steps:

[0060] Step S101, receiving a configuration instruction for hot-plugging a block device.

[0061] In this embodiment, there is a logical correspondence between the block device and the cloud disk on the storage device 30. It is a storage block device simulated by the smart network card 10 through the PCIE bus. The virtio_blk backend of the block device is implemented in the smart network card 10 through the hardware logic firmware 12, and the storage protocol conversion is performed through the CPU storage offload system software running on the CPU, and it communicates with various types of remote storage devices 30 to provide cloud storage access function for the server 20.

[0062] In this embodiment, the hot-plug configuration instructions include instructions for hot-plugging block devices and instructions for hot-plugging block devices, which respectively implement hot-plugging and hot-plugging of block devices, thereby implementing loading and unloading of block devices on the server 20.

[0063] Step S102: setting the initial value of the execution flag based on the configuration instruction and creating a scheduled processing task.

[0064] In this embodiment, one or more block devices can be hot-inserted or hot-unplugged at the same time. For any block device, a corresponding timed processing task is created based on the configuration instruction thereof. The validity period of a timed processing task is from the creation of the timed processing task to the cancellation of the timed processing task. During the validity period of the timed processing task, the timed processing task can be awakened after one or more timing cycles to perform corresponding operations. The last processing operation in the timed processing task will cancel the timed processing task to end the execution of the timed processing task.

[0065] In this embodiment, as an implementation method, the creation of the scheduled processing task can be completed by creating a timer and registering the scheduled processing task.

[0066] Step S103, when the scheduled processing task is awakened, a corresponding operation is performed according to the value of the execution flag to implement hot plugging of the block device, and the value of the execution flag is updated when the corresponding operation is completed.

[0067] In this embodiment, in order to ensure the timing of the operation of the timed processing task each time it is awakened, different values ​​of the execution flag are used to correspond to different operations of the timed processing task, and the value of the execution flag is updated when the corresponding operation is completed so that the next operation can be performed when the timed processing task is awakened next time. By assigning different values ​​to the execution flag, it is ensured that the timed processing task is executed in accordance with the processing sequence of the hot plug process after being awakened at each interval timing cycle, and the sequential processing of the hot plug complete process of the timed processing task in multiple timing cycles is realized.

[0068] The above method provided in this embodiment creates a timed processing task, and executes multiple operations involved in the hot plug processing after each interval timing cycle. Since the timed processing task will not occupy CPU resources before being awakened, and the time-consuming operations among the multiple operations involved in the hot plug processing can be executed by waiting for one or more timing cycles, thereby reducing the occupation of CPU resources during the hot plug processing, thereby reducing the impact of the hot plug processing of the block device on the data IO processing.

[0069] The following describes the process of hot-inserting block devices and hot-unplugging block devices respectively.

[0070] When the configuration instruction is an instruction for hot-inserting a block device, the processing flow for hot-inserting the block device will be started. In order to prepare the data communication channel between the smart network card 10 and the storage device 30 in advance, the following processing needs to be performed before creating the hot-insertion scheduled processing task:

[0071] First, create an operation handle corresponding to the cloud disk;

[0072] Secondly, bind the operation handle to the preset port and open the data communication channel of the operation handle.

[0073] In this embodiment, the preset port may be a PF (Physical Function) on PCIE, or a VF (Virtual Function) extended from the PF. One PF or one VF corresponds to one cloud disk.

[0074] In this embodiment, after the data communication channel of the operation handle is opened, it means that the backend is ready to provide data access services. In order for the server 20 to access the cloud disk of the storage device 30, it is also necessary to perform hot-plug processing of the block device on the smart network card, notify the server 20 that the block device backend is available, trigger the server 20 to load the block device driver, and mount this cloud disk. This part is also the main process of hot-plug processing. The smart network card initializes the execution flag and creates a hot-plug timing processing task for processing. During the hot-plug processing, the value of the execution flag will be set in sequence to: the first preset value, the second preset value, and the third preset value, such as 1, 2, and 3.

[0075] Assuming that the first preset value, the second preset value, and the third preset value of the execution flag are 1, 2, and 3 respectively, the hot plug timing processing flow is described in detail using this as an example:

[0076] First, the value of the execution flag is initialized to the first preset value, i.e., 1, and the timing period of the timed processing task is set to, for example, 1 second. The callback function of the timed processing task is set to the callback function of the hot plug processing, and the parameter of the callback function is set to the block device to be hot plugged, and then the hot plug timing processing task is created. Thereafter, the hot plug timing processing task will be awakened once every 1 second, and the set callback function will be executed when awakened. In the callback function, the corresponding operation processing is performed according to the value of the execution flag.

[0077] When the scheduled processing task is awakened for the first time, since the value of the execution flag is 1, the operation with the flag value of 1 will be executed, that is, the hardware logic firmware will be notified to perform hot insertion preprocessing; then the value of this execution flag is updated to 2, and the scheduled processing task is exited.

[0078] When the scheduled processing task is awakened for the second time, since the execution flag value is 2, the operation with the flag value of 2 will be executed, that is, the hardware logic firmware will be notified to perform hot insertion processing, and then the execution flag value will be updated to 3, and then the scheduled processing task will be exited. At the same time, the hardware logic firmware will synchronously perform the time-consuming hot insertion processing.

[0079] When the scheduled processing task is awakened for the third time, since the value of the execution flag is 3, the operation with the flag value 3 will be executed, that is, the hot-plug scheduled processing task will be cancelled, and then the complete hot-plug process of this block device will be ended.

[0080] Since the time to execute the callback function each time the scheduled processing task is awakened is much shorter than the timing cycle of 1s, the CPU resources can be released, and the hardware logic firmware can execute time-consuming processing in parallel, thus achieving the effect of coordinated processing of software and hardware.

[0081] The specific processing methods are:

[0082] When the scheduled processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to perform hot-insertion preprocessing, and the execution flag is set to the second preset value, and then the processing task is terminated, and the hardware logic firmware completes the underlying hot-insertion preprocessing operation in parallel;

[0083] When the scheduled processing task is awakened, if the execution flag is the second preset value, hot plugging is performed, and the execution flag is set to the third preset value, and then the processing task is terminated, and the underlying hot plugging operation is completed in parallel by the hardware logic firmware;

[0084] In this embodiment, the hot-plugging process may include the following processes: obtaining the size of the block device and writing it into a hardware register; and notifying the hardware logic firmware to insert the block device.

[0085] It should be noted that the processing of inserting the hardware logic firmware into the block device is relatively time-consuming. However, at this time, the operation of waking up the scheduled processing task after the expiration of this timing cycle has been terminated. From this time until the scheduled processing task is awakened when the next timing cycle expires, this process will not occupy CPU resources and realize the waiting for the processing of inserting the hardware logic firmware into the block device to be completed.

[0086] When the scheduled processing task is awakened, if the execution flag is the third preset value, the scheduled processing task is cancelled, and the complete hot insertion process of the block device is ended.

[0087] When the configuration instruction is a hot-plug block device instruction, the processing flow for the hot-plug block device will be started. Before creating a scheduled processing task for hot-plug, the following processing is required:

[0088] Unbind the operation handle from the default port.

[0089] The purpose of this processing is to reduce the IO uncompleted data still generated during the hot unplugging process and speed up the hot unplugging process.

[0090] In this embodiment, after the binding relationship is released, the smart network card no longer accepts IO requests issued by the server 20, but other hot unplugging related processing is still required at this time, and this part is also the main process of hot unplugging processing: processing is performed by creating a hot unplugging scheduled processing task, and during the processing, the execution flag value is set in sequence: the first preset value, the second preset value, the third preset value and the fourth preset value, such as the value can be 1, 2, 3, 4.

[0091] Assuming that the first preset value, the second preset value, the third preset value and the fourth preset value of the execution flag are 1, 2, 3 and 4 respectively, the hot unplug timing processing flow is described in detail using this as an example:

[0092] First, initialize the execution flag to the first preset value, i.e., 1, set the timing period of the scheduled processing task to 1 second, set the callback function of the scheduled processing task to the callback function of the hot unplug processing, set the parameter of this callback function to the block device to be hot unplugged, and then create a hot unplug scheduled processing task.

[0093] After that, the scheduled processing task will be woken up every 1 second, and the set callback function will be executed when it wakes up. In the callback function, the corresponding operation processing is performed according to the value of the execution flag.

[0094] When the scheduled processing task is awakened for the first time, since the execution flag value is 1, the operation with the flag value of 1 will be executed, that is, the hardware logic firmware will be notified to unplug the block device; then the execution flag value will be updated to 2, and the scheduled processing task will be exited; the hardware logic firmware will perform the time-consuming unplugging process in parallel;

[0095] When the scheduled processing task is awakened next time, since the value of the execution flag is 2, the operation with the flag value of 2 will be executed, that is, checking whether the hardware logic firmware unplugging process is completed. Since the unplugging process may not be completed within 1 second of the timing cycle, the value of the execution flag cannot be updated, so that the next time the scheduled processing task is awakened, it will continue to check until it is found that the hardware unplugging process is completed, and then the value of the execution flag will be updated to 3. Each time the check is completed, the scheduled processing task is exited. By notifying the hardware logic firmware processing and checking the results of the hardware logic firmware processing in the callback function, the software waits for the hardware logic firmware to complete the time-consuming hot unplugging process in parallel; this can be adapted to different scenarios, no matter how long the hot unplugging of the hardware logic firmware takes, it will not occupy extra CPU resources;

[0096] When the timed processing task is awakened next time, if the execution flag value is 2, the operation with flag value 2 is executed; if the execution flag value is 3, the operation with flag value 3 is executed, and so on until the execution flag value is 4. At this time, it means that the previous hot unplugging hardware and software processing have been completed. Then, the timed processing task is cancelled in this callback function to complete the entire hot unplugging processing flow.

[0097] In the timed processing task, the corresponding operation is completed according to the value of the execution flag; when the operation is completed, the value of the execution flag is updated to enter the next processing flow; this ensures the timing of the hot unplugging processing.

[0098] Since the time to execute the callback function each time the scheduled processing task is awakened is much shorter than the timing cycle of 1s, the CPU resources can be released, and the hardware logic firmware can execute time-consuming processing in parallel, thus achieving the effect of coordinated processing of software and hardware.

[0099] The specific processing methods are:

[0100] When the scheduled processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to unplug the block device, and the execution flag is set to the second preset value, and then the processing task is terminated;

[0101] When the scheduled processing task is awakened, if the execution flag is the second preset value, it checks whether the hardware logic firmware has completed unplugging the block device. If it is detected that it has been completed, the execution flag is set to the third preset value, and then the processing task is terminated; if it is not completed, the execution flag is not changed, and the processing task is directly terminated. Since the value of the execution flag will be updated to the next value only after the hardware logic firmware is checked to be executed, when the hardware logic firmware is not unplugged, the scheduled processing task will check in multiple processing cycles until it succeeds. This design can adapt to different scenarios of hardware logic firmware, and no matter how long the hot unplugging time is, it will not occupy extra CPU resources.

[0102] When the scheduled processing task is awakened, if the execution flag is the third preset value, the software unplugging process is performed, and it is checked whether the software unplugging the block device is completed. If it is detected that it is completed, the execution flag is set to the fourth preset value, and then the processing task is terminated; if it is detected that it is not completed, the execution flag is not changed, and the processing task is directly terminated;

[0103] In this embodiment, the software unplugging process includes the following processes:

[0104] If the software unplugging condition is met, the operation handle is released; the hardware logic firmware is notified to perform block device reset processing; check whether the hardware reset is completed. If completed, the software unplugging processing is determined to be completed. Otherwise, the software unplugging processing is directly exited and the check is continued when the scheduled processing task is woken up next time.

[0105] In this embodiment, if there is an unfinished data request for accessing the block device, it is determined that the software unplugging condition is not met; if there is no unfinished data request for accessing the block device, the data communication channel is closed and the value of the hardware register is set to 0, and it is determined that the software unplugging condition is met.

[0106] In this embodiment, the wake-up timing processing task interval timing period can be set according to the average duration of the hardware hot unplugging process performed by the hardware logic firmware, for example, the timing period is set to 500ms, or 1s.

[0107] When the execution flag is the third preset value and the software unplugging process is not completed, the execution flag is not modified at this time, the operation of the current scheduled processing task is directly terminated, and the next scheduled processing task is awakened, and the software unplugging process is checked again to see if it is completed. If it is completed, the third preset value is set to the fourth preset value, otherwise it continues to wait until the execution is checked to be completed. This removes the coupling between the hot unplugging process at the control layer in the software and the IO request process at the data layer in the software, and reduces the impact of the control layer process in the software on the IO request process of other block devices at the data layer.

[0108] When the scheduled processing task is awakened, if the execution flag is the fourth preset value, the scheduled processing task is cancelled, and the complete hot unplugging process of the block device is ended.

[0109] In order to execute the corresponding steps in the above embodiment and each possible implementation method, an implementation method of the block device hot plugging device 100 is given below. Figure 4 , Figure 4 It should be noted that the basic principle and technical effects of the hot-swappable block device 100 provided in this embodiment are the same as those in the above embodiment, and are not mentioned in this embodiment for the sake of brief description.

[0110] The block device hot plug apparatus 100 includes a receiving module 110 , a creating module 120 and an executing module 130 .

[0111] The receiving module 110 is used to receive a configuration instruction for hot-plugging a block device;

[0112] A creation module 120, configured to initialize an execution flag based on a configuration instruction and create a scheduled processing task;

[0113] The execution module 130 is used to execute a corresponding operation according to the value of the execution flag when the scheduled processing task is awakened, so as to realize hot plugging of the block device.

[0114] In an optional implementation, the configuration instruction is an instruction for hot-inserting a block device, the smart network card pre-creates an operation handle corresponding to the cloud disk, the smart network card accesses the cloud disk through the operation handle, the smart network card further includes hardware logic firmware, and the execution module 130 is specifically used to:

[0115] When the scheduled processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to perform hot-insertion preprocessing, and the execution flag is set to the second preset value, and then the processing task is terminated, and the hardware logic firmware completes the underlying hot-insertion preprocessing operation in parallel;

[0116] When the timed processing task is awakened, if the execution flag is the second preset value, hot plugging is performed, and the execution flag is set to the third preset value, and then the processing task is terminated, and the underlying hot plugging operation is completed in parallel by the hardware logic firmware;

[0117] When the scheduled processing task is awakened, if the execution flag is the third preset value, the scheduled processing task is cancelled, and the complete hot insertion process of the block device is ended.

[0118] In an optional implementation, the hardware logic firmware includes a hardware register, and the execution module 130, when specifically used for hot plugging processing, is specifically used for:

[0119] Get the size of the block device and write it to the hardware register;

[0120] Notify the hardware logic firmware to insert a block device.

[0121] In an optional implementation, the configuration instruction is an instruction for hot-plugging a block device, the smart network card further includes hardware logic firmware, and the execution module 130 is specifically used for:

[0122] When the scheduled processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to unplug the block device, and the execution flag is set to the second preset value, and then the processing task is terminated;

[0123] When the scheduled processing task is awakened, if the execution flag is the second preset value, it is checked whether the hardware logic firmware has completed unplugging the block device. If it is detected that it is completed, the execution flag is set to the third preset value, and then the processing task is terminated; if it is detected that it is not completed, the execution flag is not changed, and the processing task is directly terminated;

[0124] When the scheduled processing task is awakened, if the execution flag is the third preset value, the software unplugging process is performed, and it is checked whether the software unplugging the block device is completed. If it is detected that it is completed, the execution flag is set to the fourth preset value, and then the processing task is terminated; if it is detected that it is not completed, the execution flag is not changed, and the processing task is directly terminated;

[0125] When the scheduled processing task is awakened, if the execution flag is the fourth preset value, the scheduled processing task is cancelled, and the complete hot unplugging process of the block device is ended.

[0126] In an optional implementation, the smart network card pre-creates an operation handle corresponding to the cloud disk, and the smart network card accesses the cloud disk through the operation handle. When the execution module 130 is specifically used for hot unplugging processing, it is specifically used for:

[0127] If the software unplugging condition is met, the operation handle is released; the hardware logic firmware is notified to perform block device reset processing; check whether the hardware reset is completed. If completed, the software unplugging processing is determined to be completed. Otherwise, the software unplugging processing is directly exited and the next cycle is continued.

[0128] In an optional implementation, the configuration instruction is an instruction for hot-inserting a block device, the smart network card further includes a preset port, and the creation module 120 is further configured to:

[0129] Create an operation handle corresponding to the cloud disk;

[0130] Bind the operation handle to the preset port and open the data communication channel of the operation handle.

[0131] In an optional implementation, the configuration instruction is an instruction for hot-plugging a block device, the smart network card further includes a preset port, the smart network card pre-creates an operation handle corresponding to the cloud disk, the smart network card accesses the cloud disk through the operation handle, the operation handle and the preset port are pre-bound, and the creation module 120 is further used to:

[0132] Unbind the operation handle from the default port.

[0133] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for hot plugging a block device according to any one of the aforementioned implementations is implemented.

[0134] In summary, the embodiments of the present invention provide a block device hot-swap method, apparatus, smart network card and storage medium, which are applied to the smart network card, the smart network card is communicatively connected to the server, the smart network card is network-connected to the storage device, a cloud disk is pre-created on the storage device, the smart network card is pre-configured with a block device, the block device communicates with the cloud disk, and the server accesses the cloud disk through the block device. The method includes: receiving a configuration instruction for hot-swapping the block device; setting an initial value of an execution flag based on the configuration instruction and creating a scheduled processing task; when the scheduled processing task is awakened, executing a corresponding operation according to the value of the execution flag to realize hot-swapping of the block device, and the value of the execution flag is updated when the corresponding operation is completed. Compared with the prior art, this embodiment has at least the following advantages: (1) By creating a timed processing task, each hot-plug related operation is executed after being awakened at each set timed cycle. Since the timed processing task will not occupy CPU resources before being awakened, the time-consuming operation in the multiple operations involved in the hot-plug processing can be performed by waiting for one or more timed cycles to wake up the timed processing task once or multiple times. Therefore, by reducing the occupation of CPU resources during the hot-plug processing, the impact of the hot-plug processing of block devices on data IO processing is reduced; (2) Since it is time-consuming for the hardware logic firmware to insert the block device, after notifying the hardware logic firmware to insert the block device, the current timed processing task is terminated so that the CPU resources are released while the hardware logic firmware is processing, so that the CPU can perform data IO processing while the hardware logic firmware is processing; (3) When hot-plugging a block device, since the time taken to unplug may be different for different block devices due to the influence of residual data in the hardware logic firmware, this embodiment wakes up the timed processing task at each set timed cycle. The corresponding operation is executed by the processing task at the same time to determine whether the hardware logic firmware has successfully unplugged the block device, which not only ensures the timeliness of the detection but also releases the CPU resources in time while the hardware logic firmware processes the unplugging. (4) The hot plug timing processing task is cancelled at the end of the hot plug processing. The purpose is to avoid the CPU from issuing the hot plug command again during the insertion process while waiting for the hardware logic firmware to complete the hot plug processing, which will cause the hardware logic firmware timing to be confused and affect the correct processing of the hardware logic firmware. (5) The hot plug timing processing task is cancelled at the end of the hot unplug processing. The purpose is to wait for the hardware logic firmware to complete the hot plug processing. The CPU from issuing the hot plug command again during the unplug processing will cause the hardware logic firmware timing to be confused and affect the correct processing of the hardware logic firmware. (6) The hot plugging of multiple block devices can be processed independently and simultaneously according to the hot plug timing processing tasks created by each device, without interfering with each other. In the scenario of batch hot plugging of block devices, the CPU resource usage is effectively reduced and the data IO processing is reduced.

[0135] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A block device hot-plugging method, characterized in that: Applied to a smart network card, the smart network card is connected to a server in communication, the smart network card is connected to a storage device network, the storage device has a cloud disk created in advance, the smart network card is pre-configured with a block device, the block device communicates with the cloud disk, and the server accesses the cloud disk through the block device, the method includes: Receiving a configuration instruction for hot-plugging the block device; Setting an initial value of an execution flag based on the configuration instruction and creating a scheduled processing task; When the timed processing task is awakened, a corresponding operation is performed according to the value of the execution flag to implement hot plugging of the block device, and the value of the execution flag is updated when the corresponding operation is completed.

2. The block device hot-plugging method according to claim 1, characterized in that: The configuration instruction is an instruction for hot-plugging the block device, the smart network card pre-creates an operation handle corresponding to the cloud disk, the smart network card accesses the cloud disk through the operation handle, the smart network card also includes hardware logic firmware, and when the timed processing task is awakened, the corresponding operation is performed according to the value of the execution flag to implement the hot plugging of the block device, including: When the timed processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to perform hot-insertion preprocessing, and the execution flag is set to the second preset value, and then the processing task is terminated, and the hardware logic firmware completes the underlying hot-insertion preprocessing operation in parallel; When the timed processing task is awakened, if the execution flag is the second preset value, hot plugging is performed, and the execution flag is set to the third preset value, and then the processing task is terminated, and the hardware logic firmware completes the underlying hot plugging operation in parallel; When the scheduled processing task is awakened, if the execution flag is the third preset value, the scheduled processing task is cancelled, and the complete hot insertion process of the block device is ended.

3. The block device hot-plugging method according to claim 2, characterized in that: The hardware logic firmware includes a hardware register, and the step of performing hot insertion processing includes: Obtaining the size of the block device and writing it to the hardware register; The hardware logic firmware is notified to insert the block device.

4. The block device hot-plugging method according to claim 1, characterized in that: The configuration instruction is an instruction for hot-plugging the block device, the smart network card further includes hardware logic firmware, and the step of performing a corresponding operation according to the value of the execution flag when the timed processing task is awakened to implement hot-plugging of the block device further includes: When the scheduled processing task is awakened, if the execution flag is the first preset value, the hardware logic firmware is notified to unplug the block device, and the execution flag is set to the second preset value, and then the processing task is terminated; When the scheduled processing task is awakened, if the execution flag is the second preset value, it is detected whether the hardware logic firmware has completed unplugging the block device. If it is detected that it is completed, the execution flag is set to the third preset value, and then the processing task is terminated; if it is detected that it is not completed, the execution flag is not changed, and the processing task is directly terminated; When the scheduled processing task is awakened, if the execution flag is the third preset value, the software unplugging process is performed, and whether the software unplugging the block device is completed is detected. If it is detected that it is completed, the execution flag is set to the fourth preset value, and then the processing task is terminated; if it is detected that it is not completed, the execution flag is not changed, and the processing task is directly terminated; When the scheduled processing task is awakened, if the execution flag is the fourth preset value, the scheduled processing task is cancelled, and the complete hot unplugging process of the block device is ended.

5. The block device hot-plugging method according to claim 4, characterized in that: The smart network card pre-creates an operation handle corresponding to the cloud disk, and the smart network card accesses the cloud disk through the operation handle. The step of performing software unplugging processing includes: If the software unplugging condition is met, the operation handle is released; the hardware logic firmware is notified to perform block device reset processing; check whether the hardware reset is completed, if completed, determine that the software unplugging processing is completed, otherwise, directly exit the software unplugging processing and continue checking in the next cycle.

6. The block device hot-plugging method according to claim 1, characterized in that: The configuration instruction is an instruction for hot-inserting the block device, the smart network card further includes a preset port, and the step of creating a scheduled processing task based on the configuration instruction includes: Creating an operation handle corresponding to the cloud disk; The operation handle is bound to the preset port, and a data communication channel of the operation handle is opened.

7. The block device hot-plugging method according to claim 1, characterized in that: The configuration instruction is an instruction to hot-plug the block device, the smart network card further includes a preset port, the smart network card pre-creates an operation handle corresponding to the cloud disk, the smart network card accesses the cloud disk through the operation handle, the operation handle and the preset port are pre-bound, and before the step of creating a scheduled processing task based on the configuration instruction, the step further includes: The binding relationship between the operation handle and the preset port is released.

8. A block device hot-swap device, characterized in that: Applied to a smart network card, the smart network card is connected to a server through communication, the smart network card is connected to a storage device through a network, a cloud disk is pre-created on the storage device, a block device is pre-configured on the smart network card, the block device communicates with the cloud disk, and the server accesses the cloud disk through the block device, the device comprises: A receiving module, used for receiving a configuration instruction for hot-plugging the block device; A creation module, used to set an initial value of an execution flag based on the configuration instruction and create a scheduled processing task; The execution module is used to execute a corresponding operation according to the value of the execution flag when the scheduled processing task is awakened, so as to realize the hot plugging of the block device, and the value of the execution flag is updated when the corresponding operation is completed.

9. A smart network card, characterized in that: The invention comprises a central processing unit and a memory, wherein the memory is used to store a program, and the central processing unit is used to implement the block device hot plugging method described in any one of claims 1 to 7 when executing the program.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the block device hot plugging method described in any one of claims 1 to 7 is implemented.