Cache unit management method and storage device

Through a cache unit management method, the problem of limited resources of cache unit and detection of storage command processing completion message errors in high-performance storage devices is solved, which improves cache utilization and ensures correct storage command processing.

CN119718727APending Publication Date: 2025-03-28BEIJING STARBLAZE TECH CO LTD

Patent Information

Application Number
CN202311255502.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-26
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In high-performance storage devices, when the cache unit is used to store address positioning information indicated by IO commands (such as PRP entries or SGL descriptors), the resource is limited, and it is difficult to release the cache unit in time to cache address positioning information of subsequent IO commands, resulting in low cache utilization. At the same time, there is a problem of detecting whether there is an error in the storage command processing completion message.

Method used

By a cache unit management method, in response to receiving an NVMe read command, the indicated address positioning information is added to the allocated cache unit, and the number of times the storage command processing completion message is recorded. Determine whether to release the cache unit based on the expected number of usages and the actual number of usages, and detect whether there is an error in the storage command processing completion message.

Benefits of technology

The utilization rate of the cache unit is improved, ensuring that the cache unit can timely release the address positioning information of subsequent IO commands, and at the same time, it can effectively detect and process errors in the storage command processing completion message.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718727A_ABST
    Figure CN119718727A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a cache unit management method and storage equipment, and relates to the technical field of storage. The method comprises the following steps: in response to a received NVMe read command, adding first address positioning information indicated by the NVMe read command to an allocated cache unit, and recording a first frequency of a storage command processing completion message corresponding to the received first address positioning information; responding to the received storage command processing completion message, according to the expected number of times that the second address positioning information is used indicated by the storage command processing completion message and the recorded second number of times that the storage command processing completion message corresponding to the received second address positioning information is received; and determining whether a cache unit occupied by the second address positioning information is released or not and determining whether an erroneous storage command processing completion message exists or not. According to the method, the cache unit occupied by the address positioning information can be released in time, and meanwhile, whether a wrong storage command processing completion message exists or not is detected in the process of releasing the cache unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage technology, and in particular to a cache unit management method and a storage device. Background Art

[0002] Figure 1A The block diagram of the solid-state storage device is shown. The solid-state storage device 102 is coupled to the host to provide storage capacity for the host. The host and the solid-state storage device 102 can be coupled in a variety of ways, including but not limited to connecting the host and the solid-state storage device 102 through, for example, SATA (Serial Advanced Technology Attachment), SCSI (Small Computer System Interface), SAS (Serial Attached SCSI), IDE (Integrated Drive Electronics), USB (Universal Serial Bus), PCIE (Peripheral Component Interconnect Express, PCIe), NVMe (NVM Express), Ethernet, Fiber Channel, wireless communication network, etc. The host can be an information processing device that can communicate with the storage device in the above manner, such as a personal computer, a tablet computer, a server, a portable computer, a network switch, a router, a cellular phone, a personal digital assistant, etc. The storage device 102 (hereinafter, the solid-state storage device is referred to as the storage device for short) includes an interface 103 , a control component 104 , one or more NVM chips 105 , and a DRAM (Dynamic Random Access Memory) 110 .

[0003] The above-mentioned NVM chip 105 includes NAND flash memory, phase change memory, FeRAM (Ferroelectric RAM), MRAM (Magnetic Random Access Memory), RRAM (Resistive Random Access Memory), etc., which are common storage media.

[0004] The above-mentioned interface 103 can be adapted to exchange data with the host through, for example, SATA, IDE, USB, PCIE, NVMe, SAS, Ethernet, Fibre Channel, etc.

[0005] The control component 104 is used to control data transmission between the interface 103, the NVM chip 105 and the DRAM 110, and is also used for storage management, mapping of host logical addresses to flash physical addresses, erase leveling, bad block management, etc. The control component 104 can be implemented in a variety of ways, such as software, hardware, firmware or a combination thereof. For example, the control component 104 can be in the form of an FPGA (Field-programmable gate array), an ASIC (Application Specific Integrated Circuit) or a combination thereof. The control component 104 can also include a processor or a controller, in which software is executed to manipulate the hardware of the control component 104 to process IO (Input / Output) commands. The control component 104 can also be coupled to the DRAM 110 and can access the data of the DRAM 110. The data of the FTL table and / or cached IO commands can be stored in the DRAM.

[0006] The control part 104 issues a command to the NVM chip 105 in a manner complying with the interface protocol of the NVM chip 105 to operate the NVM chip 105, and receives a command execution result output from the NVM chip 105. Known NVM chip interface protocols include "Toggle", "ONFI" and the like.

[0007] A memory target is one or more logical units (LUNs) within a NAND flash package that share a CE (Chip Enable) signal. A NAND flash package may include one or more dies. Typically, a logical unit corresponds to a single die. A logical unit may include multiple planes. Multiple planes within a logical unit can be accessed in parallel, and multiple logical units within a NAND flash chip can execute commands and report status independently of each other. Data is usually stored and read on a storage medium in pages. Data is erased in blocks. A block (also called a physical block) contains multiple pages. A block contains multiple pages. A page on a storage medium (called a physical page) has a fixed size, such as 17664 bytes. A physical page can also have other sizes.

[0008] In the storage device 102, FTL (Flash Translation Layer) is used to maintain the mapping information from the logical address (LBA) to the physical address. The logical address constitutes the storage space of the solid-state storage device perceived by the upper-layer software such as the operating system. The physical address is the address used to access the physical storage unit of the solid-state storage device. In the related art, the address mapping can also be implemented using the intermediate address form. For example, the logical address is mapped to the intermediate address, and then the intermediate address is further mapped to the physical address. The table structure that stores the mapping information from the logical address to the physical address is called the FTL table. The FTL table is an important metadata in the storage device. The data items of the FTL table record the address mapping relationship in the storage device in units of data units.

[0009] The host accesses the storage device with IO commands that follow the storage protocol. The control component generates one or more media interface commands based on the IO commands from the host and provides them to the media interface controller. The media interface controller generates storage media access commands (e.g., programming commands, read commands, and erase commands) that follow the interface protocol of the NVM chip based on the media interface commands. The control component also tracks that all media interface commands generated from an IO command have been executed and indicates the processing results of the IO command to the host.

[0010] See also Figure 1B The control component includes a host interface 1041, a host command processing unit 1042, a storage command processing unit 1043, a medium interface controller 1044 and a storage medium management unit 1045. The host interface 1041 obtains the IO command provided by the host. The host command processing unit 1042 generates a storage command according to the IO command and provides it to the storage command processing unit 1043. The storage command can access the storage space of the same size, such as 4KB. The data unit corresponding to the data accessed by a storage command recorded in the NVM chip is called a data frame. The physical page records one or more data frames. For example, the size of the physical page is 17664 bytes, and the size of the data frame is 4KB, then one physical page can store 4 data frames.

[0011] The storage medium management unit 1045 maintains the conversion of the logical address to the physical address for each storage command. For example, the storage medium management unit 1045 includes an FTL table (the FTL will be explained below). For a read command, the storage medium management unit 1045 outputs the physical address corresponding to the logical address (LBA) accessed by the storage command. For a write command, the storage medium management unit 1045 allocates an available physical address for it and records the mapping relationship between the logical address (LBA) accessed by it and the allocated physical address. The storage medium management unit 1045 also maintains functions required for managing the NVM chip such as garbage collection and wear leveling.

[0012] The storage command processing unit 1043 operates the medium interface controller 1044 to issue a storage medium access command to the NVM chip 105 according to the physical address provided by the storage medium management unit 1045 .

[0013] For the purpose of clarity, the command sent by the host to the storage device 102 is called an IO command (including, for example, an NVMe read command and an NVMe write command), the command sent by the host command processing unit 1042 to the storage command processing unit 1043 is called a storage command, the command sent by the storage command processing unit 1043 to the medium interface controller 1044 is called a medium interface command, and the command sent by the medium interface controller 1044 to the NVM chip 105 is called a storage medium access command. The storage medium access command complies with the interface protocol of the NVM chip.

[0014] In the NVMe protocol, NVMe has two commands, one is the admin command, which is used by the host to manage and control the storage device, and the other is the IO command, including the NVMe write command and the NVMe read command, which is used to control the data transmission between the host and the storage device. After receiving the NVMe write command, the solid-state storage device 102 obtains the data from the host's memory through the host interface 1041, and then writes the data into the flash memory. For the NVMe read command, when the data is read from the flash memory, the solid-state storage device 102 moves the data to the host memory through the host interface 1041. PRP (Physical Region Page) and SGL (Scatter / Gather List) are two ways to describe the data to be transmitted between the host and the storage device. In the PRP method, several linked PRP entries are used, and each PRP entry includes a 64-bit memory physical address, which is used to describe a physical page (Page) of the host memory. SGL is a linked list consisting of one or more SGL segments, each of which consists of one or more SGL descriptors; each SGL descriptor describes the address and length of the data cache in the host memory, that is, each SGL descriptor corresponds to a host memory address space; each SGL descriptor has, for example, a fixed size (e.g., 16 bytes).

[0015] There are fields related to SGL or PRP in the NVMe write command and NVMe read command, which indicate the location of the data in the host memory (for write commands) or the host memory address to be written (for read commands). The PRP field or SGL field in the NVMe write command and NVMe read command can be an SGL or PRP entry pointing to the host memory address space to be accessed, or a pointer to an SGL or PRP linked list, or even a pointer to a pointer. If the NVMe write command and NVMe read command carry SGL or PRP, the storage device can directly obtain the SGL or PRP in response to receiving the IO command. If the NVMe write command and NVMe read command carry an SGL or PRP pointer, in response to receiving the IO command, the storage device accesses the host according to the above-mentioned SGL or PRP pointer and obtains the SGL or PRP from the host. A host command processing unit for processing NVMe read commands is provided in Chinese Patent 202110746144.1, and a host command processing unit for processing NVMe write commands is provided in Chinese Patent 202110746142.2, which describe a process in which a storage device obtains a PRP entry or an SGL descriptor from an NVMe write command or an NVMe read command.

