Data caching method and device, storage system, electronic equipment and storage medium
By introducing multiple recycling units into the storage system and optimizing cache management strategies, the problem of low data cache hit rate is solved, and more efficient data access and storage system performance improvement is achieved.
Patent Information
- Application Number
- CN202510744588.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The problem of low hit rate of data cache in the prior art leads to low efficiency of the storage system.
By introducing multiple recycling units into the storage system, each recycling unit stores the same type of data, and upon receiving the data reading instruction, the target recycling unit is determined according to the storage address, and all its data is stored in the cache, and the low-priority data is cleared first to make room to realize efficient data cache.
It improves the data cache hit rate, optimizes the overall performance of the storage system, reduces hard disk reading operations, and extends the hard disk service life.
Smart Images

Figure CN120256332A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data storage, and in particular, to a data caching method, apparatus, storage system, electronic device, and storage medium. Background Art
[0002] In the related art, when a storage system performs data caching, it can only cache the data indicated by the cache instruction. Therefore, there is a problem of low data cache hit rate in the related art.
[0003] In view of the above problems existing in the related art, no effective solution has been proposed yet. Summary of the Invention
[0004] This application provides a data caching method, apparatus, storage system, electronic device, and storage medium to at least solve the problem of low data cache hit rate existing in the related art.
[0005] This application provides a data caching method, including: determining the instruction type of the received data cache instruction; in the case that the instruction type indicates that the data cache instruction is a data read type, looking up the target data indicated by the data cache instruction in the target cache of the storage system; in the case that the target data does not exist in the target cache, determining a first recycling unit for storing the target data included in the storage system based on the first storage address included in the data cache instruction, where the first recycling unit is a unit in the target hard disk included in the storage system, and the target hard disk includes multiple recycling units, and each recycling unit is used to store the same type of data; in the case that the data cache instruction includes a target identifier, storing all the data included in the first recycling unit into the target cache.
[0006] In an exemplary embodiment, storing all the data included in the first recycling unit into the target cache includes: determining the total amount of target data included in the first recycling unit; determining the total amount of the first remaining data in the target cache; and storing all the data included in the first recycling unit into the target cache based on the total amount of target data and the total amount of the first remaining data.
[0007] In an exemplary embodiment, storing all the data included in the first recycling unit into the target cache based on the total amount of target data and the total amount of the first remaining data includes: in the case that the total amount of the first remaining data is greater than or equal to the total amount of target data, storing all the data included in the first recycling unit into the target cache; in the case that the total amount of the first remaining data is less than the total amount of target data, determining the data to be cleared in the target cache, where the total amount of the data to be cleared is greater than or equal to the total amount of target data; clearing the data to be cleared from the target cache, and after the clearing is completed, storing the target data into the target cache.
[0008] In an exemplary embodiment, determining data to be cleared in a target cache includes: determining a first data type of cache data included in the target cache; determining first data included in the cache data, where the first data is data corresponding to the type with the lowest priority among those included in the first data type; determining a first total amount of the first data; determining the data to be cleared from the first data when the first total amount is greater than or equal to a target total amount; determining second data included in the cache data when the first total amount is less than the target total amount, where the second data is data corresponding to a type with a priority higher than that of the first data among those included in the first data type; and determining the data to be cleared from the first data and the second data.
[0009] In an exemplary embodiment, storing all data included in a first recycling unit in a target cache includes: when a target total amount of all data included in the first recycling unit is equal to a total amount of cache data in the target cache, clearing the target cache, and after the clearing is completed, storing all data included in the first recycling unit in the target cache.
[0010] In an exemplary embodiment, determining a first recycling unit included in a storage system for storing target data based on a first storage address included in a data cache instruction includes: determining a placement identifier having a corresponding relationship with the first storage address; determining a recycling unit handle having a corresponding relationship with the placement identifier; and determining the recycling unit having a corresponding relationship with the recycling unit handle as the first recycling unit.
[0011] In an exemplary embodiment, after determining an instruction type of a received data cache instruction, the method further includes: when the instruction type indicates that the data cache instruction is of a data write type, determining a second storage address included in the storage system for storing data to be written; and writing the data to be written into the storage system based on the second storage address.
[0012] In an exemplary embodiment, writing data to be written into a storage system based on a second storage address includes: when the data cache instruction is a new write instruction, determining a second recycling unit included in the storage system for storing the data to be written, where a data type of data stored in the second recycling unit is the same as a data type of the data to be written; and writing the data to be written into the second recycling unit.
[0013] In an exemplary embodiment, writing data to be written into a storage system based on a second storage address includes: when the data cache instruction is a modify write instruction, determining a third recycling unit where the file to be modified is indicated by the data cache instruction; caching all data included in the third recycling unit in a hard disk cache of a target hard disk; modifying the file to be modified in the hard disk cache to obtain the data to be written.
[0014] In an exemplary embodiment, caching all data included in the third recycling unit in a hard disk cache of a target hard disk includes: determining a second total data amount of all data included in the third recycling unit; determining a second remaining data amount of the hard disk cache; caching all data included in the third recycling unit in the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount.
[0015] In an exemplary embodiment, caching all data included in the third recycling unit in a hard disk cache of a target hard disk based on the second total data amount and the second remaining data amount includes: when the second total data amount is less than or equal to the second remaining data amount, caching all data included in the third recycling unit in the hard disk cache of the target hard disk; when the second total data amount is greater than the second remaining data amount, determining first data to be flushed to disk in the hard disk cache; clearing the first data to be flushed to disk from the hard disk cache, and after the clearing is completed, caching all data included in the third recycling unit in the hard disk cache of the target hard disk.
[0016] In an exemplary embodiment, determining first data to be flushed to disk in the hard disk cache includes: determining a second data type of hard disk cache data cached in the hard disk cache; determining third data included in the hard disk cache data, where the third data is data corresponding to the type with the lowest priority included in the second data type; determining a third total data amount of the third data; when the third total data amount is greater than or equal to the second total data amount, determining first data to be flushed to disk in the hard disk cache data; when the third total data amount is less than the second total data amount, determining fourth data included in the hard disk cache data, where the fourth data is data corresponding to a type with a priority higher than that of the third data in the second data type; determining first data to be flushed to disk from the third data and the fourth data.
[0017] In an exemplary embodiment, after caching all data included in the third recycling unit in a hard disk cache of a target hard disk based on the second total data amount and the second remaining data amount, the method further includes: determining a ratio between the total data amount in the hard disk cache and the cache capacity of the hard disk cache; when the ratio is greater than a predetermined threshold, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache.
[0018] In an exemplary embodiment, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache includes: when the second data type indicates that the hard disk cache data includes cold data, clearing the cold data from the hard disk cache; when the second data type indicates that the hard disk cache data includes warm data, setting the cache duration of the warm data in the hard disk cache; and when the cache time of the warm data in the hard disk cache reaches the cache duration, clearing the warm data from the hard disk cache.
[0019] In an exemplary embodiment, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache includes: when the second data type indicates that the hard disk cache data only includes hot data, determining target hot data in the hot data whose access times are less than a predetermined threshold; and clearing the target hot data from the hard disk cache. In this embodiment, if the cache needs to be replaced, the warm data is first cleared from the cache; if all the data in the cache is hot data, then the least recently accessed hot data is cleared.
[0020] The present application also provides a data caching device, including: a first determination module, configured to determine the instruction type of a received data caching instruction; a lookup module, configured to, when the instruction type indicates that the data caching instruction is a data reading type, look up target data indicated by the data caching instruction in a target cache of a storage system; a second determination module, configured to, when the target data does not exist in the target cache, determine a first recycling unit included in the storage system for storing the target data based on a first storage address included in the data caching instruction, where the first recycling unit is a unit in a target hard disk included in the storage system, the target hard disk includes multiple recycling units, and each recycling unit is used to store data of the same type; and a caching module, configured to, when the data caching instruction includes a target identifier, store all the data included in the first recycling unit into the target cache.
[0021] The present application also provides a storage system for executing the data caching method in the above embodiment, including: a target hard disk, where the target hard disk includes multiple recycling units, and each recycling unit is used to store data of the same type; and a target cache, configured to cache data read from the target hard disk.
[0022] The present application also provides an electronic device, including: a memory, configured to store a computer program; and a processor, configured to implement the steps of any one of the above data caching methods when executing the computer program.
[0023] The present application also provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and the computer program, when executed by a processor, implements the steps of any one of the above data caching methods.
[0024] The present application also provides a computer program product, including a computer program, which when executed by a processor, implements the steps of any of the above data caching methods.
[0025] Through the present application, since the target hard disk included in the storage system includes a plurality of recycling units, and each recycling unit can store the same type of data, when the received data caching instruction is a data reading type instruction and the target cache included in the storage system does not include the target data indicated by the data caching instruction, the first recycling unit can be determined according to the first storage address included in the data caching instruction, and all the data included in the first recycling unit can be stored in the target cache, that is, it realizes reading all the data in the entire first recycling unit into the target cache according to one data caching instruction. Therefore, the technical problem of low data caching hit rate existing in the related art can be solved, and the technical effect of improving the data caching hit rate can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0027] Figure 1 It is a hardware structure block diagram of a computer terminal on which the method embodiment of the present invention runs;
[0028] Figure 2 It is a flowchart of a data caching method according to an embodiment of the present invention;
[0029] Figure 3 It is a schematic structural diagram of a target disk according to an embodiment of the present invention;
[0030] Figure 4 It is a schematic diagram of the process of determining the first recycling unit according to an embodiment of the present invention;
[0031] Figure 5 It is an internal logic and external mapping diagram of writing data into a target hard disk according to an embodiment of the present invention;
[0032] Figure 6 It is a flowchart of writing data into a storage system according to an embodiment of the present invention;
[0033] Figure 7 It is a structural block diagram of a data caching device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.
[0035] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0036] In order to enable those skilled in the art of the present technology to better understand the solution of the present application, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0037] Combined with the specific application environment architecture or specific hardware architecture on which the execution of the data caching method depends, the specific application environment architecture or specific hardware architecture is described herein.
[0038] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 is the hardware structure block diagram of the computer terminal on which the method embodiment of the present invention runs. As Figure 1 shown, the computer terminal may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processors 102 may include, but are not limited to, processing devices such as a microprocessor MCU (Microcontroller Unit) or a field-programmable gate array FPGA (Field-Programmable Gate Array)) and a memory 104 for storing data. Among them, the above computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above computer terminal. For example, the computer terminal may further include more or fewer components than Figure 1 shown in the figure, or have a different configuration from Figure 1 shown in the figure.
[0039] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data caching method in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above-mentioned method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the computer terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, intranet, local area network, mobile communication network, and their combinations.
[0040] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of a computer terminal. In one instance, the transmission device 106 includes a network adapter (abbreviated as NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (abbreviated as RF) module, which is used to communicate with the Internet wirelessly.
[0041] Embodiments of the present application provide a data caching method, and the method is described in detail in combination with the execution process of the data caching method.
[0042] The following explains the professional terms appearing in the present application:
[0043] FDP: Flexible Data Placement, a data placement method in the NVMe protocol according to a specified placement rule (hotness).
[0044] FDP disk: An NVMe SSD disk that stores data according to the FDP data placement method.
[0045] PI: Placement Identifier, a data structure that specifies a reclaim group identifier and a placement handle that references a reclaim unit.
[0046] Placement Handle: A namespace-scope handle that maps to a reclaim unit handle in the RG scope and references a reclaim unit in each reclaim group.
[0047] RG: Reclaim Group, an entity that contains one or more reclaim units.
[0048] RU: Reclaim Unit, a logical representation of non-volatile storage within a reclaim group that can be physically erased by the controller without disturbing any other reclaim units.
[0049] RUH: Reclaim Unit Handle, a controller resource that references a reclaim unit in each reclaim group.
[0050] LBA: Logical Block Address
[0051] PBA: Physics Block Address
[0052] In this embodiment, a data caching method is provided. Figure 2 It is a flowchart of the data caching method according to an embodiment of the present invention, as Figure 2 shown, and this process includes the following steps:
[0053] Step S202, determine the instruction type of the received data caching instruction;
[0054] Among them, the data caching instruction can be an instruction input by the user through the display interface, and the instruction type of the data caching instruction can include a data reading type, a data writing type, etc. When the instruction type is the data reading type, it can be to read data from the storage system, and when the instruction type is the data writing type, it can be to write data to the storage system.
[0055] Step S204, in the case that the instruction type indicates that the data caching instruction is of the data reading type, search for the target data indicated by the data caching instruction in the target cache of the storage system;
[0056] Among them, the storage system can include a target cache and a target disk. The storage system can be a system that supports the FDP protocol, and the target disk can be a multi-stream disk or a disk that supports the FDP protocol, such as an SSD (Solid State Drive, solid-state drive) that supports the FDP protocol.
[0057] In this embodiment, a schematic diagram of the structure of the target disk can be seen in the appendix Figure 3 as Figure 3 shown. The target disk can include multiple reclaim groups (Reclaim Group, RG), and each RG can include multiple reclaim units (Reclaim Unit, RU). Each reclaim unit can correspond to a reclaim unit handle (Reclaim Unit Handle, RUH), and the reclaim unit handles corresponding to different reclaim units are different.
[0058] The minimum storage structure of an SSD that supports the FDP protocol provides a non-volatile storage virtual view based on a Reclaim Group (RG), Reclaim Unit (RU), and Placement Identifier (PI), allowing the host to directly write write commands to a virtual reclaim unit referenced by a placement identifier on a specific reclaim group.
[0059] The Reclaim Unit specified by a Reclaim Unit Handle can only be accessed by one Reclaim Unit Handle. After the Reclaim Unit is reclaimed, it can be referenced by other Reclaim Unit Handles. When a ReclaimUnit is full, the controller needs to replace it with another Reclaim Unit for subsequent optimization.
[0060] In this embodiment, when the data cache instruction is a data read instruction, it is possible to first check whether the target data exists in the target cache. If the target data exists in the target cache, the target data in the target cache is directly read.
[0061] Step S206, in the case where the target data does not exist in the target cache, determine a first reclaim unit included in the storage system for storing the target data based on the first storage address included in the data cache instruction, where the first reclaim unit is a unit in the target hard disk included in the storage system, and the target hard disk includes multiple reclaim units, and each reclaim unit is used to store the same type of data;
[0062] In this embodiment, the first storage address may be a Logical Block Address (LBA), and the data cache instruction may include disk parameters such as LBA, offset, and length. The first reclaim unit included in the storage system for storing the target data can be determined according to the first storage address included in the data cache instruction. Among them, the data stored in the first reclaim unit may be the same type of data. The same type of data includes data with the same heat, for example, the data stored in the first reclaim unit are all cold data, all hot data, all warm data, etc. The same type of data may also include data with the same access count, may also include data with the same access frequency, etc., and may also include data from the same Stream Identifier (StreamID). In the present invention, there is no limitation on the data of the same type.
[0063] In this embodiment, when the same type of data stored in the reclaim unit is data with the same heat, the characteristic that data on the RG of the FDP SSD is stored according to heat can be utilized to improve the hit rate of data prefetching.
[0064] Step S208, when the target identifier is included in the data cache instruction, store all the data included in the first recovery unit into the target cache.
[0065] In this embodiment, for the read instruction of the FDP protocol, a target identifier can be added to the data cache instruction. That is, the data cache instruction can include conventional parameters such as LBA, data offset, length, etc., and can also include a target identifier. Among them, the target identifier can be an RU read flag, which is used to indicate reading the data in the entire RU. When the target identifier is included in the data cache instruction, the data on the target RU where the target data is located can be read out as a whole.
[0066] In this embodiment, taking full advantage of the characteristic that the FDP disk or multi-stream disk data is written according to the heat and different heat data is physically isolated and stored, when accessing a hot data during data access, through the modified FDP read command, the data on the same RU or a stream id can be prefetched.
[0067] In the above embodiment, by storing data in different recovery units according to types, the rapid positioning and reading of data can be realized, unnecessary hard disk reading operations are reduced, and the data access speed is improved. For example, hot data (frequently accessed data) and cold data (less frequently accessed data) are stored in different recovery units respectively. When reading hot data, it can be directly obtained from the cache without accessing the hard disk, thus significantly improving the data reading efficiency. In addition, a target identifier can also be written in the data cache instruction. When the instruction contains the target identifier, the data of the entire recovery unit can be loaded into the cache at one time, avoiding multiple reading operations, further improving the data access speed, and then increasing the hit rate of the data cache.
[0068] Through this application, since the target hard disk included in the storage system includes multiple recovery units, and each recovery unit can store the same type of data. When the received data cache instruction is a data reading type instruction and the target data indicated by the data cache instruction is not included in the target cache included in the storage system, the first recovery unit can be determined according to the first storage address included in the data cache instruction, and all the data included in the first recovery unit is stored in the target cache, that is, according to a data cache instruction, all the data in the first recovery unit is read into the target cache. Therefore, the technical problem of low data cache hit rate existing in the related technology can be solved, and the technical effect of improving the data cache hit rate can be achieved.
[0069] In an exemplary embodiment, storing all the data included in the first recovery unit into the target cache includes: determining the total amount of target data of the data included in the first recovery unit; determining the total amount of remaining data in the first target cache; and storing all the data included in the first recovery unit into the target cache based on the total amount of target data and the total amount of remaining data in the first target cache. In this embodiment, the logical block address (LBA) for data storage can be calculated according to the data caching instruction, and a read command is sent to the target disk. The read command includes conventional parameters such as the LBA, data offset, and length, and also carries the target identifier for reading the entire RU, so as to read the data on the corresponding RU as a whole. Then, it is judged whether there is remaining space in the read cache, i.e., the target cache. When there is sufficient remaining space, all the data in the first recovery unit is read into the target cache. Among them, it can be determined whether there is sufficient remaining space in the target cache according to the total amount of target data of all the data included in the first recovery unit and the total amount of remaining data in the target cache.
[0070] In the above embodiment, by calculating the total amount of target data and the remaining space of the target cache, it is intelligently determined whether all the data in the target recovery unit can be loaded into the cache. For example, if the total amount of target data is 1 GB and the remaining space of the target cache is 1.5 GB, then all the target data can be loaded into the cache without performing a data clearing operation. On the contrary, if the total amount of target data exceeds the remaining space of the target cache, a data clearing operation needs to be performed to free up enough space. This method avoids wasting cache space and ensures the efficient use of the cache.
[0071] In an exemplary embodiment, storing all the data included in the first recovery unit into the target cache based on the total amount of target data and the total amount of remaining data in the first target cache includes: when the total amount of remaining data in the first target cache is greater than or equal to the total amount of target data, storing all the data included in the first recovery unit into the target cache; when the total amount of remaining data in the first target cache is less than the total amount of target data, determining the data to be cleared in the target cache, where the total amount of the data to be cleared is greater than or equal to the total amount of target data; clearing the data to be cleared from the target cache, and after the clearing is completed, storing the target data into the target cache. In this embodiment, when the total amount of remaining data in the first target cache is greater than or equal to the total amount of target data, it indicates that there is sufficient remaining space in the target cache, so all the data in the first recovery unit can be directly stored into the target cache. When the total amount of remaining data in the first target cache is less than the total amount of target data, it indicates that there is not enough remaining space in the target cache. Therefore, the target cache can be released. For example, the data to be cleared can be determined in the target cache and cleared from the target cache to free up more space to store all the data in the first recovery unit.
[0072] In the above embodiments, the data to be cleared is determined through a priority mechanism, ensuring that the most frequently used data is stored in the cache. For example, hot data, warm data, and cold data may be stored in the cache simultaneously. When the cache space is insufficient, cold data is preferentially cleared. If the space is still insufficient, warm data is further cleared until there is enough space to load the target data. This method not only improves the data access speed but also optimizes the overall performance of the storage system.
[0073] In an exemplary embodiment, determining the data to be cleared in the target cache includes: determining the first data type of the cache data included in the target cache; determining the first data included in the cache data, where the first data is the data corresponding to the type with the lowest priority among the types included in the first data type; determining the total amount of the first data; determining the data to be cleared from the first data when the total amount of the first data is greater than or equal to the total amount of the target data; determining the second data included in the cache data when the total amount of the first data is less than the total amount of the target data, where the second data is the data corresponding to the type with a priority higher than that of the first data among the types included in the first data type; and determining the data to be cleared from the first data and the second data. In this embodiment, the first data type may include hot data, warm data, cold data, etc. Among them, hot data may be those with a very high access frequency, which usually need to be accessed and processed quickly to support high-concurrency or real-time applications. Cold Data may be those with a very low access frequency and may not be accessed or updated for a long time. Warm data is between hot data and cold data and may be those with a medium access frequency. They are not accessed as frequently as hot data but are not untouched for as long as cold data. Warm data needs to find a balance between storage cost and access speed. Among them, the priority of hot data is higher than that of warm data, and the priority of warm data is higher than that of cold data. When clearing data, cold data is preferentially cleared, that is, data with a low priority is preferentially cleared.
[0074] In the above embodiments, through the intelligent management of data types and priorities, the dynamic adjustment of the cache space is achieved, ensuring that the most frequently used data is stored in the cache. For example, hot data, warm data, and cold data may be stored in the cache simultaneously. When the cache space is insufficient, cold data is preferentially cleared. If the space is still insufficient, warm data is further cleared until there is enough space to load the target data. This method not only improves the data access speed but also optimizes the overall performance of the storage system.
[0075] In an exemplary embodiment, storing all the data included in the first recovery unit into the target cache includes: when the total amount of target data of all the data included in the first recovery unit is equal to the total amount of cached data of the target cache, clearing the target cache, and after the clearing is completed, storing all the data included in the first recovery unit into the target cache. In this embodiment, the total amount of cached data of the target cache may be the total capacity of the target cache. When the total amount of target data is equal to the total capacity of the target cache, the target cache can be directly cleared without judging the remaining space of the target cache, improving the data reading speed.
[0076] In an exemplary embodiment, determining a first recovery unit included in a storage system for storing target data based on a first storage address included in a data caching instruction includes: determining a placement identifier having a corresponding relationship with the first storage address; determining a recovery unit handle having a corresponding relationship with the placement identifier; and determining a recovery unit having a corresponding relationship with the recovery unit handle as the first recovery unit. In this embodiment, for a schematic diagram of the process of determining the first recovery unit, reference may be made to the appendix Figure 4 , such as Figure 4 shown. After determining the first storage address LBA, a placement identifier PI having a corresponding relationship with the first storage address can be determined, a recovery unit handle RUH having a corresponding relationship with PI can be determined, and an RU having a corresponding relationship with RUH can be determined, and this RU is determined as the first recovery unit.
[0077] In the above embodiment, in order to achieve the goal of reading the data of the RU specified by the logical address, the read process of the FDP protocol needs to be modified first. When reading data, a read command is sent to the disk. The read command includes conventional parameters such as LBA, data offset, and length, and should also include a flag indicating whether to read the entire RU, allowing a general read operation to only send the read request parameters of the disk and only read the data specified by the current logical address. It is also allowed to send a read command carrying the RU read flag to the disk to read the data of the entire RU.
[0078] In the above embodiment, through the association of the data storage address, the placement identifier, and the recovery unit handle, the rapid positioning and reading of data are realized, unnecessary hard disk reading operations are reduced, and the data access speed is improved. For example, when the data storage address is A, the identifier corresponding to the A address can be found by looking up the placement identifier table, and then the corresponding recovery unit handle can be found through the identifier, so as to quickly locate the target recovery unit. This method not only improves the data access speed but also optimizes the overall performance of the storage system.
[0079] In an exemplary embodiment, after determining the instruction type of the received data caching instruction, the method further includes: when the instruction type indicates that the data caching instruction is of a data write type, determining a second storage address included in the storage system for storing the data to be written; and writing the data to be written into the storage system based on the second storage address. In this embodiment, when the instruction type of the data caching instruction is of a data write type, the second storage address to which the data to be written is to be written can be determined. The second storage address can be a logical block address. And the data to be written is written into the storage system according to the second storage address.
[0080] In the above embodiment, by distinguishing between data read and data write instructions, efficient management of the storage system is achieved, frequent read and write operations on the hard disk are reduced, and the service life of the hard disk is extended. For example, when a data write instruction is received, the storage location of the data to be written can be determined first, and then the data can be written to the specified location. This method not only improves the data write speed but also optimizes the overall performance of the storage system.
[0081] In an exemplary embodiment, writing the data to be written into the storage system based on the second storage address includes: when the data caching instruction is a new write instruction, determining a second recycling unit included in the storage system for storing the data to be written based on the second storage address, where the data type of the data stored in the second recycling unit is the same as the data type of the data to be written; and writing the data to be written into the second recycling unit. In this embodiment, when the data caching instruction is a new write instruction, a new file can be directly created and written into the target hard disk, and then the process set by the system can be executed. For example, the second storage address can be determined according to the data type of the data to be written, and then the second recycling unit can be determined, and the data to be written is written into the second recycling unit. Using FDP SSD, the data heat of different types can be statistically analyzed at the storage system level. For example, the data heat inside the storage system can be divided into 4 types: metadata / write-ahead log / hot data / cold data, that is, divided into 4 streams. When business data is written, the data heat is distinguished through the storage pool (OSD). After each level in the system recognizes the data heat, they carry different information respectively, and then it is judged which RGs in the nvme SSD can be written. According to a certain mapping rule, the PI that can be mapped is calculated, and through the PI, it is mapped to the RUH on the RG, and through the RUH, it is mapped to the smallest unit RU where the specific data is stored.
[0082] In the above embodiment, the internal logic and external mapping diagram of writing data to the target hard disk can be seen in the appendix Figure 5 as Figure 5As shown, the Write CMD (Write command, that is, the data cache instruction) needs to carry PI information (including RUH and RG related information). The SSD supports a certain number of RUH and RG. Here, RU is the NAND management unit inside the SSD (the granularity of the erase operation), and RUH finds the corresponding RU in the specified RG. After a RU is full, the SSD automatically switches to another RU in the same RG. The garbage collection in the SSD is carried out according to RG and determines whether to distinguish RUH according to the FDP configuration. The host is allowed to manage which LBAs are written to the recovery unit. The host uses the Dataset Management command to release the LBAs contained in the recovery unit to minimize the movement of user data by the controller (i.e., garbage collection) and reduce write amplification. Through the mapping of LBA to PBA, PBA to PI, PI to RUH, RUH to RU, and then returning RU to the upper-layer application, RU is visible to the storage system and can read out data with the same heat.
[0083] In the above embodiment, the data on the FDP SSD can be stored in different RGs according to heat. Therefore, the data heat on the same RG is similar. When writing data, no additional data association calculation is required, which can not only improve the data cache hit rate, but also reduce write amplification and improve the lifespan of the FDP SSD. For example, when the data to be written is hot data, it can be written into the recovery unit dedicated to storing hot data. This method not only improves the data writing speed, but also optimizes the overall performance of the storage system.
[0084] In an exemplary embodiment, writing the data to be written into the storage system based on the second storage address includes: when the data cache instruction is a modify write instruction, determining the third recovery unit where the file to be modified indicated by the data cache instruction is located; caching all the data included in the third recovery unit into the hard disk cache of the target hard disk; modifying the file to be modified in the hard disk cache to obtain the data to be written. In this embodiment, when the data cache instruction is a modify write instruction, first read out the data of the original file, that is, the file to be modified, calculate the RUH of the file data first, use the modified data read command with the RU read flag, and put the data corresponding to the RU where the whole file is stored into the write cache, that is, the hard disk cache. The data of the original RU, that is, the third recovery unit, is marked invalid, and the entire third recovery unit RU can be recycled and reallocated.
[0085] In the above embodiments, by modifying data in the hard disk cache, frequent hard disk read and write operations are avoided, the data modification speed is increased, and the service life of the hard disk is extended. For example, when a file stored in the third recycling unit needs to be modified, it can be first loaded into the hard disk cache and then modified. This method not only increases the data modification speed but also optimizes the overall performance of the storage system.
[0086] In an exemplary embodiment, caching all the data included in the third recycling unit into the hard disk cache of the target hard disk includes: determining a second total data amount of all the data included in the third recycling unit; determining a second remaining data amount of the hard disk cache; and caching all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount. In this embodiment, by calculating the total data amount and the remaining cache space, it is intelligently determined whether all the data in the third recycling unit can be loaded into the hard disk cache, avoiding waste of cache space and ensuring efficient utilization of the cache. For example, if the total data amount of the third recycling unit is 500MB and the remaining space of the hard disk cache is 1GB, then all the data in the third recycling unit can be loaded into the hard disk cache without data clearing operations. On the contrary, if the total data amount exceeds the remaining space, data clearing operations need to be performed to free up enough space. This method not only increases the data access speed but also optimizes the overall performance of the storage system.
[0087] In an exemplary embodiment, caching all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount includes: when the second total data amount is less than or equal to the second remaining data amount, caching all the data included in the third recycling unit into the hard disk cache of the target hard disk; when the second total data amount is greater than the second remaining data amount, determining first data to be written to disk in the hard disk cache; clearing the first data to be written to disk from the hard disk cache, and after the clearing is completed, caching all the data included in the third recycling unit into the hard disk cache of the target hard disk. In this embodiment, the data to be written to disk can be determined through a priority mechanism, ensuring that the most frequently used data is stored in the hard disk cache, avoiding waste of cache space, and ensuring efficient utilization of the cache. For example, hot data, warm data, and cold data may be stored in the hard disk cache at the same time. When the cache space is insufficient, cold data is preferentially cleared. If the space is still insufficient, warm data is further cleared until there is enough space to load the data in the third recycling unit.
[0088] In an exemplary embodiment, determining first data to be flushed to disk in a hard disk cache includes: determining a second data type of the hard disk cache data cached in the hard disk cache; determining a third data included in the hard disk cache data, where the third data is data corresponding to the type with the lowest priority among those included in the second data type; determining a total amount of the third data; in the case where the total amount of the third data is greater than or equal to the total amount of the second data, determining the first data to be flushed to disk from the hard disk cache data; in the case where the total amount of the third data is less than the total amount of the second data, determining a fourth data included in the hard disk cache data, where the fourth data is data corresponding to the type with a priority higher than that of the third data among those included in the second data type; and determining the first data to be flushed to disk from the third data and the fourth data. In this embodiment, through the intelligent management of data types and priorities, the dynamic adjustment of the hard disk cache space is achieved, ensuring that the most frequently used data is stored in the hard disk cache, avoiding the waste of cache space, and ensuring the efficient utilization of the cache. For example, when the total amount of data to be loaded is 300 MB and the remaining space in the hard disk cache is 200 MB, cold data in the hard disk cache can be preferentially cleared. If the remaining space is still insufficient, warm data can be further cleared until there is enough space to load the required data.
[0089] In an exemplary embodiment, after caching all the data included in the third recycling unit to the hard disk cache of the target hard disk based on the total amount of the second data and the total amount of the second remaining data, the method further includes: determining a ratio between the total amount of data in the hard disk cache and the cache capacity of the hard disk cache; in the case where the ratio is greater than a predetermined threshold, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache. In this embodiment, when the write cache, that is, the capacity of the hard disk cache reaches a certain level, or a file needs to be flushed to disk, the RUH of the file to be flushed can be recalculated, and it is still written to the target hard disk according to the popularity. Among them, the hard disk cache can include non-volatile media such as memory which can be an SSD. Therefore, the files that have been flushed to disk will not be directly deleted from the cache.
[0090] In the above embodiment, by monitoring the usage of the hard disk cache, the intelligent release of cached data is achieved, avoiding data access latency caused by cache overflow and optimizing the overall performance of the storage system. For example, when the usage rate of the hard disk cache reaches 80%, cold data in the cache can be automatically released. If the usage rate is still higher than the predetermined threshold, warm data can be further released until the cache usage rate drops below the predetermined threshold.
[0091] In an exemplary embodiment, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache includes: when the second data type indicates that the hard disk cache data includes cold data, clearing the cold data from the hard disk cache; when the second data type indicates that the hard disk cache data includes warm data, setting the cache duration of the warm data in the hard disk cache; and when the cache time of the warm data in the hard disk cache reaches the cache duration, clearing the warm data from the hard disk cache. In this embodiment, for the disk-written data, the cold data is cleared from the cache according to the heat degree. For the hot data, even if it has been disk-written, it remains in the cache. For the warm data, it can be determined whether to clear it from the cache according to the cache capacity.
[0092] In the above embodiment, by setting the cache policies for different data types, the intelligent management of the cache data is realized, the waste of the cache space is avoided, and the efficient utilization of the cache is ensured. For example, the cache policy for cold data can be immediate release, while the cache policy for warm data can be to set a cache duration, such as 1 hour. When the cache time of the warm data in the hard disk cache reaches 1 hour, it is automatically released.
[0093] In an exemplary embodiment, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache includes: when the second data type indicates that the hard disk cache data only includes hot data, determining the target hot data whose access times included in the hot data are less than a predetermined threshold; and clearing the target hot data from the hard disk cache. In this embodiment, if the cache needs to be replaced, the warm data is first cleared from the cache; if all the data in the cache is hot data, then the hot data with the least recent access is cleared.
[0094] In the above embodiment, through the intelligent management of the access frequency, the dynamic adjustment of the hot data is realized, the waste of the cache space is avoided, and the efficient utilization of the cache is ensured.
[0095] In the above embodiment, the flowchart of the data writing into the storage system can be referred to in the appendix Figure 6 as Figure 6 shown, and this process includes:
[0096] Step S602, write operation.
[0097] Step S604, determine whether it is a modified write. If the determination result is yes, execute step S606; if the determination result is no, execute step S608.
[0098] Step S606, use a new read command of read RU to read the original file and read out the RU data at the same time.
[0099] Step S608, normal write process.
[0100] Step S610: Determine whether the condition for downward flushing is met. If the determination result is yes, execute Step S612; if the determination result is no, execute Step S614.
[0101] Step S612: For hot data, retain the cache during downward flushing; for cold data, clear the cache after downward flushing; for warm data, part of the cache can be retained or retained for a short time.
[0102] Step S614: End.
[0103] In an exemplary embodiment, when detecting a hot data access to a specific logical block address (LBA), not only read the data of this LBA, but also prefetch other data blocks within the same recovery unit (RU) where this LBA is located, as well as the data of other RUs with similar hotness within the same recovery group (RG) according to the LBA; adjust the prefetch range according to the dynamic change of data hotness. For newly upgraded hot data, the initial prefetch range is limited to the same RU. As the access frequency increases, the prefetch range can be extended to the same RG or multiple RGs; set prefetch priorities, and preferentially prefetch high-hotness data blocks to ensure the efficient use of limited cache resources. Among them, the pattern of hot data access can also be identified, and machine learning algorithms can be used to predict the access trend of hot data, and adjust the prefetch strategy and cache management strategy in advance; evaluate the cache space status in real time and dynamically adjust the prefetch strategy to ensure the efficient use of the cache. When performing a modified write operation, use a read command with a tag carrying the entire RU read, read the data of the entire RU, evaluate whether it is necessary to re-cache the data of the entire RU, and further reduce the write amplification; when writing data, dynamically adjust the allocation of RG and RU according to the flow ID and data hotness, optimize the data placement, and reduce the garbage collection operation.
[0104] Hot data that has not been accessed for a long time is automatically downgraded to warm data, further downgraded to cold data, and finally cleared to maintain the freshness and efficiency of the cache.
[0105] In the above embodiment, in addition to the precise reading based on LBA, the system monitors the access pattern and identifies the pattern of hot data access. For example, if frequent access to a certain LBA is detected, the system not only reads the data of this LBA, but also prefetches the data of other blocks within the same RU as this LBA, and even the data of other RUs with similar hotness within the same RG to improve the hit rate. The prefetch range can be adjusted according to the dynamic change of data hotness. When a data block is first marked as hot data, the prefetch range is small, limited to the same RU. As the access frequency increases, the prefetch range can be extended to the same RG or multiple RGs to adapt to the changing access pattern. Set prefetch priorities, and preferentially prefetch high-hotness data blocks to ensure the efficient use of limited cache resources.
[0106] In the foregoing embodiments, the FDP disk can store data physically isolated according to specific attributes. Therefore, by optimizing the FDP protocol, the read command can read the entire RU, achieving the effect that hot data is cached as much as possible, warm data is cached for a short time, and cold data is not cached even if accessed occasionally. The read command is allowed to increase the read minimum data storage unit RU, and according to the partition isolation characteristics of the FDP disk, prefetch data according to the recovery unit, so as to cache the same heat or the same data together.
[0107] In the foregoing embodiments, the data caching method can be used for a storage medium composed of FDP SSDs, and can also be applied to all media that can store data by shunting according to specific attributes, such as multi-stream disks, or subsequent disks similar to the FDP disk that can distinguish data attributes for storing data.
[0108] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method.
[0109] An embodiment of the present application also provides a data caching device. Figure 7 It is a structural block diagram of the data caching device according to an embodiment of the present invention, as Figure 7 shown. The device includes:
[0110] A first determination module 72, configured to determine the instruction type of the received data caching instruction;
[0111] A search module 74, configured to search for the target data indicated by the data caching instruction in the target cache of the storage system when the instruction type indicates that the data caching instruction is a data read type;
[0112] A second determination module 76, configured to, when the target data does not exist in the target cache, determine a first recovery unit included in the storage system for storing the target data based on a first storage address included in the data caching instruction, where the first recovery unit is a unit in the target hard disk included in the storage system, and the target hard disk includes multiple recovery units, and each recovery unit is used to store the same type of data;
[0113] A cache module 78, configured to store all the data included in the first recovery unit into the target cache when the data caching instruction includes a target identifier.
[0114] In an exemplary embodiment, the cache module 78 may store all the data included in the first recycling unit into the target cache in the following manner: determine the total amount of target data of the data included in the first recycling unit; determine the total amount of the first remaining data in the target cache; and store all the data included in the first recycling unit into the target cache based on the total amount of target data and the total amount of the first remaining data.
[0115] In an exemplary embodiment, the cache module 78 may store all the data included in the first recycling unit into the target cache based on the total amount of target data and the total amount of the first remaining data in the following manner: when the total amount of the first remaining data is greater than or equal to the total amount of target data, store all the data included in the first recycling unit into the target cache; when the total amount of the first remaining data is less than the total amount of target data, determine the data to be cleared in the target cache, where the total amount of the data to be cleared is greater than or equal to the total amount of target data; clear the data to be cleared from the target cache, and after the clearing is completed, store the target data into the target cache.
[0116] In an exemplary embodiment, the cache module 78 may determine the data to be cleared in the target cache in the following manner: determine the first data type of the cached data included in the target cache; determine the first data included in the cached data, where the first data is the data corresponding to the type with the lowest priority among the types included in the first data type; determine the total amount of the first data; when the total amount of the first data is greater than or equal to the total amount of target data, determine the data to be cleared from the first data; when the total amount of the first data is less than the total amount of target data, determine the second data included in the cached data, where the second data is the data corresponding to the type with a priority higher than that of the first data among the types included in the first data type; and determine the data to be cleared from the first data and the second data.
[0117] In an exemplary embodiment, the cache module 78 may store all the data included in the first recycling unit into the target cache in the following manner: when the total amount of target data of all the data included in the first recycling unit is equal to the total amount of the cached data in the target cache, clear the target cache, and after the clearing is completed, store all the data included in the first recycling unit into the target cache.
[0118] In an exemplary embodiment, the second determination module 76 may determine the first recycling unit included in the storage system for storing the target data based on the first storage address included in the data caching instruction in the following manner: determine the placement identifier corresponding to the first storage address; determine the recycling unit handle corresponding to the placement identifier; and determine the recycling unit corresponding to the recycling unit handle as the first recycling unit.
[0119] In an exemplary embodiment, the data caching device may be configured to, after determining the instruction type of the received data caching instruction: when the instruction type indicates that the data caching instruction is of the data writing type, determine a second storage address included in the storage system for storing the data to be written; and write the data to be written into the storage system based on the second storage address. In this embodiment,
[0120] In an exemplary embodiment, the data caching device may implement writing the data to be written into the storage system based on the second storage address in the following manner: when the data caching instruction is a new write instruction, determine a second recycling unit included in the storage system for storing the data to be written, where the data type of the data stored in the second recycling unit is the same as the data type of the data to be written; and write the data to be written into the second recycling unit.
[0121] In an exemplary embodiment, the data caching device may implement writing the data to be written into the storage system based on the second storage address in the following manner: when the data caching instruction is a modify write instruction, determine a third recycling unit where the file to be modified is located indicated by the data caching instruction; cache all the data included in the third recycling unit into the hard disk cache of the target hard disk; and modify the file to be modified in the hard disk cache to obtain the data to be written.
[0122] In an exemplary embodiment, the data caching device may implement caching all the data included in the third recycling unit into the hard disk cache of the target hard disk in the following manner: determine a second total data amount of all the data included in the third recycling unit; determine a second remaining data amount of the hard disk cache; and cache all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount.
[0123] In an exemplary embodiment, the data caching device may implement caching all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount in the following manner: when the second total data amount is less than or equal to the second remaining data amount, cache all the data included in the third recycling unit into the hard disk cache of the target hard disk; when the second total data amount is greater than the second remaining data amount, determine first data to be flushed to disk in the hard disk cache; clear the first data to be flushed to disk from the hard disk cache, and after the clearing is completed, cache all the data included in the third recycling unit into the hard disk cache of the target hard disk.
[0124] In an exemplary embodiment, the cache device for data may determine the first data to be flushed to disk in the hard disk cache in the following manner: determine the second data type of the hard disk cache data cached in the hard disk cache; determine the third data included in the hard disk cache data, where the third data is the data corresponding to the type with the lowest priority included in the second data type; determine the total amount of the third data; in the case where the total amount of the third data is greater than or equal to the total amount of the second data, determine the first data to be flushed to disk in the hard disk cache data; in the case where the total amount of the third data is less than the total amount of the second data, determine the fourth data included in the hard disk cache data, where the fourth data is the data corresponding to the type with a priority higher than that of the third data in the second data type; determine the first data to be flushed to disk from among the third data and the fourth data.
[0125] In an exemplary embodiment, the cache device for data may also be used after caching all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the total amount of the second data and the total amount of the second remaining data: determine the ratio between the total amount of data in the hard disk cache and the cache capacity of the hard disk cache; in the case where the ratio is greater than a predetermined threshold, release the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache.
[0126] In an exemplary embodiment, the cache device for data may release the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache in the following manner: in the case where the second data type indicates that the hard disk cache data includes cold data, clear the cold data from the hard disk cache; in the case where the second data type indicates that the hard disk cache data includes warm data, set the cache duration of the warm data in the hard disk cache; in the case where the cache time of the warm data in the hard disk cache reaches the cache duration, clear the warm data from the hard disk cache.
[0127] In an exemplary embodiment, the cache device for data may release the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache in the following manner: in the case where the second data type indicates that the hard disk cache data only includes hot data, determine the target hot data whose access times are less than a predetermined threshold among the hot data; clear the target hot data from the hard disk cache.
[0128] For the description of the features in the corresponding embodiments of the cache device for data, reference may be made to the relevant description of the corresponding embodiments of the data caching method, which will not be elaborated herein one by one.
[0129] An embodiment of the present application also provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any of the above-described embodiments of the data caching method.
[0130] An embodiment of the present application further provides a storage system for performing the data caching method in any of the above embodiments, including a target hard disk, the target hard disk includes a plurality of recycling units, and each recycling unit is used to store the same type of data; a target cache for caching the data read from the target hard disk.
[0131] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. Wherein, the computer program is configured to execute the steps in any of the above embodiments of the data caching method when running.
[0132] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drive, read-only memory (ROM for short), random access memory (RAM for short), mobile hard disk, magnetic disk or optical disc and other various media that can store computer programs.
[0133] An embodiment of the present application further provides a computer program product. The above computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above embodiments of the data caching method.
[0134] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above embodiments of the data caching method.
[0135] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0136] The above has introduced in detail a data caching provided by this application. Specific examples are used in this article to elaborate on the principle and implementation manner of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and modifications can still be made to this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A method for caching data, characterized in that: It includes: Determine the instruction type of the received data caching instruction; When the instruction type indicates that the data caching instruction is a data reading type, look up the target data indicated by the data caching instruction in the target cache of the storage system; When the target data does not exist in the target cache, determine the first recycling unit included in the storage system for storing the target data based on the first storage address included in the data caching instruction, where the first recycling unit is a unit in the target hard disk included in the storage system, and the target hard disk includes multiple recycling units, and each recycling unit is used to store data of the same type; When the data caching instruction includes a target identifier, store all the data included in the first recycling unit into the target cache.
2. The method for caching data according to claim 1, characterized in that: The storing all the data included in the first recycling unit into the target cache includes: Determine the total amount of target data of the data included in the first recycling unit; Determine the total amount of the first remaining data in the target cache; Based on the total amount of target data and the total amount of the first remaining data, store all the data included in the first recycling unit into the target cache.
3. The method for caching data according to claim 2, characterized in that: The storing all the data included in the first recycling unit into the target cache based on the total amount of target data and the total amount of the first remaining data includes: When the total amount of the first remaining data is greater than or equal to the total amount of target data, store all the data included in the first recycling unit into the target cache; When the total amount of the first remaining data is less than the total amount of target data, determine the data to be cleared in the target cache, where the total amount of the data to be cleared is greater than or equal to the total amount of target data; Clear the data to be cleared from the target cache, and after the clearing is completed, store the target data into the target cache.
4. The method for caching data according to claim 3, characterized in that: The determining the data to be cleared in the target cache includes: Determine the first data type of the cached data included in the target cache; Determine the first data included in the cached data, where the first data is the data corresponding to the type with the lowest priority included in the first data type; Determine the total amount of the first data; When the total amount of the first data is greater than or equal to the total amount of target data, determine the data to be cleared in the first data; When the total amount of the first data is less than the total amount of target data, determine the second data included in the cached data, where the second data is the data corresponding to the type with a priority higher than that of the first data included in the first data type; Determine the data to be cleared from the first data and the second data.
5. The caching method for data according to claim 1, wherein: The storing all data included in the first recycling unit into the target cache includes: When the total amount of target data of all data included in the first recycling unit is equal to the total amount of cached data of the target cache, clearing the target cache, and after the clearing is completed, storing all data included in the first recycling unit into the target cache.
6. The caching method for data according to claim 1, wherein: The determining the first recycling unit included in the storage system for storing the target data based on the first storage address included in the data caching instruction includes: Determining a placement identifier having a corresponding relationship with the first storage address; Determining a recycling unit handle having a corresponding relationship with the placement identifier; Determining the recycling unit having a corresponding relationship with the recycling unit handle as the first recycling unit.
7. The caching method for data according to claim 1, wherein: After determining the instruction type of the received data caching instruction, the method further includes: When the instruction type indicates that the data caching instruction is of the data writing type, determining a second storage address included in the storage system for storing the data to be written; Writing the data to be written into the storage system based on the second storage address.
8. The caching method for data according to claim 7, wherein: The writing the data to be written into the storage system based on the second storage address includes: When the data caching instruction is a new write instruction, determining a second recycling unit included in the storage system for storing the data to be written, wherein the data type of the data stored in the second recycling unit is the same as the data type of the data to be written; Writing the data to be written into the second recycling unit.
9. The caching method for data according to claim 7, wherein: The writing the data to be written into the storage system based on the second storage address includes: When the data caching instruction is a modify write instruction, determining the third recycling unit where the file to be modified indicated by the data caching instruction is located; Caching all data included in the third recycling unit into the hard disk cache of the target hard disk; Modifying the file to be modified in the hard disk cache to obtain the data to be written.
10. The caching method for data according to claim 9, wherein: The caching all data included in the third recycling unit into the hard disk cache of the target hard disk includes: Determining the total amount of second data of all data included in the third recycling unit; Determining the total amount of second remaining data of the hard disk cache; Caching all data included in the third recycling unit into the hard disk cache of the target hard disk based on the total amount of second data and the total amount of second remaining data.
11. The caching method for data according to claim 10, wherein: Caching all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount includes: When the second total data amount is less than or equal to the second remaining data amount, caching all the data included in the third recycling unit into the hard disk cache of the target hard disk; When the second total data amount is greater than the second remaining data amount, determining first data to be written to disk in the hard disk cache; Clearing the first data to be written to disk from the hard disk cache, and after the clearing is completed, caching all the data included in the third recycling unit into the hard disk cache of the target hard disk.
12. The data caching method according to claim 11, wherein: The determining first data to be written to disk in the hard disk cache includes: Determining a second data type of the hard disk cache data cached in the hard disk cache; Determining third data included in the hard disk cache data, where the third data is data corresponding to the type with the lowest priority among the types included in the second data type; Determining a third total data amount of the third data; When the third total data amount is greater than or equal to the second total data amount, determining the first data to be written to disk in the hard disk cache data; When the third total data amount is less than the second total data amount, determining fourth data included in the hard disk cache data, where the fourth data is data corresponding to the type with a priority higher than that of the third data among the types included in the second data type; Determining the first data to be written to disk from among the third data and the fourth data.
13. The data caching method according to claim 10, wherein: After caching all the data included in the third recycling unit into the hard disk cache of the target hard disk based on the second total data amount and the second remaining data amount, the method further includes: Calculating a ratio between the total data amount in the hard disk cache and the cache capacity of the hard disk cache; When the ratio is greater than a predetermined threshold, releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache.
14. The data caching method according to claim 13, wherein: The releasing the hard disk cache data based on the second data type of the hard disk cache data in the hard disk cache includes: When the second data type indicates that cold data is included in the hard disk cache data, clearing the cold data from the hard disk cache; When the second data type indicates that warm data is included in the hard disk cache data, setting a cache duration of the warm data in the hard disk cache; When the cache time of the warm data in the hard disk cache reaches the cache duration, clearing the warm data from the hard disk cache.
15. The data caching method according to claim 13, wherein: Releasing the hard disk cache data based on the second data type in the hard disk cache includes: When the second data type indicates that the hard disk cache data only includes hot data, determining target hot data in the hot data whose access times are less than a predetermined threshold; Clearing the target hot data from the hard disk cache.
16. A storage system, characterized in that, For executing the data caching method according to any one of claims 1 to 15, including: A target hard disk, the target hard disk including a plurality of recycling units, each of the recycling units being used to store data of the same type; A target cache for caching data read from the target hard disk.
17. A caching device for data, characterized in that, Including: A first determination module for determining the instruction type of a received data caching instruction; A lookup module for, when the instruction type indicates that the data caching instruction is a data reading type, looking up the target data indicated by the data caching instruction in a target cache of a storage system; A second determination module for, when the target data does not exist in the target cache, determining a first recycling unit included in the storage system for storing the target data based on a first storage address included in the data caching instruction, where the first recycling unit is a unit in a target hard disk included in the storage system, the target hard disk including a plurality of recycling units, each of the recycling units being used to store data of the same type; A caching module for, when the data caching instruction includes a target identifier, storing all data included in the first recycling unit into the target cache.
18. An electronic device, characterized in that, Including: A memory for storing a computer program; A processor for, when executing the computer program, implementing the steps of the data caching method according to any one of claims 1 to 15.
19. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, where the computer program, when executed by a processor, implements the steps of the data caching method according to any one of claims 1 to 15.
20. A computer program product comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the steps of the data caching method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Increasing data heat tracking resolution in storage devices having cache architecture
CN112346658A
File dynamic caching method and device, equipment and storage medium
CN116821072A
Garbage recycling method, device and equipment for solid state disk and medium
CN119739341A
Caching device, cache, system, method and apparatus for processing data, and medium
US20210271475A1
Cited By
Processor, display card, computer equipment and constant reading method
CN120596427A