Cache management method and related equipment
By merging the read cache and the write cache into the same data structure, the problem of low read search efficiency in the existing technology is solved, and more efficient cache management is achieved.
Patent Information
- Application Number
- CN202410878037.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-28
AI Technical Summary
In the existing cache management method, the read cache and the write cache are independent data structures, which results in the need to search separately when performing a read search operation, resulting in a long search path and low efficiency.
By obtaining the read search command, address mapping is performed based on the preset address mapping rules to determine the target dirty data block. If the data transfer status is completed, the target data is obtained. The read cache and write cache are merged into the same data structure. Only the merged data structure Search in .
The search process is simplified, search paths are reduced, search efficiency is improved, and the overall search efficiency is high.
Smart Images

Figure CN118760397A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of cache management, and more specifically, to a cache management method, a cache management apparatus, a computer device, a computer-readable storage medium, and a computer program product including instructions or a computer program. Background Art
[0002] Currently, DRAM space is mostly used as a cache for read and write IO in enterprise-level SSDs (Solid State Drives). Due to the physical characteristics of DRAM media, the host's operations on data on the DRAM disk are much faster than those on the NAND disk. Efficient use of cache space is a key factor in reducing read and write latency, improving QoS, and optimizing performance. There are generally two types of cache in the disk: read and write. The write cache is used to cache user data sent by the host. When certain conditions are met, it needs to be flushed to NAND by the background for persistence. After persistence is completed, the cache is released; the read cache is used to cache pre-fetched data. The disk prepares the data that the host is going to read in the cache in advance. If the read command hits, the data is directly returned to the host from the cache. In the business process of the host sending a read command to the disk for read search, the cache can be searched for data.
[0003] The existing cache management method is a read-write cache separation management method, which specifically refers to setting up a read cache and a write cache separately in the SSD. The read cache and the write cache belong to different data structures, and the two are independent of each other and do not interfere with each other. When performing a read search, the cache search needs to be performed separately in the write cache and the read cache. For example, assuming that the current host needs to access a data block, it first needs to search in the write cache to see if the data block exists. If not, it needs to search in the read cache to see if the data block exists. If the data block is neither in the write cache nor in the read cache, it needs to be read from the NAND.
[0004] However, in the existing cache management method, the read cache and the write cache are set independently, that is, the read cache and the write cache belong to different data structures and are managed by their own data structures. Therefore, when performing a read search operation, it is necessary to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, and two search operations are required. Therefore, the overall search path is long and the search efficiency is low. Summary of the invention
[0005] Embodiments of the present application provide a cache management method, a cache management apparatus, a computer device, a computer-readable storage medium, and a computer program product including instructions or a computer program, for performing cache management while improving search efficiency.
[0006] In a first aspect, an embodiment of the present application provides a cache management method, including:
[0007] Obtaining a read search command, wherein the read search command is used to search for and read data in a first logical address range;
[0008] Performing address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping;
[0009] Determine, in at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block;
[0010] If the data transmission status of the at least one first target dirty data block is transmission completed, obtaining target data with overlapping logical address ranges in the at least one first target dirty data block;
[0011] A search result of the first read search command is obtained based on the target data.
[0012] In a second aspect, an embodiment of the present application provides a cache management device, including:
[0013] an obtaining unit, configured to obtain a read search command, wherein the read search command is used to search for and read data in a first logical address range;
[0014] An address mapping unit, configured to perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping;
[0015] A determining unit, configured to determine, from at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block;
[0016] an acquiring unit, configured to acquire target data with overlapping logical address ranges in the at least one first target dirty data block if the data transmission status of the at least one first target dirty data block is transmission completed;
[0017] The obtaining unit is further used to obtain a search result of the first read search command based on the target data.
[0018] In a third aspect, an embodiment of the present application provides a computer device, including:
[0019] CPU, memory, input and output interfaces, wired or wireless network interfaces, and power supply;
[0020] The memory is a short-term storage memory or a persistent storage memory;
[0021] The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the aforementioned cache management method.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes instructions. When the instructions are executed on a computer, the computer executes the aforementioned cache management method.
[0023] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when the computer program product is run on a computer, enables the computer to execute the aforementioned cache management method.
[0024] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: a read search command can be obtained, the first logical address range is address mapped based on the first preset address mapping rule, at least one target first logical address range after address mapping is obtained, and at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range is determined in the at least one target dirty data block in the dirty data block linked list of the target hash table, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of the at least one first target dirty data block is completed, the target data whose logical address range overlaps in the at least one first target dirty data block is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed at the same time in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A schematic diagram of the architecture of a cache management system disclosed in an embodiment of the present application;
[0026] Figure 2 A schematic diagram of a cache management method disclosed in an embodiment of the present application;
[0027] Figure 3A flowchart of another cache management method disclosed in an embodiment of the present application;
[0028] Figure 4 A flowchart of a read search method for unified management of read and write caches disclosed in an embodiment of the present application;
[0029] Figure 5 A flowchart of another cache management method disclosed in an embodiment of the present application;
[0030] Figure 6 A schematic diagram of an existing SSD write cache management framework;
[0031] Figure 7 A schematic diagram of an existing SSD read cache management framework;
[0032] Figure 8 A flowchart of another cache management method disclosed in an embodiment of the present application;
[0033] Fig. 9 A flowchart of a read cache insertion method with unified cache management disclosed in an embodiment of the present application;
[0034] Fig.10 A flowchart of another cache management method disclosed in an embodiment of the present application;
[0035] Fig.11 A flowchart of a write cache insertion method with unified cache management disclosed in an embodiment of the present application;
[0036] Fig.12 A schematic diagram of the structure of a cache management device disclosed in an embodiment of the present application;
[0037] Fig.13 A schematic diagram of the structure of another cache management device disclosed in an embodiment of the present application;
[0038] Fig.14 A schematic diagram of the structure of a computer device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0039] Embodiments of the present application provide a cache management method, a cache management apparatus, a computer device, a computer-readable storage medium, and a computer program product including instructions or a computer program, for performing cache management while improving search efficiency.
[0040] See also Figure 1 In the embodiment of the present application, the architecture of the cache management system 100 includes:
[0041] Cache management device 101 and file management device 102 (software program such as file system or application program, etc.). When performing cache management, cache management device 101 can be connected to file management device 102. Cache management device 101 can obtain a read search command sent by file management device 102, and can perform address mapping on the first logical address range based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, and determine at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range in at least one target dirty data block in the dirty data block linked list of the target hash table, the first target dirty data block being any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of at least one first target dirty data block is transmission completed, then obtain the target data whose logical address range overlaps in at least one first target dirty data block, obtain the search result of the first read search command based on the target data, and return the search result of the first read search command to the file management device.
[0042] The cache management device 101 may be a firmware or software for managing data cache between a computer memory and an external storage device.
[0043] The file management device 102 may be a device corresponding to a software program, including but not limited to a file system, an application program, etc., wherein the file system is a software component of an operating system, responsible for managing files and directories, and providing a file system interface for the application program. An application program refers to a software program running on a computer or other electronic device, which is designed to perform specific tasks or complete specific work, such as document editing, etc., and can run on various operating systems and platforms.
[0044] Some key terms in the examples of this application are explained as follows:
[0045] DirtyNode: DirtyNode is a write cache management data structure with unit data granularity. Its main data fields include logical address range, data address, data transmission status, cache reference count, and a bitmap collection for managing data status.
[0046] The data status represented by each Bitmap in the Bitmap collection: the data status represented by each Bitmap includes Dirtybmp, Validbmp, Pendingbmp, Sentbmp, and Donebmp.
[0047] Dirtybmp: Identifies data that can be flushed to NAND, bit1 indicates that it can be flushed. There may be discontinuous bit segments in the Bitmap, so the data of the DirtyNode may need to be flushed multiple times. After the data is flushed, the corresponding bit segment is cleared to 0. When Dirtybmp is 0, it does not necessarily mean that all the data of the DirtyNode has been flushed, and Pendingbmp needs to be considered. The initial value is LEN<<(SLBA%32).
[0048] Val idbmp: identifies valid data. When data is "invalidated", the corresponding bit needs to be cleared to 0. When the read hits the cache, the Bitmap needs to be checked. The initial value is the same as Dirtybmp.
[0049] Pendingbmp: Identifies data waiting to be flushed. Generally, when there is a write conflict, the old data is being flushed, and the new DirtyNode data in the conflicting range needs to be flushed later. After the old data is flushed, Pendingbmp clears the corresponding bit segment to 0 according to the flushed data and updates Dirtybmp.
[0050] Sentbmp: identifies the data that has been sent for flushing. This Bitmap actually represents the data being flushed to NAND and the data that has been flushed, and is used to assist in updating Dirtybmp.
[0051] Donebmp: identifies the data that has been flushed. It is usually calculated together with Sentbmp to calculate the data that is currently being flushed.
[0052] Hash table: also known as hash linked list, hash linked list (HashList) is a data structure that can be quickly inserted and searched, and is widely used in the Linux kernel. Its principle is that when a node is to be inserted, the node information is first mapped to a bucket on the hash table using a hash function, and then the node is added to the linked list in the bucket. When a node needs to be searched, the bucket is found using the same hash function based on the node information, and then the search is performed on the linked list of the specific bucket.
[0053] based on Figure 1 See the cache management system shown in Figure 2 , Figure 2 This is a flow chart of a cache management method disclosed in an embodiment of the present application, the method comprising:
[0054] 201. Obtain a read search command, where the read search command is used to search for and read data in a first logical address range.
[0055] In this embodiment, when cache management is performed, a read search command may be obtained, wherein the read search command is used to search for and read data in the first logical address range.
[0056] Specifically, for example, the first logical address range may be [20KB, 100KB] or [100KB, 150KB].
[0057] 202. Perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping.
[0058] After obtaining the read search command, the first logical address range may be address mapped based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping.
[0059] Specifically, continuing with the above example, if the first logical address range is [20KB, 100KB], the first logical address range [20KB, 100KB] can be address mapped based on the first preset address mapping rule to obtain a target first logical address range [20KB, 100KB] after address mapping. If the first logical address range is [100KB, 150KB], the first logical address range [100KB, 150KB] can be address mapped based on the first preset address mapping rule to obtain two target first logical address ranges [100KB, 128KB] and [128KB, 150KB] after address mapping.
[0060] 203. Among at least one target dirty data block in the dirty data block linked list of the target hash table, determine at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block.
[0061] After address mapping is performed on the first logical address range based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range can be determined in at least one target dirty data block in the dirty data block linked list of the target hash table, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block.
[0062] Specifically, for example, for a first logical address range of [20KB, 100KB], after obtaining a target first logical address range [20KB, 100KB] after address mapping, it can be determined that the first target dirty data block (which can be a first read dirty data block or a first write dirty data block, the logical address range is [0KB, 50KB]) whose logical address range overlaps with the target first logical address range [20KB, 100KB], and the overlapping range is [20KB, 50KB]. For a first logical address range of [100KB, 150KB], after obtaining two target first logical address ranges [100KB, 128KB] and [128KB, 150KB] after address mapping, the method for determining at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range is similar to the above, and is not limited here.
[0063] Among them, in at least one target dirty data block in the dirty data block linked list of the target hash table, a method for determining at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range may include but is not limited to the following two methods:
[0064] (1) Only through traversal method:
[0065] The dirty data block linked list of the target hash table is traversed in the target hash table based on the target logical address range to determine the hit dirty data block, wherein the target hash table includes a dirty data block linked list.
[0066] Specifically, the traversal may be started from the head node until a dirty data block that meets the conditions is found.
[0067] (2) Method of traversing after determining the corresponding bucket:
[0068] Based on the target logical address range and the hash algorithm, a corresponding bucket is determined in the target hash table, and the linked list of the bucket is traversed to determine the dirty data block, wherein the target hash table includes multiple hash buckets, and each hash bucket includes a linked list of dirty data blocks.
[0069] Specifically, the bucket corresponding to the target logical address range can be obtained through a hash algorithm, and then the linked list is traversed from the head node of the bucket until a dirty data block that meets the conditions is found. Compared with the method of only traversing, this method can reduce the number of invalid traversals and improve the search efficiency.
[0070] It is worth mentioning that the first target dirty data block can be any one of the first read dirty data block and the first write dirty data block, that is, the read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed simultaneously in this data structure. Therefore, in the read search process, when determining at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, it is only necessary to search in the merged data structure, and only one search operation is required. Therefore, the path for determining at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range is shorter and more efficient.
[0071] 204. If the data transmission status of at least one first target dirty data block is transmission completed, obtain target data with overlapping logical address ranges in at least one first target dirty data block.
[0072] After determining, in at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, if the data transmission status of at least one first target dirty data block is transmission completed, the target data whose logical address range overlaps in at least one first target dirty data block can be obtained.
[0073] Specifically, if the first target dirty data block is the first read dirty data block, the data transmission status of the first read dirty data block is transmission completion, indicating that the first read dirty data block has completed reading data from the NAND, and if the first target dirty data block is the first write dirty data block, the data transmission status of the first write dirty data block is transmission completion, indicating that the host has completed writing data in the first write dirty data block. More specifically, continuing with the above example, for the first logical address range of [20KB, 100KB], after determining the first target dirty data block (which can be the first read dirty data block or the first write dirty data block, with a logical address range of [0KB, 50KB]), if the data transmission status of the first target dirty data block is transmission completion, the target data with overlapping logical address ranges (logical address range of [0KB, 50KB]) in the first target dirty data block is obtained.
[0074] It can be understood that, when the data transmission status of the first target dirty data block is completed, the target data with overlapping logical address ranges in at least one first target dirty data block is obtained, which can ensure that the obtained data is the latest and accurate data, thereby improving the accuracy of data search. If the data is not obtained until the data transmission is completed, old and inaccurate data may be obtained, affecting the accuracy of data search.
[0075] 205. Obtain a search result of a first read search command based on the target data.
[0076] If the data transmission status of at least one first target dirty data block is transmission completed, after obtaining target data with overlapping logical address ranges in at least one first target dirty data block, the search result of the first read search command can be obtained based on the target data.
[0077] Specifically, continuing with the above example, after obtaining the target data (data with a logical address range of [20KB, 50KB]) whose logical address range overlaps with the first target dirty data block (logical address range of [0KB, 50KB]), after obtaining other data with a logical address of [0KB, 20KB] (such as obtained from NAND, etc.), the data of [0KB, 20KB] and the target data of [20KB, 50KB] can be combined, and the combined data can be used as the search result of the first read search command.
[0078] It is understandable that, for the first logical address range of [20KB, 100KB], if it is determined that the logical address range of the first target dirty data block with overlap includes [20KB, 100KB], the target data of [20KB, 100KB] in the first target dirty data block can be directly obtained, and the target data of [20KB, 100KB] in the first target dirty data block is used as the search result of the first read search command. For the first logical address range of [100KB, 150KB], the method for obtaining the search result of the first read search command based on the target data is similar to the method corresponding to the first logical address range of [20KB, 100KB], and is not limited here.
[0079] In an embodiment of the present application, a read search command can be obtained, and the first logical address range is address mapped based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, and at least one first target dirty data block in the dirty data block linked list of the target hash table is determined to have a logical address range that overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of at least one first target dirty data block is completed, then the target data in the at least one first target dirty data block that overlaps with the logical address range is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed simultaneously in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, and only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high.
[0080] based on Figure 2 In the described embodiment, during the cache management process, although the method of managing the data in the read cache and the write cache at the same time through a unified data structure can reduce the search path and improve the search efficiency to a certain extent, there are still often cases where a part of the data cannot be found and / or cannot meet the user's higher search efficiency requirements, resulting in low integrity, low accuracy and / or low search efficiency of the searched data. In order to solve the above problems, the following provides a detailed embodiment that can be optionally executed during the implementation of this solution, please refer to Figure 3 , Figure 3 This is a flow chart of another cache management method disclosed in an embodiment of the present application. The method of another embodiment of the cache management method of the present application includes:
[0081] 301. Obtain a read search command, where the read search command is used to search for and read data in a first logical address range.
[0082] Step 301 in this embodiment is similar to the aforementioned Figure 2 Step 201 in the illustrated embodiment is similar and will not be described in detail here.
[0083] 302. If the first logical address range spans a range of multiples of the base area size, the first logical address range is split by multiples of the base area size to obtain multiple first logical address partial ranges, wherein the first logical address partial range is the target first logical address range, and / or, if the first logical range is within a range of multiples of the base area size, the first logical range is used as the target first logical address range.
[0084] After obtaining the read search command, if the first logical address range spans the range of multiples of the base area size, the first logical address range can be split by multiples of the base area size to obtain multiple first logical address partial ranges, wherein the first logical address partial range is the target first logical address range, and / or, if the first logical range is within the range of multiples of the base area size, the first logical range is used as the target first logical address range.
[0085] Specifically, for example, if the base area size is 128KB, and the first logical address range is [20KB, 100KB], then the first logical address range [20KB, 100KB] is within the range of multiples of the base area size (128KB), and [20KB, 100KB] can be used as the target first logical address range. If the first logical address range is [100KB, 150KB], then the first logical address range [100KB, 150KB] spans the range of multiples of the base area size (128KB), and the first logical address range is split by multiples of the base area size (128KB), and two first logical address partial ranges [100KB, 1280KB] and [128KB, 150KB] are obtained, wherein the two first logical address partial ranges [100KB, 1280KB] and [128KB, 150KB] are the target first logical address ranges.
[0086] It is worth mentioning that if the first logical address range spans the range of multiples of the base area size, the first logical address range is split by multiples of the base area size, and the first logical address partial range obtained by the split is within the range of multiples of the base area size. On this basis, the first target dirty data block with overlapping addresses is determined, which can reduce the situation where some data in the first logical address range that exceeds the alignment range of multiples of the base area size cannot be found, thereby improving the data integrity and accuracy of read searches.
[0087] 303. Determine, among at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block.
[0088] If the first logical address range spans a range of multiples of the base area size, the first logical address range is split by multiples of the base area size to obtain multiple first logical address partial ranges. Then, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range can be determined in at least one target dirty data block in the dirty data block linked list of the target hash table, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block.
[0089] Among them, in at least one target dirty data block in the dirty data block linked list of the target hash table, a method for determining at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range may be, firstly, based on a hash algorithm, determining at least one hash value corresponding to at least one target first logical address range, wherein at least one hash value is used to map at least one target first logical address range corresponding to at least one target bucket of the target hash table, and then, in at least one target bucket corresponding to at least one target first logical address range, determining at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, the target hash table includes multiple hash buckets, and the hash bucket includes a dirty data block linked list.
[0090] Among them, based on the hash algorithm, at least one hash value corresponding to at least one target first logical address range is first determined, and then in at least one target bucket corresponding to the at least one target first logical address range, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range may include but is not limited to the following two methods:
[0091] (1) For each target first logical address range, the starting logical address of the target first logical address range is divided by the base area size (such as 128KB, etc.) to obtain an integer value, and the integer value is modulo the target hash table size to obtain a remainder, wherein the remainder is a hash value used to represent the bucket number of the bucket mapped to the target first logical address range, the target hash table size is used to represent the number of buckets, and the target first logical address range includes a starting logical address and an ending logical address.
[0092] Specifically, after address mapping the first logical range to obtain the target first logical address range, the Hash function (hash algorithm) can be designed as LMA / reference area size (e.g. 128KB) % HASH_TABLE_SIZE, where HASH_TABLE_SIZE is the size of the Hash table, LMA is the starting logical address of the target first logical address range, " / " represents division operation, and "%" represents modulo operation, so that the HashList can be used to manage DirtyNode, and the target first logical address range can not cross a reference area size (e.g. 128KB) alignment range, so as to avoid the situation where the part exceeding the reference area size (e.g. 128KB) alignment range cannot be found, thereby improving the accuracy and completeness of the search.
[0093] (2) For each target first logical address range, the sum of the initial logical address and the ending logical address of the target first logical address range is modulo the target hash table size to obtain a remainder, wherein the remainder is a hash value, which is used to represent the bucket number of the bucket mapped to the target first logical address range, and the target first logical address range includes a starting logical address and an ending logical address.
[0094] Specifically, if HASH_TABLE_SIZE=4, the starting logical address LMA of a target first logical address range is 200KB, and the ending logical address is 204KB, then LMA and EMA are added to get 404KB, and the modulus of 4 is 0, then the bucket number mapped to the bucket is 0, that is, the first Hash bucket.
[0095] It is worth mentioning that for a certain target first logical address range, a hash value (bucket number) is first determined using a hash algorithm, and then the first target dirty data block with a logical address overlap with the target first logical address range is searched in the bucket corresponding to the target first logical address range. Compared with the existing method of traversing more dirty data blocks in a single dirty data block linked list, this method of first determining a bucket and then traversing fewer dirty data blocks in the dirty data block linked list of the bucket (the hash table has multiple buckets, and each bucket has a dirty data block linked list) improves the search efficiency.
[0096] 304. If the data transmission status of at least one first target dirty data block is transmission completed, obtain target data with overlapping logical address ranges in at least one first target dirty data block.
[0097] 305. Obtain a search result of a first read search command based on the target data.
[0098] If the data transmission status of at least one first target dirty data block is transmission completed, obtaining the target data whose logical address range overlaps in at least one first target dirty data block
[0099] Steps 304 to 305 in this embodiment are similar to those in the previous Figure 2 Steps 204 to 205 in the illustrated embodiment are similar and will not be described in detail here.
[0100] It is understandable that, in the process of performing read search of cache management, although the method of splitting the first logical address range by multiples of the base area size and / or determining the target bucket corresponding to the target first logical address range based on the hash algorithm, and then determining the first target dirty data block in which the logical address range in the target bucket overlaps with the target first logical address range, can improve the integrity, accuracy and / or search efficiency of the searched data to a certain extent, the read search scenario may still have a situation where the integrity and accuracy of the search result corresponding to the read search command are low. In order to solve these problems, two methods can be used to solve them, which are described below respectively:
[0101] (i) By accurately controlling the release status of the first target dirty data block, the situation where the data of the first target dirty data block is released without returning the search result is reduced, so as to improve the completeness and accuracy of the search result corresponding to the read search command.
[0102] Among them, the method for accurately controlling the release state of the first target dirty data block may be that before obtaining the target data with overlapping logical address ranges in at least one first target dirty data block, the release state of at least one first target dirty data block may be set to an unreleasable state; after obtaining the target data with overlapping logical address ranges in at least one first target dirty data block, the release state of at least one first target dirty data block may be updated from an unreleasable state to a releasable state.
[0103] Among them, if a first target dirty data block is hit by multiple read search commands, in order to ensure that each read search command can return the corresponding complete search result, it is necessary to accurately update the release status of the first target dirty data block through the cache reference count.
[0104] Specifically, each first target dirty data block corresponds to a cache reference count. When a first target dirty data block is hit by a read search command, the release state of the first target dirty data block is an unreleasable state. More specifically, when the first target dirty data block is hit by M read search commands, the cache reference count of the first target dirty data block is increased by M, and the search results of N read search commands are returned, then the cache reference count of the first target dirty data block is reduced by N, until the cache reference count of the first target dirty data block is reduced to 0, and the release state of the first target dirty data block is updated from an unreleasable state to a releasable state.
[0105] For example, if a first target dirty data block is only hit by a read search command A, the cache reference count of the first target dirty data block is 1, until the search result of the read search command A is returned, the release state of the first target dirty data block is updated from a non-releasable state to a releasable state, and the data of the first target dirty data block is released. To give another example, if the first target dirty data block is hit by a read search command A and a read search command B, the cache reference count of the first target dirty data block is 2, when only the search result of the read search command A is returned, the cache reference count of the first target dirty data block is 1, until the search result of the read search command B is returned, the cache reference count of the first target dirty data block is 0, and the data of the first target dirty data block is released.
[0106] (ii) Based on the overall hit situation and target data of the read search command, the search result of the first read search command is obtained to reduce the situation where only part of the hit data is returned without being aware of it, so as to improve the completeness and accuracy of the search result corresponding to the read search command.
[0107] Among them, based on the overall hit situation of the read search command and the target data, the method for obtaining the search result of the first read search command can be, if the overall hit situation of the read search command is a full hit, then the target data is used as the search result, and / or, if the overall hit situation of the read search command is a partial hit, then the data of the missed logical address range is obtained from the flash memory, and the data of the missed logical address range and the target data are used as the search results.
[0108] It is understandable that the cache management in the disk of the embodiment of the present application may include updating the DirtyNode data status and distinguishing between read and write caches, implementing methods for multiplexing, adding, modifying or redefining fields, and the difference between read cache and write cache in DirtyNode representation, changes to cache reference counts, flush information fields, bitmaps, etc. These details in cache management are described below:
[0109] (1) A Bitmap represents a collection of unit data, and each bit represents the unit data at the corresponding position. The write cache generally has Dirtybmp / Vaildbmp / Pendingbmp / Sendbmp / Donebmp. To facilitate the description of the principle, assume that the maximum IO size supported by the disk is 128KB, and the maximum size of the DirtyNode is 128KB. The Bitmap is generated based on the relative position of the DirtyNode address range in 128KB, for example, Dirtybmp is LEN<<(SLBA%32).
[0110] (2) The state of the DirtyNode data can be updated on the disk through fast operations on the Bitmap (mainly binary AND or OR operations). In order to make the DirtyNode compatible with the read cache, these fields can be reused, added, modified or redefined.
[0111] (3) First, a tag field must be added to distinguish between read and write caches, because the update methods of read and write caches are different. The read cache can reuse fields such as logical address range, data address, data transfer status, and cache reference count. The read cache must record the logical address access of pre-fetched data so that the host read command can find whether it hits and the hit range. The correct data address in the cache that needs to be returned to the host data can be correctly calculated based on the hit range.
[0112] (4) The data transfer status in the write cache indicates whether the host is writing data in the cache. For example, status 1 indicates that the data is ready to be written or is being written, and the data transfer is not completed. Status 0 indicates that the data writing is completed. The read cache needs to be redefined to use this field. The data transfer status indicates whether the NAND data is writing data in the cache. For example, 1 indicates that the data is ready to be pre-fetched or is being pre-fetched, and the data has not been read. Status 0 indicates that the data reading from the NAND is completed.
[0113] (5) The read cache (data structure is a dirty data block) can reuse the cache reference count field to represent hit information. In the write cache (data structure is a dirty data block), this field represents the number of times a flush is required and the number of read hits. When a flush is required or a read hit occurs, the number is increased by 1. When the flush is completed or the hit data transmission is completed, the number is decreased by 1. When the number is reduced to 0, the write cache can be released. The read cache only uses this field to represent the hit information, that is, the number of read hits. The count is increased by the number of times the cache is read hit. The count is decreased after the data transmission is completed. When the number is reduced to 0, it can be eliminated according to a certain read cache strategy.
[0114] (6) There is also a flush information field on the DirtyNode. Since the read cache does not need to be flushed, this field is reserved for the read cache and is not used. The DirtyNode of the read cache does not generate a FlushEntry structure. Similarly, the Dirtybmp / Pendingbmp / Sentbmp / Donebmp in the bitmap that manages the data status are related to the write cache flush, and are not used by the read cache. Only Validbmp is used to represent the valid data in the read cache.
[0115] (7) After the read cache is represented by DirtyNode, its usage and management methods will change. The write cache DirtyNode generally represents the cache of a write command, while the prefetching read cache usually caches the data of multiple read commands in advance. For example, if you need to read data in a large logical address range, you need to split the access into multiple DirtyNodes to represent it. The specific split data needs to be determined according to the speed of the host read command. Each DirtyNode of the read cache will be managed independently, and will no longer be managed in the way of large block cache.
[0116] To facilitate understanding of this embodiment, a specific example is given below for illustration. Figure 4 , Figure 4 A flowchart of a read search method for unified management of read and write cache disclosed in an embodiment of the present application, comprising Figure 4 It can be seen that the read search after unified cache management (a kind of cache management) can be performed, and the specific technical implementation may include the following steps:
[0117] 1. First, the disk obtains the read range information after receiving the read command (read seek command);
[0118] 2. Then, check whether the read range spans the 128KB (base area size) alignment range. If so, split it into two search ranges (target first logical address range). If not, no splitting is required.
[0119] 3. Next, the hash bucket of each search range is calculated, and the read cache (the first dirty data block read) and write cache (the first dirty data block written) are traversed on the bucket to find hits;
[0120] 4. Furthermore, if a DirtyNode is found to be hit, its data transmission field (used to represent the data transmission status) needs to be checked. If it is 1, it means that the data is not ready (not transmitted yet), and the cache cannot be used. At this time, the search must be ended and the query must be waited for the data to be ready. If it is 0 (transmission completed), the cache is available. At this time, the address range and address of the cache hit are recorded for subsequent data transmission, and the cache reference count of the hit Node is increased by 1 to ensure that the cache occupancy is not released.
[0121] 5. Furthermore, when all search ranges have completed the hit search, the overall hit situation of the read command should be calculated. The result can be used to determine whether data can be returned directly after the hit search;
[0122] 6. Finally, the read hit search ends.
[0123] In an embodiment of the present application, a read search command can be obtained, and the first logical address range is address mapped based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, and at least one first target dirty data block in the dirty data block linked list of the target hash table is determined to have a logical address range that overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of at least one first target dirty data block is completed, then the target data in the at least one first target dirty data block that overlaps with the logical address range is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed simultaneously in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, and only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high. Secondly, if the first logical address range spans the range of multiples of the reference area size, the first logical address range is split by multiples of the reference area size, and the first logical address partial range obtained by the split is within the range of multiples of the reference area size. On this basis, the first target dirty data block with overlapping addresses is determined, which can reduce the situation where the partial data in the first logical address range that exceeds the alignment range of multiples of the reference area size cannot be found, thereby improving the data integrity and accuracy of the read search. Then, for a certain target first logical address range, a hash value (bucket number) is first determined using a hash algorithm, and then the first target dirty data block with a logical address overlap with the target first logical address range is searched in the bucket corresponding to the target first logical address range. Compared with the existing method of traversing more dirty data blocks in a single dirty data block linked list, this method of first determining a bucket and then traversing fewer dirty data blocks in the dirty data block linked list of the bucket (the hash table has multiple buckets, and each bucket has a dirty data block linked list) improves the search efficiency. Furthermore, by accurately controlling the release state of the first target dirty data block, the situation where the data of the first target dirty data block is released without returning the search result is reduced, so as to improve the completeness and accuracy of the search result corresponding to the read search command. Finally, based on the overall hit situation and target data of the read search command, the search result of the first read search command is obtained, so as to reduce the situation where only part of the hit data is returned without knowing it, so as to improve the completeness and accuracy of the search result corresponding to the read search command.
[0124] based on Figure 3In the described embodiment, during the process of cache management, read search for unified management of read and write caches can be performed. However, in the actual cache management process, there may be a situation where read and / or write cache insertion occurs. Therefore, a method for read and / or write cache insertion for unified management of read and write caches is required. The following provides a detailed embodiment of this solution that can be optionally executed during implementation. Please refer to Figure 5 , Figure 5 This is a flow chart of another cache management method disclosed in an embodiment of the present application. The method of another embodiment of the cache management method of the present application includes:
[0125] 501. Obtain a target operation command, wherein the target operation command includes a read operation command and / or a write operation command, the read operation command is used to read data in a second logical address range, and the write operation command is used to write update data into the second logical address range.
[0126] In this embodiment, when performing cache management, a target operation command can be obtained, wherein the target operation command includes a read operation command and / or a write operation command, the read operation command is used to read data in the second logical address range, and the write operation command is used to write updated data to the second logical address range.
[0127] Specifically, for example, the second logical address range may be [20KB, 100KB] or [100KB, 150KB].
[0128] 502. Perform address mapping on the second logical address range based on a second preset address mapping rule to obtain at least one target second logical address range after address mapping, so as to obtain at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range.
[0129] After obtaining the target operation command, the second logical address range can be address mapped based on the second preset address mapping rule to obtain at least one target second logical address range after address mapping, so as to obtain at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range.
[0130] Specifically, continuing with the above example, for the second logical address range of [20KB, 100KB], the second logical address range [20KB, 100KB] can be address mapped based on the first preset address mapping rule to obtain a target second logical address range [20KB, 100KB] after address mapping, and a target operation dirty data block is obtained (the corresponding logical address range is [20KB, 100KB]). For the second logical address range of [100KB, 150KB], the second logical address range [100KB, 150KB] can be address mapped based on the second preset address mapping rule to obtain two target second logical address ranges [100KB, 128KB] and [128KB, 150KB] after address mapping, and the two target operation dirty data blocks are obtained (the corresponding logical address ranges are [100KB, 128KB] and [128KB, 150KB] respectively).
[0131] 503. In at least one initial dirty data block in the dirty data block linked list of the initial hash table, determine at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range, wherein the second initial dirty data block is any one of a second initial read dirty data block and a second initial write dirty data block.
[0132] The second logical address range is address mapped based on the second preset address mapping rule to obtain at least one target second logical address range after address mapping. After obtaining at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range, at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range can be determined in at least one initial dirty data block in the dirty data block linked list of the initial hash table, wherein the second initial dirty data block is any one of the second initial read dirty data block and the second initial write dirty data block.
[0133] Specifically, for example, for the second logical address range of [20KB, 100KB], after obtaining a target second logical address range [20KB, 100KB] after address mapping, it can be determined that the second target dirty data block (which can be a second read dirty data block or a second write dirty data block, the logical address range is [0KB, 50KB]) whose logical address range overlaps with the target second logical address range [20KB, 100KB], and the overlapping range is [20KB, 50KB]. For the second logical address range of [100KB, 150KB], after obtaining two target second logical address ranges [100KB, 128KB] and [128KB, 150KB] after address mapping, the method for determining at least one second target dirty data block whose logical address range overlaps with at least one target second logical address range is similar to the above, and is not limited here.
[0134] A method and method for determining, in at least one initial dirty data block in a dirty data block linked list of an initial hash table, at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range. Figure 2 The process is similar to step 203, and the logic of step 203 may be referred to, which will not be repeated here.
[0135] 504. Based on a preset invalidation rule, invalidate data in a conflicting area between at least one second initial dirty data block and at least one target operation dirty data block to obtain at least one second initial dirty data block and at least one target operation dirty data block after invalidation.
[0136] In at least one initial dirty data block of the dirty data block linked list of the initial hash table, after determining that at least one second initial dirty data block has an overlapping logical address range with at least one target second logical address range, data in a conflicting area between the at least one second initial dirty data block and at least one target operation dirty data block can be invalidated based on a preset invalidation rule to obtain at least one second initial dirty data block and at least one target operation dirty data block after the invalidation process.
[0137] It should be understood that the conflicting area is an area where the second initial dirty data block and the target operation dirty data block have the same logical address.
[0138] It is worth mentioning that the preset invalidation rule is used to invalidate the data in the conflicting area between the second initial dirty data block and the target operation dirty data block. The specific invalidation method refers to invalidating the data of only one of the dirty data blocks (the second initial dirty data block and the target operation dirty data block) to ensure that there is only one data for each logical address, thereby ensuring data uniformity.
[0139] 505. Insert at least one target operation dirty data block after invalidation processing into the dirty data block linked list of the initial hash table, so as to obtain the dirty data block linked list of the target hash table based on at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block.
[0140] After obtaining at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block, the at least one target operation dirty data block after invalidation processing can be inserted into the dirty data block linked list of the initial hash table to obtain the dirty data block linked list of the target hash table based on the at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block.
[0141] It is worth mentioning that after invalidating the data in the conflicting area between the second initial dirty data block and the target operation dirty data block, data unification can be guaranteed based on at least one second initial dirty data block and at least one target operation dirty data block after the invalidation process.
[0142] It is also worth mentioning that the actual read and write scenarios may be more complicated. For example, there may be a combination of read and write scenarios between inserting read cache, inserting write cache, and read search, or there may be a large number of corresponding times of inserting read cache, inserting write cache, and read search. By presetting an invalidation rule to invalidate only the data of one of the dirty data blocks, the second initial dirty data block and the target operation dirty data block, the uniqueness and accuracy of the data in the conflicting area (the latest data) can be guaranteed, and therefore the data consistency can be guaranteed.
[0143] It is also worth mentioning that, for the insertion method of write cache and read cache, both write DirtyNode and read DirtyNode can be inserted into HashList, and the read command can search on HashList to resolve the conflict between read and write cache at the same time.
[0144] 506. Obtain a read search command, where the read search command is used to search for and read data in a first logical address range.
[0145] 507. Perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping.
[0146] 508. Determine, in at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block.
[0147] 509. If the data transmission status of at least one first target dirty data block is transmission completed, obtain target data with overlapping logical address ranges in at least one first target dirty data block.
[0148] 510. Obtain a search result of a first read search command based on target data.
[0149] Steps 506 to 510 in this embodiment are similar to those in the previous embodiment. Figure 3 Steps 301 to 305 in the illustrated embodiment are similar and will not be described in detail here.
[0150] To facilitate understanding of the read-write cache insertion method for unified management of read-write caches in this embodiment, the difference between the read-write cache insertion method for unified management of read-write caches in this embodiment and the existing read-write cache insertion method for unified management of read-write caches is described below:
[0151] 1. Read-write cache insertion method for unified management of existing read-write cache:
[0152] (1) For the existing write cache unified management write cache insertion method:
[0153] The cache management module of the SSD firmware manages the write cache and read cache separately. For details, please refer to Figure 6 , Figure 6 A schematic diagram of the existing SSD write cache management framework. Figure 6 As can be seen, the WriteCacheManager is mainly responsible for the allocation, insertion, search, flushing and release of the write cache. The data inside the cache is organized in the form of a DirtyNode (dirty data block) linked list. A DirtyNode records the information of a write data, including the logical medium address range, data address, flushing location and other information. Since the write command size does not exceed MDTS (maximum data transfer size), the data length recorded by a DirtyNode does not exceed MDTS. Before the write command starts to transmit data, the WriteCacheManager allocates cache space for the command, and inserts the DirtyNode into the linked list after the transmission is completed. Each DirtyNode will generate a corresponding FlushEntry to add to the flush queue. When the cache data reaches a certain threshold, the WriteCacheManager selects a certain amount of FlushEntry from the flush queue and flushes it to the NAND. After the data is flushed, the DirtyNode and the corresponding cache space can be released.
[0154] (2) Read cache insertion method for existing unified read cache management:
[0155] Read cache is used in scenarios where the host sends specific IO models, such as sequential reads or hot reads. After the disk recognizes such models, it pre-fetches data from the NAND to the cache in advance. Based on the principle of spatial locality of data access, it increases the probability of the host hitting the cache to accelerate the read command. For details, please refer to Figure 7 , Figure 7 A schematic diagram of the existing SSD read cache management framework is shown in FIG. Figure 7 It can be seen that ReadCacheManager is responsible for the allocation, search and release of read cache. The cache is generally organized in a CacheBlock circular queue. CacheBlock is generally a large memory with continuous physical addresses, which is used to prefetch data for multiple read IOs. When the firmware recognizes that read cache is needed, ReadCacheManager allocates CacheBlock from the queue and then sends a read command to NAND. When the data is pre-read from NAND, the CacheBlock is marked as readable. CacheBlock records the logical media address, data length, data address, pre-read status, hit count and other information of the read cache. When ReadCacheManager checks that the CacheBlock status is readable and no read command hits, it can be eliminated and released.
[0156] In order to ensure data consistency, the firmware cache system needs to ensure the following principles: the write cache keeps the latest data, and only one valid data exists in the cache (write cache or read cache) for the same LBA data. There will be frequent read and write cache searches and updates during the processing of read and write commands. For example, when a write command generates a write cache insertion, it is first necessary to search on the DirtyNode linked list inside the write cache. If a conflict is found, the write cache of the corresponding LBA range is updated to keep the write cache up to date. Then the read cache is searched to find whether there is a conflict in the CacheBlock circular queue. If there is a conflict, the corresponding CacheBlock is eliminated. Similarly, when processing a read command, the write cache must be searched first. If the read range is hit, the data is directly returned from the write cache. If the write cache does not hit, it is searched from the read cache. If the data hits, it is returned from the read cache. If there is no hit, the data is not in the cache and is finally read from the NAND. When starting pre-reading to insert the read cache, it is necessary to first search for conflicts inside the write cache. If there is a conflict, the pre-reading is abandoned and the write cache is eliminated. If there is no conflict, the old read cache is eliminated by continuing to search in the read cache. It can be seen from the above process that when processing read and write commands and updating read and write caches, corresponding processing can only be performed after cache search.
[0157] From (1) and (2), we can know that for the existing read-write cache insertion method with unified management of read-write cache, the existing write cache management uses DirtyNode as the management unit and DirtyNode linked list as the management data structure, and the read cache management uses CacheBlock as the management unit and CacheBlock queue as the management data structure. Since the management granularity and management structure of the two caches are different, the caches cannot be managed uniformly, and if they cannot be managed uniformly, they cannot be searched uniformly.
[0158] It is worth mentioning that in order to ensure data consistency, conflicts must be searched and updated before inserting the read-write cache. Since the old cache may exist in the read-write cache, for the existing method, the insertion of the new cache requires searching (traversing) both caches, and the search path is long. In order to ensure data consistency, the existing unified method needs to eliminate the old write cache and read cache when the new write cache is inserted. Before the new read cache is inserted, it is necessary to find whether the write cache currently exists and eliminate the old read cache. In the traditional technology of separate management of read-write cache, searching and eliminating the cache requires traversing the write cache and the read cache respectively. Therefore, the efficiency of data consistency is low. Therefore, under the premise of ensuring the consistency of disk data, the search path is long and the command processing delay is large. Secondly, the current technology of separate management of read-write cache has high software management complexity, high management and maintenance costs, and low efficiency of read-write cache search, which is not conducive to improving system performance.
[0159] 2. Read-write cache insertion method for unified management of read-write cache in this embodiment:
[0160] The core idea of the cache management designed in this embodiment is to use a unified data structure DirtyNode to manage the read and write caches, and DirtyNode is organized and managed with a hash linked list structure. When the read cache or write cache is to be inserted, the DirtyNode is first hashed according to certain rules to determine the hash bucket, and then the linked list on the hash bucket is inserted. In this way, both the read and write caches can exist on the linked list. Before insertion, it is only necessary to search and resolve the conflict of the DirtyNode on the linked list to ensure the data consistency of the cache. When the read and write commands search the cache, the command range is first hashed to determine the search linked list according to the same rules, and then a search is performed on the linked list, so that the search of the read cache and the write cache is completed at the same time.
[0161] It is worth mentioning that this embodiment proposes a method for unified management of read-write cache, which can improve the efficiency of data consistency, so as to realize unified search of read-write cache, shorten the search path, simplify the complexity of read-write cache management, reduce the disk processing delay, and improve the disk performance. Therefore, this embodiment can efficiently search and update the cache, thereby improving the performance of the disk system. Secondly, this embodiment designs a unified management method for read-write cache for read-write cache search processing. Under the premise of ensuring data consistency, the read-write cache is uniformly searched for conflicts, the cache search and update efficiency is improved, and the purpose of improving the read and write performance of the disk is achieved. At the same time, the read-write cache is represented and managed with the same data structure to realize unified cache management, reduce the complexity of cache management, and facilitate maintenance by R&D personnel. Finally, the unified management of read-write cache can realize simultaneous search of read-write cache and improve the efficiency of cache search and update.
[0162] In an embodiment of the present application, a read search command can be obtained, and the first logical address range is address mapped based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, and at least one first target dirty data block in the dirty data block linked list of the target hash table is determined to have a logical address range that overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of at least one first target dirty data block is completed, then the target data in the at least one first target dirty data block that overlaps with the logical address range is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed simultaneously in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, and only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high. Secondly, if the first logical address range spans the range of multiples of the reference area size, the first target dirty data block with overlapping addresses can be split first and then determined, which can reduce the situation where part of the data in the first logical address range that exceeds the alignment range of multiples of the reference area size cannot be found, thereby improving the data integrity and accuracy of the read search. Then, by first determining the bucket and then traversing the dirty data block chain list of the bucket with fewer dirty data blocks (the hash table has multiple buckets, and each bucket has a dirty data block chain list), the search efficiency is improved. Furthermore, by accurately controlling the release state of the first target dirty data block, the situation where the search result is not returned but the data of the first target dirty data block is released is reduced, so as to improve the integrity and accuracy of the search result corresponding to the read search command. Furthermore, based on the overall hit situation and target data of the read search command, the search result of the first read search command is obtained, so as to reduce the situation where only part of the hit data is returned without knowing it, so as to improve the integrity and accuracy of the search result corresponding to the read search command. Finally, by performing invalid processing on the data of only one of the dirty data blocks, namely, the second initial dirty data block and the target operation dirty data block, it is ensured that there is only one data at each logical address, thereby ensuring data uniformity.
[0163] based on Figure 5 In the described embodiment, during the process of cache management, read and / or write cache insertion for unified management of read and write caches can be performed, wherein the address mapping method and the specific invalidation processing method will be different due to the differences in the inserted read cache and write cache. In order to further achieve the effect of data unification, it is necessary to design corresponding address mapping methods and specific invalidation processing methods for read cache insertion and write cache insertion.
[0164] In the embodiment of the present application, the address mapping method and specific invalidation processing method corresponding to the design of the read cache insertion and the write cache insertion are different, which are described below respectively:
[0165] 1. When inserting into the read cache, the address mapping method involves the base area size multiple alignment processing (if the second logical address range is within the base area size multiple range), and / or the base area size multiple splitting and base area size multiple alignment processing (if the second logical address range spans the base area size multiple range), and the invalidation method is to mark the data in the conflict area of the second initial read dirty data block as invalid (if the second initial read dirty data block is hit), and mark the data in the conflict area of the target read operation dirty data block as invalid (if the second initial write dirty data block is hit).
[0166] In the embodiment of the present application, when inserting the read cache, the insertion of the read cache can be performed through the corresponding address mapping method and invalidation method. For details, please refer to Figure 8 , Figure 8 This is a flow chart of another cache management method disclosed in an embodiment of the present application. The method of another embodiment of the cache management method of the present application includes:
[0167] 801. Obtain a read operation command, where the read operation command is used to read data in a second logical address range.
[0168] In this embodiment, when cache management is performed, a read operation command may be obtained, wherein the read operation command is used to read data in the second logical address range.
[0169] Specifically, for example, the second logical address range may be [20KB, 100KB] or [100KB, 150KB].
[0170] 802. If the second logical address range is within the range of multiples of the base area size, the second logical address range is aligned with the base area size multiples, and / or if the second logical address range spans the range of multiples of the base area size, the second logical address range is split and aligned with the base area size multiples to obtain at least one target second logical address range.
[0171] After obtaining the read operation command, if the second logical address range is within the range of multiples of the base area size, the second logical address range can be aligned with the base area size multiples, and / or if the second logical address range spans the range of multiples of the base area size, the second logical address range can be split into multiples of the base area size and aligned with the base area size multiples to obtain at least one target second logical address range.
[0172] Among them, if the second logical address range is within the range of multiples of the base area size, the second logical address range is aligned with the base area size multiples, and / or if the second logical address range spans the range of multiples of the base area size, the second logical address range is split and aligned with the base area size multiples, so as to obtain at least one target second logical address range. The method may be that if the second logical address range is within the range of multiples of the base area size, the starting second logical address is downwardly aligned with the multiples of the base area size, and the ending second logical address is upwardly aligned with the multiples of the base area size, so as to obtain the aligned second logical address range. Among them, the second logical address range after alignment processing is the target second logical address range; and / or, if the second logical address range spans a range of multiples of the base area size, the second logical address range is split according to the multiples of the base area size to obtain multiple second logical address partial ranges, the starting second logical addresses of the multiple second logical address partial ranges are downwardly aligned according to the multiples of the base area size, and the ending second logical addresses of the multiple second logical address partial ranges are upwardly aligned according to the multiples of the base area size to obtain multiple second logical address partial ranges after alignment processing, wherein the multiple second logical address partial ranges after alignment processing are multiple target second logical address ranges.
[0173] Specifically, for example, if the base area size is 128KB, when the read cache needs to prefetch a 128KB data but the range is aligned across 128KB, it can be split first, for example, the range [SLMA, ELMA] can be split into two parts [SLMA, 128KB*N] and [128KB*N, ELMA], and then each part is aligned up or down by 128KB, so that the range becomes [128KB*(N-1), 128KB*N] and [128KB*N, 128KB*(N+1)]. This prefetch uses two read cache DirtyNodes and sends two 128KB read commands to the NAND to obtain data.
[0174] 803. Obtain data in at least one target second logical address range from a flash memory, and obtain at least one target read operation dirty data block based on the data in the at least one target second logical address range.
[0175] After obtaining at least one target second logical address range, data of at least one target second logical address range can be obtained from the flash memory, and at least one target read operation dirty data block can be obtained based on the data of at least one target second logical address range.
[0176] Specifically, data in at least one target second logical address range may be obtained from the flash memory NAND, and at least one target read operation dirty data block may be created based on the data in the at least one target second logical address range.
[0177] 804. Determine, in at least one initial dirty data block in the dirty data block linked list of the initial hash table, at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range, wherein the second initial dirty data block is any one of a second initial read dirty data block and a second initial write dirty data block.
[0178] After obtaining data of at least one target second logical address range from the flash memory and obtaining at least one target read operation dirty data block based on the data of at least one target second logical address range, at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range can be determined in at least one initial dirty data block in the dirty data block linked list of the initial hash table, wherein the second initial dirty data block is any one of the second initial read dirty data block and the second initial write dirty data block.
[0179] Specifically, in at least one initial dirty data block in the dirty data block linked list of the initial hash table, a method for determining at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range is as follows: Figure 5 The process is similar to step 503, and the logic of step 503 may be referred to, which will not be repeated here.
[0180] 805. Mark data in a conflicting area in at least one second initial read dirty data block corresponding to at least one target read operation dirty data block as invalid, and / or mark data in a conflicting area in at least one target read operation dirty data block corresponding to at least one second initial write dirty data block as invalid.
[0181] In at least one initial dirty data block of the dirty data block linked list of the initial hash table, after determining at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range, data in a conflicting area corresponding to at least one target read operation dirty data block in at least one second initial read dirty data block can be marked as invalid, and / or data in a conflicting area corresponding to at least one second initial write dirty data block in at least one target read operation dirty data block can be marked as invalid.
[0182] It should be understood that if the second initial dirty data block is hit, the data in the conflicting area of the second initial dirty data block (the data in the conflicting area is old data) is marked as invalid, which can ensure that there is only one cache copy of a logical address and the data in the conflicting area is the latest data. Since the data in the conflicting area of the second initial dirty data block is the latest, and the data in the target read operation dirty data block (data obtained from NAND) is not necessarily the latest, therefore, if the second initial dirty data block is hit, the data in the conflicting area of the target read operation dirty data block is marked as invalid, which can ensure that there is only one cache copy of a logical address and the data in the conflicting area is the latest data.
[0183] 806. Insert at least one target operation dirty data block after invalidation processing into the dirty data block linked list of the initial hash table, so as to obtain the dirty data block linked list of the target hash table based on at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block.
[0184] After marking the data in the conflicting area corresponding to at least one target read operation dirty data block in at least one second initial read dirty data block as invalid, and / or marking the data in the conflicting area corresponding to at least one second initial write dirty data block in at least one target read operation dirty data block as invalid, the at least one target operation dirty data block after invalidation can be inserted into the dirty data block linked list of the initial hash table, so as to obtain the dirty data block linked list of the target hash table based on the at least one second initial dirty data block after invalidation and the at least one target operation dirty data block.
[0185] It should be understood that inserting at least one target operation dirty data block after invalidation processing into the dirty data block linked list of the initial hash table, and obtaining the dirty data block linked list of the target hash table based on at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block, can improve the feasibility of data unification.
[0186] To facilitate understanding of this embodiment, a specific example is given below for illustration. Fig. 9 , Fig. 9 A flowchart of a read cache insertion method with unified cache management disclosed in an embodiment of the present application is shown in FIG. Fig. 9 It can be seen that a unified read cache insertion (a type of cache management) can be performed for cache management, and the specific technical implementation may include the following steps:
[0187] 1. When the disk recognizes a specific read model, it initiates a prefetch (for example, reading data in the second logical address range through a read operation command) and prepares to insert it into the read cache;
[0188] 2. Determine the logical address range of the read cache (the second logical address range) according to the current position and read speed of the host read command, assuming it is [SLMA, ELMA];
[0189] 3. Perform 128KB alignment operation on the start logical address (SLMA) and end logical address (ELMA) of the read cache. Split the aligned range into 128KB (base area size) and apply for multiple DirtyNodes. Initialize each DirtyNode and set the data transfer status to 1.
[0190] 4. After the Node is found in the bucket linked list through Hash, it starts to traverse and search for conflicts;
[0191] 5. If there is a conflict in writing DirtyNode, the conflicting data on the read Node (the dirty data block of the target read operation) will be marked as invalid, because the data in the write cache is definitely the latest, but the data on the NAND may not be the latest. If there is no valid data after the conflict is resolved, that is, Val idbmp is 0, the cache of the Node will be cancelled;
[0192] 6. If there is a conflict in reading the DirtyNode, the conflicting data on the old read Node (the second initial read dirty data block) is marked invalid to ensure that only one copy of the cache for a logical address exists;
[0193] 7. After traversing the linked list and resolving conflicts, the requested DirtyNode (target read operation dirty data block) can be inserted into the HashList, and then start reading NAND data;
[0194] 8. After the data is read, the data transfer status is cleared to 0 and the cache insertion is completed.
[0195] 807. Obtain a read search command, where the read search command is used to search for and read data in a first logical address range.
[0196] 808. Perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping.
[0197] 809. Determine, among at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block.
[0198] 810. If the data transmission status of at least one first target dirty data block is transmission completed, obtain target data with overlapping logical address ranges in at least one first target dirty data block.
[0199] 811. Obtain a search result of a first read search command based on target data.
[0200] Steps 807 to 811 in this embodiment are similar to those in the previous embodiment. Figure 5 Steps 506 to 510 in the illustrated embodiment are similar and will not be described in detail herein.
[0201] In an embodiment of the present application, a read search command can be obtained, and the first logical address range is address mapped based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, and at least one first target dirty data block in the dirty data block linked list of the target hash table is determined to have a logical address range that overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of at least one first target dirty data block is completed, then the target data in the at least one first target dirty data block that overlaps with the logical address range is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed simultaneously in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, and only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high. Secondly, if the first logical address range spans the range of multiples of the reference area size, the first target dirty data block with overlapping addresses can be split first and then determined, which can reduce the situation where part of the data in the first logical address range that exceeds the alignment range of multiples of the reference area size cannot be found, thereby improving the data integrity and accuracy of the read search. Then, by first determining the bucket and then traversing the dirty data block chain list of the bucket with fewer dirty data blocks (the hash table has multiple buckets, and each bucket has a dirty data block chain list), the search efficiency is improved. Furthermore, by accurately controlling the release state of the first target dirty data block, the situation where the search result is not returned but the data of the first target dirty data block is released is reduced, so as to improve the integrity and accuracy of the search result corresponding to the read search command. Furthermore, based on the overall hit situation and target data of the read search command, the search result of the first read search command is obtained, so as to reduce the situation where only part of the hit data is returned without knowing it, so as to improve the integrity and accuracy of the search result corresponding to the read search command. Furthermore, by only invalidating the data of the dirty data block of one of the second initial dirty data block and the target operation dirty data block, it is ensured that there is only one data for each logical address, thereby ensuring data uniformity. Finally, if the second initial read dirty data block is hit, the data in the conflict area of the second initial read dirty data block (the data in the conflict area is old data) is marked as invalid, and if the second initial write dirty data block is hit, the data in the conflict area of the target read operation dirty data block is marked as invalid, which can ensure that there is only one cache of a logical address and the data in the conflict area is the latest data.
[0202] 2. When inserting the write cache, the address mapping method involves non-split and non-aligned processing (if the second logical address range is within the range of multiples of the base area size), or split processing of multiples of the base area size (if the second logical address range spans the range of multiples of the base area size), and the invalidation method is to mark the data in the conflicting area of the second initial write dirty data block and the second initial read dirty data block invalid.
[0203] In the embodiment of the present application, when inserting the write cache, the write cache can be inserted through the corresponding address mapping method and invalidation method. For details, please refer to Fig.10 , Fig.10 This is a flow chart of another cache management method disclosed in an embodiment of the present application. The method of another embodiment of the cache management method of the present application includes:
[0204] 1001. Obtain a write operation command, where the write operation command is used to write update data into a second logical address range.
[0205] In this embodiment, when cache management is performed, a write operation command may be obtained, wherein the write operation command is used to write update data into the second logical address range.
[0206] Specifically, for example, the second logical address range may be [20KB, 100KB] or [100KB, 150KB].
[0207] 1002. If the second logical address range spans a range of multiples of the base area size, the second logical address range is split according to multiples of the base area, and / or if the second logical address range is within a range of multiples of the base area size, the second logical address range is not split or aligned, so as to obtain at least one target second logical address range.
[0208] After obtaining the write operation command, if the second logical address range spans a range of multiples of the base area size, the second logical address range can be split and processed by multiples of the base area, and / or if the second logical address range is within a range of multiples of the base area size, the second logical address range can be processed without splitting or aligning, so as to obtain at least one target second logical address range.
[0209] Specifically, for example, if the base area size is 128KB and the second logical address range is [20KB, 100KB], since the second logical address range is within the range of multiples of the base area size, the target second logical address range is [20KB, 100KB]; if the second logical address range is [100KB, 150KB], since the second logical address range spans the range of multiples of the base area size, the second logical address range can be split by multiples of the base area to obtain two target second logical address ranges, namely [100KB, 128KB] and [128KB, 150KB].
[0210] It is worth mentioning that the splitting process allows the DirtyNode whose logical address range spans the alignment range of the base area size (such as 128KB) to be correctly inserted into the corresponding Hash bucket, thereby ensuring the accuracy of DirtyNode management and search. If the splitting is not performed, the DirtyNode that spans the alignment range of the base area size (such as 128KB) will be inserted into the wrong Hash bucket, resulting in problems in finding or conflict resolution. Therefore, the splitting process can ensure the correctness and effectiveness of the HashList. Secondly, when the write cache needs to insert the HashList but the logical address range spans the 128KB alignment range, it only needs to be split and inserted without alignment, so as to achieve the effect of data unification.
[0211] 1003. Obtain update data of at least one target second logical address range, and obtain at least one target write operation dirty data block based on the update data of at least one target second logical address range.
[0212] After obtaining at least one target second logical address range, update data of at least one target second logical address range may be obtained, and at least one target write operation dirty data block may be obtained based on the update data of at least one target second logical address range.
[0213] Specifically, the updated data of the target second logical address range may refer to data obtained by modifying the original data of the target second logical address range.
[0214] 1004. Determine, in at least one initial dirty data block in the dirty data block linked list of the initial hash table, at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range, wherein the second initial dirty data block is any one of a second initial read dirty data block and a second initial write dirty data block.
[0215] After obtaining update data of at least one target second logical address range and obtaining at least one target write operation dirty data block based on the update data of at least one target second logical address range, at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range can be determined in at least one initial dirty data block in the dirty data block linked list of the initial hash table, wherein the second initial dirty data block is any one of the second initial read dirty data block and the second initial write dirty data block.
[0216] Specifically, in at least one initial dirty data block in the dirty data block linked list of the initial hash table, a method for determining at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range is as follows: Figure 5 The process is similar to step 503, and the logic of step 503 may be referred to, which will not be repeated here.
[0217] 1005. Mark data in a conflicting area corresponding to at least one target write operation dirty data block in at least one second initial write dirty data block as invalid, and / or mark data in a conflicting area corresponding to at least one target write operation dirty data block in at least one second initial read dirty data block as invalid.
[0218] In at least one initial dirty data block of the dirty data block linked list of the initial hash table, after determining at least one second initial dirty data block whose logical address range overlaps with at least one target second logical address range, data in a conflicting area corresponding to at least one target write operation dirty data block in at least one second initial write dirty data block can be marked as invalid, and / or data in a conflicting area corresponding to at least one target write operation dirty data block in at least one second initial read dirty data block can be marked as invalid.
[0219] It should be understood that since the data in the conflict area of the target write operation dirty data block is the latest, regardless of whether the second initial write dirty data block or the second initial read dirty data block is hit, the data in the conflict area of the second initial write dirty data block or the second initial read dirty data block can be directly marked as invalid.
[0220] 1006. Insert at least one target operation dirty data block after invalidation processing into the dirty data block linked list of the initial hash table, so as to obtain the dirty data block linked list of the target hash table based on at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block.
[0221] After marking the data in the conflicting area corresponding to at least one target write operation dirty data block in at least one second initial write dirty data block as invalid, and / or marking the data in the conflicting area corresponding to at least one target write operation dirty data block in at least one second initial read dirty data block as invalid, the at least one target operation dirty data block after invalidation can be inserted into the dirty data block linked list of the initial hash table, so as to obtain the dirty data block linked list of the target hash table based on the at least one second initial dirty data block after invalidation and the at least one target operation dirty data block.
[0222] Step 1006 in this embodiment is similar to the above Figure 6 Step 606 in the illustrated embodiment is similar and will not be described in detail here.
[0223] To facilitate understanding of this embodiment, a specific example is given below for illustration. Fig.11 , Fig.11 A flowchart of a write cache insertion method with unified cache management disclosed in an embodiment of the present application is shown in FIG. Fig.11 It can be seen that a unified write cache insertion (a cache management) process can be performed for cache management, and the specific technical implementation may include the following steps:
[0224] 1. After receiving a write command (write operation command), the disk starts to apply for DirtyNode. If the write command range spans the 128KB (reference area size) alignment range, it is split into two DirtyNodes (target second logical address range) and the fields on them are initialized, where the data transfer status is set to 1;
[0225] 2. After finding the Hash bucket using the Hash function according to the logical address range on the DirtyNode, start traversing the linked list on the bucket to find conflicts;
[0226] 3. If a conflict is found in writing DirtyNode (the second initial dirty data block), the conflicting part of the valid data on the write Node (the second initial dirty data block) will be directly marked as invalid;
[0227] 4. If a conflict is found in reading DirtyNode (the second initial dirty data block), the conflicting part of the valid data on the read Node (the second initial dirty data block) is directly marked as invalid, that is, the conflicting position on the Val idbmp of the read DirtyNode (the second initial dirty data block) is cleared to 0, so that the read command cannot hit the data on the read cache;
[0228] 5. After traversing the linked list and resolving conflicts, the requested DirtyNode (target write operation dirty data block) can be inserted into the HashList, and then the command data transmission can be started;
[0229] 6. Data transfer is completed, data transfer status is cleared to 0, and cache insertion is completed.
[0230] 1007. Obtain a read search command, where the read search command is used to search for and read data in a first logical address range.
[0231] 1008. Perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping.
[0232] 1009. Determine, among at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block.
[0233] 1010. If the data transmission status of at least one first target dirty data block is transmission completed, obtain target data with overlapping logical address ranges in at least one first target dirty data block.
[0234] 1011. Obtain a search result of a first read search command based on target data.
[0235] Steps 1007 to 1011 in this embodiment are similar to those in the previous Figure 5 Steps 506 to 510 in the illustrated embodiment are similar and will not be described in detail herein.
[0236] In an embodiment of the present application, a read search command can be obtained, and the first logical address range is address mapped based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping, and at least one first target dirty data block in the dirty data block linked list of the target hash table is determined to have a logical address range that overlaps with at least one target first logical address range, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of at least one first target dirty data block is completed, then the target data in the at least one first target dirty data block that overlaps with the logical address range is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed simultaneously in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, and only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high. Secondly, if the first logical address range spans the range of multiples of the reference area size, the first target dirty data block with overlapping addresses can be split first and then determined, which can reduce the situation where part of the data in the first logical address range that exceeds the alignment range of multiples of the reference area size cannot be found, thereby improving the data integrity and accuracy of the read search. Then, by first determining the bucket and then traversing the dirty data block chain list of the bucket with fewer dirty data blocks (the hash table has multiple buckets, and each bucket has a dirty data block chain list), the search efficiency is improved. Furthermore, by accurately controlling the release state of the first target dirty data block, the situation where the search result is not returned but the data of the first target dirty data block is released is reduced, so as to improve the integrity and accuracy of the search result corresponding to the read search command. Furthermore, based on the overall hit situation and target data of the read search command, the search result of the first read search command is obtained, so as to reduce the situation where only part of the hit data is returned without knowing it, so as to improve the integrity and accuracy of the search result corresponding to the read search command. Furthermore, by only invalidating the data of the dirty data block of one of the two, the second initial dirty data block and the target operation dirty data block, it is ensured that there is only one data for each logical address, thereby ensuring data unification. Finally, the splitting process allows the DirtyNode whose logical address range crosses the alignment range of the benchmark area size (such as 128KB) to be correctly inserted into the corresponding Hash bucket, thereby ensuring the accuracy of DirtyNode management and search. And when the write cache needs to be inserted into the HashList but the logical address range crosses the alignment range of the benchmark area size, it only needs to be split and inserted without alignment, so as to achieve the effect of data unification.
[0237] The cache management method in the embodiment of the present application is described above. The cache management device in the embodiment of the present application is described below. Fig.12 , an embodiment of the cache management device in the embodiment of the present application includes:
[0238] An obtaining unit 1201 is used to obtain a read search command, wherein the read search command is used to search for and read data in a first logical address range;
[0239] An address mapping unit 1202 is used to perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping;
[0240] The determining unit 1203 is configured to determine, from at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block;
[0241] An acquiring unit 1204 is configured to acquire target data with overlapping logical address ranges in the at least one first target dirty data block if the data transmission status of the at least one first target dirty data block is transmission completed;
[0242] The obtaining unit 1201 is further configured to obtain a search result of the first read search command based on the target data.
[0243] In the embodiment of the present application, a read search command can be obtained, the first logical address range is address mapped based on the first preset address mapping rule, at least one target first logical address range after address mapping is obtained, and at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range is determined in at least one target dirty data block in the dirty data block linked list of the target hash table, wherein the first target dirty data block is any one of the first read dirty data block and the first write dirty data block, and if the data transmission status of the at least one first target dirty data block is completed, the target data whose logical address range overlaps in the at least one first target dirty data block is obtained, and the search result of the first read search command is obtained based on the target data. The read cache and the write cache are merged into the same data structure, and the data in the read cache and the write cache can be managed at the same time in this data structure, so when performing a read search operation, there is no need to search in the data structure corresponding to the read cache and the data structure corresponding to the write cache respectively, only the merged data structure needs to be searched, and only one search operation needs to be performed, so the overall search path is short and the search efficiency is high.
[0244] The following is a detailed description of the cache management device in the embodiment of the present application. Fig.13 Another embodiment of the cache management device in the embodiment of the present application includes:
[0245] An obtaining unit 1301 is used to obtain a read search command, wherein the read search command is used to search for and read data in a first logical address range;
[0246] An address mapping unit 1302 is used to perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping;
[0247] The determining unit 1303 is configured to determine, from at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block;
[0248] An acquiring unit 1304 is configured to acquire target data with overlapping logical address ranges in the at least one first target dirty data block if the data transmission status of the at least one first target dirty data block is transmission completed;
[0249] The obtaining unit 1301 is further configured to obtain a search result of the first read search command based on the target data.
[0250] The address mapping unit 1302 is specifically used to split the first logical address range by multiples of the base area size to obtain multiple first logical address partial ranges if the first logical address range spans across the range of multiples of the base area size, wherein the first logical address partial range is the target first logical address range; and / or, if the first logical range is within the range of multiples of the base area size, use the first logical range as the target first logical address range.
[0251] The determination unit 1303 is specifically used to determine at least one hash value corresponding to the at least one target first logical address range based on a hash algorithm, wherein the at least one hash value is used to map the at least one target first logical address range to at least one target bucket in the target hash table, and in the at least one target bucket corresponding to the at least one target first logical address range, determine at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, and the target hash table includes multiple hash buckets, and the hash bucket includes a dirty data block linked list.
[0252] The cache management device further includes: an invalidation unit 1305; an insertion unit 1306;
[0253] The obtaining unit 1301 is further used to obtain a target operation command, wherein the target operation command includes a read operation command and / or a write operation command, the read operation command is used to read data in the second logical address range, and the write operation command is used to write update data into the second logical address range;
[0254] The address mapping unit 1302 is further configured to perform address mapping on the second logical address range based on a second preset address mapping rule to obtain at least one target second logical address range after address mapping, so as to obtain at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range;
[0255] The determining unit 1303 is further configured to determine, from at least one initial dirty data block in the dirty data block linked list of the initial hash table, at least one second initial dirty data block whose logical address range overlaps with the at least one target second logical address range, wherein the second initial dirty data block is any one of a second initial read dirty data block and a second initial write dirty data block;
[0256] The invalidation unit 1305 is used to invalidate the data in the conflicting area between the at least one second initial dirty data block and the at least one target operation dirty data block based on a preset invalidation rule to obtain the at least one second initial dirty data block and the at least one target operation dirty data block after the invalidation process;
[0257] The insertion unit 1306 is used to insert at least one target operation dirty data block after invalidation processing into the dirty data block linked list of the initial hash table, so as to obtain the dirty data block linked list of the target hash table based on the at least one second initial dirty data block after invalidation processing and at least one target operation dirty data block.
[0258] The address mapping unit 1302 is specifically used to, if the second logical address range is within the range of multiples of the base area size, perform base area size multiples alignment processing on the second logical address range, and / or if the second logical address range spans the range of multiples of the base area size, perform base area size multiples splitting and base area size multiples alignment processing on the second logical address range, so as to obtain the at least one target second logical address range, the target operation command is a read operation command, the at least one target operation dirty data block is at least one target read operation dirty data block, obtain data of the at least one target second logical address range from a flash memory, and obtain the at least one target read operation dirty data block based on the data of the at least one target second logical address range;
[0259] The invalidation unit 1305 is specifically used to mark the data in the conflict area corresponding to the at least one target read operation dirty data block in at least one second initial read dirty data block as invalid, and / or mark the data in the conflict area corresponding to the at least one second initial write dirty data block in at least one target read operation dirty data block as invalid.
[0260] The address mapping unit 1302 is specifically used for, if the second logical address range is within the range of multiples of the base area size, performing downward alignment on the starting second logical address with the multiples of the base area size, and performing upward alignment on the ending second logical address with the multiples of the base area size, to obtain the aligned second logical address range, wherein the aligned second logical address range is the target second logical address range, and / or, if the second logical address range spans the range of multiples of the base area size, performing splitting processing on the second logical address range with the multiples of the base area size, to obtain multiple second logical address partial ranges, performing downward alignment on the starting second logical addresses of the multiple second logical address partial ranges with the multiples of the base area size, and performing upward alignment on the ending second logical addresses of the multiple second logical address partial ranges with the multiples of the base area size, to obtain multiple second logical address partial ranges after alignment processing, wherein the multiple second logical address partial ranges after alignment processing are multiple target second logical address ranges, and the second logical address range includes the starting second logical address and the ending second logical address.
[0261] The address mapping unit 1302 is specifically used to, if the second logical address range spans a range of multiples of the base area size, perform base area multiple splitting processing on the second logical address range, and / or if the second logical address range is within a range of multiples of the base area size, perform non-split and non-aligned processing on the second logical address range, so as to obtain the at least one target second logical address range, obtain the update data of the at least one target second logical address range, and obtain the at least one target write operation dirty data block based on the update data of the at least one target second logical address range, the target operation command is a write operation command, and the at least one target operation dirty data block is at least one target write operation dirty data block;
[0262] The invalidation unit 1305 is specifically used to mark the data in the conflicting area corresponding to the at least one target write operation dirty data block in the at least one second initial write dirty data block as invalid, and / or mark the data in the conflicting area corresponding to the at least one target write operation dirty data block in the at least one second initial read dirty data block as invalid.
[0263] In this embodiment, each unit in the cache management device performs the above Figure 2 The operation of the cache management device in the illustrated embodiment will not be described in detail here.
[0264] See below Fig.14 In the embodiment of the present application, an embodiment of the computer device 1400 includes:
[0265] CPU 1401, memory 1405, input / output interface 1404, wired or wireless network interface 1403 and power supply 1402;
[0266] The memory 1405 is a temporary storage memory or a permanent storage memory;
[0267] The CPU 1401 is configured to communicate with the memory 1405 and execute the instructions in the memory 1405 to perform the aforementioned Figures 2 to 5 ,as well as Figures 8 to 11 The method in the illustrated embodiment.
[0268] The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes instructions, when the instructions are executed on a computer, the computer executes the aforementioned Figures 2 to 5 ,as well as Figures 8 to 11 The method in the illustrated embodiment.
[0269] The present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the aforementioned Figures 2 to 5 ,as well as Figures 8 to 11 The method in the illustrated embodiment.
[0270] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0271] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0272] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0273] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0274] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0275] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A cache management method, characterized in that: include: Obtaining a read search command, wherein the read search command is used to search for and read data in a first logical address range; Performing address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping; Determine, in at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block; If the data transmission status of the at least one first target dirty data block is transmission completed, obtaining target data with overlapping logical address ranges in the at least one first target dirty data block; A search result of the first read search command is obtained based on the target data.
2. The method according to claim 1, characterized in that The performing address mapping on the first logical address range based on the first preset address mapping rule to obtain at least one target first logical address range after address mapping includes: If the first logical address range spans a range of multiples of the base area size, splitting the first logical address range by multiples of the base area size to obtain a plurality of first logical address partial ranges, wherein the first logical address partial range is the target first logical address range; and / or, If the first logical range is within the range of the multiples of the base area size, the first logical range is used as the target first logical address range.
3. The method according to claim 1, characterized in that The target hash table includes a plurality of hash buckets, and the hash buckets include a dirty data block linked list; The step of determining, in at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range comprises: Based on a hash algorithm, determine at least one hash value corresponding to the at least one target first logical address range, wherein the at least one hash value is used to map the at least one target first logical address range to at least one target bucket in the target hash table; In at least one target bucket corresponding to the at least one target first logical address range, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range is determined.
4. The method according to any one of claims 1 to 3, characterized in that Before determining, in at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, the method further includes: Obtaining a target operation command, wherein the target operation command includes a read operation command and / or a write operation command, the read operation command is used to read data in the second logical address range, and the write operation command is used to write update data into the second logical address range; Performing address mapping on the second logical address range based on a second preset address mapping rule to obtain at least one target second logical address range after address mapping, so as to obtain at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range; Determine, from at least one initial dirty data block in the dirty data block linked list of the initial hash table, at least one second initial dirty data block whose logical address range overlaps with the at least one target second logical address range, wherein the second initial dirty data block is any one of a second initial read dirty data block and a second initial write dirty data block; Based on a preset invalidation rule, invalidate data in a conflicting area between the at least one second initial dirty data block and the at least one target operation dirty data block to obtain at least one second initial dirty data block and at least one target operation dirty data block after the invalidation process; Insert at least one target operation dirty data block after invalidation into the dirty data block linked list of the initial hash table to obtain the dirty data block linked list of the target hash table based on at least one second initial dirty data block after invalidation and at least one target operation dirty data block.
5. The method according to claim 4, characterized in that The target operation command is a read operation command, and the at least one target operation dirty data block is at least one target read operation dirty data block; The performing address mapping on the second logical address range based on a second preset address mapping rule to obtain at least one target second logical address range after address mapping, and obtaining at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range, includes: If the second logical address range is within the range of the reference region size multiples, the second logical address range is aligned by the reference region size multiples, and / or if the second logical address range spans the range of the reference region size multiples, the second logical address range is split by the reference region size multiples and aligned by the reference region size multiples, so as to obtain the at least one target second logical address range; Obtain data of the at least one target second logical address range from the flash memory, and obtain the at least one target read operation dirty data block based on the data of the at least one target second logical address range; The method of performing invalidation processing on data in a conflicting area between the at least one second initial dirty data block and the at least one target operation dirty data block based on a preset invalidation rule to obtain at least one second initial dirty data block and at least one target operation dirty data block after the invalidation processing comprises: Marking data in a conflicting area corresponding to the at least one target read operation dirty data block in at least one second initial read dirty data block as invalid; and / or, Data in a conflicting area in at least one target read operation dirty data block corresponding to the at least one second initial write dirty data block is marked as invalid.
6. The method according to claim 5, characterized in that The second logical address range includes a starting second logical address and an ending second logical address; If the second logical address range is within the range of the reference area size multiple, the second logical address range is aligned by the reference area size multiple, and / or if the second logical address range spans the range of the reference area size multiple, the second logical address range is split by the reference area size multiple and aligned by the reference area size multiple, so as to obtain the at least one target second logical address range, comprising: If the second logical address range is within the range of the multiples of the base area size, the starting second logical address is downwardly aligned by the multiples of the base area size, and the ending second logical address is upwardly aligned by the multiples of the base area size to obtain an aligned second logical address range, wherein the aligned second logical address range is the target second logical address range; and / or, If the second logical address range spans a range of multiples of the base area size, splitting the second logical address range by multiples of the base area size to obtain a plurality of second logical address partial ranges; The starting second logical addresses of the multiple second logical address partial ranges are downwardly aligned as multiples of the base area size, and the ending second logical addresses of the multiple second logical address partial ranges are upwardly aligned as multiples of the base area size to obtain multiple second logical address partial ranges after alignment, wherein the multiple second logical address partial ranges after alignment are multiple target second logical address ranges.
7. The method according to claim 4, characterized in that The target operation command is a write operation command, and the at least one target operation dirty data block is at least one target write operation dirty data block; The performing address mapping on the second logical address range based on a second preset address mapping rule to obtain at least one target second logical address range after address mapping, and obtaining at least one target operation dirty data block corresponding to the target operation command based on the at least one target second logical address range, includes: If the second logical address range spans a range of multiples of the base area size, the second logical address range is split by multiples of the base area, and / or if the second logical address range is within a range of multiples of the base area size, the second logical address range is not split or aligned, so as to obtain the at least one target second logical address range; Obtaining update data of the at least one target second logical address range, and obtaining the at least one target write-operation dirty data block based on the update data of the at least one target second logical address range; The method of performing invalidation processing on data in a conflicting area between the at least one second initial dirty data block and the at least one target operation dirty data block based on a preset invalidation rule to obtain at least one second initial dirty data block and at least one target operation dirty data block after the invalidation processing comprises: Marking data in a conflicting area corresponding to the at least one target write operation dirty data block in the at least one second initial write dirty data block as invalid; and / or, Data in a conflicting area in the at least one second initial read dirty data block corresponding to the at least one target write operation dirty data block is marked as invalid.
8. A cache management device, characterized in that: include: an obtaining unit, configured to obtain a read search command, wherein the read search command is used to search for and read data in a first logical address range; An address mapping unit, configured to perform address mapping on the first logical address range based on a first preset address mapping rule to obtain at least one target first logical address range after address mapping; A determining unit, configured to determine, from at least one target dirty data block in the dirty data block linked list of the target hash table, at least one first target dirty data block whose logical address range overlaps with the at least one target first logical address range, wherein the first target dirty data block is any one of a first read dirty data block and a first write dirty data block; an acquiring unit, configured to acquire target data with overlapping logical address ranges in the at least one first target dirty data block if the data transmission status of the at least one first target dirty data block is transmission completed; The obtaining unit is further used to obtain a search result of the first read search command based on the target data.
9. A computer device, characterized in that: include: CPU and memory; The memory is a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises instructions, and when the instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 7.
11. A computer program product comprising instructions or a computer program, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and system for efficiently utilizing solid-state disk for caching
CN103678169A
Storage device capable of being accessed through memory bus
CN104951412A
Cache operation-based flash rapid read-write method and system
CN104978154A
Method and device of processing IO (Input / Output) request
CN108459826A
Distributed storage cache reading and writing method
CN111309262A