[0016] In high-performance storage devices, the control component may process hundreds or even thousands of IO commands (including NVMe read commands and NVMe write commands) per second, and each IO command carries a PRP field or an SGL field. However, the resources of the cache unit that stores the PRP field or the SGL field are limited. In order to enable the cache unit to cache the PRP or SGL sent by the host to the storage device, the resources of the cache unit need to be managed. Summary of the invention

[0017] In view of this, an embodiment of the present application provides a cache unit management method and a storage device, which can promptly release the cache unit occupied by the address location information indicated by the IO command (for example, a PRP entry, an SGL descriptor, or based on the PRP entry or the SGL descriptor), so that the cache unit has sufficient space to cache the address location information indicated by subsequent IO commands, thereby improving the cache unit utilization rate, and at the same time being able to detect whether there is an erroneous storage command processing completion message, thereby determining whether the received NVMe read command is correctly processed.

[0018] According to a first aspect of the present application, a cache unit management method is provided, comprising: in response to receiving an NVMe read command, adding each first address location information indicated by the NVMe read command to an allocated cache unit and recording a first number of storage command processing completion messages corresponding to each first address location information received;

[0019] In response to receiving a storage command processing completion message, it is determined whether to release the cache unit occupied by the second address location information and whether there is an erroneous storage command processing completion message based on the expected number of times the second address location information indicated by the storage command processing completion message is used and the second number of times the storage command processing completion message corresponding to the second address location information has been recorded and received.

[0020] In an optional embodiment, if the expected number of times the second address location information is used is equal to the sum of the value of the second number and 1, the cache unit occupied by the second address location information is released; if the expected number of times the second address location information is used is greater than the sum of the value of the second number and 1, the cache unit occupied by the second address location information is not released, and the value of the second number is controlled to increase by 1; if the expected number of times the second address location information is used is less than the sum of the value of the second number and 1, it is determined that there is an erroneous storage command processing completion message.

[0021] In an optional embodiment, the method further includes: when the expected number of times each first address location information indicated by the NVMe read command is used is not greater than 2, using a 1-bit memory to record the first number of storage command processing completion messages corresponding to a first address location information that has been received.

[0022] In an optional embodiment, if the expected number of times the second address location information is used is equal to the sum of the value of the second number and 1, releasing the cache unit occupied by the second address location information, including: if the expected number of times the second address location information is used is 1, the value of the second number is 0, and releasing the cache unit occupied by the second address location information.

[0023] In an optional embodiment, if the expected number of times the second address location information is used is equal to the sum of the value of the second number and 1, releasing the cache unit occupied by the second address location information, including: if the expected number of times the second address location information is used is 2, the value of the second number is 1, and releasing the cache unit occupied by the second address location information.

[0024] In an optional embodiment, if the expected number of times the second address location information is used is less than the sum of the value of the second number and 1, the cache unit occupied by the second address location information will not be released, including: if the expected number of times the second address location information is used is 2, the value of the second number is 0, and the cache unit occupied by the second address location information will not be released.

[0025] In an optional embodiment, when the cache unit occupied by the second address location information is released, the method further includes: clearing the second number corresponding to the second address location information recorded in the memory.

[0026] In an optional embodiment, the method further includes: determining whether there is an error in the storage command processing completion message corresponding to the received NVMe read command based on a first number of storage command processing completion messages expected to be received by the NVMe read command and a second number of second storage command processing completion messages corresponding to the NVMe read command that have been received.

[0027] In an optional embodiment, if the second number is greater than the first number, it is determined that there is an error in the storage command processing completion message corresponding to the received NVMe read command.

[0028] In an optional embodiment, if the first number is equal to the second number, it is determined whether there is an error in the storage command processing completion message corresponding to the received NVMe read command based on the first logical address corresponding to the expected storage command processing completion message of the first address location information and the second logical address corresponding to the received storage command processing completion message indicating the first address location information.

[0029] In an optional embodiment, if there is at least one first logical address corresponding to the first address location information that is different from the second logical address, it is determined that there is an error in the storage command processing completion message corresponding to the received NVMe read command.

[0030] In an optional embodiment, the method also includes: if the first delay time corresponding to the NVMe read command is greater than or equal to a specified value, and the cache unit occupied by the first address location information corresponding to the NVMe read command has not been fully released, determining that there is an erroneous storage command processing completion message.

[0031] In an optional embodiment, the method further includes: recording a first timestamp of receiving the NVMe read command, calculating a first difference between the current time and the first timestamp, and using the first difference as a first delay time corresponding to the NVMe read command.

[0032] In an optional embodiment, the method further includes: in response to receiving multiple storage command processing completion messages, recording in sequence the second timestamp of each storage command processing completion message received, and calculating a second difference between the current time and the second timestamp corresponding to each storage command processing completion message, and determining the processing order of the multiple storage command processing completion messages based on the second difference.

[0033] In an optional embodiment, determining the processing order of the multiple storage command processing completion messages according to the second difference value includes: processing the multiple received storage command processing completion messages in sequence according to the second difference value from large to small.

[0034] In an optional embodiment, the method further includes: in response to processing a first storage command processing completion message, generating a DMA command according to the first storage command processing completion message, and moving data from the storage device cache to the host according to the DMA command.

[0035] In an optional embodiment, the method further includes: in response to a second difference corresponding to the second storage command processing completion message being greater than a preset threshold, saving information of the second storage command corresponding to the second storage command processing completion message into metadata of the storage device.

[0036] In an optional embodiment, the method further includes: in response to receiving a custom command sent by the host that satisfies the NVMe protocol, reading information of a second storage command saved in the metadata of the storage device according to a logical address indicated by the custom command.

[0037] According to a second aspect of the present application, a storage device is provided, the storage device comprising a host command processing unit, the host command processing unit comprising a cache unit, a circuit for writing to the cache unit, and a circuit for releasing the cache unit, the circuit for releasing the cache unit comprising a first memory:

[0038] The circuit of the write cache unit is used to add each first address location information indicated by the NVMe read command to the allocated cache unit in response to receiving the NVMe read command;

[0039] The first memory is used to record the first number of storage command processing completion messages corresponding to each of the first address location information that has been received;

[0040] The circuit for releasing the cache unit is used to determine whether to release the cache unit occupied by the second address location information and determine whether there is an erroneous storage command processing completion message based on the expected number of times the second address location information indicated by the storage command processing completion message is used and the second number of times the storage command processing completion message corresponding to the second address location information has been received.

[0041] In an optional embodiment, the circuit for releasing the cache unit is used to: if the expected number of times the second address location information is used is equal to the sum of the value of the first memory corresponding to the second address location information and 1, release the cache unit occupied by the second address location information; if the expected number of times the second address location information is used is greater than the sum of the value of the first memory corresponding to the second address location information and 1, do not release the cache unit occupied by the second address location information; if the expected number of times the second address location information is used is less than the sum of the value of the first memory corresponding to the second address location information and 1, determine that there is an erroneous storage command processing completion message.

[0042] In an optional embodiment, when the expected number of times each first address location information indicated by the NVMe read command is used is no more than 2, the first memory is a 1-bit memory.

[0043] In an optional embodiment, the circuit for releasing the cache unit is further used to: if the expected number of times the second address location information is used is 1, the value of the second number is 0, and release the cache unit occupied by the second address location information.

[0044] In an optional embodiment, the circuit for releasing the cache unit is further used to: if the expected number of times the second address location information is used is 2, and the value of the second number is 1, release the cache unit occupied by the second address location information.

[0045] In an optional embodiment, the circuit for releasing the cache unit is further used for: if the expected number of times the second address location information is used is 2, the value of the second number is 0, and the cache unit occupied by the second address location information is not released.

[0046] In an optional embodiment, when the cache unit occupied by the second address location information is released, the host command processing unit clears the second number corresponding to the second address location information recorded in the memory.

[0047] In an optional embodiment, the host command processing unit is also used to determine whether there is an error in the storage command processing completion message corresponding to the received NVMe read command based on a first number of storage command processing completion messages expected to be received by the NVMe read command and a second number of second storage command processing completion messages corresponding to the NVMe read command that have been received.

[0048] In an optional embodiment, the host command processing unit also includes: a second memory, recording a first number of storage command processing completion messages expected to be received by the NVMe read command; and a third memory, recording a second number of second storage command processing completion messages corresponding to the NVMe read command that have been received.

[0049] In an optional embodiment, the host command processing unit is also used to: if the second number is greater than the first number, determine that there is an error in the storage command processing completion message corresponding to the received NVMe read command.

[0050] In an optional embodiment, the host command processing unit is also used to, if the first number is equal to the second number, determine whether there is an error in the storage command processing completion message corresponding to the received NVMe read command based on the first logical address corresponding to the storage command processing completion message for each first address location information and the second logical address corresponding to the received storage command processing completion message indicating the each first address location information.

[0051] In an optional embodiment, the host command processing unit is also used to determine that there is an error in the storage command processing completion message corresponding to the received NVMe read command if there is a first logical address corresponding to at least one of the first address location information that is different from the second logical address.

[0052] In an optional embodiment, the host command processing unit is also used to determine that there is an erroneous storage command processing completion message if the first delay time corresponding to the NVMe read command is greater than or equal to a specified value, and the cache unit occupied by the first address location information corresponding to the NVMe read command has not been fully released.

[0053] In an optional embodiment, the host command processing unit also includes a read initiation circuit, and the read initiation circuit includes an information cache: the information cache records a first timestamp of receiving the NVMe read command; the host command processing unit is also used to calculate a first difference between the current time and the first timestamp, and the first difference is used as a first delay time corresponding to the NVMe read command.

[0054] In an optional embodiment, the host command processing unit, in response to receiving multiple storage command processing completion messages, sequentially records the second timestamp of each storage command processing completion message, and calculates a second difference between the current time and the second timestamp corresponding to each storage command processing completion message, and determines the processing order of the multiple storage command processing completion messages according to the second difference.

[0055] In an optional embodiment, the host command processing unit processes the received multiple storage command processing completion messages in sequence according to the second difference value from large to small.

