Network block device slot management method and apparatus, electronic device, and storage medium
By obtaining the static determination result of the network block device when releasing slots in the device pool, the problem of slot release process blockage in cloud computing and virtualization scenarios is solved, realizing secure reuse and transfer of slots, and reducing input/output errors and duplicate error logs.
Patent Information
- Application Number
- CN202611710044.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-11-02
- Publication Date
- 2026-11-27
AI Technical Summary
In cloud computing and virtualization scenarios, the release process of network block device slots is easily blocked, and there are problems with input/output errors and duplicate error logs. Existing technologies lack effective strategies to ensure the safe reuse of slots and avoid blocking of the release process.
When releasing a slot in the device pool, the static status of the network block device is determined. If the device is static, the slot status is switched to idle. Otherwise, the slot is kept occupied and the determination result is obtained again according to the preset retry policy until the retry limit is reached or the device is processed according to the degradation policy.
This ensures safe reuse of slots while preventing the release process from being blocked, reducing input/output errors and duplicate error logs, and ensuring continuous turnover of slots in the device pool.
Smart Images

Figure CN123178104A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and storage medium for managing network block device slots. Background Technology
[0002] In cloud computing and virtualization scenarios, orchestrators commonly use Network Block Devices (NBDs) to map remote images to local block devices, allowing isolated execution environments to read and write after mounting the root file system image. The orchestrator maintains a device pool, managing a number of NBD slots using an occupancy status record. When an isolated execution environment is created, it takes a slot that is in an idle state; when the environment is destroyed, it initiates the removal of the device and returns the slot. The total number of local NBDs is constrained by kernel module parameters, and slots are scarce resources that need to be repeatedly used. Current practices typically return slots based on the completion of the removal action on the orchestrator's side. This involves changing the slot's occupancy status from occupied to idle in the occupancy status record and publishing it externally. If this check fails, the return is either completed directly or the return action fails and returns a value.
[0003] However, after the orchestrator initiates teardown, there may still be unprocessed read / write requests and unreleased holding relationships remaining on the device. The cleanup is handled by the kernel after the orchestrator initiates the teardown, and the two processes are not synchronized. Current practices rewrite the slot to an idle state as soon as the teardown on the orchestrator side is completed. At this point, the device's cleanup is often not yet finished. Therefore, slots in the occupancy status record that are currently idle are still in the finalization process. If these slots are subsequently re-acquired and used by new users for read / write operations, it conflicts with the device's finalization process, resulting in numerous input / output errors and excessive duplicate error log entries. Furthermore, return operations are typically designed to be completed in one go. If the decision fails, either the occupancy status record is forcibly rewritten, or the return operation fails and returns. There is a lack of an arrangement to postpone the rewriting and reconfirm according to a policy when the decision fails. Therefore, in cases where the decision fails for a long time, the return process is either blocked in waiting or prematurely completed in an unsafe manner.
[0004] Therefore, how to ensure the safe reuse of network block device slots while avoiding the blockage of the release process is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide a method, apparatus, electronic device and storage medium for managing network block device slots, which ensures the safe reuse of network block device slots while avoiding the blockage of the release process.
[0006] To achieve the above objectives, this application provides a network block device slot management method applied to an orchestrator, the method comprising: When releasing the first target slot in the device pool, a first static determination result of the first target network block device corresponding to the first target slot is obtained; wherein, the first static determination result indicates whether the asynchronous teardown of the first target network block device has been completed; If the first static determination result is that it is static, then the first target slot is switched from occupied to idle in the occupancy status record, and the first target slot is determined as a reusable slot. If the first static determination result is not static, then the first target slot is kept in the occupation status record, and the first static determination result is re-acquired according to the preset retry strategy until the first static determination result is static or the preset retry limit is reached. When the preset retry limit is reached, the first target slot is processed according to the preset degradation strategy.
[0007] Optionally, the occupancy status record includes an occupancy bitmap, which uses bit markers to indicate the occupancy and idle status of each network block device slot; Accordingly, switching the first target slot from occupied to idle in the occupancy status record includes: In the occupancy bitmap, the bit corresponding to the first target slot is rewritten from a first value indicating the occupancy state to a second value indicating the idle state.
[0008] Optionally, the first stillness determination result is reacquired according to a preset retry strategy, including: After waiting for a preset retry interval, the first static determination result is reacquired; wherein, the preset retry interval is determined based on a fixed interval and / or the number of reacquisitions; When the number of re-acquisitions reaches the maximum number of retries, or when the time elapsed since the first acquisition of the first staticity determination result reaches the maximum retry time, the acquisition of the first staticity determination result shall be stopped.
[0009] Optionally, the first target slot is processed according to a preset degradation strategy, including: Record the alarm information for the first target slot, and switch the first target slot from occupied to idle in the occupancy status record; Alternatively, the first target slot can be written into the task queue of an independent compensation task so that the static determination result of the first target slot can be retrieved again through the independent compensation task.
[0010] Optionally, after obtaining the first static determination result of the first target network block device corresponding to the first target slot, the method further includes: If the first static determination result is not obtained, then read the capacity value of the first target network block device; When the capacity value is zero, the first target slot is switched from occupied to idle in the occupancy status record.
[0011] Optionally, the method further includes: In response to the slot allocation request, a second target slot in an idle state is determined based on the occupancy status record, and a second inactivity determination result of the second network block device corresponding to the second target slot is obtained; If the second static determination result is that it is static, then the second target slot is switched from idle state to occupied state in the occupancy status record, a connection is established for the second target slot, and the second target slot is assigned to the requester of the slot allocation request.
[0012] Optionally, the method further includes: After the orchestrator restarts, the third static determination result of the third network block device is obtained; wherein, the third network block device is a network block device that has been allocated a third target slot before the orchestrator restarts, and the third target slot is in an occupied state in the occupancy status record; If the third static determination result is static, then the third target slot is switched from occupied to idle in the occupancy status record, and the third network block device is re-included in the device pool. If the third staticity determination result is not static, then the occupancy status of the third target slot in the occupancy status record is maintained, and the third staticity determination result is re-acquired according to the preset retry strategy.
[0013] To achieve the above objectives, this application provides a network block device slot management device applied to an orchestrator, the device comprising: The first acquisition module is used to acquire a first static determination result of the first target network block device corresponding to the first target slot when releasing the first target slot in the device pool; wherein, the first static determination result indicates whether the asynchronous teardown of the first target network block device has been completed. The first switching module is used to switch the first target slot from occupied to idle in the occupancy status record when the first staticity determination result is that it is stationary, and to determine the first target slot as a reusable slot. The first retry module is used to maintain the occupancy status of the first target slot in the occupancy status record when the first staticity determination result is not static, and to re-acquire the first staticity determination result according to the preset retry strategy until the first staticity determination result is static or the preset retry limit is reached. The degradation module is used to process the first target slot according to a preset degradation strategy when the preset retry limit is reached.
[0014] To achieve the above objectives, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor is used to implement the steps of the network block device slot management method described above when executing the computer program.
[0015] To achieve the above objectives, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the network block device slot management method described above.
[0016] The network block device slot management method provided in this application obtains the first static status determination result of the first target network block device when releasing the first target slot in the device pool. The action of switching the slot from an occupied state to an idle state in the occupancy status record is bound to whether the asynchronous teardown of the device has been completed. Since the first static status determination result indicates whether the asynchronous teardown of the device has been completed, it reflects the actual closing status of whether the device can be safely reused. Therefore, only when the first static status determination result is static is the first target slot switched from an occupied state to an idle state in the occupancy status record and determined as a reusable slot. When the slot is reused, there will be no conflict between new read / write requests and the device's closing processing. This avoids large-scale input / output errors and the resulting numerous duplicate error logs. When the first staticity determination result is not static, the first target slot remains in the occupied state in the occupancy status record and is not switched to the idle state, thus it will not be used. The orchestrator re-acquires the first staticity determination result according to a preset retry strategy, so that the determination result is continuously tracked as the teardown action progresses. Once the asynchronous teardown is completed, the state switch and return are completed without manual intervention. On this basis, the re-acquisition action has a preset retry limit. When the preset retry limit is reached, the first target slot is processed according to a preset degradation strategy, so that individual slots that cannot be determined to be static for a long time will not remain in the release process for a long time, and the slots in the device pool can continue to circulate without being gradually exhausted. It can be seen that this application ensures the safe reuse of network block device slots while avoiding the blockage of the release process. This application also discloses a network block device slot management device, an electronic device, and a computer-readable storage medium, which can achieve the above technical effects.
[0017] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. The drawings are used to provide a further understanding of this disclosure and constitute a part of the specification. They are used together with the following detailed description to explain this disclosure, but do not constitute a limitation of this disclosure. In the drawings: Figure 1 This is a flowchart illustrating a network block device slot management method according to an exemplary embodiment; Figure 2 This is a flowchart illustrating another network block device slot management method according to an exemplary embodiment; Figure 3 This is a flowchart illustrating yet another network block device slot management method according to an exemplary embodiment; Figure 4 A flowchart of the static lifecycle management method for slot pools provided in the application embodiments of this application; Figure 5 This is a structural diagram illustrating a network block device slot management apparatus according to an exemplary embodiment; Figure 6 This is a structural diagram of an electronic device according to an exemplary embodiment. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0020] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0021] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0022] This application discloses a network block device slot management method. The execution entity is an orchestrator, which refers to a user-space service running on the host machine, responsible for creating and destroying sandboxes and managing the device resources of the local machine. A sandbox is an isolated execution environment provided for tasks, often implemented using a micro virtual machine (microVM), and is used in scenarios such as cloud code execution, artificial intelligence (AI) agents, and continuous integration / continuous delivery (CI / CD).
[0023] See Figure 1 A flowchart illustrating a network block device slot management method according to an exemplary embodiment is shown below. Figure 1 As shown, it includes: S101: When releasing the first target slot in the device pool, obtain the first static determination result of the first target network block device corresponding to the first target slot; wherein, the first static determination result indicates whether the asynchronous teardown of the first target network block device has been completed; The device pool refers to a resource set maintained by the orchestrator, consisting of several network block device slots that can be repeatedly allocated and released. The orchestrator performs slot allocation, release, and reuse within this set. A network block device is an abstraction of a block device that maps a remote image to a local block device. It is used to mount the root file system image of the sandbox as a block device for the corresponding microvirtual machine to read and write. A slot is a network block device number that can be repeatedly allocated and released. In the local file system, it is represented as a device file in the form of / dev / nbdX, where X is the device sequence number. The total number of local network block devices is constrained by the kernel module parameter nbds_max (maximum number of network block devices), for example, a value of 4096. Therefore, slots are scarce resources that need to be repeatedly used. The first target slot refers to the slot to be released this time. The first target network block device refers to the network block device instance that has a corresponding relationship with the first target slot. This correspondence is determined when the slot is allocated and a connection is established. The same slot corresponds to only one network block device at any given time. The first static determination result refers to the conclusion that the asynchronous teardown of the network block device has been completed. Its value includes two options: "static" and "not static." "Static" indicates that the asynchronous teardown of the network block device has been completed and it can be safely reassigned. "Not static" indicates that the asynchronous teardown of the network block device is still in progress and it cannot be reassigned at this time. Asynchronous teardown refers to the cleanup process that the kernel continues to complete in the background after the orchestrator initiates the teardown action during sandbox destruction. Specifically, this includes writing any data that has not yet been written back to disk, invalidating page caches and block device buffers, closing open device descriptors, and releasing the holding relationships of each holder on the device. This cleanup process is not synchronized with the teardown action on the orchestrator side. The completion of the teardown action on the orchestrator side does not mean that the network block device can be safely reused.
[0024] In this step, when the sandbox is destroyed and the occupied slot needs to be returned, the network block device corresponding to the slot is first subjected to dismantling actions such as data write-back, buffer invalidation, descriptor closure, and connection disconnection. The first static determination result of the device is obtained after the dismantling action is completed, instead of rewriting the occupancy status record when the dismantling action is initiated. The first static determination result is determined by the underlying detection component. The determination method can be to collect kernel signals such as the in-transit block request count and holder set of the network block device and make a comprehensive determination, or it can be to have the network block device server return an acknowledgment after the disconnection is completed, or it can be to combine the above two methods and determine that it is static only when both consider it static. This embodiment does not limit the specific output method of the determination result.
[0025] S102: If the first static determination result is that it is static, then the first target slot is switched from occupied state to idle state in the occupancy status record, and the first target slot is determined as a reusable slot; The occupancy status record refers to the data structure maintained by the orchestrator that records whether each slot in the device pool is currently occupied or idle, serving as the basis for slot allocation and release. A reusable slot refers to a slot that has been switched to an idle state and is allowed to be reassigned and connected.
[0026] In this step, the first target slot is changed from occupied to idle in the occupancy status record only when the first static determination result is that it is already stationary. The slot is then marked as a reusable slot and published externally. That is, the switching of the slot from occupied to idle is strictly bound to the fact that the asynchronous dismantling of the device has been completed.
[0027] As can be seen, this step binds the state transition with the static determination result, ensuring that the asynchronous dismantling of the corresponding device for the slot that has been published as idle has been completed. This avoids the slot being used again before the device's final processing is finished, which would otherwise result in a large number of input / output errors (EIO) and a large number of duplicate error logs.
[0028] As a possible implementation, the occupancy status record includes an occupancy bitmap, which uses bits to mark the occupancy status and idle status of each network block device slot; correspondingly, switching the first target slot from an occupancy status to an idle status in the occupancy status record includes: rewriting the bit corresponding to the first target slot in the occupancy bitmap from a first value used to indicate the occupancy status to a second value used to indicate the idle status.
[0029] The occupancy bitmap is a data structure that uses binary bits to mark the occupancy and idle status of each slot. Each bit corresponds to one slot, and the bit number in the bitmap corresponds one-to-one with the device number of the slot. The first value and the second value refer to the two allowed values for that bit, such as the first value being 1 and the second value being 0, or the opposite value convention can be used.
[0030] In practice, firstly, a contiguous bitmap space is maintained in memory for the device pool. The length of this bitmap space is determined by the total number of network block devices on the local machine. For example, when the total number of network block devices on the local machine is 4096, the bitmap space occupies 512 bytes. Then, based on the device sequence number of the first target slot, the corresponding bit in the occupied bitmap is determined, and this bit is rewritten from a first value to a second value. Next, after the rewriting is complete, the slot's identifier is added to the free slot set for subsequent allocation.
[0031] As can be seen, this implementation method uses bit markers to indicate the slot status, so that the state switching can be completed by simply rewriting a single bit. The query overhead and rewriting overhead for occupied and idle slots are both very small, making it suitable for scenarios where sandboxes are frequently created and destroyed.
[0032] It should be noted that this embodiment does not limit the specific form of the occupancy status record. In addition to the occupancy bitmap, it can also use any data structure that can represent whether the slot is in an occupied or idle state, such as an occupancy set, an idle linked list, or a reference count table.
[0033] S103: If the first static determination result is not static, then the first target slot is kept in the occupation status record, and the first static determination result is re-acquired according to the preset retry strategy until the first static determination result is static or the preset retry limit is reached. The preset retry strategy refers to the pre-configured rules for reacquiring the judgment result when the first staticity determination result is not static. It specifies the timing of reacquisition and the conditions for stopping reacquisition. The preset retry limit refers to the termination limit for allowing reacquisition of the judgment result, which can be expressed as either the maximum number of retries or the maximum retry duration.
[0034] In this step, when the first staticity determination result is not static, the state of the first target slot is not rewritten in the occupied state record, so that it continues to remain occupied and is not published as a reusable slot, and will not be used by subsequent allocation requests. Then, according to the preset retry strategy, after waiting for a certain period of time, the first staticity determination result is obtained again, and the above judgment is repeated based on the re-obtained result, until the first staticity determination result obtained is static, and the process proceeds to S102 to perform state switching, or until the preset retry limit is reached, and the process proceeds to S104 to perform degradation processing.
[0035] It should be noted that the triggering method for reacquisition can be either synchronous polling initiated periodically by the orchestrator or an event-driven method triggered by a callback when the static determination result of the network block device by the underlying detection component becomes available or becomes static.
[0036] As can be seen, this step maintains the occupied state while the equipment is not stationary and re-acquires the judgment result according to the strategy, so that the slot status is continuously tracked as the asynchronous dismantling of the equipment progresses. Once the asynchronous dismantling is completed, the slot can be returned without manual intervention.
[0037] As a feasible implementation, the step of reacquiring the first staticity determination result according to a preset retry strategy includes: waiting for a preset retry interval and then reacquiring the first staticity determination result; wherein the preset retry interval is determined based on a fixed interval and / or the number of reacquisitions; and stopping the reacquisition of the first staticity determination result when the number of reacquisitions reaches the maximum number of retryes, or when the time elapsed since the first acquisition of the first staticity determination result reaches the maximum retry time.
[0038] The preset retry interval refers to the waiting time between two consecutive acquisitions of the stillness determination result. The fixed interval means waiting for the same amount of time before each re-acquisition. The number of re-acquisitions refers to the cumulative number of times the stillness determination result has been acquired since the first acquisition. The maximum number of retries refers to the maximum number of times the stillness determination result is allowed to be acquired again. The longest retry duration refers to the longest time allowed to elapse since the first acquisition of the stillness determination result.
[0039] In the specific implementation, firstly, after the initial staticity determination result is "not static," the time of this acquisition is recorded, and the reacquisition count is set to one. Then, a preset retry interval is waited for. This preset retry interval can be a fixed interval, such as reacquiring every 100 milliseconds; it can also be determined based on the number of reacquisitions, with the preset retry interval being positively correlated with the number of reacquisitions, for example, increasing sequentially to 100 milliseconds, 200 milliseconds, and 400 milliseconds with the number of reacquisitions; or it can be determined by adding a fixed interval to an interval that increases with the number of reacquisitions, for example, adding an integer multiple of 100 milliseconds based on the number of reacquisitions to a fixed interval of 100 milliseconds. Next, when the preset retry interval expires, the initial staticity determination result is reacquired, and the reacquisition count is incremented by one. Finally, when the number of reacquisitions reaches the maximum retry count, or when the elapsed time since the initial acquisition of the initial staticity determination result reaches the maximum retry duration, reacquiring the initial staticity determination result stops, and a downgrade process begins.
[0040] As can be seen, this implementation method, by setting dual stop conditions for the number of retries and the duration, not only allows sufficient completion time for asynchronous teardown, but also avoids individual slots occupying retry resources for a long time.
[0041] S104: When the preset retry limit is reached, the first target slot is processed according to the preset degradation strategy.
[0042] Among them, the preset degradation strategy refers to the pre-configured rules for processing the slot when the preset retry limit is reached. Its purpose is to prevent the release process from being blocked indefinitely because individual slots cannot be determined to be stationary for a long time.
[0043] In this step, when the preset retry limit is reached, the first static determination result will no longer be obtained again. Instead, the first target slot will be processed according to the preset degradation strategy, so that the release process can continue to proceed. At the same time, the abnormal state of the slot will be recorded for subsequent review.
[0044] As can be seen, this step, by setting an upper limit for retry and providing corresponding degradation processing, binds the state transition with the asynchronous teardown of the device, while ensuring that the release process is not blocked, and that the slots in the device pool can continue to circulate without being gradually exhausted.
[0045] As a possible implementation, the step of processing the first target slot according to the preset degradation strategy includes: recording alarm information for the first target slot and switching the first target slot from occupied state to idle state in the occupancy status record; or, writing the first target slot into the task queue of an independent compensation task so as to re-obtain the static determination result of the first target slot through the independent compensation task.
[0046] The alarm information refers to the record of an abnormal situation where the first target slot is not determined to be stationary even after reaching the preset retry limit. Its content includes at least the device serial number of the slot, the identifier of the corresponding network block device, the number of retries, and the cumulative duration. The independent compensation task refers to an asynchronous processing task independent of the release process. It has its own task queue and is used to perform subsequent verification of the slot's stationaryness determination result outside the main process.
[0047] In practical implementation, the first target slot can be handled using one of the following two methods. The first method involves recording the alarm information for the first target slot, then switching the slot from occupied to idle in the occupancy status record, thus completing the release process. This method is suitable for scenarios prioritizing the release process. The second method involves not rewriting the slot's status in the occupancy status record, but instead writing the slot's identifier into the task queue of an independent compensation task. The independent compensation task then retrieves the slot's static status determination result during its own execution cycle, and switches the slot to idle only when the result indicates it is static. This method is suitable for scenarios prioritizing reuse safety. Alternatively, the slot can be temporarily isolated from the device pool and then added back later, ensuring it neither participates in this release nor is allocated. It should be noted that the recording of the alarm information and the handover of the independent compensation task can be performed individually or simultaneously.
[0048] As can be seen, this implementation provides two types of exits for over-limit slots: alarm clearing and asynchronous compensation. This ensures that the release process is not blocked, while abnormal slots can still be reviewed outside the main process.
[0049] In a preferred embodiment, after obtaining the first static determination result of the first target network block device corresponding to the first target slot, the method further includes: if the first static determination result is not obtained, then reading the capacity value of the first target network block device; when the capacity value is zero, switching the first target slot from occupied state to idle state in the occupancy status record.
[0050] The capacity value refers to the current external capacity of the network block device, which returns to zero when the device is disconnected from the backend storage and no longer carries data. "No first quiescent determination result obtained" means that the underlying detection component failed to return a quiescent determination result for the device; for example, the local kernel did not export the signal on which the determination depends, or the underlying detection component returned a flag indicating a missing determination.
[0051] In this embodiment, firstly, after obtaining the first static determination result of the first target network block device, it is determined whether the result is available. When the underlying detection component cannot provide a determination, it returns a flag indicating a missing determination, rather than returning an error, to distinguish this situation from the situation where it is determined to be not static. Subsequently, if the first static determination result is not obtained, the capacity value of the network block device is read. Then, when the capacity value is zero, it is determined that the device is no longer carrying data, and the first target slot is switched from occupied to idle in the occupancy status record, allowing the return process to continue.
[0052] It should be noted that, in addition to advancing by resetting the capacity value to zero, a rollback method can also be adopted, which involves waiting for a fixed bounded time in silence before releasing the slot. Alternatively, a rollback method can be adopted, which involves marking the slot as degraded and adding additional monitoring to it. This embodiment does not limit the specific form of the rollback method.
[0053] As can be seen, this implementation method continues to advance the regression criterion when the static determination result is unavailable, so that the device pool will not be stuck due to waiting for a determination result that will never appear, thereby making it compatible with different underlying environments.
[0054] The network block device slot management method provided in this application, when releasing a first target slot in the device pool, first obtains the first inactivity determination result of the first target network block device, and binds the action of switching the slot from occupied state to idle state in the occupancy status record to whether the asynchronous teardown of the device has been completed. Since the first inactivity determination result indicates whether the asynchronous teardown of the device has been completed, it reflects the actual closing status of whether the device can be safely reused. Therefore, only when the first inactivity determination result is inactive, the first target slot is switched from occupied state to idle state in the occupancy status record and determined as a reusable slot. When the slot is made available for use again, there will be no conflict between new read / write requests and the closing processing of the device. This avoids large-scale input / output errors and the resulting large number of duplicate error logs. When the first staticity determination result is not static, the first target slot remains in the occupied state in the occupied state record and is not switched to the idle state, thus it will not be used. The orchestrator re-acquires the first staticity determination result according to the preset retry strategy, so that the determination result is continuously tracked as the dismantling action progresses. Once the asynchronous dismantling is completed, the state switch and return are completed without manual intervention. On this basis, the re-acquisition action has a preset retry limit. When the preset retry limit is reached, the first target slot is processed according to the preset degradation strategy, so that individual slots that cannot be determined to be static for a long time will not remain in the release process for a long time, and the slots in the device pool can continue to circulate without being gradually exhausted. It can be seen that the embodiments of this application ensure the safe reuse of network block device slots while avoiding the blockage of the release process.
[0055] This application discloses another method for network block device slot management. See [link to relevant documentation] Figure 2 A flowchart illustrating another network block device slot management method according to an exemplary embodiment, such as... Figure 2 As shown, it includes: S201: In response to the slot allocation request, determine the second target slot that is in an idle state according to the occupancy status record, and obtain the second inactivity determination result of the second network block device corresponding to the second target slot; Here, a slot allocation request refers to a request to retrieve an idle slot from the device pool, initiated by the user who needs to mount the root file system image. The second target slot refers to the idle slot to be allocated, determined based on the occupancy status record. The second network block device refers to a network block device instance corresponding to the second target slot. The second quiescent determination result refers to the conclusion indicating whether the asynchronous teardown of the second network block device has been completed; its value also includes both "quiescent" and "not quiescent."
[0056] In this step, after receiving the slot allocation request, the second target slot that is currently in an idle state is first determined based on the occupancy status record. For example, the slot corresponding to a bit with a value of the second value is taken from the occupancy bit map, and the identifier of the slot is taken from the set of idle slots. Then, before establishing the connection, the second inertia determination result of the second network block device corresponding to the slot is obtained to verify whether the slot can be safely reused.
[0057] It should be noted that the execution intensity of the review can be configured as needed. It can be executed every time a slot is allocated, or it can be executed only for slots that have been released too recently or have reached the preset retry limit, thus striking a trade-off between reuse security and acquisition overhead. It should also be noted that the above pool management strategy can be implemented on a single host machine, or the upper-layer scheduler can uniformly manage the device pool occupancy view across multiple hosts. During cross-host migration or rescheduling, the release and reallocation of slots are still constrained by the static determination.
[0058] As can be seen, this step, by adding a verification process after retrieving the free slot and before establishing the connection, ensures that any misjudgment on the release side will not be directly transmitted to the user in this case.
[0059] S202: If the second static determination result is that it is static, then the second target slot is switched from idle state to occupied state in the occupancy status record, a connection is established for the second target slot, and the second target slot is assigned to the requester of the slot allocation request.
[0060] Establishing a connection for a slot refers to connecting the network block device corresponding to the second target slot with the backend storage, enabling the image mapped to that slot to be read and written. The requester is the party initiating this slot allocation request, which is typically the microvirtual machine corresponding to the sandbox to be created.
[0061] In this step, when the second staticity determination result is "static," the second target slot is first switched from an idle state to an occupied state in the occupancy status record. For example, the bit corresponding to the slot in the occupancy bitmap is changed from the second value to the first value. Then, a connection is established for the slot, and after the connection is successfully established, the second target slot is allocated to the requester of this slot allocation request for reading and writing after mounting the root file system image. When the second staticity determination result is "not static," a connection is not established for the slot, and the slot is returned, or another idle slot is selected and the above verification process is repeated.
[0062] Therefore, this embodiment obtains a second static determination result after the slot is taken out and before the connection is established for verification. This allows the release side and the allocation side to perform a verification on whether the slot can be used safely, thus forming a double verification. This further prevents the situation where a single judgment error is transmitted to a new user and improves the correctness of slot reuse.
[0063] This application discloses yet another method for managing network block device slots; see [link to relevant documentation]. Figure 3 A flowchart illustrating another network block device slot management method according to an exemplary embodiment is shown below. Figure 3 As shown, it includes: S301: After the orchestrator restarts, obtain the third static determination result of the third network block device; wherein, the third network block device is a network block device that has been allocated a third target slot before the orchestrator restarts, and the third target slot is in an occupied state in the occupancy status record; The third network block device refers to a network block device that has been allocated a third target slot before the orchestrator restarts, and that slot is still recorded as occupied in the occupancy status record. This type of device belongs to the leaked devices that the previous generation orchestrator process failed to return properly. The third static determination result refers to the determination conclusion that characterizes whether the asynchronous teardown of the third network block device has been completed.
[0064] In this step, after the orchestrator restarts, the occupancy status records are traversed first, and the network block devices corresponding to the slots that are still in an occupied state are identified as third network block devices. Then, for each third network block device, its third inactivity determination result is obtained, rather than judging whether it can be reclaimed simply based on whether the device still has a connection.
[0065] S302: If the third static determination result is static, then the third target slot is switched from occupied to idle in the occupancy status record, and the third network block device is re-included in the device pool; In this step, when the third static determination result is static, the third target slot corresponding to the third network block device is switched from occupied to idle in the occupancy status record. For example, the corresponding bit in the occupancy bitmap is changed from the first value to the second value. At the same time, the third network block device is reinstated into the device pool so that it can participate in subsequent allocation again.
[0066] S303: If the third staticity determination result is not static, then the occupancy status of the third target slot in the occupancy status record is maintained, and the third staticity determination result is re-acquired according to the preset retry strategy.
[0067] In this step, when the third staticity determination result is not static, the third target slot is kept in the occupancy status record, it is not re-included in the equipment pool, nor is it published as a reusable slot, and the third staticity determination result is obtained again according to the same preset retry strategy as the release side, until the result is static or the preset retry limit is reached.
[0068] Therefore, this embodiment uses the third static determination result as the basis for recycling after the orchestrator restarts, and keeps the non-static slots occupied and re-determines them according to the same retry strategy. This ensures that the leaked devices left over from the previous generation process can be recycled to replenish the device pool, and will not be reassigned before the asynchronous dismantling is completed. This guarantees the correctness of slot reuse in the restart scenario.
[0069] The following example, using the creation and destruction of sandboxes in a cloud-based code execution platform, illustrates an application embodiment provided in this application. The platform creates a sandbox implemented as a micro-virtual machine for each task, and its root file system image is mounted via a network block device.
[0070] See Figure 4 , Figure 4 The flowchart of the static lifecycle management method for sandbox pools provided in the application embodiment of this application is organized into two branches: sandbox destruction and sandbox creation, as follows: In the sandbox destruction / release branch, S10 is executed first to complete the dismantling and initiate a release request: During sandbox destruction, the dismantling actions such as data write-back, buffer invalidation, descriptor closure, and connection disconnection are completed first. Then, a release request is initiated for the slot, entering the release-side orchestration. Next, S20 is executed to retrieve the stationary determination and determine if the device is stationary: The release side does not directly clear the occupied bit, but first obtains the stationary determination of the device. When the device is stationary, S30 is executed to clear the occupied bit of the slot in the occupied bitmap, return the slot to the device pool, and publish it as idle and reusable. When the device is not stationary, S40 is executed. The slot is not returned, and its occupied bit remains unchanged. A new stationary determination is retrieved and S20 is re-evaluated according to the backoff and upper limit strategy. In the diagram, the arrow indicating retry and re-evaluation points from S40 back to S20. When the retry limit is reached, the slot is handled by alarm plus local clearing or handover compensation.
[0071] In the sandbox creation and allocation branch, execute S50. First, take an empty slot from the occupied bitmap, then perform a pre-connection check to determine whether the obtained static determination passes. If the check passes, allocate the slot and connect the mirror. If the check fails, return to the slot or select another empty slot and re-execute the pre-connection check.
[0072] Furthermore, it includes two types of supplementary actions. One type is S60, which is restart reclaim. After the orchestrator restarts, it reclaims the previous generation of leaked devices based on the static determination. Leaked device reclaim refers to the process of cleaning up the network block devices left over from the previous generation process but not properly returned after the orchestrator restarts and re-incorporating them into the device pool. The other type is S70, which is missing determination rollback. When the static determination is not available, the degradation criterion continues to advance, so that the device pool does not get stuck.
[0073] In the above scenario, the static return on the sandbox destruction side and the pre-connection verification on the sandbox creation side work together on the same occupied bitmap, so that the scarce network block device slots are both returned in a timely manner and reused securely under the high-frequency creation and destruction of the sandbox, and the device pool is neither stuck nor exhausted.
[0074] The following describes a network block device slot management device provided in an embodiment of this application. The network block device slot management device described below and the network block device slot management method described above can be referred to each other.
[0075] See Figure 5 A structural diagram of a network block device slot management device is shown according to an exemplary embodiment, as follows: Figure 5 As shown, it includes: The first acquisition module 100 is used to acquire a first static determination result of the first target network block device corresponding to the first target slot when releasing the first target slot in the device pool; wherein, the first static determination result indicates whether the asynchronous teardown of the first target network block device has been completed. The first switching module 200 is used to switch the first target slot from occupied state to idle state in the occupancy status record when the first static determination result is that it is stationary, and to determine the first target slot as a reusable slot. The first retry module 300 is used to maintain the occupancy status of the first target slot in the occupancy status record when the first staticity determination result is not static, and re-acquire the first staticity determination result according to the preset retry strategy until the first staticity determination result is static or the preset retry limit is reached. The degradation module 400 is used to process the first target slot according to a preset degradation strategy when the preset retry limit is reached.
[0076] The network block device slot management device provided in this application embodiment obtains the first static status determination result of the first target network block device when releasing the first target slot in the device pool. The action of switching the slot from an occupied state to an idle state in the occupancy status record is linked to whether the asynchronous teardown of the device has been completed. Since the first static status determination result indicates whether the asynchronous teardown of the device has been completed, reflecting the actual closing status of whether the device can be safely reused, the first target slot is only switched from an occupied state to an idle state in the occupancy status record and determined as a reusable slot when the first static status determination result indicates static status. When the slot is reused, there will be no conflict between new read / write requests and the device's closing processing. This avoids large-scale input / output errors and the resulting large number of duplicate error logs. When the first staticity determination result is not static, the first target slot remains in the occupied state in the occupied state record and is not switched to the idle state, thus it will not be used. The orchestrator re-acquires the first staticity determination result according to the preset retry strategy, so that the determination result is continuously tracked as the dismantling action progresses. Once the asynchronous dismantling is completed, the state switch and return are completed without manual intervention. On this basis, the re-acquisition action has a preset retry limit. When the preset retry limit is reached, the first target slot is processed according to the preset degradation strategy, so that individual slots that cannot be determined to be static for a long time will not remain in the release process for a long time, and the slots in the device pool can continue to circulate without being gradually exhausted. It can be seen that the embodiments of this application ensure the safe reuse of network block device slots while avoiding the blockage of the release process.
[0077] Based on the above embodiments, as a preferred implementation, the occupancy status record includes an occupancy bitmap, which uses bit markers to indicate the occupancy and idle status of each network block device slot; Accordingly, the first switching module 200 is specifically used to: rewrite the bit corresponding to the first target slot in the occupancy bitmap from a first value used to indicate the occupancy state to a second value used to indicate the idle state.
[0078] Based on the above embodiments, as a preferred implementation, the first retry module 300 is specifically used to: wait for a preset retry interval, and then reacquire the first staticity determination result; wherein, the preset retry interval is determined according to a fixed interval and / or the number of reacquisitions; when the number of reacquisitions reaches the maximum number of retryes, or when the time elapsed since the first acquisition of the first staticity determination result reaches the maximum retry time, the reacquisition of the first staticity determination result is stopped.
[0079] Based on the above embodiments, as a preferred implementation, the degradation module 400 is specifically used to: record alarm information for the first target slot and switch the first target slot from occupied state to idle state in the occupancy status record; or, write the first target slot into the task queue of an independent compensation task so as to re-obtain the static determination result of the first target slot through the independent compensation task.
[0080] Based on the above embodiments, as a preferred embodiment, it further includes: The reading module is used to read the capacity value of the first target network block device when the first static determination result is not obtained; The second switching module is used to switch the first target slot from occupied to idle in the occupancy status record when the capacity value is zero.
[0081] Based on the above embodiments, as a preferred embodiment, it further includes: The second acquisition module is used to respond to the slot allocation request, determine the second target slot in the idle state according to the occupancy status record, and acquire the second inactivity determination result of the second network block device corresponding to the second target slot. The third switching module is used to switch the second target slot from an idle state to an occupied state in the occupied state record when the second static determination result is that it is static, and to establish a connection for the second target slot and allocate the second target slot to the requester of the slot allocation request.
[0082] Based on the above embodiments, as a preferred embodiment, it further includes: The third acquisition module is used to acquire the third static determination result of the third network block device after the orchestrator restarts; wherein the third network block device is a network block device that has been allocated a third target slot before the orchestrator restarts and the third target slot is in an occupied state in the occupancy status record; The fourth switching module is used to switch the third target slot from occupied to idle in the occupancy status record when the third static determination result is that it is static, and to re-include the third network block device in the device pool. The first retry module is used to maintain the occupancy status of the third target slot in the occupancy status record when the third staticity determination result is not static, and to re-acquire the third staticity determination result according to the preset retry strategy.
[0083] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0084] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 6 This is a structural diagram of an electronic device according to an exemplary embodiment, such as... Figure 6 As shown, the electronic device includes: Communication interface 1 enables information exchange with other devices, such as network devices; Processor 2 is connected to communication interface 1 to enable information interaction with other devices. When running a computer program, it executes the network block device slot management method provided by one or more of the above-mentioned technical solutions. The computer program is stored on memory 3.
[0085] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 6 The general will label all buses as Bus System 4.
[0086] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0087] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferroelectric random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0088] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in conjunction with its hardware.
[0089] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0090] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0091] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0092] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, 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 and includes several instructions to cause an electronic device (which may be a personal computer, server, network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0093] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for managing network block device slots, characterized in that, Applied to an orchestrator, the method includes: When releasing the first target slot in the device pool, a first static determination result of the first target network block device corresponding to the first target slot is obtained; wherein, the first static determination result indicates whether the asynchronous teardown of the first target network block device has been completed; If the first static determination result is that it is static, then the first target slot is switched from occupied to idle in the occupancy status record, and the first target slot is determined as a reusable slot. If the first static determination result is not static, then the first target slot is kept in the occupation status record, and the first static determination result is re-acquired according to the preset retry strategy until the first static determination result is static or the preset retry limit is reached. When the preset retry limit is reached, the first target slot is processed according to the preset degradation strategy.
2. The network block device slot management method according to claim 1, characterized in that, The occupancy status record includes an occupancy bitmap, which uses bit markers to indicate the occupancy and idle status of each network block device slot. Accordingly, switching the first target slot from occupied to idle in the occupancy status record includes: In the occupancy bitmap, the bit corresponding to the first target slot is rewritten from a first value indicating the occupancy state to a second value indicating the idle state.
3. The network block device slot management method according to claim 1, characterized in that, The first staticity determination result is reacquired according to the preset retry strategy, including: After waiting for a preset retry interval, the first static determination result is reacquired; wherein, the preset retry interval is determined based on a fixed interval and / or the number of reacquisitions; When the number of re-acquisitions reaches the maximum number of retries, or when the time elapsed since the first acquisition of the first staticity determination result reaches the maximum retry time, the acquisition of the first staticity determination result shall be stopped.
4. The network block device slot management method according to claim 1, characterized in that, The first target slot is processed according to a preset degradation strategy, including: Record the alarm information for the first target slot, and switch the first target slot from occupied to idle in the occupancy status record; Alternatively, the first target slot can be written into the task queue of an independent compensation task so that the static determination result of the first target slot can be retrieved again through the independent compensation task.
5. The network block device slot management method according to claim 1, characterized in that, After obtaining the first static determination result of the first target network block device corresponding to the first target slot, the method further includes: If the first static determination result is not obtained, then read the capacity value of the first target network block device; When the capacity value is zero, the first target slot is switched from occupied to idle in the occupancy status record.
6. The network block device slot management method according to claim 1, characterized in that, The method further includes: In response to the slot allocation request, a second target slot in an idle state is determined based on the occupancy status record, and a second inactivity determination result of the second network block device corresponding to the second target slot is obtained; If the second static determination result is that it is static, then the second target slot is switched from idle state to occupied state in the occupancy status record, a connection is established for the second target slot, and the second target slot is assigned to the requester of the slot allocation request.
7. The network block device slot management method according to claim 1, characterized in that, The method further includes: After the orchestrator restarts, the third static determination result of the third network block device is obtained; wherein, the third network block device is a network block device that has been allocated a third target slot before the orchestrator restarts, and the third target slot is in an occupied state in the occupancy status record; If the third static determination result is static, then the third target slot is switched from occupied to idle in the occupancy status record, and the third network block device is re-included in the device pool. If the third staticity determination result is not static, then the occupancy status of the third target slot in the occupancy status record is maintained, and the third staticity determination result is re-acquired according to the preset retry strategy.
8. A network block device slot management device, characterized in that, Applied to an orchestrator, the device includes: The first acquisition module is used to acquire a first static determination result of the first target network block device corresponding to the first target slot when releasing the first target slot in the device pool; wherein, the first static determination result indicates whether the asynchronous teardown of the first target network block device has been completed. The first switching module is used to switch the first target slot from occupied to idle in the occupancy status record when the first staticity determination result is that it is stationary, and to determine the first target slot as a reusable slot. The first retry module is used to maintain the occupancy status of the first target slot in the occupancy status record when the first staticity determination result is not static, and to re-acquire the first staticity determination result according to the preset retry strategy until the first staticity determination result is static or the preset retry limit is reached. The degradation module is used to process the first target slot according to a preset degradation strategy when the preset retry limit is reached.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the network block device slot management method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the network block device slot management method as described in any one of claims 1 to 7.
