Data processing method, device and equipment and readable storage medium
By extending the CETYPE field of NVMe I/O commands, defining the Cacheable Per I/O characteristic, determining and processing the caching mode, the problem of caching algorithms in NVMe devices being incompatible with diverse scenarios is solved, improving caching performance and adaptability.
Patent Information
- Application Number
- CN202511308473.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-09-15
AI Technical Summary
Different caching algorithms in NVMe devices are incompatible with various scenarios, causing VWC to fail to achieve its maximum performance.
By extending the CETYPE field of NVMe I/O commands in NVMe devices, the Cacheable Per I/O feature is defined. The data cache flag of the data to be processed is determined by using the command extension type field in the read and write commands, the corresponding cache mode is determined, and the data is processed according to the matching cache strategy.
It enables NVMe devices to flexibly adapt caching strategies in multiple scenarios, improving cache hit rate and performance, and meeting the needs of different host applications.
Smart Images

Figure CN120803375A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a data processing method, device, equipment and readable storage medium. BACKGROUND
[0002] The NVMe (Non-Volatile Memory Express) controller realizes the response of fast writing through VWC (Volatile Write Cache).
[0003] Because the VWC capacity is limited, it cannot save a large amount of data for a long time, so it is necessary to implement cache eviction algorithm and hot and cold data management, and to keep hot data in the cache as much as possible and discard some data to non-volatile media in time.
[0004] Different cache algorithms in the NMVe device cannot be compatible with various scenarios, resulting in the inability to maximize the performance of the VWC.
[0005] To sum up, how to effectively solve the problems of cache data management and the like is a technical problem that the technical personnel in the field urgently need to solve at present. SUMMARY
[0006] The purpose of the present application is to provide a data processing method, device, equipment and readable storage medium, which can realize the control of the host on the VWC behavior in the NVMe device, so that the NVMe device can be compatible with the requirements of multiple scenarios, and the VWC can maximize the performance.
[0007] To solve the above technical problems, the present application provides the following technical solutions.
[0008] The present application provides a data processing method, comprising: receiving a read-write command sent by a host based on a non-volatile memory host controller interface protocol; in the process of analyzing the read-write command to determine the data to be processed, determining the data cache mark of the data to be processed by using the command extension type field in the read-write command; determining the cache mode corresponding to the data cache mark; processing the data to be processed according to the cache strategy matched with the cache mode, and responding to the host.
[0009] Preferably, the to-be-processed data is processed and a response is fed back to the host according to a cache strategy matched with the cache mode, including: in the case that the cache mode is a forced cache mode, obtaining a cache hit status of the to-be-processed data; in the case that the read-write command is a write command, if the to-be-processed data is all cache hit, modifying the cache data and then feeding back a response of data being written to the host; in the case that the read-write command is a write command, if the to-be-processed data is partially cache hit or cache miss, a new cache space is forced to be applied, and after the to-be-processed data is written in the cache space, a response of data being written is fed back to the host; in the case that the read-write command is a read command, if the to-be-processed data is all cache hit, the to-be-processed data is read from the cache and fed back to the host; in the case that the read-write command is a read command, if the to-be-processed data is partially cache hit or cache miss, a new cache space is forced to be applied, and after the to-be-processed data in the non-volatile medium is moved to the cache space, the to-be-processed data is read from the cache and fed back to the host.
[0010] Preferably, the forced application of the new cache space includes: determining whether the current cache is sufficient; if the cache is sufficient, a new cache space is applied from the cache; if the cache is insufficient, old data in the cache is evicted, and after the old data is evicted, a new cache space is applied from the cache.
[0011] Preferably, the evicting of the old data in the cache includes: deleting the old data written first in the cache.
[0012] Preferably, the evicting of the old data in the cache includes: obtaining a latest access timestamp of data in the cache; determining the old data to be evicted by using the latest access timestamp; and deleting the old data from the cache.
[0013] Preferably, the evicting of the old data in the cache includes: obtaining an access frequency of data in the cache; determining the old data to be evicted by using the access frequency; and deleting the old data from the cache.
[0014] Preferably, the to-be-processed data is processed and a response is fed back to the host according to a cache strategy matched with the cache mode, including: in the case that the cache mode is a bypass cache mode, the to-be-processed data is processed by bypassing the cache and a response is fed back to the host.
[0015] Preferably, the to-be-processed data is processed bypassing the cache and a response is fed back to the host, including: in the case that the read-write command is a write command, after the to-be-processed data is written into the non-volatile medium, a response is fed back to the host that the data has been written; in the case that the read-write command is a read command, the to-be-processed data is read from the non-volatile medium and the to-be-processed data is fed back to the host.
[0016] Preferably, the to-be-processed data is processed according to the cache strategy matching the cache mode and a response is fed back to the host, including: in the case that the cache mode is a try-cache mode, a cache hit state of the to-be-processed data is acquired; in the case that the read-write command is a write command, if the to-be-processed data all hit the cache, after the cache data is modified, a response is fed back to the host that the data has been written; in the case that the read-write command is a write command, if the to-be-processed data partially hit the cache or did not hit the cache, after the to-be-processed data is written into the non-volatile memory, a response is fed back to the host that the data has been written, and a new cache space is tried to be applied for and the to-be-processed data located in the non-volatile medium is moved to the cache space; in the case that the read-write command is a read command, if the to-be-processed data all hit the cache, the to-be-processed data is read from the cache and fed back to the host; in the case that the read-write command is a read command, if the to-be-processed data partially hit the cache or did not hit the cache, a new cache space is tried to be applied for and the to-be-processed data located in the non-volatile medium is moved to the cache space, and the to-be-processed data is read from the non-volatile medium or the cache and fed back to the host.
[0017] Preferably, the new cache space is tried to be applied for, including: determining whether the current cache is sufficient; if the cache is sufficient, a new cache space is applied for from the cache; if the cache is insufficient, the application for the new cache space is abandoned.
[0018] Preferably, the to-be-processed data is processed according to the cache strategy matching the cache mode and a response is fed back to the host, including: in the case that the cache mode is a default mode, the to-be-processed data is processed according to a default cache strategy and a response is fed back to the host.
[0019] Preferably, the to-be-processed data is processed according to the default cache strategy, including: the to-be-processed data is cached according to a first-in-first-out.
[0020] Preferably, the to-be-processed data is processed according to the default cache strategy, including: a latest access time stamp of the to-be-processed data is acquired; the to-be-processed data is cached according to the latest access time stamp.
[0021] Preferably, the default cache strategy is used to process the to-be-processed data, comprising: obtaining the access frequency of the to-be-processed data; and performing cache processing on the to-be-processed data according to the access frequency.
[0022] Preferably, the read-write command sent by the host based on the non-volatile memory host controller interface protocol comprises: a read-write command sent by the host according to the data cache requirement of the to-be-processed data; the data cache requirement corresponds to the data cache mark, and the data cache mark is carried in the command extension type field of the read-write command.
[0023] Preferably, the data cache mark of the to-be-processed data is determined by using the command extension type field in the read-write command, comprising: reading the extension bit in the command extension type field to obtain an extension value; and determining the data cache mark corresponding to the extension value according to the mapping relationship between the extension value and the data cache mark.
[0024] Preferably, the extension bit in the command extension type field is read to obtain an extension value, comprising: reading the value in the command extension type field; if the value corresponds to the opening of the cache customization function, the extension bit in the command extension type field is read to obtain the extension value.
[0025] The application provides a data processing device, comprising: a command receiving module, configured to receive a read-write command sent by a host based on a non-volatile memory host controller interface protocol; a mark determining module, configured to determine the data cache mark of to-be-processed data by using the command extension type field in the read-write command in the process of analyzing the read-write command; a mode determining module, configured to determine the cache mode corresponding to the data cache mark; and a processing response module, configured to process the to-be-processed data according to the cache strategy matched with the cache mode, and to respond to the host.
[0026] The application provides an electronic device, comprising: a memory, configured to store a computer program; and a processor, configured to execute the computer program to realize the steps of the above data processing method.
[0027] The application provides a readable storage medium, wherein the readable storage medium stores a computer program, and the computer program is executed by a processor to realize the steps of the above data processing method.
[0028] The application provides a computer program product, comprising a computer program, and the computer program is executed by a processor to realize the steps of any one of the above data processing methods.
[0029] The method provided by the embodiment of the application is used for receiving a read-write command sent by a host based on a non-volatile memory host controller interface protocol; in the process of analyzing the read-write command to determine the data to be processed, the data cache mark of the data to be processed is determined by using the command extension type field in the read-write command; the cache mode corresponding to the data cache mark is determined; the data to be processed is processed according to the cache strategy matched with the cache mode, and a response is sent to the host.
[0030] In the application, after receiving the read-write command sent by the host based on NVME, the read-write command is analyzed. In the process of analyzing the read-write command to determine the data to be processed, the data cache mark of the data to be processed is determined by using the command extension type field in the read-write command. That is, the host carries the corresponding data cache mark when sending the read-write command. Based on the data cache mark, the corresponding cache mode can be determined, and the data to be processed is processed based on the cache strategy matched with the cache mode in the process of processing the data to be processed, and a response is sent to the host. Since the host is the subject of reading and writing data, the cache requirement of the data is the most explicit. Processing the data to be processed based on the cache strategy corresponding to the cache data mark can make the cache effect more consistent with the cache requirement of the host side for the data.
[0031] That is, in the application, the read-write command sent by the host can control the VWC behavior in the NVMe device, so that the NVMe device can be compatible with the requirements of multiple scenes, and the VWC can play the maximum performance.
[0032] Correspondingly, the embodiment of the application also provides a data processing method, a data processing device, a readable storage medium and a computer program product corresponding to the above-mentioned data processing method, which have the above-mentioned technical effects, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the application or the related art, the following will briefly introduce the drawings needed to be used in the embodiments or the related art description. Obviously, the drawings in the following description only some embodiments of the application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0034] Figure 1 The implementation flowchart of a data processing method in the embodiment of the application; Figure 2 The data reading schematic diagram in the embodiment of the application; Figure 3 The data writing schematic diagram in the embodiment of the application; Figure 4It is a structural schematic diagram of a data processing device in an embodiment of the present application. Figure 5 It is a structural schematic diagram of an electronic device in an embodiment of the present application. Figure 6 It is a structural schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the personnel in the technical field better understand the present application scheme, the present application is further described in detail below in combination with the drawings and specific embodiments. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0036] In order to facilitate understanding, the related art is explained and described below.
[0037] NVMe: (Non-Volatile Memory Express, Non-Volatile Memory Host Controller Interface Specification) is a high-performance interface protocol for accessing non-volatile storage media (such as solid state disk SSD). It is designed for solid state disk, with high performance (supporting multiple queues and high concurrency operation, which can significantly improve the speed of data transmission), low delay (compared with traditional SATA protocol, NVMe has lower delay).
[0038] VWC: is the abbreviation of Volatile Write Cache (volatile write cache), which is a cache mechanism existing in the storage controller. Its main function is to improve the performance of data writing. In the NVMe (Non-Volatile Memory Express) protocol, VWC is located in the information structure of the controller, which is used to indicate whether the controller supports volatile write cache. When VWC is enabled, the write operation is first cached in volatile storage, which can speed up the write speed and reduce the write operation to non-volatile storage medium, thereby prolonging its life.
[0039] NVMe Namespace: namespace is a logical storage area, which divides the non-volatile storage space of NVMe device into multiple independent logical blocks (Logical Blocks), and each logical block can be formatted and presented as a standard block device. In Linux system, each namespace usually appears as an independent block device.
[0040] The standard NVMe command format is shown in Table 1, which is a standard NVMe command format table.
[0041] Table 1
[0042] NVMe TP4055 specification defines a command extension type (Command Extension Type) and command extension value (Command Extension Value) in the CDW13 field of the NVMe command, which is defined as shown in Table 2, which is a CDW13 field schematic table.
[0043] Table 2
[0044] Among them, the CETYPE value of bits 19:16 is defined as shown in Table 3, which is a CETYPE schematic table.
[0045] Table 3
[0046] The NVMe controller implements a fast write response through VWC. VWC essentially uses volatile storage media (such as DRAM) as a cache layer, allowing the host to complete the operation directly through the cache when writing data, without waiting for the data to be persisted to non-volatile storage media (such as NAND flash). This mechanism significantly reduces write latency, especially in high-concurrency random write scenarios.
[0047] Because the VWC has limited capacity and cannot store a large amount of data for a long time, it is necessary to implement a cache eviction algorithm and cold and hot data management to keep hot data in the cache as much as possible. At the same time, due to the size limit of the cache, some data needs to be evicted to non-volatile media in time when the cache capacity is insufficient.
[0048] LRU (Least Recently Used) algorithm, which considers that the data recently accessed has a higher probability of being accessed in the future, while the data that has not been accessed for a long time has a lower probability of being accessed in the future. Therefore, when the cache data is insufficient, the data that has not been accessed for the longest time is preferentially evicted.
[0049] LFU (Least Frequently Used) algorithm, which maintains a frequency counter of data access. When the cache space is insufficient, the data with the lowest access frequency is preferentially evicted.
[0050] FIFO (First In First Out) algorithm, which maintains a first-in first-out queue. When the cache space is insufficient, the cache data that enters the queue first is preferentially evicted.
[0051] Different cache algorithms in the NMVe device cannot be compatible with various scenarios. For example, when the application performs cyclic access to a large amount of data, the LRU algorithm can cause frequent cache replacement and almost no hit, resulting in a decrease in performance data. In the random access mode scenario, the LFU cannot effectively distinguish between hot and cold data, causing the cache to be frequently replaced and reducing the hit probability.
[0052] Different host applications have different requirements for cache strategies. For example, a database application may require more stringent data persistence guarantees, and a streaming application may focus more on performance. The cache algorithm of the device cannot flexibly adapt to these diverse host application requirements and may not be able to maximize the performance of the VWC.
[0053] In view of the above situation, in combination with the existing command set specification of NVMe, the present application considers extending from the command level to allow the host to control the cache strategy of the VWC. Specifically, please refer to Figure 1 , Figure 1 A flowchart of a data processing method in an embodiment of the present application, the method can be applied in an NVMe device, and the method comprises the following steps.
[0054] S101, receiving a read-write command sent by a host based on a non-volatile memory host controller interface protocol.
[0055] When the host needs to write data or read data to the NVMe device, a read-write command, i.e., a read command or a write command, can be sent based on the NVMe protocol. Specifically, the host can send the read-write command to the NVMe controller through the submission queue member.
[0056] In a specific embodiment of the present application, receiving a read-write command sent by a host based on a non-volatile memory host controller interface protocol comprises: receiving a read-write command sent by the host according to the data cache requirement of the to-be-processed data; the data cache requirement corresponds to a data cache mark, and the data cache mark is carried in a command extension type field of the read-write command.
[0057] Specifically, the host can send a command carrying a data cache mark to the NVMe device according to the specific cache requirement of the to-be-processed data corresponding to the current read-write command.
[0058] The data cache mark can be used to inform the NVMe device whether the to-be-processed data needs to be cached and the degree of cache requirement. For example, it is necessary to cache, or it is not necessary to cache, or it is cacheable or not cacheable, or the host does not specify the cache requirement.
[0059] Specifically, the CETYPE field of CDW13 (Command Double Word 13 in the NVMe protocol) in the NVMe I / O read and write command can be extended, and the Cacheable Per I / O (CPIO) feature is defined to realize the control of the host on the VWC behavior in the NVMe device. The extended command definition of the feature is shown in Table 4, which is an extended CETYPE table.
[0060] Table 4
[0061] In the I / O command, the CETYPE value of the CDW13 field is 2, which indicates that the Cacheable Per I / O capability is enabled, and the CEV in the CDW13 can be defined according to actual needs. For example, 00b corresponds to the default mode, 01b corresponds to the bypass cache mode, 10b corresponds to the forced cache mode, and 11b corresponds to the best effort mode.
[0062] In the process of parsing the read and write command to determine the data to be processed, the data cache mark of the data to be processed is determined by using the command extension type field in the read and write command.
[0063] After the NVMe device receives the read and write command sent by the host, the read and write command can be parsed to determine the data to be processed and whether to encrypt, determine the key and other operations.
[0064] It should be noted that in the embodiment, in the process of parsing the read and write command to determine the data to be processed, the data cache mark of the data to be processed is determined by using the command extension type field in the read and write command.
[0065] The data cache mark, that is, marks the data to be processed to be processed in which mode. For example, whether it needs to be cached, and if it needs to be cached, the strength of the cache is determined.
[0066] In a specific embodiment of the present application, the data cache mark of the data to be processed is determined by using the command extension type field in the read and write command, which includes: reading the extension bit in the command extension type field to obtain an extension value; and determining the data cache mark corresponding to the extension value according to the mapping relationship between the extension value and the data cache mark.
[0067] In the process of parsing the read and write command to determine the data to be processed, the data cache mark of the data to be processed is determined by using the command extension type field in the read and write command.
[0068] For example, when the CETYPE of the CDW13 field in the I / O command is 2, it indicates that the Cacheable Per I / O function is enabled, and the extension value of the CEV in the CDW13 corresponds to the data cache tag. When the CETYPE of the CDW13 field in the I / O command is not 2, it indicates that the Cacheable Per I / O function is not enabled, and the extension value of the CEV in the CDW13 does not need to be read, and at this time, the default cache model can be used for processing.
[0069] S103, determining a cache mode corresponding to the data cache tag.
[0070] The data cache tag and different cache modes can be set to have a mapping relationship, and different cache modes can have different cache processing strategies for data, which can be set according to actual conditions. The cache mode can be set to at least two kinds, so as to adopt the corresponding cache mode for different data.
[0071] For example, the data cache tag is 00b, indicating that the cache mode is the default mode; the data cache tag is 01b, indicating that the cache mode is the bypass cache mode; the data cache tag is 10b, indicating that the cache mode is the forced cache mode; and the data cache tag is 11b, indicating that the cache mode is the attempt cache mode.
[0072] S104, processing the to-be-processed data according to the cache strategy matched with the cache mode, and responding to the host.
[0073] Different cache modes can be set to have different cache strategies, and the specific setting of the cache strategy can be set differently according to different actual business scenarios.
[0074] After the cache mode corresponding to the to-be-processed data is determined, the to-be-processed data can be processed according to the cache strategy matched with the cache mode, and the host is responded. If the read-write command is a read command, the host is responded, which can be feeding back the read data to the host, and the read data is the to-be-processed data; if the read-write command is a write command, the host is responded, which can be feeding back the write data to the host after the data is written, or feeding back the write failure to the host in the case of write failure.
[0075] In one specific embodiment of the present application, the data to be processed is processed according to a cache strategy matching the cache mode, and a response is fed back to the host, including: in the case of the cache mode being a forced cache mode, obtaining a cache hit state of the data to be processed; in the case of the read-write command being a write command, if the data to be processed is all cache hit, after the cache data is modified, a response that the data has been written is fed back to the host; in the case of the read-write command being a write command, if the data to be processed is partially cache hit or cache miss, a new cache space is forced to be applied, and after the data to be processed is written in the cache space, a response that the data has been written is fed back to the host; in the case of the read-write command being a read command, if the data to be processed is all cache hit, the data to be processed is read from the cache, and the data to be processed is fed back to the host; in the case of the read-write command being a read command, if the data to be processed is partially cache hit or cache miss, a new cache space is forced to be applied, and after the data to be processed in the non-volatile medium is moved to the cache space, the data to be processed is read from the cache, and the data to be processed is fed back to the host.
[0076] For the convenience of description, the above steps are described in combination.
[0077] When the cache mode is a forced cache mode, it indicates that the data to be processed must be cached. First, the cache hit state of the data to be processed can be determined.
[0078] If the read-write request is a write command, and the cache hit state is that the data to be processed is all cache hit, a response that the data has been written can be fed back to the host immediately after the cache data is modified. If the read-write request is a write command, but the data to be processed is not all cache hit at this time, a new cache space can be forced to be applied, and after the data to be processed is written in the new cache space, a response that the data has been written is fed back to the host, so as to ensure that the data is written in the cache.
[0079] If the read-write command is a read command, and the data to be processed is all cache hit, the data to be processed can be directly read from the cache, and the data to be processed is fed back to the host. If the read-write command is a read command, and the data to be processed is not all cache hit, a new cache space can be forced to be applied, and after the data to be processed in the non-volatile medium is moved to the cache space, the data to be processed is read from the cache, and the data is fed back to the host, so as to ensure that the data is stored in the cache.
[0080] In one specific embodiment of the present application, the forced application of a new cache space includes: determining whether the current cache is sufficient; if the cache is sufficient, a new cache space is applied from the cache; if the cache is insufficient, old data in the cache is discarded, and after the old data is discarded, a new cache space is applied from the cache.
[0081] That is, whether the current cache is sufficient or not, new cache space is applied to store the to-be-processed data. When the cache is sufficient, new cache space is directly applied from the cache; when the cache is insufficient, old data in the cache needs to be evicted first, and after sufficient space is vacated by evicting the old data, new cache space is applied from the cache.
[0082] In the case of insufficient cache space, the specific old data eviction mechanism is not specifically limited in the embodiment.
[0083] In a specific embodiment of the application, evicting old data in the cache includes deleting the oldest old data in the cache. That is, the old data to be deleted in the cache can be determined based on the first-in-first-out mode.
[0084] In a specific embodiment of the application, evicting old data in the cache includes obtaining the latest access timestamp of the data in the cache, determining the old data to be evicted using the latest access timestamp, and deleting the old data from the cache. That is, when evicting old data, the longest accessed data can be deleted based on the sorting of the latest access timestamp.
[0085] In a specific embodiment of the application, evicting old data in the cache includes obtaining the access frequency of the data in the cache, determining the old data to be evicted using the access frequency, and deleting the old data from the cache. That is, when evicting old data, the data with the lowest access frequency can be deleted based on the sorting of the access frequency.
[0086] In a specific embodiment of the application, the to-be-processed data is processed according to the cache strategy matched with the cache mode, and a response is fed back to the host, including: in the case of a bypass cache mode, the to-be-processed data is processed by bypassing the cache, and a response is fed back to the host. The bypass cache mode is to read and write the to-be-processed data by bypassing the cache, thereby avoiding occupying the cache. That is, the bypass cache mode is to close the cache mechanism for the to-be-processed data.
[0087] In a specific embodiment of the application, the to-be-processed data is processed by bypassing the cache, and a response is fed back to the host, including: in the case of a write command, the to-be-processed data is written into the non-volatile medium, and a response is fed back to the host that the data has been written; in the case of a read command, the to-be-processed data is read from the non-volatile medium, and a response is fed back to the host.
[0088] That is, for read and write data, the cache is directly skipped, and the non-volatile medium is directly written and read, without the need to write the to-be-processed data into the cache, thereby reducing the occupation of cache resources.
[0089] In one specific embodiment of the present application, the data to be processed is processed and a response is fed back to the host according to the cache strategy matched with the cache mode, including: in the case that the cache mode is the try cache mode, obtaining the cache hit state of the data to be processed; in the case that the read-write command is a write command, if the data to be processed is all cache hit, modifying the cache data and then feeding back to the host a response that the data has been written; in the case that the read-write command is a write command, if the data to be processed is partially cache hit or cache miss, writing the data to be processed in the non-volatile memory, feeding back to the host a response that the data has been written, and trying to apply for new cache space and move the data to be processed in the non-volatile medium to the cache space; in the case that the read-write command is a read command, if the data to be processed is all cache hit, reading the data to be processed from the cache and feeding back to the host the data to be processed; in the case that the read-write command is a read command, if the data to be processed is partially cache hit or cache miss, trying to apply for new cache space, moving the data to be processed in the non-volatile medium to the cache space, and reading the data to be processed from the non-volatile medium or the cache and feeding back to the host the data to be processed.
[0090] That is, in the try cache mode (i.e. the best-effort cache mode), when writing data, the controller will try to write the data into the cache as much as possible, but even if part or all of the data does not enter the cache due to the algorithm of the controller itself or the insufficient cache capacity, etc., this controller behavior is consistent with the host's expectation, and there is no need to forcibly apply for cache space; when reading data, if all hit, the data is read from the cache to the host; if partially hit or miss, new cache space is tried to be applied for for the miss data and the data in the non-volatile medium is read, and if the space is insufficient, the controller behavior can refer to the bypass cache mode, i.e. the data to be processed can be read from the non-volatile medium.
[0091] In one specific embodiment of the present application, the try to apply for new cache space includes: determining whether the current cache is sufficient; if the cache is sufficient, applying for new cache space from the cache; and if the cache is insufficient, giving up applying for new cache space.
[0092] That is, when the cache is sufficient, new cache space can be applied for, and in the case that the cache is insufficient, there is no need to forcibly apply for new cache space.
[0093] In one specific embodiment of the present application, the data to be processed is processed and a response is fed back to the host according to the cache strategy matched with the cache mode, including: in the case that the cache mode is the default mode, the data to be processed is processed and a response is fed back to the host according to the default cache strategy.
[0094] In the default mode, the host does not specify the cache requirement of the data to be processed, and the controller in the NVMe can process the data to be processed according to the default cache strategy and respond to the host. In the embodiment, the algorithm used for the default cache strategy to manage the data is not limited.
[0095] In one specific embodiment of the present application, processing the data to be processed according to the default cache strategy includes: processing the data to be processed according to the first-in first-out. That is, the cache processing is based on the FIFO (First In First Out) algorithm, which maintains a first-in first-out queue, and when the cache space is insufficient, the cache data that enters the queue first is preferentially eliminated.
[0096] In one specific embodiment of the present application, processing the data to be processed according to the default cache strategy includes: obtaining the latest access timestamp of the data to be processed; and processing the data to be processed according to the latest access timestamp. That is, the cache processing is based on the LRU (Least Recently Used) algorithm, which considers that the data recently accessed has a higher probability of being accessed in the future, and the data not accessed for a long time has a lower probability of being accessed in the future. Therefore, when the cache data is insufficient, the data not accessed for the longest time is preferentially eliminated.
[0097] In one specific embodiment of the present application, processing the data to be processed according to the default cache strategy includes: obtaining the access frequency of the data to be processed; and processing the data to be processed according to the access frequency.
[0098] That is, the cache processing is based on the LFU (Least Frequently Used) algorithm, which maintains a frequency counter of data access, and when the cache space is insufficient, the data with the lowest access frequency is preferentially eliminated.
[0099] By applying the method provided by the embodiment of the present application, the read-write command sent by the host based on the non-volatile memory host controller interface protocol is received; in the process of analyzing the read-write command to determine the data to be processed, the data cache mark of the data to be processed is determined by using the command extension type field in the read-write command; the cache mode corresponding to the data cache mark is determined; and the data to be processed is processed according to the cache strategy matched with the cache mode, and the host is responded.
[0100] In the present invention, after receiving the read and write commands sent by the host based on NVME, the read and write commands are parsed. In the process of parsing the read and write commands to determine the data to be processed, the command extension type field in the read and write commands will be used to determine the data cache tag of the data to be processed. That is to say, when the host sends the read and write commands, it will let the read and write commands carry the corresponding data cache tag. Based on the data cache tag, the corresponding cache mode can be determined. In the process of processing the data to be processed, the data to be processed will be processed based on the cache strategy that matches the cache mode, and a response will be given to the host. Since the host is the subject that reads and writes the data, the cache requirements for the data are the most clear. Processing the data to be processed based on the cache strategy corresponding to the cache data tag can make the cache effect more in line with the host side's cache requirements for the data.
[0101] That is to say, in the present invention, the read and write commands sent by the host can control the behavior of the VWC in the NVMe device, so that the NVMe device can be compatible with the requirements of multiple scenarios and the VWC can achieve maximum performance.
[0102] To facilitate those skilled in the art to better understand and implement the data processing method provided by the embodiment of the present invention, the data processing method is described in detail below with reference to a specific application scenario as an example.
[0103] When a host needs to read or write data, it obtains the characteristics of the data being processed and determines the cache requirements for the data based on these characteristics. When generating read or write commands, based on this cache requirement, it extends the CETYPE field in the CDW13 field of the NVMe I / O command and assigns a corresponding extended value in the CEV based on the cache requirements. Because the host has a better understanding of the characteristics of the data being processed, such as whether it is critical data or hot data, it can effectively distinguish whether subsequent accesses will be frequent, which helps improve the cache command rate. For data with high reliability requirements, it can control the NVMe controller to skip caching to ensure data consistency. Specifically, for the host, please refer to Table 5, which shows the correspondence between host scenarios and CPIO modes. Different CPIO (Cacheable Per I / O) configurations can be selected based on different scenarios.
[0104] Table 5
[0105] Please refer to Figure 2In the process of data reading, the data processing method provided by the embodiment of the application is implemented, and the process includes: a host computer submits a read I / O command, and an extended value of CPIO is selected according to a specific scene of the I / O data; the value of the extended value can be referred to Table 5; an NVMe controller analyzes the command; the values of CETYPE and CEV are passed to a cache management module (cache line mgt); and the controller uses different cache strategies according to the value of CEV to send data to the host computer.
[0106] Please refer to Figure 3 In the process of data writing, the data processing method provided by the embodiment of the application is implemented, and the process includes: a host computer submits a write I / O command, and an extended value of CPIO is selected according to a specific scene of the I / O data; the value of the extended value can be referred to Table 5; an NVMe controller analyzes the command; the values of CETYPE and CEV are passed to a cache management module (cache line mgt); and the controller uses different cache strategies to process write data and reply to the host computer according to the value of CEV.
[0107] By extending the NVMe command, a Cacheable Per I / O feature is defined, different cache strategies are defined for each specific I / O, so as to achieve the purpose of controlling the internal cache of the controller by the host computer. Specifically, the CPIO extended command: the CETYPE in the CDW13 field of the NVMe I / O command is extended, and if it is 2h, it indicates that the CPIO feature is enabled. CPIO cache strategy: different strategies of the NVMe device cache and different values of CEV in the CDW13 field of the I / O command are defined, such as default mode, bypass mode, forced mode and best effort mode.
[0108] The host computer can flexibly control the caching of specific data in the NVMe device according to different specific data application scenes and different cold and hot degrees, improve the utilization rate of the cache in the NVMe device, increase the adaptability of the NVMe device to different application scenes, and improve the overall execution efficiency of the system.
[0109] Corresponding to the above method embodiment, the embodiment of the application also provides a data processing device, and the data processing device described below can be mutually referred to the data processing method described above.
[0110] Please refer to Figure 4 The device includes the following modules.
[0111] The command receiving module 101 is configured to receive a read / write command sent by a host computer based on a non-volatile memory host controller interface protocol.
[0112] The marking determination module 102 is configured to determine the data cache marking of the data to be processed by using the command extension type field in the read-write command in the process of analyzing the read-write command to determine the data to be processed.
[0113] The mode determination module 103 is configured to determine the cache mode corresponding to the data cache marking.
[0114] The processing response module 104 is configured to process the data to be processed according to the cache strategy matched with the cache mode, and respond to the host.
[0115] The apparatus provided by the embodiment of the application receives the read-write command sent by the host based on the NVMe, determines the data cache marking of the data to be processed by using the command extension type field in the read-write command in the process of analyzing the read-write command to determine the data to be processed, determines the cache mode corresponding to the data cache marking, processes the data to be processed according to the cache strategy matched with the cache mode, and responds to the host.
[0116] In the application, after receiving the read-write command sent by the host based on the NVMe, the read-write command is analyzed. In the process of analyzing the read-write command to determine the data to be processed, the data cache marking of the data to be processed is determined by using the command extension type field in the read-write command. That is, the host carries the corresponding data cache marking when sending the read-write command. Based on the data cache marking, the corresponding cache mode can be determined, and in the process of processing the data to be processed, the data to be processed is processed based on the cache strategy matched with the cache mode, and the host is responded. Since the host is the subject of reading and writing data, the cache requirement of the data is the most explicit. The data to be processed is processed based on the cache strategy corresponding to the cache data marking, which can make the cache effect more consistent with the cache requirement of the host side for the data.
[0117] That is, in the application, the read-write command sent by the host can control the VWC behavior in the NVMe device, so that the NVMe device can be compatible with the requirements of multiple scenes, and the VWC can play the maximum performance.
[0118] In one specific embodiment of the present application, the processing and response module is specifically configured to: in the case that the cache mode is a forced cache mode, acquire a cache hit state of the to-be-processed data; in the case that the read-write command is a write command, if the to-be-processed data all hit the cache, after modifying the cache data, feed back to the host a response that the data has been written; in the case that the read-write command is a write command, if the to-be-processed data partially hit the cache or did not hit the cache, forcibly apply for a new cache space, and after writing the to-be-processed data in the cache space, feed back to the host a response that the data has been written; in the case that the read-write command is a read command, if the to-be-processed data all hit the cache, read the to-be-processed data from the cache, and feed back to the host the to-be-processed data; in the case that the read-write command is a read command, if the to-be-processed data partially hit the cache or did not hit the cache, forcibly apply for a new cache space, and after moving the to-be-processed data located in the non-volatile medium to the cache space, read the to-be-processed data from the cache, and feed back to the host the to-be-processed data.
[0119] In one specific embodiment of the present application, the processing and response module is specifically configured to: determine whether the current cache is sufficient; if the cache is sufficient, apply for a new cache space from the cache; if the cache is insufficient, eliminate old data in the cache, and after eliminating the old data, apply for a new cache space from the cache.
[0120] In one specific embodiment of the present application, the processing and response module is specifically configured to delete the old data written first in the cache.
[0121] In one specific embodiment of the present application, the processing and response module is specifically configured to: acquire a most recently accessed time stamp of the data in the cache; determine the old data to be eliminated by using the most recently accessed time stamp; and delete the old data from the cache.
[0122] In one specific embodiment of the present application, the processing and response module is specifically configured to: acquire an access frequency of the data in the cache; determine the old data to be eliminated by using the access frequency; and delete the old data from the cache.
[0123] In one specific embodiment of the present application, the processing and response module is specifically configured to, in the case that the cache mode is a bypass cache mode, bypass the cache to process the to-be-processed data, and feed back to the host a response.
[0124] In one specific embodiment of the present application, the processing and response module is specifically configured to, in the case that the read-write command is a write command, after writing the to-be-processed data into the non-volatile medium, feed back to the host a response that the data has been written; in the case that the read-write command is a read command, read the to-be-processed data from the non-volatile medium, and feed back to the host the to-be-processed data.
[0125] In one specific embodiment of the present application, the processing and responding module is specifically configured to acquire a cache hit state of the to-be-processed data in the case that the cache mode is a try cache mode; in the case that the read-write command is a write command, if all the to-be-processed data hit the cache, the cache data is modified, and a response that the data has been written is fed back to the host; in the case that the read-write command is a write command, if the to-be-processed data partially hit the cache or did not hit the cache, the to-be-processed data is written in the non-volatile memory, a response that the data has been written is fed back to the host, new cache space is tried to be applied for, and the to-be-processed data located in the non-volatile medium is moved to the cache space; in the case that the read-write command is a read command, if all the to-be-processed data hit the cache, the to-be-processed data is read from the cache, and the to-be-processed data is fed back to the host; in the case that the read-write command is a read command, if the to-be-processed data partially hit the cache or did not hit the cache, new cache space is tried to be applied for, the to-be-processed data located in the non-volatile medium is moved to the cache space, and the to-be-processed data is read from the non-volatile medium or the cache, and the to-be-processed data is fed back to the host.
[0126] In one specific embodiment of the present application, the processing and responding module is specifically configured to determine whether the current cache is sufficient; if the cache is sufficient, new cache space is applied for from the cache; if the cache is insufficient, the application of new cache space is abandoned.
[0127] In one specific embodiment of the present application, the processing and responding module is specifically configured to process the to-be-processed data according to a default cache strategy and respond to the host in the case that the cache mode is a default mode.
[0128] In one specific embodiment of the present application, the processing and responding module is specifically configured to cache process the to-be-processed data according to a first-in-first-out mode.
[0129] In one specific embodiment of the present application, the processing and responding module is specifically configured to acquire a latest access time stamp of the to-be-processed data; and cache process the to-be-processed data according to the latest access time stamp.
[0130] In one specific embodiment of the present application, the processing and responding module is specifically configured to acquire an access frequency of the to-be-processed data; and cache process the to-be-processed data according to the access frequency.
[0131] In one specific embodiment of the present application, the command receiving module is specifically configured to receive a read-write command sent by the host according to a data cache requirement of the to-be-processed data; the data cache requirement corresponds to a data cache mark, and the data cache mark is carried in a command extension type field of the read-write command.
[0132] In a specific implementation of the present application, the tag determination module is specifically configured to read an extension bit in the command extension type field to obtain an extension value; and determine a data cache tag corresponding to the extension value according to a mapping relationship between the extension value and the data cache tag.
[0133] In a specific implementation of the present application, the tag determination module is specifically configured to read a value in the command extension type field; and if the value corresponds to starting the cache customization function, read an extension bit in the command extension type field to obtain an extension value.
[0134] Corresponding to the above method embodiments, the present application also provides an electronic device, and the electronic device described below can be correspondingly referred to the data processing method described above.
[0135] Referring to Figure 5 The electronic device includes a memory 332 configured to store a computer program, and a processor 322 configured to execute the computer program to implement the steps of the data processing method of the above method embodiments.
[0136] Specifically, refer to Figure 6 , Figure 6 A specific structural diagram of an electronic device provided in the present embodiment can be quite different due to different configurations or performances, and can include one or more than one processor (central processing unit, CPU) (for example, one or more than one processor) and a memory 332, and the memory 332 stores one or more than one computer program 342 or data 344. The memory 332 can be temporary storage or persistent storage. The program stored in the memory 332 can include one or more than one module (not shown in the figure), and each module can include a series of instruction operations in the data processing device. Further, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
[0137] The electronic device 301 can also include one or more than one power supply 326, one or more than one wired or wireless network interface 350, one or more than one input / output interface 358, and / or one or more than one operating system 341.
[0138] The steps in the above-described data processing method can be implemented by the structure of the electronic device.
[0139] The data processing method comprises the following steps: receiving a read-write command sent by a host based on a non-volatile memory host controller interface protocol; in the process of analyzing the read-write command to determine the data to be processed, determining the data cache mark of the data to be processed by using a command extension type field in the read-write command; determining a cache mode corresponding to the data cache mark; and processing the data to be processed according to a cache strategy matched with the cache mode and responding to the host.
[0140] In one specific embodiment of the present application, processing the data to be processed according to the cache strategy matched with the cache mode and responding to the host comprises the following steps: in the case that the cache mode is a forced cache mode, obtaining a cache hit state of the data to be processed; in the case that the read-write command is a write command, if the data to be processed is all hit in the cache, modifying the cache data and then feeding back a response of data written to the host; in the case that the read-write command is a write command, if the data to be processed is partially hit in the cache or not hit in the cache, forcibly applying for a new cache space and then feeding back a response of data written to the host after writing the data to be processed in the cache space; in the case that the read-write command is a read command, if the data to be processed is all hit in the cache, reading the data to be processed from the cache and then feeding back the data to be processed to the host; and in the case that the read-write command is a read command, if the data to be processed is partially hit in the cache or not hit in the cache, forcibly applying for a new cache space, moving the data to be processed in the non-volatile medium to the cache space, reading the data to be processed from the cache and then feeding back the data to be processed to the host.
[0141] In one specific embodiment of the present application, forcibly applying for a new cache space comprises the following steps: determining whether the current cache is sufficient; if the cache is sufficient, applying for a new cache space from the cache; and if the cache is insufficient, discarding old data in the cache and then applying for a new cache space from the cache after discarding the old data.
[0142] In one specific embodiment of the present application, discarding the old data in the cache comprises the following step: deleting the old data written first in the cache.
[0143] In one specific embodiment of the present application, discarding the old data in the cache comprises the following steps: obtaining a latest access time stamp of the data in the cache; determining the old data to be discarded by using the latest access time stamp; and deleting the old data from the cache.
[0144] In one specific embodiment of the present application, discarding the old data in the cache comprises the following steps: obtaining an access frequency of the data in the cache; determining the old data to be discarded by using the access frequency; and deleting the old data from the cache.
[0145] In an embodiment of the present application, the data to be processed is processed and a response is fed back to the host according to the cache strategy matched with the cache mode, including: in the case that the cache mode is the bypass cache mode, the data to be processed is processed by bypassing the cache and a response is fed back to the host.
[0146] In an embodiment of the present application, the data to be processed is processed and a response is fed back to the host by bypassing the cache, including: in the case that the read-write command is the write command, after the data to be processed is written into the non-volatile medium, a response is fed back to the host that the data has been written; in the case that the read-write command is the read command, the data to be processed is read from the non-volatile medium and a response is fed back to the host.
[0147] In an embodiment of the present application, the data to be processed is processed and a response is fed back to the host according to the cache strategy matched with the cache mode, including: in the case that the cache mode is the try cache mode, the cache hit state of the data to be processed is obtained; in the case that the read-write command is the write command, if the data to be processed is all cache hit, after the cache data is modified, a response is fed back to the host that the data has been written; in the case that the read-write command is the write command, if the data to be processed is partially cache hit or cache miss, after the data to be processed is written into the non-volatile memory, a response is fed back to the host that the data has been written, and new cache space is tried to be applied for and the data to be processed located in the non-volatile medium is moved to the cache space; in the case that the read-write command is the read command, if the data to be processed is all cache hit, the data to be processed is read from the cache and a response is fed back to the host; in the case that the read-write command is the read command, if the data to be processed is partially cache hit or cache miss, new cache space is tried to be applied for and the data to be processed located in the non-volatile medium is moved to the cache space, and the data to be processed is read from the non-volatile medium or the cache and a response is fed back to the host.
[0148] In an embodiment of the present application, the new cache space is tried to be applied for, including: it is determined whether the current cache is sufficient; if the cache is sufficient, new cache space is applied for from the cache; if the cache is insufficient, the application for new cache space is abandoned.
[0149] In an embodiment of the present application, the data to be processed is processed and a response is fed back to the host according to the cache strategy matched with the cache mode, including: in the case that the cache mode is the default mode, the data to be processed is processed and a response is fed back to the host according to the default cache strategy.
[0150] In an embodiment of the present application, the data to be processed is processed according to the default cache strategy, including: the data to be processed is processed according to the first-in-first-out.
[0151] In an embodiment of the present application, the processing of the to-be-processed data according to the default cache strategy comprises: obtaining a latest access timestamp of the to-be-processed data; and performing cache processing on the to-be-processed data according to the latest access timestamp.
[0152] In an embodiment of the present application, the processing of the to-be-processed data according to the default cache strategy comprises: obtaining an access frequency of the to-be-processed data; and performing cache processing on the to-be-processed data according to the access frequency.
[0153] In an embodiment of the present application, the receiving of the read-write command sent by the host based on the NVM Express protocol comprises: receiving, by the host, the read-write command sent according to a data cache requirement of the to-be-processed data; the data cache requirement corresponds to a data cache mark, and the data cache mark is carried in a command extension type field of the read-write command.
[0154] In an embodiment of the present application, the determination of the data cache mark of the to-be-processed data by using the command extension type field in the read-write command comprises: reading an extension bit in the command extension type field to obtain an extension value; and determining the data cache mark corresponding to the extension value according to a mapping relationship between the extension value and the data cache mark.
[0155] In an embodiment of the present application, the reading of the extension bit in the command extension type field to obtain the extension value comprises: reading a value in the command extension type field; and if the value corresponds to the opening of the cache customization function, reading the extension bit in the command extension type field to obtain the extension value.
[0156] Corresponding to the above method embodiment, the embodiment of the present application further provides a readable storage medium, and the readable storage medium described below can be mutually referred to with the data processing method described above.
[0157] A readable storage medium, the readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the data processing method of the above method embodiment.
[0158] The readable storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various readable storage media that can store program codes.
[0159] The embodiment of the present application further provides a computer program product, and the computer program product comprises a computer program, and the computer program is executed by a processor to implement the steps in any one of the above data processing method embodiments.
[0160] An embodiment of the present invention further provides another computer program product, comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned data processing method embodiments are implemented.
[0161] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0162] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0163] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0164] Finally, it should be noted that, in this document, relationships such as first and second, etc., are used solely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms include, comprise, or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0165] The principles and implementation manners of the present application are described by using specific examples in the present application, and the above examples are only used to help understand the method of the present application and its core idea; meanwhile, for the general technical personnel in the art, according to the idea of the present application, the specific implementation manners and application ranges will be changed, and the above description should not be understood as the limitation of the present application.
Claims
1. A data processing method, characterized in that: include: Receiving read and write commands sent by the host based on the non-volatile memory host controller interface protocol; In the process of parsing the read / write command to determine the data to be processed, using the command extension type field in the read / write command to determine the data cache tag of the data to be processed; Determining a cache mode corresponding to the data cache tag; The data to be processed is processed according to a cache policy that matches the cache mode, and a response is sent to the host.
2. The method according to claim 1, characterized in that Processing the data to be processed according to a cache policy that matches the cache mode and responding to the host includes: When the cache mode is a forced cache mode, obtaining a cache hit status of the data to be processed; In the case where the read / write command is a write command, if all the data to be processed hits the cache, after modifying the cache data, a response indicating that the data has been written is fed back to the host; In the case where the read / write command is a write command, if the data to be processed partially hits the cache or misses the cache, a new cache space is forcibly requested, and after the data to be processed is written into the cache space, a response that the data has been written is fed back to the host; In the case where the read / write command is a read command, if all the data to be processed hits the cache, the data to be processed is read from the cache and fed back to the host; In the case where the read-write command is a read command, if the data to be processed partially hits the cache or misses the cache, a new cache space is forcibly applied for, and the data to be processed located in the non-volatile medium is moved to the cache space, and then the data to be processed is read from the cache and fed back to the host.
3. The method according to claim 2, characterized in that Force application of new cache space, including: Determine whether the current cache is sufficient; If the cache is sufficient, new cache space is requested from the cache; If the cache is insufficient, the old data in the cache will be eliminated, and after the old data is eliminated, new cache space will be requested from the cache.
4. The method according to claim 3, characterized in that Eliminate old data from the cache, including: The oldest data written first in the cache is deleted.
5. The method according to claim 3, characterized in that Eliminate old data from the cache, including: Get the most recently accessed timestamp of the data in the cache; Determining old data to be eliminated using the most recently accessed timestamp; The old data is deleted from the cache.
6. The method according to claim 3, characterized in that Eliminate old data from the cache, including: Get the access frequency of data in the cache; Determining old data to be eliminated using the access frequency; The old data is deleted from the cache.
7. The method according to claim 1, characterized in that Processing the data to be processed according to a cache policy that matches the cache mode and responding to the host includes: In the case where the cache mode is the bypass cache mode, the to-be-processed data is processed bypassing the cache and a response is sent to the host.
8. The method according to claim 7, characterized in that Bypassing the cache to process the data to be processed and responding to the host, including: In the case where the read / write command is a write command, after writing the data to be processed into the non-volatile medium, feeding back a response to the host indicating that the data has been written; In the case where the read / write command is a read command, the data to be processed is read from a non-volatile medium, and the data to be processed is fed back to the host.
9. The method according to claim 1, characterized in that Processing the data to be processed according to a cache policy that matches the cache mode and responding to the host includes: When the cache mode is a try cache mode, obtaining a cache hit status of the data to be processed; In the case where the read / write command is a write command, if all the data to be processed hits the cache, after modifying the cache data, a response indicating that the data has been written is fed back to the host; In the case where the read / write command is a write command, if the data to be processed partially hits the cache or misses the cache, after writing the data to be processed into the non-volatile memory, a response that the data has been written is fed back to the host, and an attempt is made to apply for new cache space, and the data to be processed located in the non-volatile medium is moved to the cache space; In the case where the read / write command is a read command, if all the data to be processed hits the cache, the data to be processed is read from the cache and fed back to the host; In the case where the read-write command is a read command, if the data to be processed partially hits the cache or misses the cache, an attempt is made to apply for new cache space, and the data to be processed located in the non-volatile medium is moved to the cache space, and the data to be processed is read from the non-volatile medium or cache, and the data to be processed is fed back to the host.
10. The method according to claim 9, characterized in that Try to apply for new cache space, including: Determine whether the current cache is sufficient; If the cache is sufficient, new cache space is requested from the cache; If the cache is insufficient, give up applying for new cache space.
11. The method according to claim 1, wherein Processing the data to be processed according to a cache policy that matches the cache mode and responding to the host includes: When the cache mode is the default mode, the data to be processed is processed according to the default cache policy, and a response is sent to the host.
12. The method according to claim 11, characterized in that Processing the data to be processed according to the default cache policy includes: The data to be processed is cached according to first-in first-out.
13. The method according to claim 11, characterized in that Processing the data to be processed according to the default cache policy includes: Obtaining the most recently accessed timestamp of the data to be processed; The data to be processed is cached according to the most recently accessed timestamp.
14. The method according to claim 11, characterized in that Processing the data to be processed according to the default cache policy includes: Obtaining the access frequency of the data to be processed; The data to be processed is cached according to the access frequency.
15. The method according to claim 1, wherein Receive read and write commands sent by the host based on the non-volatile memory host controller interface protocol, including: Receive a read / write command sent by the host according to a data cache requirement of the data to be processed; the data cache requirement corresponds to the data cache tag, and the command extension type field of the read / write command carries the data cache tag.
16. The method according to any one of claims 1 to 15, characterized in that Determining the data cache tag of the to-be-processed data by using the command extension type field in the read / write command includes: Read the extension bit in the command extension type field to obtain the extension value; According to the mapping relationship between the extension value and the data cache tag, the data cache tag corresponding to the extension value is determined.
17. The method according to claim 16, characterized in that Read the extension bit in the command extension type field to obtain the extension value, including: Read the value in the command extension type field; If the value corresponds to enabling the cache customization function, the extension bit is read from the command extension type field to obtain the extension value.
18. A data processing device, characterized in that: include: A command receiving module, configured to receive read and write commands sent by a host based on a non-volatile memory host controller interface protocol; a tag determination module, configured to determine a data cache tag of the data to be processed by using a command extension type field in the read / write command during a process of parsing the read / write command to determine the data to be processed; A mode determination module, configured to determine a cache mode corresponding to the data cache tag; The processing response module is used to process the data to be processed according to the cache strategy matching the cache mode and respond to the host.
19. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data processing method according to any one of claims 1 to 17 when executing the computer program.
20. A readable storage medium, characterized in that The readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the data processing method according to any one of claims 1 to 17.
Citation Information
Patent Citations
Data caching method and terminal device
CN107992432A
Data processing method and device, electronic device and storage system
CN109634874A
NVMe (Non-Volatile Memory Express) full-flash memory storage method and system based on data buffering mechanism
CN115576489A
Method and device for improving read-write performance of solid state disk based on small-batch data
CN116048420A
NVMe write data processing method, terminal and storage medium
CN118860290A