A system, method, device and medium for invalidating cache data
By introducing the failed task management module and the failed task execution module in the storage system, the waiting timeout problem when batch failed cache data is solved, and efficient and reliable cached data failure processing is achieved.
Patent Information
- Application Number
- CN202210756398.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-06-30
AI Technical Summary
When the prior art fails in batches of multi-volume cache data, some subtasks may wait for timeout on busy CPUs, resulting in business interruption.
By introducing the failure task management module and the failure task execution module, the failure subtasks are scheduled and executed, and the efficient and reliable failure of cached data is ensured, and the multi-threaded task processing mechanism is avoided directly relying on the multi-threaded task processing mechanism.
The batch failure processing of cached data is realized to ensure efficient and reliable completion of tasks and avoid waiting timeouts and business interruptions.
Smart Images

Figure CN115033501B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a system, method, device and medium for invalidating cache data. Background Art
[0002] In the storage field, batch invalidation of cached data of multiple volumes is a common demand scenario, such as deleting volumes, rejoining a cluster after a node exits a multi-node storage device, etc. In the existing common implementation method, the invalidation tasks of each volume are generally run in parallel on the bound CPU, and in each task, the linked list of cached data blocks is maintained in the cache partition to invalidate the respective data.
[0003] At the same time, because the overall process of invalidation tasks is often long, in order to ensure the normal operation of other businesses, a whole volume invalidation task often needs to be split into multiple subtasks. However, due to reasons such as lock performance and different congestion levels of multiple CPUs processing invalidation tasks, this processing mechanism may cause some pre-scheduled subtasks to time out on a busier CPU, causing business interruption. As business requirements for storage device performance and availability continue to increase, a solution for batch processing of invalid cache data is urgently needed to solve the above problems. Summary of the invention
[0004] In view of this, the present invention proposes a system, method, device and medium for invalidating cache data, which ensures the efficient and reliable completion of batch invalidation cache data tasks through an invalidation task management module and an invalidation task execution module, so that multi-volume cache data invalidation tasks no longer directly rely on the original multi-threaded task processing mechanism, and therefore will not cause waiting timeouts, resulting in business interruptions and other problems.
[0005] Based on the above purpose, an embodiment of the present invention provides a system for invalidating cache data, and the system specifically includes:
[0006] Failure task management module and failure task execution module;
[0007] The failure task management module is configured to receive a failure request initiated by a volume, add the volume that initiated the failure request to a task request array under write lock protection, and schedule a failure subtask to execute the failure request;
[0008] The failure task execution module is configured to add all volumes in the task request array to the task execution array and clear the task request array when the failure subtask is performed;
[0009] The invalidation task execution module is further configured to traverse a linked list of cache data maintained in the cache partition to obtain cache data based on the linked list, and determine whether to invalidate the cache data based on whether the cache data belongs to a volume in the task execution array;
[0010] The failure task execution module is further configured to terminate the failure subtask in response to the traversal step reaching a threshold value, and record the traversal position to the first volume in the task progress array;
[0011] The failed task execution module is further configured to compare the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array;
[0012] The invalidation task execution module is further configured to determine whether the task request array and the task progress array are empty, and determine whether the invalidation task of the cache data is completed based on the determination result.
[0013] In some implementations, traversing a linked list of cache data maintained in a cache partition to obtain cache data based on the linked list includes:
[0014] A linked list for maintaining cache data in the cache partition is traversed, and cache data whose invalidation flag is FALSE is acquired based on the linked list.
[0015] In some implementations, determining whether to invalidate the cached data based on whether the cached data belongs to a volume in the task progress array includes:
[0016] Determine whether the cache data whose invalidation flag is FALSE belongs to a volume in the task progress array;
[0017] In response to the cache data whose invalidation flag is FALSE belonging to a volume in the task progress array, the invalidation flag of the cache data is set to TRUE.
[0018] In some implementations, comparing the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array includes:
[0019] In response to the completion of the execution of the invalid subtask, determining whether the traversal position is greater than or equal to the tail of the linked list;
[0020] In response to the traversal position being greater than or equal to the end of the linked list, the invalidation subtask of the first volume is terminated, and the first volume is removed from the task array;
[0021] In response to the traversal position being not greater than or equal to the end of the linked list, a message is sent to the failed task management module to notify the failed task management module to schedule a new subtask to continue executing the volume in the task progress array.
[0022] In some implementations, determining whether the task request array and the task progress array are empty, and determining whether the cache data invalidation task is completed based on the determination result includes:
[0023] Determine whether the task request array and the task progress array are empty;
[0024] In response to the task request array being empty and the task progress array being empty, the cache data invalidation task is terminated;
[0025] In response to the task request array being not empty and the task progress array being not empty or the task request array being not empty and the task progress array being empty or the task request array being empty and the task progress array being not empty, the failed task management module is notified to schedule a new subtask to continue executing the volumes in the task progress array.
[0026] In some implementations, the failed task management module is further configured to mark the status of the failed task management module accordingly based on the scheduling and execution status of the failed subtasks.
[0027] In some implementations, the states of the failed task management module include an idle state, a scheduling state, an execution state, and a waiting scheduling state.
[0028] Another aspect of the embodiment of the present invention further provides a method for invalidating cache data, including:
[0029] Based on the failure task management module, the failure request initiated by the volume is received, and the volume initiating the failure request is added to the task request array under the protection of the write lock, and the failure subtask is scheduled to execute the failure request;
[0030] When the failure subtask is being performed, all volumes in the task request array are added to the task execution array based on the failure task execution module, and the task request array is cleared;
[0031] Traversing a linked list of cache data maintained in a cache partition based on the invalidation task execution module to obtain cache data based on the linked list, and determining whether to invalidate the cache data based on whether the cache data belongs to a volume in the task execution array;
[0032] In response to the traversal step reaching a threshold, ending the failed subtask based on the failed task execution module, and recording the traversal position to the first volume in the task progress array;
[0033] Based on the failed task execution module, the traversal position is compared with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue to execute the volume in the task progress array;
[0034] Based on the invalidation task execution module, it is determined whether the task request array and the task progress array are empty, and based on the determination result, it is determined whether the invalidation task of the cache data is completed.
[0035] According to another aspect of an embodiment of the present invention, a computer device is provided, comprising: at least one processor; and a memory, wherein the memory stores a computer program executable on the processor, and the computer program implements the steps of the above method when executed by the processor.
[0036] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, which stores a computer program that implements the above method steps when executed by a processor.
[0037] The present invention has at least the following beneficial technical effects: the cache data invalidation request (i.e., invalidation task) of one or more volumes of the unified cache partition is scheduled to the corresponding subtask according to the traversal step length through the invalidation task management module and handed over to the invalidation task execution module for execution, thereby realizing batch invalidation processing of cache data and ensuring that batch invalidation processing of cache data can be completed efficiently and reliably, so that the multi-volume cache data invalidation task is no longer directly dependent on the original multi-threaded task processing mechanism, and there will be no waiting timeout, resulting in business interruption and other problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A schematic diagram of an embodiment of a system for invalidating cache data provided by the present invention;
[0040] Figure 2 A schematic diagram of an embodiment of the state transition of the failed task management module provided by the present invention;
[0041] Figure 3 A flowchart of an embodiment of the present invention based on the invalidation task management module and the invalidation execution management module invalidation cache data;
[0042] Figure 4 A schematic diagram of another embodiment of the state transition of the failed task management module provided by the present invention;
[0043] Figure 5 A schematic diagram of another embodiment of the state transition of the failed task management module provided by the present invention;
[0044] Figure 6 A schematic diagram of another embodiment of the state transition of the failed task management module provided by the present invention;
[0045] Figure 7 A block diagram of an embodiment of a method for invalidating cache data provided by the present invention;
[0046] Figure 8 A schematic diagram of the structure of an embodiment of a computer device provided by the present invention;
[0047] Fig. 9 A schematic diagram of the structure of an embodiment of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION
[0048] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0049] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. The subsequent embodiments will not explain this one by one.
[0050] Based on the above purpose, the first aspect of the embodiments of the present invention provides an embodiment of a system for invalidating cache data. Figure 1 As shown, the system specifically includes: a failure task management module 10 and a failure task execution module 20;
[0051] The failure task management module 10 is configured to receive a failure request initiated by a volume, add the volume that initiated the failure request to a task request array under write lock protection, and schedule a failure subtask to execute the failure request;
[0052] The failure task execution module 20 is configured to add all volumes in the task request array to the task execution array and clear the task request array when the failure subtask is performed;
[0053] The invalidation task execution module 20 is further configured to traverse a linked list of cache data maintained in the cache partition to obtain cache data based on the linked list, and determine whether to invalidate the cache data based on whether the cache data belongs to a volume in the task execution array;
[0054] The failure task execution module 20 is further configured to terminate the failure subtask in response to the traversal step reaching a threshold, and record the traversal position to the first volume in the task progress array;
[0055] The failed task execution module 20 is further configured to compare the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array;
[0056] The invalidation task execution module 20 is further configured to determine whether the task request array and the task progress array are empty, and determine whether the invalidation task of the cache data is completed based on the determination result.
[0057] Specifically, the cache partition where the volume that needs to be invalidated is located is bound to the invalidation task management module and the invalidation task execution module. The invalidation task of the cache data in the specific volume is scheduled and executed by the invalidation task management module and the invalidation task execution module bound to the cache partition. Based on this, the multi-volume cache data invalidation task is no longer directly dependent on the original multi-threaded task processing mechanism.
[0058] The failure task management module determines whether a new failure task needs to be scheduled based on the task status constraints. Figure 2 The figure shows a state transition diagram of the failure task management module.
[0059] The states of the failed task management module include the idle state IDLE, the scheduling state WILL_RUN, the execution state RUNNING, and the waiting scheduling state WILL_RUN_AGAIN.
[0060] When the status is IDLE, it means that there is no invalid task at present and a new task can be scheduled; when the status is WILL_RUN, it means that an invalid subtask has been scheduled, that is, it exists in the thread waiting queue of a certain CPU; RUNNING means that an invalid subtask is in progress; when the status is WILL_RUN_AGAIN, it means that a new subtask will be rescheduled on the current CPU after the currently executed subtask is completed.
[0061] The state transition of the failure task management module is explained through the following process.
[0062] The failure task management module determines whether there is a failure task currently being executed. Assuming that there is no failure task currently, the status of the failure task management module is marked as IDLE; at this time, upon receiving the failure request initiated by the volume, the failure task management module schedules the failure subtask and changes the status of the failure task management module from IDLE to WILL_RUN; after the failure task management module schedules the subtask, when a CPU is executing the failure subtask, the status of the failure task management module is changed from WILL_RUN to RUNNING; when the subtask is being executed, if a failure request is received from other volumes, the status of the failure task management module is changed from RUNNING to WILL_RUN_AGAIN; when the subtask ends, if the failure requests of all volumes have been executed, the status of the failure task management module is changed from RUNNING to IDLE.
[0063] The above describes the state transition of the failure task management module based on the failure request, the scheduling of the failure subtask and the execution request. The state transition of the failure task management module is modified according to the application scenario during the actual application process, including but not limited to the above process.
[0064] The following describes the invalidation process of cache data based on the invalidation task management module and the invalidation task execution module.
[0065] Invalidation task management module: When a volume on the cache partition needs to invalidate cache data, it is first added to the task request array under write lock protection, and a new subtask is scheduled. Based on the current invalidation task execution status, the status of the invalidation task management module is changed to WILL_RUN or WILL_RUN_AGAIN. The organization and execution of subtasks are handed over to the invalidation task execution module.
[0066] Invalidation task execution module: When a new invalidation subtask is in progress, first store the volumes in the task request array into the task progress array and empty the task request array. Then traverse the partition linked list, find the cache data with the invalidation flag bit as FALSE (that is, valid cache data) based on the linked list, and determine whether the valid cache data belongs to the volume in the task progress array. If it does, invalidate it and set the invalidation flag bit to TRUE. After a invalidation subtask reaches the traversal step, end this subtask and record the traversal position to the first volume of the task progress array.
[0067] At the end of a certain invalidation subtask, if the recorded traversal position is greater than or equal to the tail position of the cache partition linked list, the volume cache data is invalidated and removed from the task array; if the recorded traversal position is less than the tail position of the partition linked list or there are still volumes that need to be invalidated in the task array, a new subtask is scheduled to continue the above process. The task of batch invalidation of cache data is completed until both the task array and the task request array are empty.
[0068] The above solution can invalidate all volumes under the same cache partition. Since the invalidation task management module and the invalidation task are bound to the cache partition as execution modules, the volumes under multiple cache partitions can also be invalidated at the same time based on the above solution.
[0069] The above scheme uses the invalidation task management module to schedule the cache data invalidation requests (i.e., invalidation tasks) of one or more volumes of the unified cache partition according to the traversal step length and hand them over to the invalidation task execution module for execution, thereby realizing batch invalidation processing of cache data and ensuring that batch invalidation processing of cache data can be completed efficiently and reliably, so that the multi-volume cache data invalidation task no longer directly relies on the original multi-threaded task processing mechanism, and there will be no waiting timeouts, resulting in business interruptions and other problems.
[0070] In some implementations, traversing a linked list of cache data maintained in a cache partition to obtain cache data based on the linked list includes:
[0071] A linked list for maintaining cache data in the cache partition is traversed, and cache data whose invalidation flag is FALSE is acquired based on the linked list.
[0072] In some implementations, determining whether to invalidate the cached data based on whether the cached data belongs to a volume in the task progress array includes:
[0073] Determine whether the cache data whose invalidation flag is FALSE belongs to a volume in the task progress array;
[0074] In response to the cache data whose invalidation flag is FALSE belonging to a volume in the task progress array, the invalidation flag of the cache data is set to TRUE.
[0075] In some implementations, comparing the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array includes:
[0076] In response to the completion of the execution of the invalid subtask, determining whether the traversal position is greater than or equal to the tail of the linked list;
[0077] In response to the traversal position being greater than or equal to the end of the linked list, the invalidation subtask of the first volume is terminated, and the first volume is removed from the task array;
[0078] In response to the traversal position being not greater than or equal to the end of the linked list, a message is sent to the failed task management module to notify the failed task management module to schedule a new subtask to continue executing the volume in the task progress array.
[0079] In some implementations, determining whether the task request array and the task progress array are empty, and determining whether the cache data invalidation task is completed based on the determination result includes:
[0080] Determine whether the task request array and the task progress array are empty;
[0081] In response to the task request array being empty and the task progress array being empty, the cache data invalidation task is terminated;
[0082] In response to the task request array being not empty and the task progress array being not empty or the task request array being not empty and the task progress array being empty or the task request array being empty and the task progress array being not empty, the failed task management module is notified to schedule a new subtask to continue executing the volumes in the task progress array.
[0083] The invalidation process of cache data is described below through another embodiment.
[0084] like Figure 3 As shown, it is a flowchart of invalidating cache data based on the invalidation task management module and the invalidation execution management module.
[0085] The specific implementation process is as follows:
[0086] 1) The failure task management module adds the volume to be failed to the task request array under write lock protection (only once when the volume granularity initiates the task), schedules the failure subtask, and modifies the status of the failure task management module to WILL_RUN or WILL_RUN_AGAIN according to the current status;
[0087] 2) In the invalidation task execution module, when a new subtask is executed, the volumes in the task request array are added to the task execution array, the linked list of cache data maintained in the cache partition is traversed, the cache data of the volumes that have not been invalidated and belong to the task execution array are invalidated, and the invalidated cache data is marked as invalid, so as to improve the traversal efficiency;
[0088] 3) In each failure subtask, when the set traversal step is reached, the failure subtask ends and the traversal end position is recorded in the first volume of the task progress array;
[0089] 4) When the recorded traversal end position is greater than or equal to the tail position of the linked list of the cache data maintained in the cache partition, the volume cache data is invalidated and removed from the task queue;
[0090] 5) When the recorded traversal position is less than the tail position of the partition linked list, or there are still volumes that need to be invalidated in the task progress array, the invalidation task management module is notified to schedule a new subtask to continue the above steps;
[0091] 6) When both the task progress array and the task request array are cleared, the task of batch invalidation of cache data is completed.
[0092] The above solution implements batch invalidation processing of cache data, improves invalidation efficiency, and ensures that batch invalidation processing of cache data can be completed efficiently and reliably.
[0093] In some implementations, the failed task management module is further configured to mark the status of the failed task management module accordingly based on the scheduling and execution status of the failed subtasks.
[0094] In some implementations, the states of the failed task management module include an idle state, a scheduling state, an execution state, and a waiting scheduling state.
[0095] The state transition of the failed task management module is described below through another embodiment.
[0096] like Figure 4 , Figure 5 , Figure 6 The figure shows a schematic diagram of the state transition of the failure task management module in different scenarios.
[0097] Scenario 1: When an invalidation subtask is in progress, the invalidation task execution module is traversing the invalidation data of the cache partition. If the invalidation task management module receives an invalidation request for a new volume under the same cache partition, the new volume is added to the task request array. When the invalidation task execution module completes the execution of the subtask, the message of the completion of the subtask execution is sent to the invalidation task management module. The invalidation task management module calls the new subtask and determines that the current state is WILL_RUN_AGAIN, and changes its state to WILL_RUN.
[0098] Scenario 2: When a failure subtask is in progress, the failure task execution module is traversing the failure data of the cache partition. After the failure task execution module completes the execution of the subtask, the failure task execution module determines that there are still volumes in the task array, and then sends the message to the failure task management module. The failure task management module calls the new subtask, and determines that the current state is RUNNING, and changes its state to WILL_RUN.
[0099] Scenario three: When an invalidation subtask is in progress, the invalidation task execution module is traversing the invalidation data of the cache partition. After the invalidation task execution module completes the execution of the subtask, the invalidation task execution module determines that the task progress array is empty and the task request array is empty, then the message is sent to the invalidation task management module, the invalidation task management module calls the new subtask, and determines that the current state is RUNNING, and changes its state to RUNNING.
[0100] Based on the same inventive concept, according to another aspect of the present invention, Figure 7 As shown, an embodiment of the present invention also provides a method for invalidating cache data, comprising:
[0101] S10, receiving an invalidation request initiated by a volume based on an invalidation task management module, adding the volume initiating the invalidation request to a task request array under write lock protection, and scheduling an invalidation subtask to execute the invalidation request;
[0102] S20, when the failure subtask is being performed, all volumes in the task request array are added to the task execution array based on the failure task execution module, and the task request array is cleared;
[0103] S30, traversing the linked list of cache data maintained in the cache partition based on the invalidation task execution module to obtain cache data based on the linked list, and determining whether to invalidate the cache data based on whether the cache data belongs to a volume in the task execution array;
[0104] S40, in response to the traversal step reaching a threshold, ending the failed subtask based on the failed task execution module, and recording the traversal position to the first volume in the task progress array;
[0105] S50, based on the failed task execution module comparing the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array;
[0106] S60: judging whether the task request array and the task progress array are empty based on the invalidation task execution module, and determining whether the invalidation task of the cache data is completed based on the judgment result.
[0107] Based on the same inventive concept, according to another aspect of the present invention, Figure 8 As shown, an embodiment of the present invention further provides a computer device 30, which includes a processor 310 and a memory 320. The memory 320 stores a computer program 321 that can be run on the processor. When the processor 310 executes the program, the steps of the above method are performed.
[0108] Among them, the memory, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as the program instructions / modules corresponding to the method for invalidating cache data in the embodiment of the present application. The processor executes various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory, that is, the method for invalidating cache data in the above method embodiment is implemented.
[0109] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the local module via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0110] Based on the same inventive concept, according to another aspect of the present invention, Fig. 9 As shown, an embodiment of the present invention further provides a computer-readable storage medium 40, which stores a computer program 410 for executing the above method when executed by a processor.
[0111] Finally, it should be noted that a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium of the program can be a disk, an optical disk, a read-only storage memory (ROM) or a random access memory (RAM), etc. The above-mentioned computer program embodiments can achieve the same or similar effects as the corresponding above-mentioned arbitrary method embodiments.
[0112] It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.
[0113] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope of the embodiments disclosed in the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. The serial numbers of the embodiments disclosed in the above embodiments of the present invention are for description only and do not represent the advantages and disadvantages of the embodiments. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.
[0114] It should be understood that, as used herein, the singular forms "a", "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations including one or more of the associated listed items.
[0115] A person skilled in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the concept of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the embodiments of the present invention as above, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.
Claims
1. A system for invalidating cache data, characterized in that: include: Failure task management module and failure task execution module; The failure task management module is configured to receive a failure request initiated by a volume, add the volume that initiated the failure request to a task request array under write lock protection, and schedule a failure subtask to execute the failure request; The failure task execution module is configured to add all volumes in the task request array to the task execution array and clear the task request array when the failure subtask is performed; The invalidation task execution module is further configured to traverse a linked list of cache data maintained in the cache partition to obtain cache data based on the linked list, and determine whether to invalidate the cache data based on whether the cache data belongs to a volume in the task execution array; The failure task execution module is further configured to terminate the failure subtask in response to the traversal step length reaching a threshold value, and record the traversal position to the first volume in the task progress array; The failed task execution module is further configured to compare the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array; The invalidation task execution module is further configured to determine whether the task request array and the task progress array are empty, and determine whether the invalidation task of the cache data is completed based on the determination result.
2. The system according to claim 1, characterized in that Traversing a linked list of cache data maintained in a cache partition to obtain cache data based on the linked list includes: A linked list for maintaining cache data in the cache partition is traversed, and cache data whose invalidation flag is FALSE is acquired based on the linked list.
3. The system according to claim 2, characterized in that Determining whether to invalidate the cached data based on whether the cached data belongs to a volume in the task execution array includes: Determine whether the cache data whose invalidation flag is FALSE belongs to a volume in the task progress array; In response to the cache data whose invalidation flag is FALSE belonging to a volume in the task progress array, the invalidation flag of the cache data is set to TRUE.
4. The system according to claim 1, characterized in that Comparing the traversal position with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue executing the volume in the task progress array includes: In response to the completion of the execution of the invalid subtask, determining whether the traversal position is greater than or equal to the tail of the linked list; In response to the traversal position being greater than or equal to the end of the linked list, the invalidation subtask of the first volume is terminated, and the first volume is removed from the task array; In response to the traversal position being not greater than or equal to the end of the linked list, a message is sent to the failed task management module to notify the failed task management module to schedule a new subtask to continue executing the volume in the task progress array.
5. The system according to claim 1, characterized in that Determining whether the task request array and the task progress array are empty, and determining whether the cache data invalidation task is completed based on the determination result includes: Determine whether the task request array and the task progress array are empty; In response to the task request array being empty and the task progress array being empty, the cache data invalidation task is terminated; In response to the task request array being not empty and the task progress array being not empty or the task request array being not empty and the task progress array being empty or the task request array being empty and the task progress array being not empty, the failed task management module is notified to schedule a new subtask to continue executing the volumes in the task progress array.
6. The system according to claim 1, characterized in that The failed task management module is further configured to mark the status of the failed task management module accordingly based on the scheduling and execution status of the failed subtasks.
7. The system according to claim 6, characterized in that The states of the failed task management module include an idle state, a scheduling state, an execution state, and a waiting scheduling state.
8. A method for invalidating cache data, characterized in that: include: Based on the failure task management module, the failure request initiated by the volume is received, and the volume initiating the failure request is added to the task request array under the protection of the write lock, and the failure subtask is scheduled to execute the failure request; When the failure subtask is being performed, all volumes in the task request array are added to the task execution array based on the failure task execution module, and the task request array is cleared; Traversing a linked list of cache data maintained in a cache partition based on the invalidation task execution module to obtain cache data based on the linked list, and determining whether to invalidate the cache data based on whether the cache data belongs to a volume in the task execution array; In response to the traversal step length reaching a threshold, ending the failed subtask based on the failed task execution module, and recording the traversal position to the first volume in the task progress array; Based on the failed task execution module, the traversal position is compared with the tail of the linked list to determine whether to remove the first volume from the task progress array and whether to notify the failed task management module to call a new subtask to continue to execute the volume in the task progress array; Based on the invalidation task execution module, it is determined whether the task request array and the task progress array are empty, and based on the determination result, it is determined whether the invalidation task of the cache data is completed.
9. A computer device comprising: at least one processor; as well as A memory storing a computer program executable on the processor, wherein the processor executes the steps of the method according to claim 8 when executing the program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to claim 8 are performed.
Citation Information
Patent Citations
Buffer array regularization method, device, terminal and readable medium
CN109344091A
Results cache invalidation
US9305056B1