[0056] In an optional embodiment, the host command processing unit is further used to: in response to processing a first storage command processing completion message, generate a DMA command according to the first storage command processing completion message, and move data from the storage device cache to the host according to the DMA command.

[0057] In an optional embodiment, the host command processing unit is also used to: in response to a second difference corresponding to the second storage command processing completion message being greater than a preset threshold, save information of the second storage command corresponding to the second storage command processing completion message into the metadata of the storage device.

[0058] In an optional embodiment, the host command processing unit is also used to: in response to receiving a custom command sent by the host that satisfies the NVMe protocol, read information of a second storage command saved in the metadata of the storage device according to the logical address indicated by the custom command. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0060] Figure 1A shows a block diagram of a solid-state storage device;

[0061] Figure 1B A block diagram showing control components in a solid-state storage device;

[0062] Figure 2 A schematic diagram showing the structure of a host command processing unit according to an embodiment of the present application is shown;

[0063] Figure 3 A schematic diagram showing the structure of a host command processing unit according to another embodiment of the present application is shown;

[0064] Figure 4 A schematic diagram showing the organization of data of a storage device on a physical page of an NVM chip according to an embodiment of the present application;

[0065] Figure 5 A schematic diagram showing a physical page of a storage device according to another embodiment of the present application is shown;

[0066] Figure 6A schematic diagram showing the transfer of data from a storage device to a host according to an embodiment of the present application is shown;

[0067] Fig. 7A A schematic diagram showing data to be moved indicated by an NVMe read command according to an embodiment of the present application is shown;

[0068] Figure 7B A schematic diagram showing a host memory address indicated by an NVMe read command according to an embodiment of the present application is shown;

[0069] Figure 7C A schematic diagram showing the storage of data indicated by an NVMe read command in a host memory according to an embodiment of the present application;

[0070] Figure 8 A schematic diagram showing a circuit for releasing a cache unit according to an embodiment of the present application is shown;

[0071] Fig. 9 A schematic diagram showing a circuit for releasing a cache unit according to another embodiment of the present application is shown;

[0072] Fig. 10A A schematic diagram showing a host memory address indicated by an NVMe read command according to an embodiment of the present application is shown;

[0073] Fig. 10B A schematic diagram showing the storage of data indicated by an NVMe read command in a host memory according to an embodiment of the present application;

[0074] Fig.11 A schematic diagram showing a flow chart of a cache unit management method of a storage device according to an embodiment of the present application;

[0075] Fig.12 A schematic diagram of a circuit for releasing a cache unit provided in an embodiment of the present application is shown;

[0076] Fig.13 A schematic diagram of another circuit for releasing a cache unit provided in an embodiment of the present application is shown;

[0077] Fig.14 A schematic flow chart of a cache unit management method of a storage device according to another embodiment of the present application is shown. DETAILED DESCRIPTION

[0078] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0079] For ease of understanding, the following briefly describes how the host and storage device move data through PRP entries or SGL descriptors.

[0080] If data is moved from the storage device to the host, the host sends an NVMe read command to the storage device. The NVMe read command sent by the host to the storage device indicates the address of the host memory to be written, and also includes the starting logical address (LBA) of the storage device to be accessed and the data length. The storage device searches the FTL table based on the LBA, finds the corresponding physical address, and obtains the data from the physical block corresponding to the physical address. The address indicated by the NVMe read command to write data to the host memory can be indicated by a PRP entry or an SGL descriptor. The NVMe read command indicates one or more RPR entries or SGL descriptors.

[0081] If data is moved from the host to the storage device, the host sends an NVMe write command to the storage device. The NVMe write command sent by the host to the storage device indicates the length of the data to be written and the location where the data to be written is stored in the host memory. The location where the data to be written is stored in the host memory can be indicated by a PRP entry or an SGL descriptor. The NVMe write command can indicate one or more RPR entries or SGL descriptors. The storage location of the data to be written in the storage device is allocated by the storage device.

[0082] The host carries a PRP or SGL related field in the NVMe read command or NVMe write command, which can be the SGL or PRP itself, pointing to the host memory address space to be accessed, or a pointer, pointing to the SGL or PRP linked list, or even a pointer to a pointer. Whether it is a PRP entry or an SGL descriptor, it essentially describes one or more address spaces in the host memory, and the location of these address spaces in the host memory is arbitrary. The PRP entry indicates a fixed-size storage space in the host memory, that is, the storage space size indicated by different PRP entries is the same, such as 4KB, 16KB, etc. The SGL descriptor indicates a storage space of indefinite size in the host memory. For example, the NVMe read command indicates three SGL descriptors (SGL1, SGL2, and SGL3), where SGL1 indicates a 4KB storage space, SGL2 indicates a 2KB storage space, and SGL3 indicates a 3KB storage space.

[0083] Regardless of the form, according to the NVMe read command or the NVMe write command, the storage device can always obtain the corresponding SGL descriptor or PRP entry. It can be understood that the embodiments of the present application are not limited to transmitting data between the host and the storage device through PRP entries or SGL descriptors, but can also transmit data through other information with similar functions. In some cases, they are collectively referred to as address location information indicated by IO commands.

[0084] In response to receiving an NVMe read command or an NVMe write command (collectively referred to as an IO command), the storage device first obtains the PRP or SGL according to the IO command before accessing the data. For example, all PRP entries or SGL descriptors corresponding to the IO command are obtained. Since there can be multiple PRP entries or SGL descriptors corresponding to the IO command, the movement of the data described by each PRP entry or SGL descriptor (movement between the host and the storage device) is independent of each other and performed in parallel. Therefore, the movement of the data described by each PRP entry or SGL descriptor is usually not completed at the same time. For this reason, the control component of the storage device provides a cache, in particular, a cache unit located inside the control component to temporarily record the PRP entry or SGL descriptor corresponding to the IO command. However, the cache unit inside the control component is extremely limited and valuable, and it is necessary to release the PRP entry or SGL descriptor corresponding to the IO command in the cache unit as soon as possible to provide caching capacity for the PRP entries or SGL descriptors of other IO commands.

[0085] Taking the storage device processing NVMe write commands and the NVMe write commands using PRP to describe the host memory address as an example, the process of the storage device processing NVMe write commands is explained. Figure 2 FIG. 2 shows a schematic diagram of the structure of a host command processing unit according to an embodiment of the present application. Figure 2 As shown, the host command processing unit includes a PRP circuit, a write initiation circuit, a DMA transmission circuit and a cache unit. Among them, the write initiation circuit includes a DMA command generation circuit and a storage command generation circuit. Figure 2 An example of a write initiation circuit is schematically shown. Other forms of write initiation circuits can refer to Chinese Patent 202310788448.3, which will not be described in detail in this application.

[0086] The process of the host command processing unit processing the NVMe write command includes:

[0087] The PRP circuit responds to receiving an NVMe write command (such as Figure 2 In process (1), a PRP entry is obtained from an NVMe write command, the PRP entry is cached in a cache unit, and a PRP index indicating the PRP entry is provided to a DMA command generation circuit (such as a DMA command generation circuit) of a write initiation circuit. Figure 2 Process (2)). Among them, obtaining the PRP entry from the NVMe write command and obtaining the PRP index belongs to the prior art (such as the PRP unit shown in Chinese patent 202110746142.2), which will not be repeated here.

[0088] The PRP index has various forms, for example, the PRP index carries the host memory address indicated in the PRP entry, or the PRP index carries a pointer to a cache unit, the cache unit stores the PRP entry, and the PRP entry is obtained from the cache unit through the PRP index to obtain the host memory address. Still optionally, the PRP index corresponds to the PRP entry one-to-one.

[0089] In response to receiving the PRP index, the DMA command generation circuit generates a DMA command based on the PRP index and provides the generated DMA command to the DMA transmission circuit (eg, Figure 2 process (3)).

[0090] The DMA command is used to control the DMA transfer circuit to perform data transfer. It indicates the mapping relationship between the host memory address space and the storage device cache address space (such as DRAM address) and is used to perform a data movement operation between the host and the storage device. The host memory address indicated by the DMA command is determined according to the address space indicated by the PRP, and the storage device cache address is allocated by the storage device.

[0091] For NVMe write commands, the host memory address is the source address and the storage device cache address is the destination address. Generating a DMA command requires the host memory address as the source address and the storage device cache address as the destination address. The DMA command generation circuit obtains the host memory address based on the PRP index and allocates storage space from the storage device cache to obtain the storage device cache address.

[0092] The DMA transmission circuit responds to the received DMA command, moves data between the host memory and the storage device cache according to the DMA command, and after the data move is completed, provides a message indicating that the DMA command processing is completed to the storage command generation circuit (such as Figure 2 process (4)).

