Memory control method, storage device, medium and computer equipment
By combining a three-level index structure and a chained hash table, the contradiction between memory usage and access performance in NAND Flash storage devices is resolved, achieving efficient and low-latency address mapping control, adapting to storage devices of different capacities, and improving system performance and scalability.
Patent Information
- Application Number
- CN202511978028.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-12-25
AI Technical Summary
In the mapping process from logical address to physical address, existing NAND Flash storage devices face a trade-off between memory usage and access performance. Single-level mapping tables consume too much memory, while multi-level paging structures result in excessively high access latency and poor scalability.
It adopts a three-level index structure, including a first-level root table, a second-level block table, and a third-level page table. It uses a chained hash table, quickly locates index values through bitwise operations, and loads uncached table entries as needed. It also combines DMA technology to optimize memory utilization and access efficiency.
It significantly reduces address mapping latency, improves system performance and stability, adapts to storage devices of different capacities, supports flexible expansion, and saves bandwidth and memory resources.
Smart Images

Figure CN121387204A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a memory control method, a storage device, a medium, and a computer equipment, belonging to the field of memory control technology. Background Technology
[0002] NAND Flash is a non-volatile storage medium widely used in storage products such as SD, eMMC, UFS, and SSD. Due to the non-rewritable nature of NAND Flash, data updates are not directly overwritten but are instead written to a new physical address.
[0003] In NAND Flash storage devices, the FTL (Flash Translation Layer) uses a logical-to-physical address mapping table (L2P table) to achieve data addressing, and its performance directly determines the read and write efficiency of the storage device. Traditional L2P mapping mechanisms mainly exist in two paradigms: one is a single-level contiguous array structure, and the other is a multi-level page table structure.
[0004] A single-level contiguous array structure stores all mapping relationships sequentially. For high-capacity storage devices (such as 4TB SSDs), the logical address space can be as high as 1 billion entries (1e9). If each entry occupies 8 bytes, the entire L2P table requires approximately 8GB of memory, which far exceeds the capacity limit of SRAM (Static Random-Access Memory) in DRAM-Less architecture embedded devices.
[0005] To reduce memory footprint, existing technologies employ multi-level page table mechanisms, storing the entire mapping table in pages in flash memory and loading only the active portions into SRAM. However, this method requires multiple flash accesses to load the page table level by level when handling random read / write accesses (e.g., a four-level page table structure requires four flash accesses), resulting in a single address translation latency of over 120μs, becoming a major bottleneck for system performance. Furthermore, traditional index calculation methods rely on division or modulo operations, requiring 10-15 clock cycles on embedded processors, which is inefficient. When storage capacity is upgraded, the existing page table structure typically needs to be redesigned, resulting in poor scalability.
[0006] The core flaw of existing technologies can be summarized as follows: in DRAM-less products, the contradiction between "memory usage" and "access performance" is irreconcilable. Single-level paging consumes too much memory, while multi-level paging reduces memory usage but introduces unacceptable performance jitter due to multiple accesses to NAND Flash (whose access latency is more than a thousand times that of DRAM). Summary of the Invention
[0007] In view of the shortcomings of the prior art, the purpose of this invention is to provide a memory control method, a storage device, a medium, and a computer device.
[0008] In a first aspect, according to an embodiment of the present invention, a first solution is provided as: a memory control method applied to a memory device comprising a non-volatile storage medium and a cache unit, the method comprising: A three-level index structure is constructed, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. Obtain the logical address requested by the host, and extract the index value of the three-level index structure through bitwise operations; The root table entry is located in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table entry is located in the second-level block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the third-level page table into the page table cache area. After locating the corresponding third-level page table based on the page table index of the index value, the hash value is calculated. The hash bucket in the third-level page table is located by the hash value. The linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry node that matches the logical address. The physical page number stored in the mapping entry node is extracted as the physical address of the actual data stored in the non-volatile storage medium, thus completing the mapping conversion from logical address to physical page number.
[0009] Furthermore, the cache unit is SRAM, and the non-volatile storage medium is NAND Flash.
[0010] Furthermore, the first-level root table is a fixed array of resident cache units. The first-level root table contains R root table entries, and each root table entry in the first-level root table points to the physical page number and valid bit of the second-level block table. The second-level block table is an array that is loaded into the cache unit on demand. The second-level block table contains B block table entries, and each block table entry points to the physical page number and valid bit of the third-level page table. Each page table in a three-level page table contains P logical page management modules. The hash bucket array of the linked hash table has a size of H, and new nodes are inserted into the linked list using the head insertion method.
[0011] Furthermore, the physical page number of the second-level block table pointed to by the root table entry is only valid when the valid bit of the root table entry is 1, and the physical page number of the third-level page table pointed to by the block table entry is only valid when the valid bit of the block table entry is 1.
[0012] Furthermore, the primary root table employs dual-copy backup: The first-level root table is stored in two independent copies in NAND Flash, located in different physical blocks; When the root table needs to be updated, first update one copy and verify that the write was successful, then update the other copy; If an abnormal power outage occurs during the update process, the valid copy will be selected and loaded into SRAM upon the next power-on by checking the integrity of the two copies.
[0013] Furthermore, each node in the linked list of the mapping entries contains a logical address (LBA), a physical page number (PPN), and a pointer to the next node.
[0014] Furthermore, the steps for extracting the index value of the three-level index structure using bitwise operations include: Obtain the total logical address space width W, the number of entries in the first-level root table R, and the number of entries in the second-level block table of the storage device; Calculate the number of bits to right shift the root table, S1 = W - log2(R), and extract the root table index through the right shift operation: root_index = LBA>>S1; Calculate the number of bits to right shift the block table, S2 = W - log2(R) - log2(B), and determine the block table mask M_b = B-1. Extract the block table index through right shift and bitwise AND operation: block_index = (LBA>>S2)&M_b; Calculate the number of bits to right shift the page table, S3 = log2(Page_Size), where Page_Size is the logical page size of the storage device. Determine the page table mask M_p = P-1, where P is the number of logical page management modules. Extract the page table index by right shift and bitwise AND operation: page_index = (LBA>>S3)&M_p.
[0015] Furthermore, the steps for loading the second-level block table into the cache unit on demand include: When the root table entry is located with a valid bit of 1 based on the root table index value, and the corresponding secondary block table is not stored in the cache unit, DMA is triggered to load the secondary block table from the non-volatile storage medium into the block table cache area.
[0016] Furthermore, the block table cache uses the LRU algorithm as the cache replacement strategy. The cache replacement strategy maintains the access bit and dirty bit of each block table. When the cache capacity reaches a preset threshold, it prioritizes replacing the least accessed non-dirty block table. If the block table to be replaced is dirty, it is persisted to non-volatile storage medium through an atomic write-back mechanism before the replacement is performed.
[0017] Furthermore, it also includes a dirty data write-back step: Mark the block table to be replaced as dirty; Combining periodic write-back and condition-triggered write-back of dirty data: Periodic write-back involves writing the dirty block table back to NAND Flash at preset time intervals; When the number of dirty blocks reaches a threshold or when cache replacement requires swapping out the dirty block table, the corresponding dirty block table is written back to NAND Flash. After a successful write-back, the dirty status marker of the block table is cleared.
[0018] Furthermore, the execution steps via the atomic write-back mechanism include: Write the updated content of the first-level root table to the log area of the NAND Flash; Verify that the log area was successfully written. Update the primary replica of the first-level root table based on the log content; In the event of an abnormal power outage, the first-level root table will be restored to a consistent state based on the contents of the log area upon the next power-on.
[0019] Furthermore, the steps for loading the level 3 page table into the cache unit on demand include: When the valid bit of a block table entry is located to be 1 based on the block table index value, and the corresponding level 3 page table is not stored in the cache unit, DMA is triggered to load the level 3 page table from the non-volatile storage medium into the page table cache area.
[0020] Further, the steps of calculating the hash value and locating the hash bucket within the third-level page table using the hash value include: Get the preset size H of the third-level page table and the system array; The hash value is obtained by performing a modulo operation on the logical address requested by the host: hash = LBA % H; The hash value is used to locate the corresponding hash bucket in the third-level page table.
[0021] Furthermore, the steps of traversing the linked list of mapping entry nodes corresponding to the hash bucket to find the mapping entry node that matches the logical address include: Traverse the linked list of mapping entry nodes corresponding to the hash bucket starting from the head; The logical address stored in each node is compared with the logical address requested by the host to see if they match. If a node is found that matches the logical address requested by the host, then that node is determined to be a matching mapping entry node. If a matching node is not found after traversing to the end of the linked list, it is determined that there is no corresponding mapping entry node for that logical address.
[0022] Furthermore, it also includes the following steps: After obtaining the logical address of the host request, adjust the number of root table entries R of the first-level root table, the number of block table entries B of the second-level block table, and the number of logical page management modules P of the third-level page table according to the access locality of the logical address. When the proportion of continuous accesses exceeds the preset access value, the number of block table entries B in the secondary block table is increased to reduce prefetching overhead. When hotspot areas are concentrated in a few logical address spaces, reduce the number P of logical page management modules in the three-level page table to improve the loading efficiency of the hotspot page table; The adjusted granularity parameters are atomically written to the non-volatile storage medium through the log structure.
[0023] According to an embodiment of the present invention, utilizing the memory control method in the first solution provided by the present invention, a second solution is provided as follows: In a second aspect, a storage device is used to apply the memory control method according to any one of the first aspects, the storage device comprising: The three-level index construction module is used to construct a three-level index structure, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure. Each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. The request retrieval module is used to obtain the logical address of the host request and extract the index value of the three-level index structure through bitwise operations; The root table processing module is used to locate the root table entry in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table processing module is used to locate the block table entry in the secondary block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the tertiary page table into the page table cache area. The page table processing module is used to locate the corresponding third-level page table based on the page table index of the index value, calculate the hash value, locate the hash bucket in the third-level page table through the hash value, traverse the linked list of mapping entry nodes corresponding to the hash bucket to find the mapping entry node that matches the logical address, extract the physical page number stored in the mapping entry node as the physical address of the actual data stored in the non-volatile storage medium, and complete the mapping conversion from logical address to physical page number.
[0024] Thirdly, a computer device includes a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the following steps: A three-level index structure is constructed, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. Obtain the logical address requested by the host, and extract the index value of the three-level index structure through bitwise operations; The root table entry is located in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table entry is located in the second-level block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the third-level page table into the page table cache area. After locating the corresponding third-level page table based on the page table index of the index value, the hash value is calculated. The hash bucket in the third-level page table is located by the hash value. The linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry node that matches the logical address. The physical page number stored in the mapping entry node is extracted as the physical address of the actual data stored in the non-volatile storage medium, thus completing the mapping conversion from logical address to physical page number.
[0025] Fourthly, a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the following steps: A three-level index structure is constructed, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. Obtain the logical address requested by the host, and extract the index value of the three-level index structure through bitwise operations; The root table entry is located in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table entry is located in the second-level block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the third-level page table into the page table cache area. After locating the corresponding third-level page table based on the page table index of the index value, the hash value is calculated. The hash bucket in the third-level page table is located by the hash value. The linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry node that matches the logical address. The physical page number stored in the mapping entry node is extracted as the physical address of the actual data stored in the non-volatile storage medium, thus completing the mapping conversion from logical address to physical page number.
[0026] Compared with the prior art, the unique advantages of the technical solution provided in this application are as follows: This memory control method employs a three-level index structure. Only the first-level root table is permanently cached, and bitwise operations are used to quickly extract the index, reducing cache usage and unnecessary I / O overhead. The hash buckets of the third-level page table narrow the search range, and linked lists resolve collisions. This fixed structure improves mapping efficiency and system stability. The second-level block table and the third-level page table are loaded non-blockingly, saving bandwidth and improving concurrency performance and cache hit rate.
[0027] This solution balances resource utilization and efficiency improvement, adapts to the characteristics of storage systems, and supports parameter adjustment with strong scalability. Attached Figure Description
[0028] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] in: Figure 1 Here is a flowchart of a memory control method in one embodiment; Figure 2 This is a schematic diagram of an overview of the dynamic three-level index architecture of an L2P table in one embodiment; Figure 3 This is a schematic diagram illustrating index value extraction in one embodiment; Figure 4 This is a structural block diagram of a storage device in one embodiment; Figure 5 This is a structural block diagram of a computer device in one embodiment. Detailed Implementation
[0030] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0031] Example 1 In the existing technology, the multi-level page table mechanism and traditional index calculation methods used for data addressing in NAND Flash storage devices through logical address to physical address mapping tables are inefficient, have poor scalability, and present an irreconcilable contradiction between memory consumption and access performance. The existing single-level mapping table consumes too much memory, and although multi-level paging consumes less memory, it introduces unacceptable performance jitter due to multiple accesses to NAND Flash. Therefore, there is an urgent need for a new solution to achieve a balance between resource utilization and efficiency improvement in L2P table hierarchical indexing.
[0032] To address the aforementioned technical problems, this embodiment provides a memory control method applied to a storage device comprising a non-volatile storage medium and a cache unit, such as... Figure 1 As shown, it includes: S1: Construct a three-level index structure, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure. Each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. S2: Obtain the logical address requested by the host and extract the index value of the three-level index structure through bitwise operations; S3: Locate the root table entry in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, trigger DMA to load the second-level block table from the non-volatile storage medium into the block table cache area. S4: Locate the block table entry in the secondary block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, trigger DMA to load the tertiary page table into the page table cache area. S5: After locating the corresponding third-level page table based on the page table index of the index value, calculate the hash value, locate the hash bucket in the third-level page table through the hash value, traverse the linked list of the mapping entry node corresponding to the hash bucket to find the mapping entry node that matches the logical address, extract the physical page number stored in the mapping entry node as the physical address of the actual data stored in the non-volatile storage medium, and complete the mapping conversion from logical address to physical page number.
[0033] The above scheme constructs a three-level index structure: a resident high-speed cache unit for the first-level root table, a second-level block table, and a third-level page table that are loaded on demand. The index value is extracted through bitwise operations, and the root table, block table, and page table are located level by level. The uncached block table / page table is loaded as needed by DMA.
[0034] Only the first-level root table resides in SRAM, while the second-level block table and third-level page table are loaded on demand. This avoids the waste of SRAM resources caused by the traditional full loading of the index table and significantly improves the utilization of the cache. The on-demand loading mechanism reads the block table / page table from NAND Flash only when needed, avoiding unnecessary storage medium reads and writes, reducing IO overhead, and improving the response speed of address mapping. By using bitwise operations to replace traditional arithmetic operations such as division and modulo operations to extract index values, the execution speed is faster, further shortening the index location time.
[0035] The three-level page table employs a linked hash table structure consisting of a fixed-size hash bucket array and a linked list of mapping entry nodes. Hash buckets are located by hash values, and the linked list is traversed to find matching mapping entries. The hash bucket array enables fast hashing of logical addresses, significantly reducing the search range and improving efficiency compared to linear searches. The linked list of mapping entry nodes effectively resolves hash collisions, ensuring efficient traversal to find the target entry even in the event of collisions. The fixed size of the hash bucket array in each three-level page table facilitates memory management and the implementation of cache replacement strategies, improving system stability.
[0036] This solution improves system concurrency performance and saves bandwidth through the coordinated control of on-demand loading and DMA triggering. When the secondary block table / tertiary page table is not in the cache, DMA is triggered to load it from non-volatile storage media to the corresponding cache area. DMA loading does not consume CPU resources, allowing the system to handle other host requests while loading the index table, thus improving concurrency performance. Only the required block table / page table is loaded, avoiding invalid data transfer and saving bandwidth resources between the storage media and the cache. On-demand loading avoids cache overflow caused by full loading, ensuring that the cache area always stores frequently accessed index data, thus improving cache hit rate.
[0037] The memory control method in this embodiment significantly reduces the overall latency from logical address input to physical address output through a three-level index, linked hash table, on-demand loading, and bitwise operations, meeting the low-latency requirements of high-performance storage systems. It achieves an optimal balance between cache usage, I / O overhead, and lookup efficiency, adapting to the characteristics of storage systems with limited SRAM resources and high NAND Flash I / O latency. The three-level index structure supports flexible adjustment of the root table, block table, and page table sizes, such as R, B, and P values, adapting to storage devices of different capacities and exhibiting good scalability. It effectively solves the pain points of existing technologies, achieving efficient, low-power, and stable memory address mapping control, providing key technical support for high-performance storage systems.
[0038] Specifically, Figure 2 The diagram presents an overview of the L2P table dynamic three-level index architecture, showcasing the overall scheme architecture and illustrating the hierarchical relationship of the three-level index and the flow of data in SRAM and NAND Flash.
[0039] Example 2 This embodiment specifically illustrates the implementation steps of the memory control method in Embodiment 1.
[0040] A memory control method is applied to a memory device comprising a non-volatile storage medium and a cache unit, wherein the non-volatile storage medium is NAND Flash and the cache unit is SRAM.
[0041] The constructed three-level index structure is as follows: The first-level root table is a fixed array of resident cache units. The first-level root table contains R root table entries. Each root table entry in the first-level root table points to the physical page number and valid bit of the second-level block table. The physical page number of the second-level block table pointed to by the root table entry is valid only when the valid bit of the root table entry is 1.
[0042] The second-level block table is an array loaded into the cache unit on demand. The second-level block table contains B block table entries. All block table entries in the second-level block table point to the physical page number and valid bit of the third-level page table. The physical page number of the third-level page table pointed to by the block table entry is valid only when the valid bit of the block table entry is 1.
[0043] Each page table in a three-level page table contains P logical page management modules. The hash bucket array of the linked hash table has a size of H, and new nodes are inserted into the linked list using the head insertion method.
[0044] Furthermore, the primary root table employs dual-copy backup: the primary root table is stored in two independent copies in NAND Flash, located in different physical blocks; when the root table needs to be updated, one copy is updated first and the write is verified to be successful, and then the other copy is updated; if an abnormal power outage occurs during the update process, the valid copy is selected and loaded into SRAM by checking the integrity of the two copies upon the next power-on.
[0045] This step further employs dual-copy backup in the primary root table. Because NAND Flash suffers from unreliability issues such as physical block corruption and write bit flips, if the two copies are stored on the same physical block, a bad block will cause both copies to fail simultaneously. Storing them on different physical blocks achieves physical isolation, avoids single points of failure, and ensures that at least one copy survives. Setting up dual-copy backup in the primary root table is crucial because the primary root table is the entry point for the three-level index structure; all mappings from logical addresses to physical addresses rely on the root table. If the root table is lost or damaged, the entire storage system will be inaccessible. Dual copies serve as the last line of defense for the reliability of the root table.
[0046] The core of this solution lies in sequential updates. If two replicas are updated simultaneously, neither replica may be completed or may be written incorrectly during a power outage, resulting in no valid replicas available. Sequential updates ensure that at least one replica is in a valid state during a power outage.
[0047] Data errors may occur during NAND Flash writing due to interference or wear. Verifying successful writing can confirm that the current copy is written correctly, avoid synchronizing erroneous data to another copy, and prevent the spread of errors.
[0048] The above mechanism solves the reliability problem of the root table at minimal cost, and is the fundamental guarantee for the stable operation of the three-level index structure.
[0049] Each node in the linked list of the mapped entries contains a logical address (LBA), a physical page number (PPN), and a pointer to the next node.
[0050] Example 3 This embodiment details how to implement fast index value extraction using bitwise operations. See [link to documentation]. Figure 3 As shown.
[0051] The steps for extracting the index value of a three-level index structure using bitwise operations include: Obtain the total logical address space width W, the number of entries in the first-level root table R, and the number of entries in the second-level block table of the storage device; Calculate the number of bits to right shift the root table, S1 = W - log2(R), and extract the root table index through the right shift operation: root_index = LBA>>S1; Calculate the number of bits to right shift the block table, S2 = W - log2(R) - log2(B), and determine the block table mask M_b = B-1. Extract the block table index through right shift and bitwise AND operation: block_index = (LBA>>S2)&M_b; Calculate the number of bits to right shift the page table, S3 = log2(Page_Size), where Page_Size is the logical page size of the storage device. Determine the page table mask M_p = P-1, where P is the number of logical page management modules. Extract the page table index by right shift and bitwise AND operation: page_index = (LBA>>S3)&M_p.
[0052] The steps for loading the secondary block table into the cache unit on demand include: when the valid bit of the root table entry is located based on the root table index value and the corresponding secondary block table is not stored in the cache unit, DMA is triggered to load the secondary block table from the non-volatile storage medium into the block table cache area.
[0053] Specifically, the block table cache uses the LRU algorithm as the cache replacement strategy. The cache replacement strategy maintains the access bit and dirty bit of each block table. When the cache capacity reaches a preset threshold, it prioritizes replacing the least accessed non-dirty block table. If the block table to be replaced is dirty, it is persisted to non-volatile storage medium through an atomic write-back mechanism before the replacement is performed.
[0054] Specifically, it also includes a dirty data write-back step: marking the block table to be replaced as dirty; combining periodic write-back and condition-triggered write-back of dirty data: periodic write-back means writing the dirty block table back to NAND Flash at preset time intervals; when the number of dirty block tables reaches a threshold or when cache replacement requires swapping out dirty block tables, the corresponding dirty block table is written back to NAND Flash; after successful write-back, the dirty status mark of the block table is cleared.
[0055] Specifically, the execution steps via the atomic write-back mechanism include: writing the updated content of the first-level root table to the log area of the NAND Flash; verifying that the content of the log area has been successfully written; updating the primary replica of the first-level root table based on the log content; and restoring the first-level root table to a consistent state based on the content of the log area upon the next power-on if an abnormal power outage occurs.
[0056] Specifically, the steps for loading the level 3 page table into the cache unit on demand include: when the valid bit of the block table entry is located to be 1 according to the block table index value, and the corresponding level 3 page table is not stored in the cache unit, DMA is triggered to load the level 3 page table from the non-volatile storage medium into the page table cache area.
[0057] In this embodiment, the total logical address space width W=32 bits can support a maximum logical address space of 4GB. Therefore, the number of entries in the first-level root table is R=256, the number of entries in the second-level block table is B=128, the logical page size is Page_Size=4KB, the number of logical page management modules in the third-level page table is P=64, the block table cache capacity threshold is 100 block tables, the dirty block table number threshold is 50, and the periodic write-back interval is 10 seconds.
[0058] The steps for extracting a third-level index using bitwise operations are as follows: Calculate displacement parameters: The number of right shifts in the root table is S1 = 32 - 8 = 24; The right shift bits for the block table are S2 = 32 - 8 - 7 = 17; the block table mask is M = 128 - 1 = 127. Page table right shift bits S3=12; Page table mask M=64-1=63; Extracting the index: If the host requests logical address LBA=0x12345678: root_index = 0x12345678>>24 = 0x12; block_index = (0x12345678>>17)&127 = (0x12345678>>17)=0x48D →&127=0x0D; page_index = (0x12345678>>12)&63 = (0x12345678>>12)=0x12345 →&63=0x25.
[0059] The process of loading the second-level block table on demand is as follows: check the valid bit of the root table entry corresponding to root_index=0x12: if it is 1 and the block table is not in the cache, then trigger DMA to load the block table from NAND Flash to the block table cache area.
[0060] Second-level block table replacement uses LRU replacement. When the number of cached block tables reaches 100, the least accessed non-dirty block table is replaced first.
[0061] Periodic and conditionally triggered write-back mechanisms enable efficient management of dirty data. The atomic write-back mechanism ensures no data loss after a power outage, resolving the issue of data loss due to abnormal power outages during table updates.
[0062] Example 4 Because the number of mapping entries in the three-level page table is huge, direct linear lookup of the physical page number corresponding to the logical address is extremely inefficient; hash collisions can lead to lookup failures or a significant increase in latency, affecting the overall performance of address mapping.
[0063] The storage device in this embodiment uses a chained hash table structure for its three-level page table: the hash bucket array has a preset size of H=256; the host request logical address is LBA=0x12345078.
[0064] Get hash bucket size: Read the system's preset hash bucket array size H=256; Calculate hash value: Perform a modulo operation on LBA: hash = LBA % H = 305419896 % 64 = 78; Locate hash bucket: Based on hash=78, directly locate the 78th hash bucket in the three-level page table linked hash table.
[0065] Traversing the linked list quickly narrows down the search range.
[0066] Furthermore, the step of traversing the linked list of mapping entry nodes corresponding to the hash bucket to find a mapping entry node that matches the logical address includes: starting from the head of the linked list of mapping entry nodes corresponding to the hash bucket; comparing the logical address stored in each node with the logical address requested by the host; if a node that matches the logical address requested by the host is found, then the node is determined to be a matching mapping entry node; if no matching node is found after traversing to the tail of the linked list, then the logical address has no corresponding mapping entry node.
[0067] It should be noted that the linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry that matches the LBA. If it is a read request, the physical address where the corresponding mapping entry is stored is returned; if it is a write request, the physical address of the entry is updated or a new node is inserted. Follow the steps in the documentation to traverse the linked list to avoid omissions or misjudgments.
[0068] Example 5 Since the granular parameters of the three-level index structure are mostly static fixed values, it is not convenient to adapt to the dynamic changes in host access patterns.
[0069] Based on Embodiment 1, in this embodiment, after obtaining the logical address of the host request, the number of root table entries R of the first-level root table, the number of block table entries B of the second-level block table, and the number of logical page management modules P of the third-level page table are adjusted according to the access locality of the logical address. When the proportion of continuous access exceeds the preset access value, the number of block table entries B of the second-level block table is increased to reduce prefetch overhead. When the hot area is concentrated in a few logical address spaces, the number of logical page management modules P of the third-level page table is reduced to improve the loading efficiency of the hot page table. The adjusted granularity parameters are atomically written to non-volatile storage medium through a log structure to ensure consistency of each system restart.
[0070] It should be noted that when acquiring access pattern data, the system performs real-time statistics on host logical address access records, calculating the percentage of consecutive accesses and the percentage of hotspot areas. When adjusting the number of entries in the second-level block table (B), the value of B is increased if the percentage of consecutive accesses is detected to be greater than a first preset value. When adjusting the number of management modules in the third-level page table (P), the value of P is decreased if the percentage of hotspot areas is detected to be less than a second preset value. The adjusted parameters are written to the NAND Flash log area, and the main configuration area is updated after successful write verification to ensure consistency during reboots. Increasing the value of B expands the management scope of the second-level block table, reduces the number of times the second-level block table is prefetched, and lowers the NAND Flash read / write overhead. Decreasing the value of P reduces the management granularity of the third-level page table, allowing for more centralized storage of the thermoelectric page table and improving loading efficiency.
[0071] Example 6 This embodiment provides a storage device, see reference. Figure 4 As shown, for applying the memory control method described in any of the above embodiments, the memory device includes: The three-level index construction module 100 is used to construct a three-level index structure, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure. Each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. The request acquisition module 200 is used to obtain the logical address of the host request and extract the index value of the three-level index structure through bitwise operations; The root table processing module 300 is used to locate the root table entry in the first-level root table according to the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table processing module 400 is used to locate the block table entry in the secondary block table according to the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, the DMA is triggered to load the tertiary page table into the page table cache area. The page table processing module 500 is used to locate the corresponding third-level page table based on the page table index of the index value, calculate the hash value, locate the hash bucket in the third-level page table through the hash value, traverse the linked list of mapping entry nodes corresponding to the hash bucket to find the mapping entry node that matches the logical address, extract the physical page number stored in the mapping entry node as the physical address of the actual data stored in the non-volatile storage medium, and complete the mapping conversion from logical address to physical page number.
[0072] The memory control method in this embodiment, through a comprehensive scheme of three-level indexing, linked hash tables, on-demand loading, and bitwise operations, significantly reduces the end-to-end latency from logical address input to physical address output, meeting the low-latency requirements of high-performance storage systems. It achieves an optimal balance between cache usage, I / O overhead, and lookup efficiency, adapting to the characteristics of storage systems with limited SRAM resources and high NAND Flash I / O latency. The three-level index structure supports flexible adjustment of the root table, block table, and page table sizes, such as R, B, and P values, adapting to storage devices of different capacities and exhibiting good scalability. It effectively solves the pain points of existing technologies, achieving efficient, low-power, and stable memory address mapping control, providing key technical support for high-performance storage systems.
[0073] Example 7 Figure 5 An internal structural diagram of a computer device in one embodiment is shown. This computer device can specifically be a terminal or a server. Figure 5 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and may also store a computer program. When executed by the processor, this computer program enables the processor to implement memory control methods. The memory may also store a computer program, which, when executed by the processor, enables the processor to perform memory control methods. Those skilled in the art will understand that... Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0074] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the following steps: A memory control method is applied to a storage device comprising a non-volatile storage medium and a cache unit, the method comprising: A three-level index structure is constructed, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. Obtain the logical address requested by the host, and extract the index value of the three-level index structure through bitwise operations; The root table entry is located in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table entry is located in the second-level block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the third-level page table into the page table cache area. After locating the corresponding third-level page table based on the page table index of the index value, the hash value is calculated. The hash bucket in the third-level page table is located by the hash value. The linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry node that matches the logical address. The physical page number stored in the mapping entry node is extracted as the physical address of the actual data stored in the non-volatile storage medium, thus completing the mapping conversion from logical address to physical page number.
[0075] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, causes the processor to perform the following steps: A memory control method is applied to a storage device comprising a non-volatile storage medium and a cache unit, the method comprising: A three-level index structure is constructed, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. Obtain the logical address requested by the host, and extract the index value of the three-level index structure through bitwise operations; The root table entry is located in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table entry is located in the second-level block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the third-level page table into the page table cache area. After locating the corresponding third-level page table based on the page table index of the index value, the hash value is calculated. The hash bucket in the third-level page table is located by the hash value. The linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry node that matches the logical address. The physical page number stored in the mapping entry node is extracted as the physical address of the actual data stored in the non-volatile storage medium, thus completing the mapping conversion from logical address to physical page number.
[0076] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0077] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0078] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A memory control method applied to a memory device comprising a non-volatile storage medium and a cache unit, characterized in that, The method includes: A three-level index structure is constructed, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. Obtain the logical address requested by the host, and extract the index value of the three-level index structure through bitwise operations; The root table entry is located in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table entry is located in the second-level block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the third-level page table into the page table cache area. After locating the corresponding third-level page table based on the page table index of the index value, the hash value is calculated. The hash bucket in the third-level page table is located by the hash value. The linked list of mapping entry nodes corresponding to the hash bucket is traversed to find the mapping entry node that matches the logical address. The physical page number stored in the mapping entry node is extracted as the physical address of the actual data stored in the non-volatile storage medium, thus completing the mapping conversion from logical address to physical page number.
2. The memory control method according to claim 1, characterized in that, The cache unit is SRAM, and the non-volatile storage medium is NAND Flash.
3. The memory control method according to claim 1, characterized in that: The first-level root table is a fixed array of resident cache units. The first-level root table contains R root table entries, and each root table entry points to the physical page number and valid bit of the second-level block table. The second-level block table is an array that is loaded into the cache unit on demand. The second-level block table contains B block table entries, and each block table entry points to the physical page number and valid bit of the third-level page table. Each page table in a three-level page table contains P logical page management modules. The hash bucket array of the linked hash table has a size of H, and new nodes are inserted into the linked list using the head insertion method.
4. The memory control method according to claim 3, characterized in that: The physical page number of the second-level block table pointed to by the root table entry is valid only when the valid bit of the root table entry is 1, and the physical page number of the third-level page table pointed to by the block table entry is valid only when the valid bit of the block table entry is 1.
5. The memory control method according to claim 3, characterized in that: The first-level root table is backed up with two copies: The first-level root table is stored in two independent copies in NAND Flash, located in different physical blocks; When the root table needs to be updated, first update one copy and verify that the write was successful, then update the other copy; If an abnormal power outage occurs during the update process, the valid copy will be selected and loaded into SRAM upon the next power-on by checking the integrity of the two copies.
6. The memory control method according to claim 3, characterized in that: Each node in the linked list of mapped entries contains a logical address (LBA), a physical page number (PPN), and a pointer to the next node.
7. The memory control method according to claim 1, characterized in that: The steps for extracting the index value of a three-level index structure using bitwise operations include: Obtain the total logical address space width W, the number of entries in the first-level root table R, and the number of entries in the second-level block table of the storage device; Calculate the number of bits to right shift the root table, S1 = W - log2(R), and extract the root table index through the right shift operation: root_index = LBA>> S1; Calculate the number of bits to right shift the block table, S2 = W - log2(R) - log2(B), and determine the block table mask M_b = B-1. Extract the block table index by right shift and bitwise AND operation: block_index = (LBA >> S2) & M_b; Calculate the number of bits to right shift the page table, S3 = log2(Page_Size), where Page_Size is the logical page size of the storage device. Determine the page table mask M_p = P-1, where P is the number of logical page management modules. Extract the page table index by right shift and bitwise AND operation: page_index = (LBA >> S3) & M_p.
8. The memory control method according to claim 1, characterized in that, The method further includes the step of loading the secondary block table into the cache unit on demand, which includes: When the root table entry is located with a valid bit of 1 based on the root table index value, and the corresponding secondary block table is not stored in the cache unit, DMA is triggered to load the secondary block table from the non-volatile storage medium into the block table cache area.
9. The memory control method according to claim 8, characterized in that, The method further includes: the block table cache uses the LRU algorithm as the cache replacement strategy. The cache replacement strategy maintains the access bit and dirty bit of each block table. When the cache capacity reaches a preset threshold, the least accessed non-dirty block table is replaced first. If the block table to be replaced is dirty, it is persisted to a non-volatile storage medium through an atomic write-back mechanism before the replacement is performed.
10. The memory control method according to claim 9, characterized in that, The method also includes a dirty data write-back step: Mark the block table to be replaced as dirty; Combining periodic write-back and condition-triggered write-back of dirty data: Periodic write-back involves writing the dirty block table back to NAND Flash at preset time intervals; When the number of dirty blocks reaches a threshold or when cache replacement requires swapping out the dirty block table, the corresponding dirty block table is written back to NAND Flash. After a successful write-back, the dirty status marker of the block table is cleared.
11. The memory control method according to claim 9, characterized in that, The method includes the following execution steps via an atomic write-back mechanism: Write the updated content of the first-level root table to the log area of the NAND Flash; Verify that the log area was successfully written. Update the primary replica of the first-level root table based on the log content; In the event of an abnormal power outage, the first-level root table will be restored to a consistent state based on the contents of the log area upon the next power-on.
12. The memory control method according to claim 1, characterized in that, The steps for loading level 3 page tables into cache units on demand include: When the valid bit of a block table entry is located to be 1 based on the block table index value, and the corresponding level 3 page table is not stored in the cache unit, DMA is triggered to load the level 3 page table from the non-volatile storage medium into the page table cache area.
13. The memory control method according to claim 1, characterized in that, The steps for calculating the hash value and locating the hash bucket within the third-level page table using the hash value include: Get the preset size H of the third-level page table and the system array; The hash value is obtained by performing a modulo operation on the logical address requested by the host: hash = LBA % H; The hash value is used to locate the corresponding hash bucket in the third-level page table.
14. The memory control method according to claim 13, characterized in that, The steps for traversing the linked list of mapping entry nodes corresponding to the hash bucket to find the mapping entry node that matches the logical address include: Traverse the linked list of mapping entry nodes corresponding to the hash bucket starting from the head; The logical address stored in each node is compared with the logical address requested by the host to see if they match. If a node is found that matches the logical address requested by the host, then that node is determined to be a matching mapping entry node. If a matching node is not found after traversing to the end of the linked list, it is determined that there is no corresponding mapping entry node for that logical address.
15. The memory control method according to claim 1, characterized in that, It also includes the following steps: After obtaining the logical address of the host request, adjust the number of root table entries R of the first-level root table, the number of block table entries B of the second-level block table, and the number of logical page management modules P of the third-level page table according to the access locality of the logical address. When the proportion of continuous accesses exceeds the preset access value, the number of block table entries B in the secondary block table is increased to reduce prefetching overhead. When hotspot areas are concentrated in a few logical address spaces, reduce the number P of logical page management modules in the three-level page table to improve the loading efficiency of the hotspot page table; The adjusted granularity parameters are atomically written to the non-volatile storage medium through the log structure.
16. A storage device, characterized in that, For applying the memory control method according to any one of claims 1 to 15, the memory device comprises: The three-level index construction module is used to construct a three-level index structure, which includes a first-level root table, a second-level block table, and a third-level page table. The first-level root table resides in the cache unit, the second-level block table is loaded into the cache unit on demand, and the third-level page table is loaded into the cache unit on demand. The third-level page table adopts a chained hash table structure, and each third-level page table's chained hash table includes a fixed-size hash bucket array and a linked list of mapping entry nodes. The request retrieval module is used to obtain the logical address of the host request and extract the index value of the three-level index structure through bitwise operations; The root table processing module is used to locate the root table entry in the first-level root table based on the root table index of the index value to obtain the block table physical page number. If the block table is not in the cache unit, DMA is triggered to load the second-level block table from the non-volatile storage medium into the block table cache area. The block table processing module is used to locate the block table entry in the secondary block table based on the block table index of the index value to obtain the physical page number of the page table. If the page table is not in the cache unit, DMA is triggered to load the tertiary page table into the page table cache area. The page table processing module is used to locate the corresponding third-level page table based on the page table index of the index value, calculate the hash value, locate the hash bucket in the third-level page table through the hash value, traverse the linked list of mapping entry nodes corresponding to the hash bucket to find the mapping entry node that matches the logical address, extract the physical page number stored in the mapping entry node as the physical address of the actual data stored in the non-volatile storage medium, and complete the mapping conversion from logical address to physical page number.
17. A computer-readable storage medium, characterized in that, The device stores a computer program that, when executed by a processor, causes the processor to perform the steps of the method as described in any one of claims 1 to 15.
18. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method as described in any one of claims 1 to 15.
Citation Information
Patent Citations
Memory control system, address mapping method and address mapping device
CN113419975A
Cache processing method and device, computer equipment and storage medium
CN117992366A
Techniques using a unified cache for storing and accessing translation table entries and updates
US12314186B1
Caching techniques using a mapping cache and a data cache
US20250328469A1
Cited By
L2P linked list establishing method in storage controller and storage device
CN121833548A
