Data request processing method, device, computer equipment and storage medium
By monitoring the cache occupation of water level and release the method to clean the data block when it exceeds its threshold, it solves the problem of increased data request delay when the cache space is full, and improves the performance of the storage system.
Patent Information
- Application Number
- CN202411367369.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-09-29
AI Technical Summary
In the storage system, if the cache space is full, cache replacement is required, resulting in an increase in the processing delay of data requests.
By obtaining the cache occupation water level, when it is higher than the preset threshold, it is determined to be cleaned up and releases the cache space it occupied to ensure that the data request can directly use the free cache space.
The processing delay of the data request is reduced, the read -writing performance of the storage system is improved, and the direct impact of the cache replacement process has on the data request.
Smart Images

Figure CN118897655B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data request processing method, device, computer equipment and storage medium. Background Art
[0002] In the process of the storage system responding to data requests, caching the IO (Input / Output) data corresponding to the data request to DRAM (Dynamic Random Access Memory) can improve the performance of the storage system. For example, for a write request, the data written to the cache can be responded to by the host. The data written to the cache is flushed to non-volatile media such as HDD (Hard Disk Drive) or SSD (Solid State Disk) that are slower than DRAM in the background, reducing the response time of the write request. For a read request, if the read data is in the cache, there is no need to read the data from storage media such as HDD or SSD. The data can be directly read from the cache and returned to the host, reducing the response time of the read request.
[0003] However, in the process of processing data requests, if the cache space is full, it is necessary to use the cache replacement algorithm to replace the existing data in the cache and then store new data in the cache. The time consumption of these processes is included in the processing time of the I / O process. The cache space is limited, and it is normal for the cache space to be full during the use of the storage system. Therefore, every data request involving cached data needs to handle the cache replacement process during the processing, which increases the delay in processing data requests. The processing delay of a large number of data requests can accumulate during the use of the storage system.
[0004] Therefore, the related art has a problem that during the process of processing a data request, if the cache space is full, replacing the existing data in the cache will cause an increase in the delay of processing the data request. Summary of the invention
[0005] In view of this, the present invention provides a data request processing method, apparatus, computer equipment and storage medium to solve the problem that in the process of processing data requests, if the cache space is full, replacing the existing data in the cache will cause an increase in the delay in processing the data request.
[0006] In a first aspect, the present invention provides a data request processing method, comprising:
[0007] Get the cache occupancy level;
[0008] When the cache occupancy level is higher than a preset threshold, determine the data blocks to be cleaned up, and release the cache space occupied by the data blocks to be cleaned up;
[0009] When a data request is received from the host, a target cache space is determined from free cache space in the cache, data corresponding to the data request is saved in the target cache space, and the data request is responded to.
[0010] The data request processing method provided in this embodiment determines the data blocks to be cleared and releases the cache space occupied by the data blocks to be cleared when the cache occupancy level is higher than a preset threshold. The cache replacement process is not included in the process of processing data requests, and the cache replacement processing time is not included in the time of processing data requests. In addition, by timely releasing the cache space occupied by the cleared data blocks, the free cache space in the cache can be directly used in the process of processing each data request, which can reduce the response time of data request processing. The processing delay of data requests is reduced, and the read and write performance of the storage system is improved. The problem that in the process of processing data requests, if the cache space is full, replacing the existing data in the cache will increase the delay in processing data requests is solved.
[0011] In some optional implementations, before obtaining the cache occupancy watermark, the method further includes:
[0012] Get the number of threads that handle cache replacement tasks;
[0013] A first preset number of data block processing queues are generated according to the number of threads, wherein the data block processing queues are used to determine and release data blocks to be cleared.
[0014] In this embodiment, a first preset number of data block processing queues are generated according to the number of threads processing cache replacement tasks, and the data block processing queues are used to manage the data blocks, determine and release the data blocks to be cleaned, so that the free cache space in the cache can be directly used in the process of processing each data request, which can reduce the response time of data request processing.
[0015] In some optional implementations, after generating a first preset number of data block processing queues, the method further includes:
[0016] Determine the identity of the logical volume to which the data block in the cache belongs;
[0017] According to the identifier of the logical volume and the first preset number, a data block processing queue corresponding to the data block is determined, and the data block is put into the corresponding data block processing queue.
[0018] In this embodiment, the data block processing queue corresponding to the data block is determined, and the data block is placed in the corresponding data block processing queue. The data block is managed by the data block processing queue to facilitate cleaning of the data block and release of the cache space occupied by the data block.
[0019] In some optional implementations, after placing the data block into the corresponding data block processing queue, the method further includes:
[0020] Determining a first replacement priority of the data block;
[0021] According to the first replacement priority, sequence numbers of data blocks are generated in a first preset number of data block processing queues.
[0022] In this embodiment, according to the first replacement priority, the sequence numbers of the data blocks are generated in the first preset number of data block processing queues, which is convenient for managing the data blocks, and the data blocks to be cleared are determined and released according to the sequence numbers, which is accurate and efficient.
[0023] In some optional implementations, when the cache occupancy level is higher than a preset threshold, determining the data block to be cleared includes:
[0024] When the cache occupancy level is higher than a first preset threshold and lower than a second preset threshold, data blocks with sequence numbers smaller than a first preset value in a first preset number of data block processing queues are used as data blocks to be cleared;
[0025] When the cache occupancy level is higher than the second preset threshold and lower than the third preset threshold, data blocks with sequence numbers smaller than the second preset value in the first preset number of data block processing queues are used as data blocks to be cleared;
[0026] When the cache occupancy level is higher than the third preset threshold and lower than the fourth preset threshold, data blocks with sequence numbers smaller than the third preset value in the first preset number of data block processing queues are used as data blocks to be cleared;
[0027] When the cache occupancy level is higher than a fourth preset threshold, data blocks with sequence numbers less than a fourth preset value in the first preset number of data block processing queues are taken as data blocks to be cleared.
[0028] In this embodiment, the cache occupancy level is compared with the first preset threshold to the fourth preset threshold, and the number of data blocks to be cleared in the data block processing queue is determined based on the comparison results, the speed of cache replacement is modified, and the computing resources of the system are reasonably utilized to ensure that the free cache space in the cache can be directly used during the processing of each data request.
[0029] In some optional implementations, after determining the data blocks to be cleared and releasing the cache space occupied by the data blocks to be cleared, the method further includes:
[0030] Determining a second replacement priority of remaining data blocks in the first preset number of data block processing queues;
[0031] According to the second replacement priority, the sequence numbers of the remaining data blocks are updated.
[0032] In some optional implementations, when a data request is received from a host, determining a target cache space from free cache space in a cache, saving data corresponding to the data request to the target cache space, and responding to the data request include:
[0033] In the case where the data request is a read request, if the data block corresponding to the read request does not exist in the cache, the target cache space is determined from the free cache space in the cache;
[0034] Acquire data corresponding to the read request from a preset storage medium, and write the data corresponding to the read request into a target cache space to generate a read request data block corresponding to the read request;
[0035] Returns the data in the read request data block to the host.
[0036] In this embodiment, by separating the cache replacement process from the data request processing process, it is ensured that free cache space in the cache can be directly used in the process of processing each read request, thereby reducing the processing delay of the read request.
[0037] In some optional implementations, releasing the cache space occupied by the data block to be cleared includes:
[0038] In the case where the data block to be cleaned is a read request data block, the data block to be cleaned in the data block processing queue is deleted;
[0039] The positions of the remaining data blocks in the data block processing queue are swapped using a preset algorithm.
[0040] In some optional implementations, when a data request is received from a host, determining a target cache space from free cache space in a cache, saving data corresponding to the data request to the target cache space, and responding to the data request include:
[0041] In the case where the data request is a write request, determining a target cache space from free cache space in the cache;
[0042] Write the data corresponding to the write request into the target cache space, generate a write request data block corresponding to the write request, and respond to the host.
[0043] In this embodiment, by separating the cache replacement process from the data request processing process, it is ensured that the free cache space in the cache can be directly used in the process of processing each write request, thereby reducing the processing delay of the write request.
[0044] In some optional implementations, releasing the cache space occupied by the data block to be cleared includes:
[0045] In the case where the data block to be cleared is a write request data block, determining whether the data of the data block to be cleared has been written into a preset storage medium;
[0046] If it has been written, delete the data block to be cleaned up in the data block processing queue;
[0047] If not written, the data of the data block to be cleared is written into a preset storage medium, and the data block to be cleared in the data block processing queue is deleted.
[0048] In some optional implementations, obtaining the cache occupancy level includes:
[0049] Enable the preset timer, and call the timer processing function when the preset timer duration is the preset duration;
[0050] Use the timer processing function to obtain the cache occupancy level.
[0051] In this embodiment, when the duration of the preset timer is the preset duration, the cache occupancy level is obtained, ensuring that the cache occupancy level is obtained in time and the cache replacement process is started, while avoiding excessive computing resources from being occupied by obtaining the cache occupancy level in real time.
[0052] In some optional implementations, obtaining the cache occupancy level includes:
[0053] Get the used cache space and total cache space of the cache;
[0054] The ratio of used cache space to total cache space is used as the cache occupancy watermark.
[0055] In a second aspect, the present invention provides a data request processing device, comprising:
[0056] An acquisition module is used to obtain the cache occupancy level;
[0057] A release module is used to determine the data blocks to be cleaned up and release the cache space occupied by the data blocks to be cleaned up when the cache occupancy level is higher than a preset threshold;
[0058] The processing module is used to determine the target cache space from the free cache space in the cache when receiving a data request from the host, save the data corresponding to the data request to the target cache space, and respond to the data request.
[0059] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the data request processing method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0060] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the data request processing method of the first aspect or any corresponding embodiment thereof.
[0061] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the data request processing method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0063] Figure 1 is a flow chart of processing a read request using a traditional solution according to an embodiment of the present invention;
[0064] Figure 2 is a flow chart of a data request processing method according to an embodiment of the present invention;
[0065] Figure 3 is a schematic diagram of a data block processing queue according to an embodiment of the present invention;
[0066] Figure 4 is a schematic diagram of a process for processing a read request according to an embodiment of the present invention;
[0067] Figure 5 is a structural block diagram of a data request processing device according to an embodiment of the present invention;
[0068] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0070] DRAM used as cache in storage systems is more expensive than non-volatile storage devices such as HDD and SSD. Therefore, the DRAM capacity configured in the storage system is limited, and it is impossible to cache all the data corresponding to all data requests in DRAM. Therefore, in the process of processing data requests, if the DRAM storage space is full, if new data needs to be cached, it is necessary to replace the existing data in DRAM to cache the new data. The commonly used cache replacement algorithms are FIFO (First In First Out), LRU (Least Recently Used), LFU (Least Frequently Used), etc. The current traditional solution processes data requests as follows: Figure 1 As shown, taking a read request processing flow as an example, in the processing of a read request, the read request is sent to the cache module to check whether it can hit the cache. If it can hit, the data is read from the cache and returned to the host, and the process ends. If it cannot hit the cache, it is necessary to read the data from the backend data disk and return the read data to the cache module to determine whether the cache space is full. If not, the read data is placed in the cache and then returned to the host. If so, according to the replacement algorithm, some data is invalidated to release the cache space, and the read data is placed in the cache and then returned to the host, and the process ends. Similarly, for write requests, when data is written to the cache, if the cache space is full, it is also necessary to use the cache replacement algorithm to replace the existing data and write the new data.
[0071] In the above-mentioned traditional scheme, in the process of processing data requests, if data needs to be put into the cache and the cache space is full, it is necessary to use the cache replacement algorithm to replace the existing data in the cache and then store the new data. This process involves the processing of the cache replacement algorithm, the release of cache resources, and the application of cache resources for data requests. The time consumption of these processing flows is included in the processing time of the cache request, and the cache space is limited. It is normal for the cache space to be full during the use of the storage system. Therefore, every data request involving cache data needs to execute the cache replacement process during the processing process, which prolongs the processing delay of each data request and causes the system performance to degrade.
[0072] Based on the above content, an embodiment of the present invention provides a data request processing method, so that the cache replacement processing process is not included in the process of processing data requests. When the cache occupancy level is higher than the preset threshold, the data block to be cleared is determined, and the cache space occupied by the data block to be cleared is released. The above cache replacement processing time is not included in the time of processing data requests; and in the process of processing each data request, the free cache space in the cache can be directly used, which can reduce the response time of data request processing. In this way, the free cache space in the cache can be directly used in the process of processing each data request, the processing delay of the data request is reduced, and the read and write performance of the storage system is improved.
[0073] According to an embodiment of the present invention, a data request processing embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer device with data processing capabilities, such as a computer, a server, etc., and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0074] In this embodiment, a data request processing method is provided. Figure 2 is a flow chart of a data request processing method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0075] Step S201, obtaining the cache occupancy level.
[0076] Specifically, DRAM is a cache in the storage system. The cache occupancy level is obtained. The cache occupancy level is, for example, the size of the used space in the DRAM divided by the total size of the DRAM. The cache occupancy level can be used to determine the usage of the DRAM and whether the DRAM has enough free cache space for the subsequent processing of data requests.
[0077] Step S202: when the cache occupancy level is higher than a preset threshold, determine the data blocks to be cleared, and release the cache space occupied by the data blocks to be cleared.
[0078] Specifically, the preset thresholds are, for example, 70%, 80%, 90%, etc., and the specific values are set according to actual needs. If the cache occupancy level is higher than the preset threshold, it means that there is insufficient free cache space in the DRAM for subsequent processing of data requests, and cache replacement is required.
[0079] The data blocks to be cleaned are determined in the DRAM, and the cache space occupied by the data blocks to be cleaned is released. It should be noted that during the data request processing in this embodiment, the data corresponding to the data request will be stored in the DRAM in the form of data blocks, so as to efficiently respond to the host sending the data request.
[0080] In addition, multiple preset thresholds may be set, and when the cache occupancy level is higher than different preset thresholds, different cache replacement speeds may be used.
[0081] Step S203, when a data request is received from the host, a target cache space is determined from the free cache space in the cache, data corresponding to the data request is saved in the target cache space, and the data request is responded to.
[0082] Specifically, a data request is, for example, an IO request. When a data request is received from a host, including a write request and a read request, a target cache space is determined from the free cache space in the DRAM. The size of the target cache space is greater than or equal to the data size of the data request, and the target cache space is preferably a continuous space, so that when responding to the host sending the data request, only one data transmission needs to be initiated, thereby improving the response speed. The data corresponding to the data request is saved in the target cache space in the form of a data block, and the data in the data block is returned to the host to achieve the response to the data request.
[0083] The data request processing method provided in this embodiment determines the data blocks to be cleared and releases the cache space occupied by the data blocks to be cleared when the cache occupancy level is higher than a preset threshold. The cache replacement process is not included in the process of processing data requests, and the cache replacement processing time is not included in the time of processing data requests. In addition, by timely releasing the cache space occupied by the cleared data blocks, the free cache space in the cache can be directly used in the process of processing each data request, which can reduce the response time of data request processing. The processing delay of data requests is reduced, and the read and write performance of the storage system is improved. The problem that in the process of processing data requests, if the cache space is full, replacing the existing data in the cache will increase the delay in processing data requests is solved.
[0084] In some optional implementations, before obtaining the cache occupancy watermark, the method further includes:
[0085] Get the number of threads that handle cache replacement tasks;
[0086] A first preset number of data block processing queues are generated according to the number of threads, wherein the data block processing queues are used to determine and release data blocks to be cleared.
[0087] Specifically, in the process of processing a data request, this embodiment stores the data corresponding to the data request in the form of a data block in the DRAM, so as to efficiently respond to the host sending the data request.
[0088] This embodiment stores the data blocks in the DRAM in multiple data block processing queues to facilitate the management of the data blocks, including: determining and releasing the data blocks to be cleaned. Therefore, it is necessary to first generate a first preset number of data block processing queues, and the process includes: obtaining the number of threads m for processing cache replacement tasks. According to the number of threads, a first preset number of data block processing queues is generated. The first preset number can be equal to the number of threads m, that is, there are as many bidirectional queues as there are threads processing cache replacement tasks. In addition, if necessary during actual use, the first preset number can also be an integer multiple of the number of threads m, for example: the first preset number is m, 2m, 3m, etc.
[0089] Taking the first preset number as the number of threads m as an example, combined with Figure 3 This embodiment is described. There are m threads processing cache replacement tasks, and m bidirectional queues are created as data block processing queues. Figure 3 As shown, m task queues including task queue 0, task queue 1, ..., task queue m-1 are created. The task queue is a data block processing queue, and each task queue stores multiple cache data blocks.
[0090] In this embodiment, a first preset number of data block processing queues are generated according to the number of threads processing cache replacement tasks, and the data block processing queues are used to manage the data blocks, determine and release the data blocks to be cleaned, so that the free cache space in the cache can be directly used in the process of processing each data request, which can reduce the response time of data request processing.
[0091] In some optional implementations, after generating a first preset number of data block processing queues, the method further includes:
[0092] Determine the identity of the logical volume to which the data block in the cache belongs;
[0093] According to the identifier of the logical volume and the first preset number, a data block processing queue corresponding to the data block is determined, and the data block is put into the corresponding data block processing queue.
[0094] Specifically, an identifier of a logical volume (Logical Unit Number, LUN) to which the data block in the cache belongs is determined, wherein LUN is a logical unit number, which is a logical volume in a storage system.
[0095] Determine the identifier (LUN ID) of the logical volume to which the data block in the cache belongs. Taking the first preset number as the number of threads m as an example, the queue into which the data block in the cache is placed is determined according to the LUN (logical volume) to which the cache data block belongs. The calculation method can be: queue ID = LUN ID % m, where % represents the remainder calculation. The data block processing queue ID corresponding to the data block is determined by the above method. For example, the remainder of m is calculated based on the number of the LUN to which the data belongs, that is, the data of LUN 0 is placed in queue 0, the data of LUN 1 is placed in queue 1, ..., the data of LUN m-1 is placed in queue m-1, the data of LUN m is placed in queue 0, and so on. Figure 3 As shown, the data block processing queue corresponding to cache data block 0-1, cache data block 0-2, ..., cache data block 0-n is task queue 0, and cache data block 0-1, cache data block 0-2, ..., cache data block 0-n are put into task queue 0. Other task queues are as follows Figure 3 As shown, no further description is given here.
[0096] The data block processing queue corresponding to the data block is determined according to the data block processing queue ID, and the data block is placed in the corresponding data block processing queue.
[0097] In this embodiment, the data block processing queue corresponding to the data block is determined, and the data block is placed in the corresponding data block processing queue. The data block is managed by the data block processing queue to facilitate cleaning of the data block and release of the cache space occupied by the data block.
[0098] In some optional implementations, after placing the data block into the corresponding data block processing queue, the method further includes:
[0099] Determining a first replacement priority of the data block;
[0100] According to the first replacement priority, sequence numbers of data blocks are generated in a first preset number of data block processing queues.
[0101] Specifically, in each data block processing queue, according to the corresponding cache replacement algorithm, the data block to be replaced first is placed at the head of the data block processing queue, and other data blocks are stored in a linked list in sequence according to the replacement order.
[0102] The replacement order can be determined according to the first replacement priority of the data block. For example, the first replacement priority of the data block in each data block processing queue is determined according to the time when the data block joins the data block processing queue. The smaller the joining time, the higher the first replacement priority; the first replacement priority of the data block is determined according to the usage frequency and hit rate of the data in the data block. During the business cycle, the lower the data usage frequency and the lower the hit rate of the data block, the higher the first replacement priority.
[0103] According to the first replacement priority, serial numbers of data blocks are generated in a first preset number of data block processing queues, wherein the higher the first replacement priority, the smaller and more forward the generated serial numbers are, and the subsequent data blocks with smaller serial numbers are more likely to be determined as data blocks to be cleaned; or, conversely, the higher the first replacement priority, the larger and more forward the generated serial numbers are, and the subsequent data blocks with larger serial numbers are more likely to be determined as data blocks to be cleaned.
[0104] In this embodiment, according to the first replacement priority, the sequence numbers of the data blocks are generated in the first preset number of data block processing queues, which is convenient for managing the data blocks, and the data blocks to be cleared are determined and released according to the sequence numbers, which is accurate and efficient.
[0105] In some optional implementations, when the cache occupancy level is higher than a preset threshold, determining the data block to be cleared includes:
[0106] When the cache occupancy level is higher than a first preset threshold and lower than a second preset threshold, data blocks with sequence numbers smaller than a first preset value in a first preset number of data block processing queues are used as data blocks to be cleared;
[0107] When the cache occupancy level is higher than the second preset threshold and lower than the third preset threshold, data blocks with sequence numbers smaller than the second preset value in the first preset number of data block processing queues are used as data blocks to be cleared;
[0108] When the cache occupancy level is higher than the third preset threshold and lower than the fourth preset threshold, data blocks with sequence numbers smaller than the third preset value in the first preset number of data block processing queues are used as data blocks to be cleared;
[0109] When the cache occupancy level is higher than a fourth preset threshold, data blocks with sequence numbers less than a fourth preset value in the first preset number of data block processing queues are taken as data blocks to be cleared.
[0110] Specifically, in order to prevent the cache replacement process from being included in the process of processing data requests, the cache replacement process is placed in the background for execution. In order to prevent the foreground process of processing data requests from being blocked due to the full DRAM cache space, the background cache replacement task cannot be started when the cache space is full. Therefore, a preset threshold is set. When the cache occupancy level is higher than the preset threshold, the cache replacement process is started.
[0111] This embodiment dynamically adjusts the cache replacement speed according to the preset threshold value exceeded by the cache occupancy level by setting different preset threshold values. The different preset threshold values include: a first preset threshold value, for example, 70%; a second preset threshold value, for example, 80%; a third preset threshold value, for example, 90%; a fourth preset threshold value, for example, 95%. The specific values of the above preset values can be adjusted according to actual needs and are not limited here. Take the first preset number as the number of threads m as an example.
[0112] When the cache occupancy level is higher than the first preset threshold and lower than the second preset threshold, it indicates that the DRAM cache space is insufficient and the cache replacement process needs to be started. The m threads for handling the cache replacement task simultaneously process the cache data in the m data block processing queues, and the data blocks with sequence numbers less than the first preset value in each data block processing queue are taken as data blocks to be cleaned. For example, the first preset value is 2, that is, the data block with sequence number 1 in each queue is taken as the data block to be cleaned. Each thread invalidates a data block at the head of the corresponding data block processing queue as the data block to be cleaned from the cache, releases the cache space of the data block to be cleaned, and ends this processing.
[0113] When the cache occupancy level is higher than the second preset threshold and lower than the third preset threshold, it indicates that the DRAM cache space is insufficient and a cache replacement process needs to be performed quickly. m threads for processing cache replacement tasks simultaneously process cache data in m data block processing queues, and use data blocks with sequence numbers less than the second preset value in each data block processing queue as data blocks to be cleaned. For example, the second preset value is 3, that is, data blocks with sequence numbers 1 and 2 in each queue are used as data blocks to be cleaned. When each thread processes this, it invalidates the first two data blocks in the queue from the corresponding queue, releases the cache space for the data blocks to be cleaned, and ends this processing.
[0114] When the cache occupancy level is higher than the third preset threshold and lower than the fourth preset threshold, it means that the DRAM cache space is very insufficient and the cache replacement process needs to be performed faster. m threads for processing cache replacement tasks simultaneously process the cache data in m data block processing queues, and use the data blocks with sequence numbers less than the third preset value in each data block processing queue as data blocks to be cleaned. For example, the third preset value is 5, that is, the data blocks with sequence numbers 1 to 4 in each queue are used as data blocks to be cleaned. When each thread processes this, it invalidates the first four data blocks in the queue from the corresponding queue, releases the cache space for the data blocks to be cleaned, and ends this processing.
[0115] When the cache occupancy level is higher than the fourth preset threshold, it means that the DRAM cache space is seriously insufficient and the cache replacement process needs to be performed at the fastest speed. m threads for processing cache replacement tasks simultaneously process the cache data in m data block processing queues, and take the data blocks with sequence numbers less than the fourth preset value in each data block processing queue as data blocks to be cleaned. For example: the fourth preset value is 9, that is, the data blocks with sequence numbers 1 to 8 in each queue are taken as data blocks to be cleaned. When each thread processes this, it invalidates the first eight data blocks in the queue from the corresponding queue, releases the cache space of the data blocks to be cleaned, and ends this processing.
[0116] In this embodiment, the cache occupancy level is compared with the first preset threshold to the fourth preset threshold, and the number of data blocks to be cleared in the data block processing queue is determined based on the comparison results, the speed of cache replacement is modified, and the computing resources of the system are reasonably utilized to ensure that the free cache space in the cache can be directly used during the processing of each data request.
[0117] In some optional implementations, in the process of releasing the data blocks to be cleared, in order to avoid directly deleting the data blocks to be cleared which may affect the subsequent user's read and write service needs, the data blocks to be cleared can be temporarily locked first, and the read and write service conditions for the next period of time can be obtained. If the read and write service needs of the user are not affected, the data blocks to be cleared can be deleted and the cache space of the data blocks to be cleared can be released. The specific process includes steps A1 to A4.
[0118] Step A1: Lock the determined data block to be cleared.
[0119] Specifically, after the data block to be cleaned is locked, data cannot be read from the data block to be cleaned and data cannot be written into the data block to be cleaned.
[0120] Step A2: determine whether the transmission bandwidth corresponding to the user decreases within a preset time period.
[0121] Specifically, a 5% error is allowed for determining whether the transmission bandwidth has decreased, that is, an impact of less than 5% can be regarded as an error. If the transmission bandwidth has not decreased within the preset time period, it can be determined that deleting the data block to be cleared will not affect the subsequent user's read and write service needs, and the data block to be cleared can be deleted, and the cache space of the data block to be cleared can be released.
[0122] Step A3: if the transmission bandwidth does not decrease within the preset time period, the data to be cleared in the data block processing queue is deleted, and the cache space of the data to be cleared is released.
[0123] Specifically, the preset time period is, for example, two weeks. If the transmission bandwidth does not decrease within the preset time period, it is determined that the user's read and write service efficiency is not affected, the data to be cleared in the data block processing queue is deleted, and the cache space of the data to be cleared is released. It should be noted that the preset time period can be set according to actual needs, for example, it can be longer or shorter.
[0124] Step A4: if the transmission bandwidth decreases within a preset time period, the data blocks to be cleared are unlocked and the data blocks to be cleared are re-determined.
[0125] Specifically, if the transmission bandwidth decreases by more than a threshold within a period of time, it is determined that locking the data block to be cleared will affect the user's read and write services, and the data block to be cleared is unlocked. Other data blocks are detected cyclically and the data block to be cleared is re-determined, so as to reclaim redundant cache space and maximize the utilization of cache resources.
[0126] In this embodiment, the data block to be cleaned is temporarily locked first, and the read and write business conditions in the next period of time are obtained. If it does not affect the user's read and write business needs, the data block to be cleaned is deleted and the cache space of the data block to be cleaned is released to maximize the utilization of cache resources.
[0127] In some optional implementations, after determining the data blocks to be cleared and releasing the cache space occupied by the data blocks to be cleared, the method further includes:
[0128] Determining a second replacement priority of remaining data blocks in the first preset number of data block processing queues;
[0129] According to the second replacement priority, the sequence numbers of the remaining data blocks are updated.
[0130] Specifically, after the data blocks to be cleared are deleted from the data block processing queue and the cache space occupied by the data blocks to be cleared is released, the sequence numbers of the data blocks in the data block processing queue are not continuous, for example: Figure 3 In task queue 1, cached data block 1-1 is deleted. At this time, the sequence numbers of the data blocks in task queue 1 start from 1-2, which is not conducive to the subsequent determination of the data blocks to be cleared.
[0131] Therefore, the second replacement priority of the remaining data blocks in the first preset number of data block processing queues is re-determined, and the sequence numbers of the remaining data blocks are updated according to the second replacement priority. For example, the second replacement priority of the data block is the same as the first replacement priority, and both are generated by using the time when the data block joins the data block processing queue. Figure 3As shown, in task queue 1, cached data block 1-1 is deleted. At this time, the sequence number of the data block in task queue 1 starts from 1-2, and the sequence number 1-2 is modified to 1-1, and the sequence number 1-3 is modified to 1-2, and so on. If the second replacement priority of the data block is different from the first replacement priority, the first replacement priority is generated using the time when the data block joins the data block processing queue, and the second replacement priority is generated using the usage frequency and hit rate of the data in the data block, then the sequence number of the remaining data blocks is directly regenerated according to the second replacement priority. The position of the remaining data blocks in the data block processing queue is dynamically swapped according to the updated sequence number.
[0132] In some optional implementations, when a data request is received from a host, determining a target cache space from free cache space in a cache, saving data corresponding to the data request to the target cache space, and responding to the data request include:
[0133] In the case where the data request is a read request, if the data block corresponding to the read request does not exist in the cache, the target cache space is determined from the free cache space in the cache;
[0134] Acquire data corresponding to the read request from a preset storage medium, and write the data corresponding to the read request into a target cache space to generate a read request data block corresponding to the read request;
[0135] Returns the data in the read request data block to the host.
[0136] Specifically, in this embodiment, there is no need to process the processing logic of cache replacement in the process of processing the read request, and the target cache space can be directly determined from the free cache space in the DRAM.
[0137] Determine whether there is a data block corresponding to the read request in DRAM, that is, determine whether the read request hits the cache. If so, it is determined that the data read by the read request is in DRAM, so there is no need to read the data corresponding to the read request from storage media such as HDD and SSD. The data corresponding to the read request can be directly read from DRAM and returned to the host, reducing the response time of the read request.
[0138] If the data block corresponding to the read request does not exist in the cache, it is determined that the data read by the read request is not in the DRAM, and the target cache space is determined from the free cache space in the DRAM. The data corresponding to the read request is obtained from a preset storage medium, such as a non-volatile storage medium such as HDD or SSD that is slower than DRAM. After obtaining the data corresponding to the read request, the read data is written to the target cache space of the DRAM, and a read request data block corresponding to the read request is generated so that subsequent requests can hit the cache. Finally, the data in the read request data block is returned to the host.
[0139] The above process is as follows Figure 4 As shown, the read request is sent to the cache module to determine whether the read request hits the cache. If so, the data is read from the cache and returned to the host; if not, the data is read from the backend data disk, and the read data is returned to the cache module, the read data is placed in the cache, and then returned to the host, and the process ends.
[0140] In this embodiment, by separating the cache replacement process from the data request processing process, it is ensured that free cache space in the cache can be directly used in the process of processing each read request, thereby reducing the processing delay of the read request.
[0141] In some optional implementations, releasing the cache space occupied by the data block to be cleared includes:
[0142] In the case where the data block to be cleaned is a read request data block, the data block to be cleaned in the data block processing queue is deleted;
[0143] The positions of the remaining data blocks in the data block processing queue are swapped using a preset algorithm.
[0144] Specifically, when the data block to be cleared is a read request data block, the data block to be cleared in the data block processing queue can be directly deleted.
[0145] After the data blocks to be cleared are deleted from the data block processing queue and the cache space occupied by the data blocks to be cleared is released, the sequence numbers of the data blocks in the data block processing queue are discontinuous. Therefore, a preset algorithm is used to dynamically swap the positions of the remaining data blocks in the data block processing queue, and the sequence numbers of the remaining data blocks are updated. For example, the above-mentioned second replacement priority is used to update the sequence numbers of the remaining data blocks, and the positions of the remaining data blocks in the data block processing queue are dynamically swapped according to the updated sequence numbers.
[0146] In some optional implementations, when a data request is received from a host, determining a target cache space from free cache space in a cache, saving data corresponding to the data request to the target cache space, and responding to the data request include:
[0147] In the case where the data request is a write request, determining a target cache space from free cache space in the cache;
[0148] Write the data corresponding to the write request into the target cache space, generate a write request data block corresponding to the write request, and respond to the host.
[0149] Specifically, when the data request is a write request, the target cache space is determined from the free cache space in the DRAM. The size of the target cache space is greater than or equal to the data size of the write request, and the target cache space is preferably a continuous space. In this way, when writing the data of the write request to the target cache space, only one data transfer needs to be initiated, thereby improving the processing speed of the data request.
[0150] For write requests, the data of the write request is written into DRAM and the host data request processing is completed. The data written into DRAM is flushed to non-volatile storage media such as HDD or SSD, which are slower than DRAM, in the background, reducing the system's response time to write requests. Therefore, the data corresponding to the write request is written into the target cache space, the write request data block corresponding to the write request is generated, and the host is responded to.
[0151] In this embodiment, by separating the cache replacement process from the data request processing process, it is ensured that the free cache space in the cache can be directly used in the process of processing each write request, thereby reducing the processing delay of the write request.
[0152] In some optional implementations, releasing the cache space occupied by the data block to be cleared includes:
[0153] In the case where the data block to be cleared is a write request data block, determining whether the data of the data block to be cleared has been written into a preset storage medium;
[0154] If it has been written, delete the data block to be cleaned up in the data block processing queue;
[0155] If not written, the data of the data block to be cleared is written into a preset storage medium, and the data block to be cleared in the data block processing queue is deleted.
[0156] Specifically, the data written to DRAM is flushed to a preset storage medium in the background, such as a non-volatile storage medium such as HDD or SSD that is slower than DRAM. The process of background flushing is carried out simultaneously with the process of releasing the cache space occupied by the data block to be cleared. Therefore, when a certain write request data block is confirmed as a data block to be cleared, the data of the write request data block has not been flushed to a non-volatile storage medium such as HDD or SSD. If the write request data block is directly deleted, data loss will result.
[0157] Determine whether the data of the data block to be cleaned has been written into the preset storage medium. If so, directly delete the data block to be cleaned in the data block processing queue. If not, write the data of the data block to be cleaned into the preset storage medium and then delete the data block to be cleaned in the data block processing queue.
[0158] In some optional implementations, obtaining the cache occupancy level includes:
[0159] Enable the preset timer, and call the timer processing function when the preset timer duration is the preset duration;
[0160] Use the timer processing function to obtain the cache occupancy level.
[0161] Specifically, if the cache occupancy level is obtained in real time, it will occupy too much computing resources of the system. Therefore, a timer can be set to obtain the cache occupancy level once every certain period of time to determine whether a cache replacement process is needed.
[0162] Enable the preset timer, for example, a 100ms timer. The preset duration is, for example, 100ms. When the preset timer duration is the preset duration, call the timer processing function. In the timer processing function, get the cache occupancy level and determine whether the current cache occupancy level has reached the threshold, for example, 70%. If it has not reached, do nothing. If it has reached, start replacing the data in the cache, that is, invalidate the corresponding data and release the corresponding cache space.
[0163] In this embodiment, when the duration of the preset timer is the preset duration, the cache occupancy level is obtained, ensuring that the cache occupancy level is obtained in time and the cache replacement process is started, while avoiding excessive computing resources from being occupied by obtaining the cache occupancy level in real time.
[0164] In some optional implementations, obtaining the cache occupancy level includes:
[0165] Get the used cache space and total cache space of the cache;
[0166] The ratio of used cache space to total cache space is used as the cache occupancy watermark.
[0167] Specifically, in order to prevent the cache replacement process from being included in the process of processing data requests, the cache replacement process is placed in the background for execution. In order to prevent the foreground process of processing data requests from being blocked due to the full DRAM cache space, the background cache replacement task cannot be started when the cache space is full. Therefore, a preset threshold is set. When the cache occupancy level is higher than the preset threshold, the cache replacement process is started.
[0168] DRAM is the cache in the storage system. Get the cache occupancy level. For example, the cache occupancy level is the used cache space of DRAM divided by the total cache space of DRAM. The used cache space is the sum of the cache spaces of all data blocks in DRAM. The cache occupancy level can be used to determine the usage of DRAM and whether DRAM has enough free cache space for the subsequent data request processing process.
[0169] In this embodiment, a data request processing device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0170] This embodiment provides a data request processing device, such as Figure 5 As shown, including:
[0171] Acquisition module 501, used to acquire the cache occupancy level;
[0172] A release module 502 is used to determine the data blocks to be cleared and release the cache space occupied by the data blocks to be cleared when the cache occupancy level is higher than a preset threshold;
[0173] The processing module 503 is used to determine the target cache space from the free cache space in the cache when receiving a data request from the host, save the data corresponding to the data request to the target cache space, and respond to the data request.
[0174] In some optional implementations, before obtaining the cache occupancy water level, the device is used to:
[0175] Get the number of threads that handle cache replacement tasks;
[0176] A first preset number of data block processing queues are generated according to the number of threads, wherein the data block processing queues are used to determine and release data blocks to be cleared.
[0177] In some optional implementations, after generating a first preset number of data block processing queues, the apparatus is further configured to:
[0178] Determine the identity of the logical volume to which the data block in the cache belongs;
[0179] According to the identifier of the logical volume and the first preset number, a data block processing queue corresponding to the data block is determined, and the data block is put into the corresponding data block processing queue.
[0180] In some optional implementations, after placing the data block into the corresponding data block processing queue, the device is further configured to:
[0181] Determining a first replacement priority of the data block;
[0182] According to the first replacement priority, sequence numbers of data blocks are generated in a first preset number of data block processing queues.
[0183] In some optional implementations, when the cache occupancy level is higher than a preset threshold, the release module 502 determines the data block to be cleared, including:
[0184] When the cache occupancy level is higher than a first preset threshold and lower than a second preset threshold, data blocks with sequence numbers smaller than a first preset value in a first preset number of data block processing queues are used as data blocks to be cleared;
[0185] When the cache occupancy level is higher than the second preset threshold and lower than the third preset threshold, data blocks with sequence numbers smaller than the second preset value in the first preset number of data block processing queues are used as data blocks to be cleared;
[0186] When the cache occupancy level is higher than the third preset threshold and lower than the fourth preset threshold, data blocks with sequence numbers smaller than the third preset value in the first preset number of data block processing queues are used as data blocks to be cleared;
[0187] When the cache occupancy level is higher than a fourth preset threshold, data blocks with sequence numbers less than a fourth preset value in the first preset number of data block processing queues are taken as data blocks to be cleared.
[0188] In some optional implementations, after determining the data blocks to be cleared and releasing the cache space occupied by the data blocks to be cleared, the release module 502 is further used to:
[0189] Determining a second replacement priority of remaining data blocks in the first preset number of data block processing queues;
[0190] According to the second replacement priority, the sequence numbers of the remaining data blocks are updated.
[0191] In some optional implementations, when the processing module 503 receives a data request from the host, it determines the target cache space from the free cache space in the cache, saves the data corresponding to the data request to the target cache space, and responds to the data request, including:
[0192] In the case where the data request is a read request, if the data block corresponding to the read request does not exist in the cache, the target cache space is determined from the free cache space in the cache;
[0193] Acquire data corresponding to the read request from a preset storage medium, and write the data corresponding to the read request into a target cache space to generate a read request data block corresponding to the read request;
[0194] Returns the data in the read request data block to the host.
[0195] In some optional implementations, the processing module 503 releases the cache space occupied by the data block to be cleared, including:
[0196] In the case where the data block to be cleaned is a read request data block, the data block to be cleaned in the data block processing queue is deleted;
[0197] The positions of the remaining data blocks in the data block processing queue are swapped using a preset algorithm.
[0198] In some optional implementations, when the processing module 503 receives a data request from the host, it determines the target cache space from the free cache space in the cache, saves the data corresponding to the data request to the target cache space, and responds to the data request, including:
[0199] In the case where the data request is a write request, determining a target cache space from free cache space in the cache;
[0200] Write the data corresponding to the write request into the target cache space, generate a write request data block corresponding to the write request, and respond to the host.
[0201] In some optional implementations, the processing module 503 releases the cache space occupied by the data block to be cleared, including:
[0202] In the case where the data block to be cleared is a write request data block, determining whether the data of the data block to be cleared has been written into a preset storage medium;
[0203] If it has been written, delete the data block to be cleaned up in the data block processing queue;
[0204] If not written, the data of the data block to be cleared is written into a preset storage medium, and the data block to be cleared in the data block processing queue is deleted.
[0205] In some optional implementations, the acquisition module 501 acquires the cache occupancy level, including:
[0206] Enable the preset timer, and call the timer processing function when the preset timer duration is the preset duration;
[0207] Use the timer processing function to obtain the cache occupancy level.
[0208] In some optional implementations, the acquisition module 501 acquires the cache occupancy level, including:
[0209] Get the used cache space and total cache space of the cache;
[0210] The ratio of used cache space to total cache space is used as the cache occupancy watermark.
[0211] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0212] The data request processing device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0213] The embodiment of the present invention also provides a computer device having the above Figure 5 The data request processing device shown.
[0214] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0215] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include an integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0216] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0217] The memory 20 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 computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device 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.
[0218] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0219] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0220] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0221] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0222] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined in this application.
Claims
1. A data request processing method, characterized in that: The method comprises: Obtaining the number of threads for processing cache replacement tasks; generating a first preset number of data block processing queues according to the number of threads, wherein the data block processing queues are used to determine and release data blocks to be cleared; Get the cache occupancy level; When the cache occupancy level is higher than a preset threshold, determining the data block to be cleared, and releasing the cache space occupied by the data block to be cleared; The releasing of the cache space occupied by the data block to be cleared includes: if the data block to be cleared is a write request data block, determining whether the data of the data block to be cleared has been written into a preset storage medium; if it has been written, deleting the data block to be cleared in the data block processing queue; if it has not been written, writing the data of the data block to be cleared into the preset storage medium, and deleting the data block to be cleared in the data block processing queue; When a data request is received from a host, a target cache space is determined from free cache space in the cache, data corresponding to the data request is saved in the target cache space, and the data request is responded to, wherein the free cache space in the cache is obtained after releasing the cache space occupied by the data block to be cleared.
2. The method according to claim 1, characterized in that After generating the first preset number of data block processing queues, the method further includes: Determining an identifier of a logical volume to which the data block in the cache belongs; According to the identifier of the logical volume and the first preset number, a data block processing queue corresponding to the data block is determined, and the data block is put into the corresponding data block processing queue.
3. The method according to claim 2, characterized in that After placing the data block into the corresponding data block processing queue, the method further includes: determining a first replacement priority of the data block; According to the first replacement priority, sequence numbers of the data blocks are generated in the first preset number of data block processing queues.
4. The method according to claim 3, characterized in that When the cache occupancy level is higher than a preset threshold, determining the data block to be cleared includes: When the cache occupancy level is higher than a first preset threshold and lower than a second preset threshold, data blocks with sequence numbers smaller than a first preset value in the first preset number of data block processing queues are used as the data blocks to be cleared; When the cache occupancy level is higher than the second preset threshold and lower than the third preset threshold, the data blocks with sequence numbers smaller than the second preset value in the first preset number of data block processing queues are used as the data blocks to be cleared; When the cache occupancy level is higher than a third preset threshold and lower than a fourth preset threshold, the data blocks with sequence numbers smaller than the third preset value in the first preset number of data block processing queues are used as the data blocks to be cleared; When the cache occupancy level is higher than the fourth preset threshold, data blocks with sequence numbers less than a fourth preset value in the first preset number of data block processing queues are used as the data blocks to be cleared.
5. The method according to claim 3, characterized in that: After determining the data blocks to be cleared and releasing the cache space occupied by the data blocks to be cleared, the method further includes: Determining a second replacement priority of remaining data blocks in the first preset number of data block processing queues; According to the second replacement priority, the sequence numbers of the remaining data blocks are updated.
6. The method according to claim 1, characterized in that The method of determining a target cache space from free cache space in a cache when a data request is received from a host, storing data corresponding to the data request in the target cache space, and responding to the data request includes: In the case where the data request is a read request, if the data block corresponding to the read request does not exist in the cache, determining the target cache space from free cache space in the cache; Acquire data corresponding to the read request from a preset storage medium, and write the data corresponding to the read request into the target cache space to generate a read request data block corresponding to the read request; The data in the read request data block is returned to the host.
7. The method according to claim 6, characterized in that The releasing the cache space occupied by the data block to be cleared includes: In the case where the data block to be cleared is the read request data block, deleting the data block to be cleared in the data block processing queue; The positions of the remaining data blocks in the data block processing queue are swapped using a preset algorithm.
8. The method according to claim 1, characterized in that The method of determining a target cache space from free cache space in a cache when a data request is received from a host, storing data corresponding to the data request in the target cache space, and responding to the data request includes: In the case where the data request is a write request, determining a target cache space from free cache space in the cache; The data corresponding to the write request is written into the target cache space, a write request data block corresponding to the write request is generated, and the host is responded to.
9. The method according to claim 1, characterized in that: The obtaining of the cache occupancy level includes: Enable a preset timer, and when the duration of the preset timer is the preset duration, call a timer processing function; The timer processing function is used to obtain the cache occupancy level.
10. The method according to claim 1 or 9, characterized in that: The obtaining of the cache occupancy level includes: Obtaining the used cache space and the total cache space of the cache; The ratio of the used cache space to the total cache space is used as the cache occupancy watermark.
11. A data request processing device, characterized in that: The device comprises: Obtaining the number of threads for processing cache replacement tasks; generating a first preset number of data block processing queues according to the number of threads, wherein the data block processing queues are used to determine and release data blocks to be cleared; An acquisition module is used to obtain the cache occupancy level; A release module, used to determine the data block to be cleared and release the cache space occupied by the data block to be cleared when the cache occupancy level is higher than a preset threshold; The release module releases the cache space occupied by the data block to be cleaned, including: if the data block to be cleaned is a write request data block, determining whether the data of the data block to be cleaned has been written into a preset storage medium; if it has been written, deleting the data block to be cleaned in the data block processing queue; if it has not been written, writing the data of the data block to be cleaned into the preset storage medium, and deleting the data block to be cleaned in the data block processing queue; A processing module is used to determine a target cache space from free cache space in a cache when a data request is received from a host, save data corresponding to the data request to the target cache space, and respond to the data request, wherein the free cache space in the cache is obtained after releasing the cache space occupied by the data block to be cleared.
12. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the data request processing method according to any one of claims 1 to 10 by executing the computer instructions.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the data request processing method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and storage medium
CN115543938A