An updating method of an L2P table, an SSD controller and a storage medium
By receiving, parsing, and storing host commands sequentially in the SSD controller and updating the L2P table, the problem of disordered processing order of TRIM and WRITE commands is solved, improving data reliability and storage efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI DATANG STORAGE TECH CO LTD
- Filing Date
- 2026-02-02
- Publication Date
- 2026-05-29
AI Technical Summary
The SSD controller lacks a dynamic command sequence preservation mechanism when processing TRIM and WRITE commands issued by the host, which leads to disordered L2P table mapping relationships, resulting in data loss and decreased reliability.
By receiving and parsing commands from the host, command information is generated and stored in the host command cache in the order of receipt. The L2P table is read sequentially and updated according to the physical block function allocation information to ensure the correct processing order of write commands and garbage collection commands.
It significantly reduces the overhead of command information storage resources, avoids the disorder of L2P table mapping relationships, and improves data reliability and processing efficiency.
Smart Images

Figure CN122111332A_ABST
Abstract
Description
Technical Field
[0001] This article relates to, but is not limited to, the field of data processing technology, and in particular to an L2P table update method, apparatus, and computer-readable storage medium. Background Technology
[0002] In recent years, with the explosive growth of big data services, the demand for real-time writing and dynamic updating of massive amounts of data has placed higher requirements on storage devices (especially SSDs).
[0003] In related technologies, SSD controllers generally lack a dynamic command sequence preservation mechanism when processing TRIM commands (marking invalid data) and WRITE commands (writing valid data) issued by the host. This deficiency can cause the SSD controller to incorrectly mark valid data on the host as invalid data and trigger an erase operation due to disordered command execution order. This can lead to disorder in the L2P table (logical-to-physical address mapping table), ultimately resulting in data loss, abnormal L2P table updates, and decreased reliability. Summary of the Invention
[0004] This application provides an L2P table update method, an SSD controller, and a storage medium, which can avoid the disorder of L2P table mapping relationships and improve data reliability.
[0005] This application provides an L2P table update method, including: Receive commands from the host. If the received command is a write command or a garbage collection command, parse the received command and generate command information based on the parsing result. Then, store the generated command information in the host command cache in the order of receipt. According to the receiving order, each command information in the host command cache is read sequentially, and for each read command information: the corresponding physical block number is obtained from the command information, the command type of the command corresponding to the command information is determined according to the physical block function allocation information and the obtained physical block number, and the L2P table is updated according to the command information and the determined command type. The corresponding physical block number refers to the physical block number of the command corresponding to the command information, and the physical block function allocation information is the information on the function allocation of multiple physical blocks corresponding to the logical storage unit in the memory, which is obtained in advance.
[0006] On the other hand, embodiments of this application also provide an SSD controller, including a memory and a processor; The memory is used to store executable programs; The processor is used to read and execute the executable program to perform the L2P table update method as described above.
[0007] In another aspect, embodiments of this application also provide a storage medium storing a computer program, wherein when the computer program is executed by a processor, it can implement the L2P table update method as described above.
[0008] Compared with related technologies, the L2P table update method, SSD controller, and storage medium provided in this application generate command information for received write commands and garbage collection commands and store them in the host command cache according to the receiving order; each command information in the host command cache is read sequentially according to the receiving order, and for each read command information: the corresponding physical block number is obtained from the command information, the command type of the command corresponding to the command information is determined according to the physical block function allocation information and the obtained physical block number, and the L2P table is updated according to the command information and the determined command type. Therefore, the command information for write commands and garbage collection commands can be stored together in the receiving order and the two can be effectively distinguished, thereby significantly reducing the resource overhead required for command information storage, avoiding the disorder of L2P table mapping relationship, and greatly improving data reliability.
[0009] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. Other advantages of this application can be realized and obtained by means of the embodiments described in the description and the accompanying drawings. Attached Figure Description
[0010] The accompanying drawings are used to provide an understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.
[0011] Figure 1 This is a flowchart illustrating an L2P table update method according to an embodiment of this application; Figure 2 This is a schematic diagram illustrating the functional division of physical blocks in an SSD storage device according to an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an L2P table update device according to an embodiment of this application; Figure 4 This is a schematic diagram of a 4KB page information layout according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an L2P table update device according to an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an SSD controller according to an embodiment of this application. Detailed Implementation
[0012] This application describes several embodiments, but these descriptions are exemplary and not limiting, and it will be apparent to those skilled in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with, or may replace, any feature or element of any other embodiment.
[0013] This application includes and contemplates combinations of features and elements known to those skilled in the art. The embodiments, features, and elements disclosed in this application can also be combined with any conventional features or elements to form unique inventive solutions. Any feature or element of any embodiment can also be combined with features or elements from other inventive solutions to form another unique inventive solution. Therefore, it should be understood that any feature shown and / or discussed in this application can be implemented individually or in any suitable combination. Therefore, the embodiments are not limited except by the limitations imposed by the appended claims and their equivalents. Furthermore, various modifications and changes can be made within the scope of the appended claims.
[0014] Furthermore, in describing representative embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to the specific order of steps described herein, to the extent that it does not depend on such a specific order. As will be understood by those skilled in the art, other sequences of steps are also possible. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Moreover, the claims concerning the method and / or process should not be limited to the steps performed in the written order, and those skilled in the art will readily understand that these orders can be varied and still remain within the spirit and scope of the embodiments of this application.
[0015] Driven by big data applications such as 5G and artificial intelligence, SSDs need to efficiently handle high-frequency data write, deletion, and update operations. The host manages the data lifecycle collaboratively through two types of commands: garbage collection commands (TRIM command) and write commands (WRITE command). When deleting data, a TRIM command is issued to indicate that the logical address range has expired; when updating data, a WRITE command is issued to write the new data to the new physical location and establish a new mapping. Both types of operations must be completed within the protocol's time limit, and their core relies on the accurate maintenance of the L2P table (a mapping table between logical block addresses and physical block addresses). The update logic of the L2P table differs fundamentally between the two: The TRIM command sets the physical block address corresponding to the specified logical address to an invalid flag (such as NULL), explicitly declaring that there is no valid data at that logical address; The WRITE command updates the logical address mapping to the physical block address of the newly written data, and the original physical address is implicitly invalidated due to the unmapping.
[0016] This difference makes command processing timing crucial to data reliability. If, for the same logical address, the host issues commands in the order of "TRIM first, then WRITE" (e.g., deleting old data and immediately writing new data), but the SSD controller executes WRITE first and then TRIM due to misordering, the newly written valid data will have its mapping cleared by TRIM. This logical address will become invalid in the L2P table. During subsequent garbage collection, new data, having lost its mapping, will be mistakenly identified as garbage and erased, causing host read failures or permanent data loss. This risk is particularly prominent in high-frequency write / erase scenarios such as database log flushing and cache hot updates.
[0017] Therefore, it is necessary to establish a strict TRIM and WRITE command order preservation mechanism to ensure that command processing strictly follows the host's issuance sequence, so as to accurately restore the host's operational intent and fundamentally eliminate the risk of "valid data being mislabeled as garbage".
[0018] Therefore, this disclosure provides an L2P table update method, such as... Figure 1 As shown, it includes: Step 100: Receive commands sent by the host. If the received command is a write command or a garbage collection command, parse the received command and generate command information based on the parsing result. Store the generated command information in the host command cache in the order of receipt. Step 101: Read each command information in the host command cache in sequence according to the receiving order, and for the read command information: obtain the corresponding physical block number from the command information, determine the command type of the command corresponding to the command information according to the physical block function allocation information and the obtained physical block number, and update the L2P table according to the command information and the determined command type. The corresponding physical block number refers to the physical block number of the command corresponding to the command information, and the physical block function allocation information is the information on the function allocation of multiple physical blocks corresponding to the logical storage unit in the memory, which is obtained in advance.
[0019] For example, identifying commands issued by the host primarily relies on the command interpreter's comprehensive analysis of the command's initial word, functional parameters, and execution context. The command interpreter (such as a shell) breaks down the input command into words using spaces and other delimiters, using the initial word as a core identifier (e.g., "ping" or "netstat"), and then searches for the corresponding executable file in the path specified by the environment variable PATH to confirm the command type. Secondly, by analyzing the command's function and parameter combinations (e.g., "ping -t" for continuous network testing, "netstat -a" for viewing all connection statuses), the command's purpose can be further precisely distinguished. Simultaneously, logs and monitoring mechanisms record the detailed context of command execution, including time, user identity, and operation sequence, to identify abnormal behavior (e.g., executing sensitive commands outside of working hours). Network communication pattern analysis is also crucial; for example, detecting high-frequency connections between the host and suspicious IPs or abnormal data packet characteristics can help determine the command intent. Furthermore, security tools such as arp-scan and netdiscover provide network-layer assisted identification. Additionally, AI / ML models can be introduced, and data annotation training can improve the accuracy of command word recognition.
[0020] The core step in SSD controller command processing is to sequentially read command information from the host command cache according to the order of receipt. The corresponding physical block number is extracted from the command information; this number identifies the specific physical storage location involved in the command operation, providing basic location information for subsequent processing.
[0021] By using the pre-configured physical block function allocation information (which describes the functional division of logical storage units into corresponding physical blocks in memory) and the obtained physical block number, the command type corresponding to the command information can be accurately determined.
[0022] After determining the command type, the L2P table (logical-to-physical mapping table) is updated based on the command information (such as logical address, data content, etc.) and the determined command type. The L2P table, as the core data structure maintained by the SSD controller, records the mapping relationship between logical block addresses and physical addresses; when processing write commands, it is updated to point to the new physical location, and when processing garbage collection commands, it reflects the change in physical location after data migration.
[0023] For example, the execution entity of the L2P table update method provided in this application embodiment can be an SSD controller.
[0024] The L2P table update method provided in this application generates command information for received write commands and garbage collection commands and stores it in the host command cache according to the receiving order. It then reads each command information from the host command cache sequentially according to the receiving order, and for each read command information: obtains the corresponding physical block number from the command information, determines the command type of the command corresponding to the command information based on the physical block function allocation information and the obtained physical block number, and updates the L2P table according to the command information and the determined command type. Therefore, it can store the command information for write commands and garbage collection commands together sequentially according to the receiving order and effectively distinguish between the two, thereby significantly reducing the resource overhead required for command information storage, avoiding the disorder of the L2P table mapping relationship, and greatly improving data reliability.
[0025] The L2P table update method provided in this application process commands in the order of receipt and updates the L2P table synchronously, ensuring the accuracy and consistency of the mapping from logical address to physical address, effectively avoiding the disorder of the L2P table mapping relationship, thereby significantly improving the reliability of data processing and storage efficiency.
[0026] In one exemplary instance, the physical block function allocation information includes: the range of physical block numbers for user information physical blocks and the range of physical block numbers for user data physical blocks among multiple physical blocks corresponding to a unit of logical storage unit in the memory; The command type corresponding to the command information is determined based on the physical block function allocation information and the obtained physical block number, including: If the physical block number of the command corresponding to the command information falls within the range of physical block numbers of the user information physical block, then the command corresponding to the command information is determined to be a garbage collection command. If the physical block number of the command corresponding to the command information falls within the range of physical block numbers of the user data physical block, then the command corresponding to the command information is determined to be a write command.
[0027] For example, physical block function allocation information defines the functional division of physical blocks in an SSD storage device, such as... Figure 2 As shown, they are clearly divided into two categories: User information physical blocks: their numbering range is dedicated to storing internal management data required by the SSD firmware, including metadata such as L2P mapping tables, firmware binary code, bad block information, and remapping tables; User data physical blocks: their numbering range is dedicated to storing the actual user data written by the host through the WRITE command.
[0028] In SSD implementation, the physical storage resources associated with each Logical Unit Number (LUN, i.e., the logical storage unit provided by the SSD to the host) are allocated according to this rule. It is important to clarify that the Logical Block Address (LBA) space visible to the host is mapped entirely to the user data physical block, not logically divided according to whether it is "dedicated to the WRITE command" or "dedicated to the TRIM command." Both the WRITE and TRIM commands operate on the LBA range carried by the user data physical block—the WRITE command writes new data to the user data physical block and updates the L2P table mapping, while the TRIM command marks the specified LBA range as invalid through the L2P table. The content of the user information physical block is maintained autonomously by the firmware, is invisible to the host, and is not directly affected by the host's WRITE / TRIM commands.
[0029] For example, when processing a command, the type is determined by comparing the physical block number in the command information with a preset range: if the physical block number falls within the range of user information physical block numbers, the command is identified as a garbage collection command; if it falls within the range of user data physical block numbers, it is identified as a write command.
[0030] This identification mechanism based on number range ensures that garbage collection and data writing operations are performed in the correct physical area, effectively avoiding mapping disorder and thus guaranteeing the accuracy of data processing and storage efficiency.
[0031] In one exemplary instance, when the command corresponding to the command information is the garbage collection command, the parsing result includes: the starting logical block address and the length of invalid data of the received garbage collection command; Parse the received command and generate command information based on the parsing result, including: The command information is generated based on the starting logical block address and invalid data length of the received garbage collection command.
[0032] For example, when a garbage collection command (such as the TRIM instruction) is received, the starting logical block address and the length of invalid data are resolved. The starting logical block address identifies the starting position of the data that needs to be marked as invalid, while the length of invalid data specifies the size of the data region that needs to be marked as invalid. These parameters are provided by the operating system when deleting a file to precisely specify which data regions can be marked as invalid.
[0033] After parsing, command information is generated based on these parameters. This command information contains specific parameters for the garbage collection operation, enabling the executing entity, such as the SSD controller, to accurately identify which logical block regions have invalid data, thereby avoiding unnecessary migration and rewriting of this data during garbage collection. This command information generation mechanism based on the starting logical block address and the length of invalid data ensures that garbage collection operations can be performed accurately and efficiently, effectively reducing the amount of data moved by the SSD during garbage collection, reducing write amplification, and improving the SSD's write performance and lifespan.
[0034] In one exemplary instance, when the command corresponding to the command information is the write command, the parsing result includes: the starting logical block address and the write data length of the received write command; Parse the received command and generate command information based on the parsing result, including: The mapping relationship between logical block addresses and physical block addresses is used to obtain the physical block address corresponding to the starting logical block address of the received write command; The first part of the command information is determined based on the relationship between the starting logical block address of the received write command and the preset logical block size, and the second part of the command information is determined based on the relationship between the obtained physical block address, the write data length of the received write command, and the preset logical block size, so as to obtain the command information.
[0035] For example, when the command is a write command, the starting logical block address and the write data length of the received write command are parsed out. The starting logical block address identifies the starting position of the data in the logical storage space, and the write data length specifies the amount of data to be written. These parameters are provided by the host to locate the write operation.
[0036] By establishing a mapping between logical block addresses and physical block addresses, the physical block address corresponding to the starting logical block address is obtained. This mapping converts the logical storage location into the actual physical storage location, ensuring that data can be accurately written to the target block.
[0037] Based on the relationship between the starting logical block address and the preset logical block size, the first part of the command information is determined, describing the location range of the logical address. Simultaneously, based on the relationship between the physical block address, the write data length, and the preset logical block size, the second part of the command information is determined, containing the mapping details between the physical address and the data length. This segmented generation method allows the command information to precisely guide the data write operation.
[0038] For example, the physical block address corresponding to the starting logical block address of the received write command can be obtained by using the mapping relationship between logical block addresses and physical block addresses. This can be achieved through the core processing unit (FTLhandle module) in the flash translation layer architecture. The obtained physical block address includes the physical block number (i.e., block num).
[0039] In one exemplary instance, the command information is generated based on the starting logical block address and invalid data length of the received garbage collection command, including: Determine whether the starting logical block address of the received garbage collection command is an integer multiple of the host-side logical block size. If the starting logical block address of the received garbage collection command is an integer multiple of the logical block size, the first part of the command information is determined according to the relationship between the starting logical block address of the received garbage collection command and the logical block size, and the invalid data length of the received garbage collection command is used as the second part of the command information to obtain the command information. When the starting logical block address of the received garbage collection command is an integer multiple of the preset logical block size, the quotient and remainder are obtained according to the relationship between the starting logical block address of the received garbage collection command and the logical block size. The quotient is used as the first part of the command information, and the second part of the command information is determined according to the remainder and the length of invalid data, so as to obtain the command information.
[0040] For example, when processing a garbage collection command, the first step is to determine whether the starting logical block address is an integer multiple of the preset logical block size. This determination is based on the physical characteristics of flash memory storage—the logical block size is typically a fixed value (such as 4KB or 512 bytes), and the erasure and management operations of flash memory blocks require data alignment to avoid fragmentation and performance loss. When the starting address is strictly aligned, the garbage collection operation can directly apply to the complete logical block without additional boundary handling, thereby significantly improving execution efficiency.
[0041] If the starting logical block address is an integer multiple of the logical block size (e.g., if the logical block size is 4KB and the starting address is 8KB), the first part of the command message is directly determined by the quotient of this address and the logical block size (8KB ÷ 4KB = 2, the quotient is 2), representing the starting logical block index; the second part directly uses the length of the received invalid data (e.g., the invalid data length is 12KB), indicating the total amount of data to be marked as invalid. This alignment process ensures that the command message perfectly matches the physical structure of the storage unit, avoids redundant calculations, and enables garbage collection operations to efficiently mark entire blocks of data.
[0042] When the starting logical block address is not an integer multiple (e.g., the starting address is 6KB and the logical block size is 4KB), fine-tuning is required: calculate the quotient (6KB ÷ 4KB = 1, the quotient is 1) and the remainder (6KB - 1 × 4KB = 2KB). The quotient, as the first part of the command information, identifies the starting logical block index; the remainder, together with the length of invalid data, determines the second part.
[0043] The L2P table update method provided in this disclosure significantly optimizes the garbage collection command processing flow by intelligently distinguishing between aligned and unaligned cases, thus maintaining the integrity of stored data. In practical applications, this design significantly reduces write amplification, extends the lifespan of storage media, and ensures the real-time performance and reliability of data operations in high-concurrency write scenarios.
[0044] In one exemplary instance, determining the second part of the command information based on the remainder and the length of invalid data includes: The remainder is converted into an offset relative to the starting address of the physical block according to the layout rules of the physical block number in the physical address; The second part of the command information is determined based on the obtained offset and the length of invalid data.
[0045] For example, in storage devices, physical address layout rules ensure an exact correspondence between logical and physical addresses. When processing garbage collection commands, the remainder (i.e., the result of taking the starting logical block address modulo the logical block size) directly represents the offset within the physical block. Since the physical block size is typically the same as the logical block size (e.g., 4KB), this remainder can be used as the offset relative to the starting address of the physical block without additional conversion. For instance, if the logical block size is 4KB and the starting logical block address is 6KB, the remainder is 2KB, meaning that data starts 2KB off the starting address of the physical block.
[0046] Based on the obtained offset and the length of invalid data, the second part of the command message is precisely determined. Specifically, the length of valid data starting from the offset is limited by the remaining space in the physical block.
[0047] The L2P table update method provided in this disclosure ensures that garbage collection operations can accurately mark invalid data boundaries, avoid data overwriting or omission due to offset mismatch, thereby maintaining the integrity of stored data and optimizing garbage collection efficiency.
[0048] In one exemplary instance, the host command cache includes: at least two host command sub-caches; storing generated command information into the host command cache in the order of receipt includes: The generated command information is stored in one of the host command sub-caches in the order of receipt. When the storage volume in the host command sub-cache reaches a preset threshold, the subsequent command information is stored in another host command sub-cache in the order of receipt.
[0049] For example, the host command cache adopts a multi-sub-cache design, containing at least two independent host command sub-caches to distribute the storage of command information, avoid single point of overload and improve processing efficiency.
[0050] Command information is stored sequentially in the currently active host command sub-cache in the order of receipt. When the storage capacity of the sub-cache reaches a preset threshold (such as capacity limit or data entry limit), it automatically switches to another host command sub-cache, and subsequent command information continues to be stored in the order of receipt to ensure the continuity of the processing flow.
[0051] The L2P table update method provided in this disclosure effectively balances storage load by dynamically switching sub-caches, preventing command processing interruption due to single cache overflow, while maintaining the consistency of command reception order, thus providing a stable and reliable data foundation for subsequent command parsing and L2P table updates.
[0052] In one exemplary instance, updating the L2P table based on the command information and the determined command type includes: If the determined command type is the write command, the second part of the command information is updated to the L2P table using the first part of the command information as the address; wherein, the first part of the command information is determined according to the starting logical block address of the write command, and the second part of the command information is determined according to the physical block address of the write command; If the determined command type is the garbage collection command, the contents of the L2P table are updated to invalid content using the first part and the second part of the command information as addresses; wherein, the first part of the command information is determined according to the starting logical block address of the garbage collection command, and the second part of the command information is determined according to the invalid data length of the garbage collection command.
[0053] For example, when the command type is a write command, the first part of the command information (determined by the starting logical block address of the write command) serves as the index address of the L2P table, and the second part (determined by the physical block address of the write command) serves as the mapping value, which is directly written into the L2P table. This operation establishes a precise mapping from logical address to physical address, ensuring that subsequent data reads and writes can correctly locate the specified physical storage location, thereby completing the data write operation.
[0054] When the command type is a garbage collection command, the first part (determined by the starting logical block address of the garbage collection command) and the second part (determined by the length of invalid data) of the command information work together to update the contents of the corresponding address range in the L2P table to an invalid state. Specifically, the first part specifies the starting logical address, and the second part defines the length range of invalid data. Based on this, the system marks the continuous logical blocks in the L2P table starting from the starting address as invalid, providing accurate invalid data identification for the subsequent garbage collection process and avoiding accidental operations on deleted data.
[0055] This application also provides an L2P table update device, the structure of which is as follows: Figure 3 As shown, the device mainly includes a host command parsing module 21 and a data caching module 22. Through a collaborative working mechanism, this device achieves accurate parsing of host commands, cache management, and orderly updates of the L2P table. The specific process of updating the L2P table based on this device is as follows: 1. The host command parsing module 21 is used to parse commands issued from the host. When the commands issued by the host are write and trim, they are recorded one by one in their original order in the host command cache SRAM inside the module. Each data entry cached in this SRAM is 64 bits, of which the high 32 bits are the host logical address (LBA_4K info) and the low 32 bits are the device physical address (PBA_4K info) or trim length information (trim length info), as shown in Figure 4.
[0056] Once 512 data entries are collected, DMA is initiated to move these 4KB of data to the data cache module in burst mode. The host command cache SRAM is a ping-pong structure with a total depth of 1024. This ensures that while DMA is moving data from the ping SRAM, the pong SRAM can still record write and trim command information sent by the host.
[0057] 2. When the host sends a "write" command, the host command parsing module will send the parsed LBA_4K field to the FTL handle module. The FTL handle module will return a PBA_4K to the host command parsing module, the specific content of which is shown in Table 1. Table 1 This establishes a mapping between the logical address on the host side and the physical address on the device side. When the host sends a command called "trim", the host command parsing module directly caches the LBA_4K and trim length information in the host command SRAM.
[0058] 3. The data caching module 22 updates the L2P Table based on the contents of the host command Table.
[0059] 1) For the host write command, the lower 32 bits corresponding to LBA_4K are PBA_4K. In the PBA_4K field, block num is the actual number of user data blocks. At this time, the data buffer uses LBA_4K as the address and fills PBA_4K into the L2P Table.
[0060] 2) For the host trim command, the lower 32 bits of LBA_4K are the trim length. In this trim length field, block num is the number of the actual user information storage block area. At this time, the data caching module updates the L2P Table content of LBA_4K to LBA_4K+trim length to null.
[0061] In other words, when the data buffer module parses the lower 32 bits of the host command table and finds that block num corresponds to the user data storage block area, these lower 32 bits represent the physical address mapped to the logical address of the host write command. When the data buffer parses the lower 32 bits of the host command cache table and finds that block num corresponds to the user information storage block area, these lower 32 bits represent the trim length corresponding to the logical address of the host trim command. Furthermore, because the host command parsing module records the host write and trim commands in the host command cache ping-pong SRAM according to the order they are issued by the host, it can be ensured that the SSD host trim and write commands are strictly ordered.
[0062] 4. According to the firmware policy, during runtime, the L2P Table is programmed into the user information storage block area in blocks according to the set time intervals; the host command cache Table is programmed into the user information storage block area when it is filled into a program page. In the event of an abnormal power failure, the L2P Table update area and the host command cache Table will be programmed into the user information storage block area with higher priority.
[0063] In a typical storage configuration, each Logical Unit (LUN) is allocated 2224 physical blocks. Blocks numbered 0 to 31 are dedicated to storing user information (including L2P mapping tables, firmware code, bad block management tables, and other metadata), while blocks numbered 32 to 2223 are dedicated to storing user data written by the host. Since the total number of physical blocks in a single LUN is 2224, each physical block number requires a 12-bit binary number for unique identification (2^32 - 12^24). 11 =2048 < 2224 ≤ 4096=2 12 Therefore, in the 4KB page information layout (P4K info layout), such as Figure 4 As shown, the 4KB page information layout includes: physical block number (block num), page number (page num), logical unit number (LUN num), and NAND chip number (CE num). When the physical block number field is designed to be 12 bits, it can correspond to bits [31:19] of the P4K address. Based on the above configuration, this application embodiment also provides some examples of command information storage.
[0064] Example 1: With a host logical block address (LBA) size of 512 bytes, the host issues three commands sequentially: the first is a write command (starting LBA address 0x400, write length 0x8, i.e., 4KB); the second is a garbage collection command (starting LBA address 0xC8, invalid data length 0x10, i.e., 8KB); and the last is a write command (starting LBA address 0x280, write length 0x8, i.e., 4KB). These commands are recorded in the SRAM cache strictly according to the receive timing, and their contents are shown in Table 2.
[0065] Table 2 As shown in Table 2, the first line "0x80, PBA_4K0" corresponds to the first write command, where 0x80 is the quotient (128) of the starting LBA 0x400 (decimal 1024) divided by the preset logical block unit (8 LBAs = 4KB), which identifies the logical block index, and PBA_4K0 represents the physical block address where the new data is written; the second line "0x19, 0x10" is dedicated to the garbage collection command, where 0x19 is calculated by dividing the starting LBA 0xC8 (decimal 200) by 8 (quotient 25), and 0x10 directly records the length of invalid data specified by the host (16 LBAs), which is clearly different from the write command; the third line "0x50, PBA_4K2" corresponds to the last write command, where 0x50 is the quotient (80) of the starting LBA 0x280 (decimal 640) divided by 8, and PBA_4K2 identifies the physical block address it maps to.
[0066] Example 2: With an LBA size of 512 bytes, the host sequentially issues three commands: the first write command (starting LBA=0x400, write length 0x8), the second TRIM command (starting LBA=0xC9, invalid data length 0x10), and the last write command (starting LBA=0x280, write length 0x8). These commands are recorded in the SRAM buffer strictly according to the receive timing, and their contents are shown in Table 3.
[0067] Table 3 As shown in Table 3, the first line "0x80, PBA_4K0" corresponds to the first write command. 0x80 is the quotient value obtained by dividing the starting LBA 0x400 (1024) by 8 (4KB alignment unit), which identifies the logical 4K block index. PBA_4K0 represents the physical block address where the new data is written. The second line "0xC9, 0x10" is dedicated to the TRIM command. The BLOCK NUMBER field directly stores the starting LBA value 0xC9 (decimal 201). Its lower 3 bits "001" implicitly contain the block offset remainder of 1 (201 ÷ 8 = 25 remainder 1), and the higher 5 bits "11001" correspond to the logical block address 25. 0x10 explicitly records the length of data to be marked as invalid (16 LBAs). This design seamlessly embeds the remainder information into the BLOCK NUMBER field, accurately solving the boundary handling problem when the TRIM starting address is not 4KB aligned (0xC9 mod 8 = 1). The third line "0x50, "PBA_4K2" corresponds to the last write command. 0x50 is the quotient (80) of the starting LBA 0x280 (640) divided by 8. PBA_4K2 identifies the physical block address it maps to.
[0068] Example 3: With an LBA size of 512 bytes, the host sequentially issues three commands: the first write command (starting LBA=0x400, write length 0x8), the second garbage collection command (starting LBA=0xCA, invalid data length 0x10), and the last write command (starting LBA=0x280, write length 0x8). These commands are recorded in the SRAM cache strictly according to the receive timing, and their contents are shown in Table 4.
[0069] Table 4 As shown in Table 4, the first row "0x80, PBA_4K0" corresponds to the first write command. The left field 0x80 is the quotient of the starting LBA 0x400 (decimal 1024) divided by 8 (4KB alignment unit), which identifies the logical 4K block index. The right field PBA_4K0 indicates the physical block address where the new data is written. The second row "0x19, 0x2<<19+0x10" is dedicated to garbage collection instructions. The left field 0x19 is the quotient (25) of the starting LBA 0xCA (decimal 202) divided by 8. The right composite parameter "0x2<<19+0x10" shifts the block offset remainder (2, i.e., 202 mod 8 = 2) 19 bits to the left and combines it with the invalid data length 0x10 (16 LBAs) to encode the remainder information accurately embedded in the high bits of the parameter, effectively solving the problem that the garbage collection instruction starting address is not 4KB aligned (0xCA mod 8). =2) boundary handling issues; the third line “0x50, PBA_4K2” corresponds to the last write command, the left field 0x50 is the quotient (80) of the starting LBA0x280 (decimal 640) divided by 8, and the right field PBA_4K2 identifies the physical block address it maps to.
[0070] Example 4: With an LBA size of 512 bytes, the host sequentially issues three commands: a first write command (starting LBA=0x400, write length 0x8, covering 8 consecutive 4KB logical blocks), a second garbage collection command (starting LBA=0xCA, invalid data length 0x10, covering 16 consecutive 4KB logical blocks), and a final write command (starting LBA=0x280, write length 0x8, covering 8 consecutive 4KB logical blocks). These commands are strictly recorded in the SRAM cache according to the receive timing, and their contents are shown in Table 5.
[0071] Table 5 As shown in Table 5, the first row "0x400, PBA_4K0~PBA_4K7" corresponds to the first write command. The left field 0x400 is the starting logical block address, and the right field clearly indicates that the write operation is mapped to physical block addresses PBA_4K0 to PBA_4K7. The second row "0xCA, 0x10" is dedicated to garbage collection instructions. The left field 0xCA is the starting logical block address, and the right field 0x10 directly records the number of logical blocks to be marked as invalid (16). Since the LBA unit itself is 4KB, the starting address naturally meets the 4KB alignment requirement, and there is no need to process the offset remainder within the block. The third row "0x280, PBA_4K8~PBA_4K15" corresponds to the last write command. The left field 0x280 is the starting logical block address, and the right field indicates the range of physical block addresses to which the new data is written.
[0072] The L2P table update method provided in this application has the following characteristics: 1. Leveraging the physical architecture characteristics of SSDs, storage blocks are divided into user information storage blocks (for L2P tables, firmware, and other metadata) and user data storage blocks (for host data). The write commands and garbage collection instructions issued by the host are accurately identified through the physical block number range, achieving efficient distinction between command types. Maintaining only a single host command cache strictly guarantees the timing of receiving and processing both types of commands, fundamentally avoiding the risk of mislabeling valid data due to out-of-order commands.
[0073] 2. For boundary scenarios where the starting logical address of garbage collection instructions is not aligned to 4KB, a remainder embedding encoding strategy is adopted (such as storing the offset remainder within the block in combination with the invalid length) to ensure that instructions with any starting address and length can be accurately parsed, thus completely solving the problem of non-alignment processing.
[0074] 3. Possesses universality and robustness, suitable for all operating scenarios including sequential / random read / write and abnormal power-off recovery; it imposes no constraints on the starting logical address and length of garbage collection instructions; it significantly reduces instruction response latency and improves system real-time performance; simultaneously, the circuit structure is simple, with low hardware resource overhead, making it easy to implement in engineering and mass production. The overall design, while ensuring L2P mapping consistency and data reliability, balances high performance and low cost, providing an efficient and robust L2P table update solution for SSD controllers in high-frequency data update scenarios.
[0075] This application also provides an L2P table update device, such as... Figure 5 As shown, it includes: The receiving and storage module 31 is used to receive commands sent by the host. When the received command is a write command or a garbage collection command, it parses the received command and generates command information based on the parsing result, and stores the generated command information into the host command cache in the order of receipt. The reading and processing module 32 is used to read each command information in the host command cache in the order of receipt, and for the read command information: obtain the corresponding physical block number from the command information, determine the command type of the command corresponding to the command information according to the physical block function allocation information and the obtained physical block number, and update the L2P table according to the command information and the determined command type. The corresponding physical block number refers to the physical block number of the command corresponding to the command information, and the physical block function allocation information is the information on the function allocation of multiple physical blocks corresponding to the logical storage unit in the memory, which is obtained in advance.
[0076] In one exemplary instance, the physical block function allocation information includes: the physical block number range of user information physical blocks and the physical block number range of user data physical blocks among multiple physical blocks corresponding to a unit logical storage unit in the memory; the reading and processing module 32 is further configured to: If the physical block number of the command corresponding to the command information falls within the range of physical block numbers of the user information physical block, then the command corresponding to the command information is determined to be a garbage collection command. If the physical block number of the command corresponding to the command information falls within the range of physical block numbers of the user data physical block, then the command corresponding to the command information is determined to be a write command.
[0077] In one exemplary instance, when the command corresponding to the command information is the garbage collection command, the parsing result includes: the starting logical block address of the received garbage collection command and the length of invalid data; the receiving and storage module 31 is further configured to: The command information is generated based on the starting logical block address and invalid data length of the received garbage collection command.
[0078] In one exemplary instance, when the command corresponding to the command information is the write command, the parsing result includes: the starting logical block address of the received write command and the write data length; the receiving and storage module 31 is further configured to: The mapping relationship between logical block addresses and physical block addresses is used to obtain the physical block address corresponding to the starting logical block address of the received write command; The first part of the command information is determined based on the relationship between the starting logical block address of the received write command and the preset logical block size, and the second part of the command information is determined based on the relationship between the obtained physical block address, the write data length of the received write command, and the preset logical block size, so as to obtain the command information.
[0079] In one exemplary instance, the receiving and storage module 31 is further configured to: Determine whether the starting logical block address of the received garbage collection command is an integer multiple of the host-side logical block size. If the starting logical block address of the received garbage collection command is an integer multiple of the logical block size, the first part of the command information is determined according to the relationship between the starting logical block address of the received garbage collection command and the logical block size, and the invalid data length of the received garbage collection command is used as the second part of the command information to obtain the command information. When the starting logical block address of the received garbage collection command is an integer multiple of the preset logical block size, the quotient and remainder are obtained according to the relationship between the starting logical block address of the received garbage collection command and the logical block size. The quotient is used as the first part of the command information, and the second part of the command information is determined according to the remainder and the length of invalid data, so as to obtain the command information.
[0080] In one exemplary instance, the receiving and storage module 31 is further configured to: The remainder is converted into an offset relative to the starting address of the physical block according to the layout rules of the physical block number in the physical address; The second part of the command information is determined based on the obtained offset and the length of invalid data.
[0081] In one exemplary instance, the host command cache includes at least two host command sub-caches; the receiving and storage module 31 is further configured to: The generated command information is stored in one of the host command sub-caches in the order of receipt. When the storage volume in the host command sub-cache reaches a preset threshold, the subsequent command information is stored in another host command sub-cache in the order of receipt.
[0082] In one exemplary instance, the reading and processing module 32 is further configured to: If the determined command type is the write command, the second part of the command information is updated to the L2P table using the first part of the command information as the address; wherein, the first part of the command information is determined according to the starting logical block address of the write command, and the second part of the command information is determined according to the physical block address of the write command; If the determined command type is the garbage collection command, the contents of the L2P table are updated to invalid content using the first part and the second part of the command information as addresses; wherein, the first part of the command information is determined according to the starting logical block address of the garbage collection command, and the second part of the command information is determined according to the invalid data length of the garbage collection command.
[0083] The L2P table updating device provided in this application generates command information for received write commands and garbage collection commands and stores it in the host command cache according to the receiving order. It then reads each command information from the host command cache sequentially according to the receiving order, and for each read command information: obtains the corresponding physical block number from the command information, determines the command type of the command corresponding to the command information based on the physical block function allocation information and the obtained physical block number, and updates the L2P table according to the command information and the determined command type. Therefore, it can store the command information for write commands and garbage collection commands together sequentially according to the receiving order and effectively distinguish between the two, thereby significantly reducing the resource overhead required for command information storage, avoiding disorder in the L2P table mapping relationship, and greatly improving data reliability.
[0084] This application also provides an SSD controller, such as... Figure 6 As shown, it includes: memory 400 and processor 410; The memory 400 is connected to the processor 410 and is used to store programs; The processor 410 is used to implement the L2P table update method described in any of the above embodiments by running the program in the memory 400.
[0085] Specifically, the aforementioned electronic device may also include: a bus, a communication interface 420, an input device 430, and an output device 440.
[0086] The processor 410, memory 400, communication interface 420, input device 430, and output device 430 are interconnected via a bus. Among them: A bus can include a pathway for transmitting information between various components of a computer system.
[0087] The processor 410 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0088] Processor 410 may include a main processor, as well as a baseband chip, modem, etc.
[0089] The memory 400 stores a program that executes the technical solution of this invention, and may also store an operating system and other key business functions. Specifically, the program may include program code, which includes computer operation instructions. More specifically, the memory 400 may include read-only memory (ROM), other types of static storage devices capable of storing static information and instructions, random access memory (RAM), other types of dynamic storage devices capable of storing information and instructions, disk storage, Flash memory, etc.
[0090] Input device 430 may include a device for receiving user input data and information, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor.
[0091] Output device 430 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0092] The communication interface 420 may include a device that uses any transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0093] The processor 410 executes the program stored in the memory 400 and calls other devices, which can be used to implement the various steps of any of the L2P table update methods provided in the above embodiments of this application.
[0094] In addition to the methods and devices described above, embodiments of this application may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the L2P table update methods according to various embodiments of this application as described in any of the above embodiments of this specification.
[0095] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this application. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0096] Furthermore, this application embodiment also provides a storage medium storing a computer program, which, when executed by a processor, implements the L2P table update method described in any of the above embodiments.
[0097] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term "computer storage medium" includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
Claims
1. A method for updating an L2P table, characterized in that, include: Receive commands from the host. If the received command is a write command or a garbage collection command, parse the received command and generate command information based on the parsing result. Then, store the generated command information in the host command cache in the order of receipt. According to the receiving order, each command information in the host command cache is read sequentially, and for each read command information: the corresponding physical block number is obtained from the command information, the command type of the command corresponding to the command information is determined according to the physical block function allocation information and the obtained physical block number, and the L2P table is updated according to the command information and the determined command type. The corresponding physical block number refers to the physical block number of the command corresponding to the command information, and the physical block function allocation information is the information on the function allocation of multiple physical blocks corresponding to the logical storage unit in the memory, which is obtained in advance.
2. The method according to claim 1, characterized in that, The physical block function allocation information includes: the range of physical block numbers for user information physical blocks and user data physical blocks among the multiple physical blocks corresponding to a unit of logical storage unit in the memory; The command type corresponding to the command information is determined based on the physical block function allocation information and the obtained physical block number, including: If the physical block number of the command corresponding to the command information falls within the range of physical block numbers of the user information physical block, then the command corresponding to the command information is determined to be a garbage collection command. If the physical block number of the command corresponding to the command information falls within the range of physical block numbers of the user data physical block, then the command corresponding to the command information is determined to be a write command.
3. The method according to claim 1, characterized in that, When the command corresponding to the command information is the garbage collection command, the parsing result includes: the starting logical block address and invalid data length of the received garbage collection command; Parse the received command and generate command information based on the parsing result, including: The command information is generated based on the starting logical block address and invalid data length of the received garbage collection command.
4. The method according to claim 1, characterized in that, When the command corresponding to the command information is the write command, the parsing result includes: the starting logical block address and the write data length of the received write command; Parse the received command and generate command information based on the parsing result, including: The mapping relationship between logical block addresses and physical block addresses is used to obtain the physical block address corresponding to the starting logical block address of the received write command; The first part of the command information is determined based on the relationship between the starting logical block address of the received write command and the preset logical block size, and the second part of the command information is determined based on the relationship between the obtained physical block address, the write data length of the received write command, and the preset logical block size, so as to obtain the command information.
5. The method according to claim 3, characterized in that, The command information is generated based on the starting logical block address and invalid data length of the received garbage collection command, including: Determine whether the starting logical block address of the received garbage collection command is an integer multiple of the host-side logical block size. If the starting logical block address of the received garbage collection command is an integer multiple of the logical block size, the first part of the command information is determined according to the relationship between the starting logical block address of the received garbage collection command and the logical block size, and the invalid data length of the received garbage collection command is used as the second part of the command information to obtain the command information. When the starting logical block address of the received garbage collection command is an integer multiple of the preset logical block size, the quotient and remainder are obtained according to the relationship between the starting logical block address of the received garbage collection command and the logical block size. The quotient is used as the first part of the command information, and the second part of the command information is determined according to the remainder and the length of invalid data, so as to obtain the command information.
6. The method according to claim 5, characterized in that, The second part of the command information is determined based on the remainder and the length of invalid data, including: The remainder is converted into an offset relative to the starting address of the physical block according to the layout rules of the physical block number in the physical address; The second part of the command information is determined based on the obtained offset and the length of invalid data.
7. The method according to claim 1, characterized in that, The host command cache includes: at least two host command sub-caches; and storing generated command information into the host command cache in the order of receipt, including: The generated command information is stored in one of the host command sub-caches in the order of receipt. When the storage volume in the host command sub-cache reaches a preset threshold, the subsequent command information is stored in another host command sub-cache in the order of receipt.
8. The method according to claim 1, characterized in that, Update the L2P table based on the command information and the determined command type, including: If the determined command type is the write command, the second part of the command information is updated to the L2P table using the first part of the command information as the address; wherein, the first part of the command information is determined according to the starting logical block address of the write command, and the second part of the command information is determined according to the physical block address of the write command; If the determined command type is the garbage collection command, the contents of the L2P table are updated to invalid content using the first part and the second part of the command information as addresses; wherein, the first part of the command information is determined according to the starting logical block address of the garbage collection command, and the second part of the command information is determined according to the invalid data length of the garbage collection command.
9. An SSD controller, characterized in that, Including memory and processor; The memory is used to store executable programs; The processor is used to read and execute the executable program to perform the L2P table update method as described in any one of claims 1-8.
10. A storage medium, characterized in that, The storage medium contains a computer program, which, when executed by a processor, can implement the method for updating the L2P table as described in any one of claims 1-8.