[0093] The storage command generation circuit generates a storage command in response to receiving a DMA command processing completion message sent by the DMA transmission circuit, and sends the storage command to the storage command processing unit (such as Figure 2 As an example, the storage command causes the storage command processing unit to move the data in the storage device cache to the NVM chip of the storage device according to the storage command. The storage command processing unit and the storage command are both prior art and will not be described in detail here.

[0094] By the above Figure 2 It can be seen from the processes (1)-(5) shown that the PRP entry indicated by the NVMe write command is mainly used to generate a DMA command. Once a DMA command is generated based on a PRP entry indicated by the NVMe write command, the PRP entry in the cache unit can be released.

[0095] Therefore, the host command processing unit of the storage device receives the NVMe write command, allocates a cache unit for the address location information indicated by the NVMe write command, generates a DMA command according to the address location information indicated by the NVMe write command, and releases the cache unit occupied by the address location information indicated by the NVMe write command corresponding to the DMA command in response to the generation of the DMA command. Figure 2 In the write initiation circuit shown, the function of releasing the cache unit can be implemented by a DMA command generation circuit, that is, the DMA command generation circuit releases the cache unit occupied by the address location information indicated by the NVMe write command corresponding to the DMA command in response to generating a DMA command.

[0096] Taking the storage device processing the NVMe read command and the NVMe read command using the PRP descriptor host memory address as an example, the process of the storage device processing the NVMe read command is explained. Figure 3 FIG. 2 shows a schematic diagram of the structure of a host command processing unit according to an embodiment of the present application. Figure 3 As shown, the host command processing unit includes: a PRP circuit, a read initiation circuit, a DMA transmission circuit and a cache unit, wherein the read initiation circuit includes an information cache, a DMA command generation circuit and a completion message processing circuit. Figure 3 An example of a write initiation circuit is schematically shown. Other forms of write initiation circuits can refer to Chinese patent 202310788454.9, which will not be described in detail in this application.

[0097] In response to receiving an NVMe read command, the PRP circuit obtains a PRP entry from the NVMe read command, caches the PRP entry to a cache unit, and provides a PRP index indicating the PRP entry to a read initiation circuit. Obtaining a PRP entry from an NVMe read command and obtaining a PRP index belongs to the prior art (such as the PRP circuit shown in Chinese Patent 202110746144.1), which will not be repeated here.

[0098] In response to receiving a PRP index or an NVMe read command, the read initiation circuit updates the information cache (such as Figure 3Process (1)). The information cache can accommodate multiple entries, each entry corresponds to an NVMe read command, different entries correspond to different NVMe read commands, and all PRP entries, all DMA commands, and all DMA command processing completion messages associated with the same NVMe read command correspond to the same entry. Thus, the storage device concurrently processes multiple NVMe read commands at the same time. It can be understood that the NVMe read command stored in the information cache may be different in form from the NVMe read command received from the host, but each NVMe read command occupies an entry in the information cache. For example, in order to read the needs of the initiating circuit processing, the NVMe read command in the information cache includes information such as a command identifier, a cache unit index, a DMA command count, and a timestamp. The command identifier is used to identify a specified NVMe read command from multiple NVMe read commands. The cache unit index is used to indicate the PRP entry in the cache unit. The DMA command count is used to indicate the number of DMA commands that have been processed corresponding to the NVMe read command to which it belongs. The timestamp indicates the time when the NVMe read command is received.

[0099] It is understandable that the control component of the storage device also performs other processing on the NVMe read command, for example, generating a physical address based on the logical address to be accessed by the NVMe read command through the FTL table, and using the physical address to read data from the NVM chip, etc. These processing processes and the components that implement these processes belong to the prior art. The components that implement these processes are collectively referred to as back-end modules. After reading the data from the NVM chip and adding it to the storage device cache (such as DRAM), the back-end module provides a storage command processing completion message (such as DRAM) to the read initiation circuit. Figure 3 In process (2)). A single NVMe read command corresponds to one or more storage commands, and thus a single NVMe read command corresponds to one or more storage command completion messages.

[0100] The DMA command generation circuit responds to receiving a storage command processing completion message (such as Figure 3 In process (2), the cache unit index corresponding to the storage command is obtained from the information cache (such as Figure 3 In process (3), based on the cache unit index, a PRP entry corresponding to the storage command is obtained from the cache unit (such as Figure 3 Process (4)), and based on the PRP entry, a corresponding DMA command is generated, and the DMA command is sent to the DMA transmission circuit (such as Figure 3 process (5)).

[0101] To generate a DMA command, it is necessary to know the storage device cache address as the DMA transmission source address and the host memory address as the destination address. According to an embodiment of the present application, the storage device cache address is obtained according to the storage command processing completion message, and the host memory address is obtained according to the PRP entry. Figure 3 The NVMe read command stored in the information cache includes, for example, a cache unit index, obtaining the corresponding NVMe read command based on a storage command processing completion message, obtaining the cache unit index from the information cache, and obtaining a PRP entry from the corresponding cache unit based on the cache unit index.

[0102] In response to receiving the DMA command, the DMA transmission circuit moves data from the storage device cache to the host memory, and in response to the completion of the DMA command processing, sends a DMA command processing completion message (such as Figure 3 process (6)).

[0103] The completion message processing circuit is coupled to the DMA transmission circuit and the cache unit, and in response to receiving the DMA command processing completion message, updates the NVMe read command corresponding to the DMA command processing completion message in the cache unit. For example, the DMA command count value is updated (for example, incremented), or if all DMA commands corresponding to the NVMe read command are processed, the NVMe read command is deleted from the cache unit (for example, Figure 3 process (7)).

[0104] exist Figure 3 In the illustrated embodiment, there are two different stages in the NVMe read command processing process, and the information cache of the read initiation circuit is updated. Stage (1) After the control component of the storage device receives the NVMe read command and obtains the PRP entry from the host according to the NVMe read command, the entry associated with the NVMe read command is added to the information cache, and the entry associated with the NVMe read command added to the information cache includes a PRP index indicating the cache address of the PRP entry; Stage (2) In response to receiving one or more DMA command processing completion messages corresponding to the NVMe read command, the DMA command count of the NVMe read command in the information cache is updated or the NVMe read command is deleted.

[0105] Figure 4 FIG. 1 is a schematic diagram showing the organization of data of a storage device according to an embodiment of the present application on a physical page of an NVM chip. Figure 4 As shown in FIG. 1 , in the NVM chip, the storage space for storing data is organized into physical blocks and physical pages. In the IO command provided by the host to the storage device, the storage unit size represented by the logical address LBA is, for example, 4KB. In addition to recording the 4KB data provided by the user (recorded in Figure 4The spare data area also records information generated by the storage device itself, such as the verification data generated by the ECC algorithm for the user data, the LBA of the user data, the random number seed when scrambling the user data, the encryption or decryption key, etc. For the sake of simplicity, the data recorded in the spare data area are also collectively referred to as metadata. Optionally, the size of the storage unit represented by each LBA can be 4KB, 8KB, 16KB, etc., and the size of the metadata can be 512Byte or other sizes.

[0106] exist Figure 4 In the illustrated embodiment, the physical page is slightly larger than the storage unit represented by the LBA, that is, the size of the physical page is slightly larger than 4KB. In an optional embodiment, the storage device also provides a larger physical page (for example, larger than 16KB), so that the capacity of the physical page is inconsistent with the capacity of the storage unit represented by the LBA. Figure 5 As shown in FIG. 1 , the physical page records metadata corresponding to four LBAs and metadata corresponding to each user data. The combination of user data stored in a physical page and its corresponding metadata is called DU (Date Unit). Figure 5 As described above, four DUs are recorded in a physical page. When a host reads data from a storage device, the data is moved according to the DUs.

[0107] In some optional embodiments, the size of the storage block (in the host memory) indicated by each PRP entry is consistent with the size of the storage unit represented by the LBA, for example, the size of the storage block indicated by each PRP is 4KB, and the size of the storage unit represented by the LBA is also 4KB. In other optional embodiments, the size of the storage block (host memory) indicated by the PRP entry is inconsistent with the size of the storage unit represented by the LBA, for example, the storage block indicated by the PRP entry is 4KB, while the size of the storage unit represented by the LBA is 2KB.

[0108] For example, the size of the storage block (in the host memory) indicated by each PRP entry is consistent with the size of the storage unit represented by the LBA. For example, the size of the storage block indicated by each PRP entry is 4KB, and the size of the storage unit represented by each LBA is also 4KB. Figure 6As shown, the storage unit size represented by each logical address LBA indicated by the NVMe read command is, for example, 4KB, the metadata size is, for example, 512Byte, and the data size moved from the NVM chip to the DRAM by each storage command is, for example, (4KB+512Byte). The data of each size (4KB++512Byte) stored in the DRAM is called a DTU (Data Transfer Unit). The DTU is moved to the storage block described by the PRP entry on the host side through a DMA command. However, the size of the storage block (in the host memory) indicated by each PRP entry is, for example, 4KB, resulting in the data size of the DTU (4KB+512Byte) being larger than the storage unit size (4KB) represented by each PRP entry on the host side. Furthermore, when the logical address LBA corresponding to the DTU is not 4KB aligned, part of the data in the DTU is not valid data, so it does not need to be transmitted to the host, which results in the data moved to the host according to some DTUs (even with metadata) being smaller than the storage block size (e.g., 4KB) indicated by the PRP entry. Still further, in addition to the metadata recorded in the spare data area of ​​the NVM chip, the control component may also generate other metadata (e.g., PI, protection information) so that when the DTU is moved to the host memory, the required host memory space is not equal to the storage block size (e.g., 4KB) indicated by the PRP entry. However, when storing data on the host side, the data is stored in a 4KB aligned manner (the storage block size indicated by each PRP is 4KB, and its address space is aligned along 4KB), so that the storage block indicated by a PRP entry on the host side may store data of one or more DTUs.

[0109] Since the host memory storage block size indicated by the PRP entry is inconsistent with the DTU size, the storage command processing completion message and the PRP entry are not one-to-one corresponding. Therefore, when a storage command processing completion message is received during the processing of an NVMe read command, it is necessary to determine whether to delete the corresponding PRP entry.

[0110] like Fig. 7A , 7B , 7C, in Fig. 7AIn the process, according to the physical addresses corresponding to the logical addresses LBA0~LBA5 indicated by the NVMe read command, 5 copies of data are read from the NVM chip respectively, and the data is stored in the DRAM. The size of the storage unit represented by each logical address is 4KB. Among them, data 1 is the data in the (4KB+512Byte) data corresponding to LBA0 that needs to be moved to the host memory. Since LBA0 indicated by the NVMe read command is not 4KB aligned, the beginning part of data 1 does not need to be moved to the host, and the part to be moved to the host is less than 4KB; data 2 is the data in the (4KB+512Byte) data corresponding to LBA1 that needs to be moved to the host memory, and the size is equal to 4KB+512Byte; data 3 is the data in the (4KB+512Byte) data corresponding to LBA2 that needs to be moved to the host memory, and the size is equal to 4KB+512Byte; data 4 is the (4KB+512Byte) data corresponding to LBA3. Data 6 is the data in the (4KB+512Byte) data corresponding to LBA5 that needs to be moved to the host memory. Data 6 corresponds to the last data indicated by the NVMe read command. When LBA5 is not 4KB aligned, the end of Data 6 may not be 4KB aligned, resulting in that the end of Data 6 may not need to be moved to the host, and the part to be moved to the host may be less than 4KB.

[0111] like Figure 7B As shown, PRP0-PRP6 are PRP entries indicated by NVMe read commands, and the size of the storage block in the host memory represented by each PRP in PRP0-PRP6 is 4KB. Figure 7B The storage blocks indicated by PRP0-PRP6 that are spatially continuous are shown in the figure. Optionally, these storage blocks may be discontinuous storage blocks in the host memory space. However, these storage blocks together form a continuous virtual storage space in the order of PRP0-PRP6. And the positions of each data (DTU) moved to the storage block indicated by the PRP entry according to the NVMe read command in the continuous virtual storage space are sorted according to their LBAs, so that each DTU has a certain position and size in the continuous virtual storage space. Therefore, according to the LBA and size of the DTU, it is determined that it has a certain position in the virtual storage space, and it is determined which storage block indicated by which PRP the position belongs to.

[0112] like Figure 7CAs shown, data is stored starting from the storage block represented by PRP0, that is, data 1 is stored in the storage block represented by PRP0. Since the size of data 1 is less than 4KB, and the starting address of the required data is not 4KB aligned, data 1 is not stored from the beginning (but from the middle position) in the storage block indicated by PRP0. After data 1 is stored in the storage block indicated by PRP0, the storage block represented by PRP0 also needs to store part of the data in data 2. Part of the data of data 2 is stored in the data block represented by PRP1. Since the size of data 2 is greater than 4KB, the data block represented by PRP1 cannot completely store data 2, and the storage block represented by PRP2 needs to be occupied. Data 3 is stored in the data blocks represented by PRP2 and PRP3. Data 4 needs to be stored in the data blocks represented by PRP3 and PRP4. Data 5 needs to be stored in the data blocks represented by PRP5 and PRP6. Data 6 needs to be stored in the data block represented by PRP6. Figure 7C In the figure, shaded boxes are used to represent the data corresponding to the LBA to be stored in the host memory.

[0113] For PRP0, since the storage block represented by PRP0 stores data 1 and data 2, after receiving the message that the storage command processing corresponding to data 1 is completed, the PRP0 entry in the cache unit cannot be deleted (because PRP0 is still needed when processing the storage command processing corresponding to data 2 next). PRP0 in the cache unit can only be deleted after receiving the storage command processing corresponding to data 2. Further, the order in which the storage command processing corresponding to data 1 and the storage command processing corresponding to data 2 are received is not guaranteed, so that when the storage command processing corresponding to data 2 is received, it cannot be guaranteed that the storage command processing corresponding to data 1 has been received. Therefore, the PRP entry in the cache unit cannot be deleted according to the number or index of the data corresponding to the storage command processing completed message, but the PRP entry in the cache unit is deleted according to the number of storage command processing completed messages received, and the storage command processing completed messages corresponding to each PRP entry may be different. For example, for the PRP0 entry, it is necessary to receive two storage command processing completed messages related to PRP0 before it is deleted from the cache unit. For PRP1, since only data 2 is stored in PRP1, it needs to receive a storage command processing completion message related to PRP1 before it can be deleted from the cache unit. Similarly, the release process of PRP2-PRP6 can be known.

[0114] Combination Fig. 7A , 7BAs shown in 7C, when the PRP entry represents a 4KB host storage block and the storage command processing completion message represents 4KB+512B, it is determined how many DTUs of data each PRP entry contains:<PRP0,2> (Indicates that PRP0 accommodates 2 DTUs of data).<PRP1,1> ,<PRP2,2> ,<PRP3,2> ,<PRP4,1> ,<PRP5,1> ,<PRP6,2> According to the number of DTUs corresponding to each PRP entry, it is determined that after receiving several storage command completion messages, the corresponding PRP entry is deleted to release the cache unit.

[0115] As an example, a register is set for each PRP entry in the control component, and the number of storage command processing completion messages indicating the PRP entry received is recorded through each register, so that the control component releases the cache unit according to the number of storage command completion messages corresponding to each PRP entry received. The number of storage command completion messages that each PRP entry needs to receive before it can be released is related to the number of DTUs corresponding to the PRP entry, for example, the number of DTUs corresponding to the PRP entry is 1, 2 or 3; when the number of DTUs corresponding to the PRP entry is 1, upon receiving a storage command completion message corresponding to the PRP entry, the cache unit storing the PRP entry can be released; when the number of DTUs corresponding to the PRP entry is 2, upon receiving two storage command completion messages corresponding to the PRP entry, the cache unit storing the PRP entry can be released; when the number of DTUs corresponding to the PRP entry is 3, upon receiving three storage command completion messages corresponding to the PRP entry, the cache unit storing the PRP entry can be released. In order to record the number of storage command completion messages corresponding to the PRP entry, the register corresponding to each PRP entry contains at least 1 bit.

[0116] Combination Fig. 7A , 7B As can be seen from 7C, when the size of the storage unit represented by each logical address is 4KB and the size of the host storage unit represented by each PRP entry is also 4KB, the host storage unit represented by the PRP entry can accommodate data of up to 2 DTUs, and can receive a storage command processing completion message indicating the PRP entry at most twice. As another example, the register corresponding to each PRP entry contains 1 bit, and the number of times the PRP entry indicated by the storage command processing completion message has been used can be counted based on the value recorded in the 1-bit register. For example, the value of the 1-bit register is 0, indicating that the storage command processing completion message has not been received. The value of the 1-bit register is 1, indicating that the storage command processing completion message has been received once.

[0117] by Figure 7CTaking the PRP0 entry shown as an example, the PRP0 entry contains data of 2 DTUs, and the expected number of times the PRP0 entry is used is 2. A 1-bit register A1 is used to record the number of times the PRP entry has been used, that is, a 1-bit register is used to record the number of times the storage command processing completion message indicating the PRP0 entry is received. If a storage command processing completion message indicating the PRP0 entry is received (the storage command processing completion message indicating the PRP0 entry is recorded as CPL1), the value of register A1 is determined. If the value of register A1 is 0, it means that the received CPL1 is the first time that the storage command processing completion message indicating the PRP0 entry is received. At this time, the number of times the PRP0 entry has been used is 1, and the number of times the PRP0 entry has been used is not equal to the expected number of times the PRP0 entry is used, then the value of register A1 is updated to 1, for example, by inverting the value of register A1, the value of register A1 is updated from 0 to 1. If a storage command processing completion message indicating the PRP0 entry is received again (the storage command processing completion message indicating the PRP0 entry is recorded as CPL2), the value of register A1 is determined. If the value of register A1 is 1, it means that CPL2 is the second storage command processing completion message indicating the PRP0 entry received, and the number of times the current PRP0 entry has been used is equal to the expected number of times the PRP0 entry is used. The PRP0 entry is deleted from the cache unit, and the cache unit occupied by the PRP0 entry is released. Optionally, in the case of releasing the cache unit occupied by the PRP0 entry, the value of register A1 can also be cleared so that register A1 can be used to record the number of storage command processing completion messages corresponding to subsequent PRP0 entries.

[0118] by Figure 7C Taking the PRP1 entry shown as an example, the PRP1 entry contains the data of 1 DTU, and the expected number of times the PRP1 entry is used is 1. The 1-bit register A2 is used to record the number of storage command processing completion messages indicating the PRP1 entry. If a storage command processing completion message indicating the PRP1 entry is received (the storage command processing completion message indicating the PRP1 entry is recorded as CPL3), the value of register A2 is determined. If the value of register A2 is 0, it means that CPL3 is the first storage command processing completion message indicating the PRP1 entry received, and the number of times the PRP1 entry has been used is 1, which is equal to the expected number of times the PRP1 entry is used. The PRP1 entry is deleted from the cache unit, and the cache unit occupied by the PRP1 entry is released. If the value of register A2 is 1, it means that CPL3 is the second storage command processing completion message indicating the PRP1 entry received, and the number of times the PRP1 entry has been used is 2, which is greater than the expected number of times the PRP1 entry is used. The storage command processing completion message fed back by the storage command processing unit is wrong, and an error is reported.

[0119] As another example, when the expected number of times the PRP entry indicated by the NVMe read command is used is not greater than 2, for example, the storage unit represented by each logical address is consistent with the host storage unit represented by each PRP entry, both of which are 4KB, a 1-bit register is used to record the number of times the PRP entry has been used. When a storage command processing completion message corresponding to a PRP entry is received, for the PRP entry, the logic for determining whether to release the cache unit occupied by the PRP entry is based on the value of the corresponding register and the expected number of times the PRP entry is used:

[0120] (1) If the expected number of times the PRP entry is used is 1, the value of the register is 0, the cache unit occupied by the PRP entry is released, and the register is cleared;

[0121] (2) If the expected number of times the PRP entry is used is 1, the value of the register is 1, and an error is reported;

[0122] (3) If the expected number of times the PRP entry is used is 2, the value of the register is 0, and the value of the register is updated to 1 without releasing the cache unit occupied by the PRP entry;

[0123] (4) If the expected number of times the PRP entry is used is 2, the value of the register is 1, the cache unit occupied by the PRP entry is released, and the register is cleared.

[0124] In an alternative embodiment, reference Figure 3 The function of releasing the cache unit can be realized by the completion message processing circuit in the read initiation circuit, or other circuits can be set in the read initiation circuit to realize the function of releasing the cache unit.

[0125] Figure 8 FIG. 1 is a schematic diagram showing a circuit for releasing a cache unit according to an embodiment of the present application. Figure 8 As shown, the circuit of the release cache unit includes: a memory M1, a calculation circuit W1, a comparison circuit and a PRP entry deletion circuit.

[0126] Among them, the memory M1 is used to record the number of storage command processing completion messages corresponding to the PRP entry indicated by the NVMe read command, that is, the number of times the PRP entry indicated by the NVMe read command has been used. Each time a storage command processing completion message is received, the number of times the PRP entry corresponding to the storage command processing completion message has been used is increased by 1 and recorded in the memory.

[0127] The calculation circuit W1 receives the storage command processing completion message, and calculates the expected number of times the PRP entry associated with it is used according to the storage command processing completion message. Fig. 7A and 7CAs shown, for example, the computing circuit receives a storage command processing completion message corresponding to data 1, whose LBA=0, and the corresponding PRP entry is: PRP0, PRP0 contains 2 DTUs of data, and PRP0 should be released after receiving 2 storage command processing completion messages corresponding to PRP0, so the expected number of times PRP0 is used is 2. For another example, the computing circuit receives a storage command processing completion message corresponding to data 2, whose LBA=1, and the corresponding PRP entries include: PRP0, PRP1 and PRP2. PRP0 contains 2 DTUs of data, and PRP0 should be released after receiving 2 storage command processing completion messages corresponding to PRP0, so the expected number of times PRP0 is used is 2. PRP1 contains 1 DTU of data, and PRP1 should be released after receiving 1 storage command processing completion message corresponding to PRP1, so the expected number of times PRP0 is used is 1. PRP2 contains 2 DTUs of data, and PRP2 should be released after receiving 2 storage command processing completion messages corresponding to PRP2, so the expected number of times PRP2 is used is 2.

[0128] The comparator is coupled to the memory M1 and the calculation circuit W1, and is used to compare whether the number of times the PRP has been used recorded by the memory M1 is the same as the expected number of times calculated by the calculation circuit W1, and if they are the same, the index of the PRP entry is provided to the PRP entry deletion circuit. For example, the comparator compares whether the number of times PRP0 has been used is equal to 2, and if so, the index of the PRP0 entry is provided to the PRP entry deletion circuit.

[0129] The PRP entry deletion circuit deletes the corresponding PRP entry in the cache unit according to the index of the received PRP entry. For example, the PRP entry deletion circuit receives PRP0 provided by the comparator and deletes PRP0 in the cache unit to release the cache unit.

[0130] Optionally, when the size of the storage unit represented by the logical address and the host storage unit represented by each PRP entry are both 4KB, the memory M1 can be a 1-bit register. The calculation circuit W1 receives a storage command processing completion message, and calculates the expected number of times the corresponding PRP entry is used according to the storage command processing completion message. The comparator obtains the expected number of times the PRP entry is used calculated by the calculation circuit W1 and the value of the memory M1. If the expected number of times the PRP entry is used is 1 and the value of the memory M1 is 0, when the calculation circuit W1 receives the storage command processing completion message corresponding to the PRP entry, the comparator provides the index of the PRP entry to the PRP entry deletion circuit. If the expected number of times the PRP entry is used is 2 and the value of the memory M1 is 1, the current calculation circuit W1 receives the storage command processing completion message corresponding to the PRP entry for the second time, and the comparator provides the index of the PRP entry to the PRP entry deletion circuit.

[0131] Fig. 9 FIG. 2 is a schematic diagram showing another circuit for releasing a cache unit according to an embodiment of the present application. Fig. 9 As shown, the circuit of the release cache unit includes a memory M2, a calculation circuit W2 and a control circuit.

[0132] Among them, the memory M2 is used to record the number of storage command processing completion messages corresponding to the PRP entry indicated by the NVMe read command, that is, the number of times the PRP entry indicated by the NVMe read command has been used.

[0133] The calculation circuit W2 receives the storage command processing completion message, calculates the expected number of times the corresponding one or more PRP entries are used according to the LBA indicated by the storage command processing completion message, and provides the expected number of times the PRP entries are used to the control circuit.

[0134] The control circuit is coupled to the memory M2 and the calculation circuit W2, and receives the expected number of times the PRP entry is used provided by the calculation circuit W2 (eg Fig. 9 In process (1)), the number of times the PRP entry has been used is obtained from memory M2 (such as Fig. 9 In process (2), the number of times the PRP entry has been used is compared with the expected number of times, and the PRP entry in the cache unit is managed according to the comparison result. If the number of times the PRP entry has been used is equal to the expected number of times, the PRP entry in the cache unit is deleted, and the cache unit is released (such as Fig. 9 If the number of times the PRP entry has been used is not equal to the expected number of times, the number of times the PRP entry has been used in the control memory M2 is increased by 1 (e.g. Fig. 9 process (4)).

[0135] Optionally, when the size of the storage unit represented by the logical address and the host storage unit represented by each PRP entry are both 4KB, the memory M2 can be a 1-bit register. The calculation circuit W2 receives a storage command processing completion message, and calculates the expected number of times the corresponding PRP entry is used according to the storage command processing completion message. The control circuit receives the expected number of times the PRP entry is used provided by the calculation circuit W2, and obtains the value of the memory M2. If the expected number of times the PRP entry is used is 2, the value of the memory M2 is 1. In this case, the calculation circuit W2 receives a storage command processing completion message corresponding to the PRP entry, and the control circuit deletes the PRP entry in the cache unit and releases the cache unit. If the expected number of times the PRP entry is used is 2, the value of the memory M2 is 0, the calculation circuit W2 receives a storage command processing completion message corresponding to the PRP entry, the control circuit inverts the value of the memory M2, and updates the value of the memory M2 to 1. If the expected number of times the PRP entry is used is 1, the value of the memory M2 is 0, the calculation circuit W2 receives a storage command processing completion message corresponding to the PRP entry, the control circuit deletes the PRP entry in the cache unit, and releases the cache unit. If the expected number of times the PRP entry is used is 1, the value of the memory M2 is 1, and the control circuit reports an error.

[0136] As can be seen from the above, the size of the storage block (in the host memory) indicated by each PRP entry is inconsistent with the size of the storage unit represented by the LBA. For example, the size of the storage block indicated by each PRP entry is 8KB, and the size of the storage unit represented by each LBA is 4KB. Fig. 10A ), the size of the storage unit represented by each LBA is 4KB as an example to illustrate the process of releasing the cache unit.

[0137] The data that needs to be moved from the storage device indicated by the NVMe read command is recorded as data 1 to data 6. Fig. 10B As shown, PRP0-PRP3 are PRP entries indicated by NVMe read commands, and the size of the storage block represented by each PRP in PRP0-PRP3 is 8KB. Fig. 10BAs shown, data is stored starting from the storage block indicated by PRP0, that is, data 1 is stored in PRP0. Since data 1 is less than 4KB, and the starting address of the required data is not aligned with 8KB, after data 1 is stored in the storage block indicated by PRP0, the storage block indicated by PRP0 also needs to store data 2. Since the sum of data 1 and data 2 is less than 8KB, the storage block indicated by PRP0 can also store part of data 3. Similarly, it can be known that the storage block indicated by PRP1 can store the remaining data of data 3, the complete data 4 and part of data 5, and the storage block represented by PRP2 can store the remaining data of data 5 and data 6.

[0138] For PRP0, since the storage block represented by PRP0 stores part of data 1, data 2, and data 3, after receiving the message that the storage command processing corresponding to data 1 is completed, PRP0 in the cache unit will not be deleted. It is necessary to receive the storage command processing completion message corresponding to data 2 and data 3 before initiating the operation of deleting PRP0 in the cache unit. That is, for PRP0, it is necessary to receive three storage command processing completion messages related to PRP0 before it is deleted from the cache unit. For PRP1, since PRP1 stores part of data 3, data 4, and data 5, it is also necessary to receive three storage command processing completion messages related to PRP1 before it is deleted from the cache unit. For PRP2, since PRP2 only stores part of data 5 and data 6, it is necessary to receive two storage command processing completion messages related to PRP2 before it is deleted from the cache unit.

[0139] Combination Figure 3-10B The embodiment shown, as Fig.11 As shown, the cache unit management method of the storage device provided in the embodiment of the present application includes:

[0140] Step S1101: In response to receiving an IO command, obtain address location information indicated by the IO command and add it to the allocated cache unit. The address location information includes a PRP entry, an SGL descriptor, and a host memory address determined according to the PRP entry or the SGL descriptor. The number of the PRP entry, the SGL descriptor, and the host memory address determined according to the PRP entry or the SGL descriptor can be one or more.

[0141] Step S1102: If the IO command is an NVMe write command, in response to generating a DMA command according to the address location information indicated by the NVMe write command, release the cache unit occupied by the target address location information.

[0142] Step S1103: If the IO command is an NVMe read command, in response to the fact that the address location information indicated by the storage command processing completion message has been used a number of times equal to the expected number of times, release the cache unit occupied by the address location information indicated by the storage command processing completion message; wherein the storage command indicated by the storage command processing completion message is generated based on the NVMe read command.

[0143] Step S1104: If the IO command is an NVMe read command, in response to the fact that the number of times the address location information indicated by the storage command processing completion message has been used is not equal to the expected number of times, the number of times the address location information indicated by the storage command processing completion message has been used is controlled to be increased by one.

[0144] In the process of processing NVMe read commands, the storage command processing completion message fed back by the storage command processing unit may contain errors. Errors include, for example, for a PRR entry, the storage command processing unit feeds back multiple storage command processing completion messages (such as repeated responses) or the storage command processing unit feeds back less or misses the storage command processing completion message. For another example, refer to Figure 7C For NVMe read commands, the storage command processing completion message that the storage command processing unit expects to feedback includes: two storage command processing completion messages indicating PRP0 entries, one storage command processing completion message indicating PRP1 entries, two storage command processing completion messages indicating PRP2 entries, two storage command processing completion messages indicating PRP3 entries, one storage command processing completion message indicating PRP4 entries, one storage command processing completion message indicating PRP5 entries, and two storage command processing completion messages indicating PRP6 entries. However, the storage command processing completion message actually received from the storage command processing unit may lack the storage command processing completion message corresponding to a certain PRP entry, or receive duplicate storage command processing completion messages, for example:

[0145] (1) The storage command processing completion messages actually received include: two storage command processing completion messages indicating PRP0 entries, two storage command processing completion messages indicating PRP2 entries, two storage command processing completion messages indicating PRP3 entries, one storage command processing completion message indicating PRP4 entries, one storage command processing completion message indicating PRP5 entries, and two storage command processing completion messages indicating PRP6 entries. The storage command processing completion message indicating PRP1 entries is missing. The storage command processing completion message of PRP1 entries is missed from being fed back, resulting in that the cache unit occupied by the PRP1 entry cannot be released.

[0146] (2) It is expected that two storage command processing completion messages indicating the PRP0 entry are received (the logical addresses corresponding to the two storage command processing completion messages are LBA0 and LBA1 respectively), but only one storage command processing completion message indicating the PRP0 entry is actually received (the logical address corresponding to the storage command processing completion message actually received is LBA0), and the storage command processing completion message of the PRP0 entry is not fed back, resulting in that the cache unit occupied by the PRP0 entry cannot be released;

[0147] (3) It is expected that two storage command processing completion messages indicating the PRP0 entry are received (the logical addresses corresponding to the two storage command processing completion messages are LBA0 and LBA1 respectively), which actually means that two storage command processing completion messages indicating the PRP0 entry are received, but the logical address corresponding to the received storage command processing completion messages is LBA1, so that the storage command processing completion message corresponding to LBA1 is repeatedly fed back, while the storage command processing completion message corresponding to LBA0 is missed to be fed back, resulting in the cache occupied by the PRP0 entry being released, and the storage command corresponding to LBA0 cannot be processed;

[0148] (4) It is expected to receive a storage command processing completion message indicating the PRP1 entry once, but the storage command processing completion message indicating the PRP1 entry is received twice, so the storage command processing completion message of the PRP1 entry is repeatedly fed back, resulting in an error in the storage command processing completion message, and an error will be reported.

[0149] It can be seen that in the process of processing NVMe read commands, there may be an error of receiving less storage command processing completion messages, or there may be an error of receiving storage command processing completion messages repeatedly. In order to identify whether the NVMe read command is processed correctly, it is necessary to monitor whether the received storage command processing completion message has errors.

[0150] As an example, repeated receipt of storage command processing completion messages indicating a certain PRP entry may be detected by the number of received storage command processing completion messages corresponding to the PRP entry. For example, if a PRP entry has been used more times than the expected number of times it has been used, it is determined that repeated receipt of storage command processing completion messages indicating the PRP entry is received. Figure 7C The PRP1 entry in the datafile is expected to be used 1 times, but actually two storage command processing completion messages indicating the PRP1 entry are received (i.e., the PRP1 entry has been used 2 times), then it is determined that the storage command processing completion message indicating the PRP1 entry is repeated and there is an error in the storage command processing completion message.

[0151] For another example, for the PRP0 entry, releasing the cache unit occupied by the PRP0 entry requires receiving two storage command processing completion messages. If two storage command processing completion messages are received and the actual number of storage command processing completion messages is equal to the expected number, the cache unit occupied by the PRP0 entry is released. However, if both of the two received storage command processing completion messages correspond to LBA1 and the storage command processing completion message corresponding to LBA0 is not received, it will cause the storage command corresponding to LBA0 to be unable to be processed because the cache unit occupied by the PRP0 entry is released. An incorrect storage command processing completion message is determined based on the situation where the storage command cannot be processed.

[0152] In an alternative embodiment, the monitoring of the storage command processing completion message is implemented together during the process of releasing the cache unit. For example, a corresponding counter is provided for each PRP entry, and this counter is used to record the number of times the storage command processing completion message indicating this PRP entry is received. Let count represent the value of the counter. For another example, as Figure 8 Or Fig. 9 shown, a memory is provided to record the number of times the storage command processing completion messages indicating each PRP entry are received. At this time, count represents the value of the memory. When a storage command processing completion message such as CPL1 is received, determine the expected number of times the PRP entry it indicates is used, and use Pcount to represent the expected number of times the PRP entry is used. Then obtain the count value in the counter (the number of storage command processing completion messages recorded by count does not include CPL1), and compare Pcount with count:

[0153] If Pcount > count + 1, do not release the cache unit occupied by the PRP entry, and increment by 1 the number of times the PRP entry recorded by the counter has been used;

[0154] If Pcount == count + 1, release the cache unit occupied by the PRP entry;

[0155] If Pcount < count + 1, determine that there is an error in the storage command processing completion message and a duplicate storage command processing completion message is received.

[0156] As an alternative example, as Fig. 9 shown, the memory M2 is used to record the number of times the received storage command processing completion messages are received. At Fig. 9In the illustrated embodiment, in response to receiving a storage command processing completion message such as CPL2, the calculation circuit W2 calculates the expected number of times a PRP entry indicated by the storage command processing completion message, such as PRP entry 3, is used, and Pcount3 is used to represent the expected number of times the PRP entry is used, and the calculated Pcount3 is provided to the control circuit. The control circuit obtains the number of storage command processing completion messages corresponding to PRP entry 3 from the memory M2, and count3 is used to represent the number of storage command processing completion messages corresponding to PRP entry 3. The control circuit compares Pcount3 with count3. If Pcoun3>(count3)+1, the cache unit occupied by PRP entry 3 is not released, and the number of storage command processing completion messages corresponding to PRP entry 3 recorded by the control memory M2 is increased by 1; if Pcoun3==(count3)+1, the control circuit releases the cache unit occupied by PRP entry 3; if Pcoun3<(count3)+1, the control circuit determines that there is an error in the storage command processing completion message and a duplicate storage command processing completion message is received.

[0157] In the case where a storage command processing completion message is received less, it is impossible to determine, based on the release of the cache unit occupied by the PRP entry, whether the storage command corresponding to the PRP entry has not been processed, or whether the storage command corresponding to the PRP entry has been processed, but the correct storage command processing completion message has not been generated. Therefore, in an optional embodiment, a timestamp representing the receipt of the NVMe read command can be recorded for each NVMe read command, for example, in the information cache (such as Figure 3 The time when the NVMe read command is added to the information cache is recorded in (as shown). If the NVMe read command indicates multiple PRP entries, the timestamp corresponding to each PRP entry is the same. For each PRP entry, the difference between the current time and its corresponding timestamp is calculated to obtain the delay time corresponding to the PRP entry. When the delay time is greater than the specified value and the cache unit occupied by it has not been released, it is determined that the storage command processing completion message indicating the PRP entry is not received (the storage command processing completion message of the PRP entry is not returned), and there is an error in the storage command processing completion message.

[0158] In an optional embodiment, if multiple storage command processing completion messages are received, the timestamps of each storage command processing completion message in the multiple storage command processing completion messages received are recorded in turn, the difference between the current time and the timestamp corresponding to each storage command processing completion message is calculated, and the difference is used as the delay time corresponding to the storage command processing completion message. According to the delay time corresponding to each storage command processing completion message, the processing order of the multiple storage command processing completion messages is determined, for example, in order of delay time from large to small, the storage command processing completion message with the longest delay time is processed first, that is, it is prioritized to determine whether to release the cache unit occupied by the PRP entry indicated by the storage command processing completion message with the longest delay time.

[0159] Optionally, multiple registers may be provided in the control component to record the maximum and minimum values ​​of the delay time corresponding to each storage command processing completion message, and the number of storage command processing completion messages in each delay time interval between the maximum and minimum values. Among them, the boundary value of each delay time interval is configurable. The value of each register can be read by the firmware. When multiple storage command processing completion messages are received, each storage command processing completion message is processed according to the delay time, for example, the storage command processing completion message with the longest delay time is processed first, and the cache unit occupied by the PRP entry indicated by the storage command processing completion message with the longest delay time is released first. Optionally, if the delay time corresponding to the storage command processing completion message is greater than a preset threshold, that is, the difference between the current time and the timestamp corresponding to the storage command processing completion message is greater than the preset threshold, then the relevant information of the storage command corresponding to the storage command processing completion message is saved in the metadata of the storage device. The host reads the storage command related information saved in the metadata of the storage device according to the logical address indicated by the custom command through a custom command that satisfies the NVMe protocol. For example, three storage command processing completion messages are received, namely, storage command processing completion message 1, storage command processing completion message 2, and storage command processing completion message 3. The timestamp corresponding to storage command processing completion message 1 is t1, the timestamp corresponding to storage command processing completion message 2 is t2, and the timestamp corresponding to storage command processing completion message 3 is t3. The current time is t4. If (t4-t3)>(t4-t2)>(t4-t1), storage command processing completion message 3 is processed first, followed by storage command processing completion message 2, and finally storage command processing completion message 1. If (t4-t3)>specified threshold T m , then the relevant information of the storage command corresponding to the storage command processing completion message 3 is saved in the metadata of the storage device. In response to receiving a custom command that meets the NVMe protocol sent by the host, the relevant information of the storage command saved in the metadata is read according to the logical address indicated by the custom command.

[0160] In an optional embodiment, in response to processing the storage command processing completion message, a DMA command (such as Figure 3 In process (2), data is moved from the storage device cache to the host according to the DMA command.

[0161] Optionally, during the process of releasing the cache unit, it is detected whether there is a situation where less storage command processing completion messages are received. Fig.12 As shown, in Figure 3 The information cache shown records the timestamp representing the time when the NVMe read command is received. Figure 3 The information cache shown is the same as Fig. 9 The control circuit is coupled to the control circuit shown. The control circuit obtains the timestamp of the NVMe read command recorded in the information cache, and determines the timestamp of the PRP entry corresponding to the NVMe read command, such as PRP entry 4. The control circuit calculates the difference between the current time and the timestamp of PRP entry 4 to obtain the delay time corresponding to the PRP4 entry. If the delay time corresponding to the PRP4 entry is greater than or equal to the specified value, and the cache unit occupied by the PRP4 entry has not been released, it is determined that the storage command processing completion message corresponding to the PRP4 entry has been received. Still optionally, Figure 3 The information cache shown records the timestamp representing the receipt of the NVMe read command and synchronizes the timestamp to Fig. 9 In the memory M2 shown. Fig. 9 The memory M2 shown not only records the number of storage command processing completion messages corresponding to the PRP entry, but also can record the timestamps corresponding to the PRP entry. The control circuit obtains the timestamps corresponding to each PRP entry from the memory M2.

[0162] Alternatively, if Fig.13 The embodiment of the present application provides a block diagram of another circuit for releasing a cache unit. Fig.13 As shown, the circuit of the release cache unit includes a calculation circuit W2, a calculation circuit W3, a memory M2, a memory M3 and a control circuit. The functions implemented by the calculation circuit W2 and the memory M2 are similar to those implemented by the control circuit W2. Fig. 9 The calculation circuit W2 shown is the same as the memory M2, and will not be described in detail here. The memory M3 records the timestamp corresponding to the address location information, and the calculation circuit W3 calculates the difference between the current time and the timestamp corresponding to the address location information to determine the delay time of the address location information. When the delay time is greater than or equal to the specified value, the address location information is provided to the control circuit, and the control circuit determines whether the cache unit occupied by the address location information is released. If it is not released, it is determined that there is an error in the storage command processing completion message.

[0163] From the perspective of the PRP entry, the above article determines whether there is an erroneous storage command processing completion message based on the expected number of times the PRP entry is used and the number of times it has been used, as well as the delay time corresponding to the PRP entry. The following describes the process of determining whether there is an erroneous storage command processing completion message from the perspective of the NVMe read command.

[0164] Optionally, according to the number of storage command processing completion messages expected to be received by the NVMe read command and the number of storage command processing completion messages received, it is determined whether the storage command processing completion message corresponding to the NVMe read command has an error. For example, for NVMe read command 1, the storage command processing completion messages expected to be received include: a storage command processing completion message corresponding to LBA0, a storage command processing completion message corresponding to LBA1, a storage command processing completion message corresponding to LBA2, a storage command processing completion message corresponding to LBA3, a storage command processing completion message corresponding to LBA4, and a storage command processing completion message corresponding to LBA5. For NVMe read command 1, it is expected to receive 6 storage command processing completion messages.

[0165] In some optional embodiments, if the storage command processing completion message actually received includes: a storage command processing completion message corresponding to LBA0, two storage command processing completion messages corresponding to LBA1, a storage command processing completion message corresponding to LBA2, a storage command processing completion message corresponding to LBA3, a storage command processing completion message corresponding to LBA4, and a storage command processing completion message corresponding to LBA5. For NVMe read command 1, 7 storage command processing completion messages are actually received. The number of storage command processing completion messages actually received is greater than the number of storage command processing completion messages expected to be received, and it is determined that the storage command processing completion message corresponding to the NVMe read command has an error.

[0166] In other optional embodiments, if the storage command processing completion message actually received includes: a storage command processing completion message corresponding to LBA0, two storage command processing completion messages corresponding to LBA1, a storage command processing completion message corresponding to LBA2, a storage command processing completion message corresponding to LBA3, and a storage command processing completion message corresponding to LBA4. For NVMe read command 1, 6 storage command processing completion messages are actually received. The number of storage command processing completion messages actually received is equal to the number of storage command processing completion messages expected to be received, but one storage command processing completion message corresponding to LBA1 is expected to be received, two storage command processing completion messages corresponding to LBA1 are actually received, one storage command processing completion message indicating LBA5 is expected to be received, and no storage command processing completion message indicating LBA5 is actually received. The logical address indicated by the storage command processing completion message expected to be received is different from the logical address indicated by the storage command processing completion message actually received, and thus it is determined that the storage command processing completion message corresponding to the NVMe read command has an error.

[0167] Still optionally, determine whether there is an erroneous storage command processing completion message based on the delay time corresponding to the NVMe read command. If the delay time corresponding to the NVMe read command is greater than or equal to the specified value, and the cache unit occupied by the PRP entry corresponding to the NVMe read command has not been fully released, it is determined that there is an erroneous storage command processing completion message. For example, the PRP entries corresponding to the NVMe read command 1 include: PRP0 entry, PRP1 entry, PRP2 entry, PRP3 entry, PRP4 entry, PRP5 entry and PRP6 entry. The current delay time corresponding to the NVMe read command 1 is 1 second, the specified value is 45 milliseconds, the delay time corresponding to the NVMe read command 1 is greater than the specified value, and the cache unit occupied by the PRP5 entry has not been released, then it is determined that there is an erroneous storage command processing completion message. Among them, upon receiving the NVMe read command 1, to the following: Figure 3 When the NVMe read command 1 is added to the information cache shown, a timestamp representing the reception of the NVMe read command 1 is recorded. The delay time corresponding to the NVMe read command 1 is obtained according to the difference between the current time and the timestamp.

[0168] Combination Figure 3-Figure 13 The embodiment shown, as Fig.14 As shown, the cache unit management method of the storage device in the embodiment of the present application includes:

[0169] Step S1401: In response to receiving an IO command, obtain address location information indicated by the IO command and add it to the allocated cache unit. The address location information includes a PRP entry, an SGL descriptor, and a host memory address determined according to the PRP entry or the SGL descriptor. The number of the PRP entry, the SGL descriptor, and the host memory address determined according to the PRP entry or the SGL descriptor can be one or more.

[0170] Step S1402: If the IO command is an NVMe write command, in response to generating a DMA command according to the address location information indicated by the NVMe write command, release the cache unit occupied by the target address location information.

[0171] Step S1403: If the IO command is an NVMe read command, in response to receiving a storage command processing completion message, if the address location information indicated by the storage command processing completion message has been used the same number of times as the expected number of times, release the cache unit occupied by the address location information indicated by the storage command processing completion message; wherein the storage command indicated by the storage command processing completion message is generated based on the NVMe read command.

[0172] Step S1404: If the IO command is an NVMe read command, in response to receiving a storage command processing completion message, if the number of times the address location information indicated by the storage command processing completion message has been used is less than the expected number of times, the cache unit occupied by the address location information indicated by the storage command processing completion message is not released, and the number of times the address location information indicated by the storage command processing completion message has been used is controlled to be increased by 1.

[0173] Step S1405: If the IO command is an NVMe read command, in response to receiving a storage command processing completion message, if the address location information indicated by the storage command processing completion message has been used a number of times greater than the expected number of times, it is determined that there is an erroneous storage command processing completion message.

[0174] Step S1406: If the IO command is an NVMe read command, in response to the delay time corresponding to the NVMe read command being greater than or equal to a specified value, and the cache units occupied by the address location information indicated by the NVMe read command have not been fully released, it is determined that there is an erroneous storage command processing completion message, wherein the delay time corresponding to the NVMe read command is equal to the difference between the current time and the timestamp of the NVMe read command.

[0175] The cache unit management method of the storage device in the embodiment of the present application can timely release the address location information indicated by the IO command in the cache unit, provide a cache unit for the address location information indicated by other IO commands, improve cache utilization, and at the same time can detect whether there is an error in the storage command processing completion message during the process of releasing the cache unit.

[0176] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application. Obviously, those skilled in the art may make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A cache unit management method, characterized in that: include: In response to receiving an NVMe read command, each first address location information indicated by the NVMe read command is added to the allocated cache unit and a first number of storage command processing completion messages corresponding to each first address location information received is recorded; In response to receiving a storage command processing completion message, the expected number of times the second address location information indicated by the storage command processing completion message is used and the second number of times the storage command processing completion message corresponding to the second address location information has been recorded, determining whether to release the cache unit occupied by the second address location information and determining whether there is an erroneous storage command processing completion message.

2. The method according to claim 1, characterized in that in: If the expected number of times the second address location information is used is equal to the sum of the value of the second number and 1, releasing the cache unit occupied by the second address location information; If the expected number of times the second address location information is used is greater than the sum of the value of the second number and 1, the cache unit occupied by the second address location information is not released, and the value of the second number is controlled to increase by 1; If the expected number of times the second address location information is used is less than the sum of the value of the second number and 1, it is determined that there is an erroneous storage command processing completion message.

3. The method according to claim 1 or 2, characterized in that: The method also includes: when the expected number of times each first address location information indicated by the NVMe read command is used is not greater than 2, using a 1-bit memory to record the first number of storage command processing completion messages corresponding to the first address location information that have been received.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: According to the first number of storage command processing completion messages expected to be received by the NVMe read command and the second number of storage command processing completion messages corresponding to the NVMe read command that have been received, determine whether there is an error in the storage command processing completion message corresponding to the received NVMe read command.

5. The method according to claim 4, characterized in that If the second number is greater than the first number, it is determined that there is an error in the storage command processing completion message corresponding to the received NVMe read command.

6. The method according to claim 4, characterized in that If the first number is equal to the second number, determine whether there is an error in the storage command processing completion message corresponding to the received NVMe read command based on the first logical address corresponding to the expected storage command processing completion message of each first address location information and the second logical address corresponding to the received storage command processing completion message indicating the each first address location information.

7. The method according to claim 6, characterized in that If there is at least one first logical address corresponding to the first address location information that is different from the second logical address, it is determined that there is an error in the storage command processing completion message corresponding to the received NVMe read command.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: If the first delay time corresponding to the NVMe read command is greater than or equal to a specified value, and the cache unit occupied by the first address location information corresponding to the NVMe read command has not been fully released, it is determined that there is an erroneous storage command processing completion message.

9. The method according to claim 8, characterized in that The method further comprises: Record a first timestamp of receiving the NVMe read command, calculate a first difference between the current time and the first timestamp, and use the first difference as a first delay time corresponding to the NVMe read command.

10. A storage device, comprising a host command processing unit, characterized in that: The host command processing unit includes a cache unit, a circuit for writing into the cache unit, and a circuit for releasing the cache unit, wherein the circuit for releasing the cache unit includes a first memory: The circuit of the write cache unit is used to add each first address location information indicated by the NVMe read command to the allocated cache unit in response to receiving the NVMe read command; The first memory is used to record the first number of storage command processing completion messages corresponding to each of the first address location information that has been received; The circuit for releasing the cache unit is used to determine whether to release the cache unit occupied by the second address location information and determine whether there is an erroneous storage command processing completion message based on the expected number of times the second address location information indicated by the storage command processing completion message is used and the second number of times the storage command processing completion message corresponding to the second address location information has been received.

Citation Information

Patent Citations

  • Method for data access and controller for data writing

    CN113485643A

  • Method for controlling data to be read to host, and controller

    CN113515234A

  • NVMe write IO initiating circuit of NVMe controller

    CN119229912A

  • NVMe read IO initiating circuit of NVMe controller

    CN119229913A

Cited By

  • Simulation excitation generation method and device, electronic equipment and storage medium

    CN120068752A