Storage controller, storage device, method of reading data and method of writing data
By introducing cache and query modules into the storage controller, data is read from the cache to reduce read interference effect, the problem of data loss and performance degradation under high frequency reads is solved, and higher data integrity and storage device performance are achieved.
Patent Information
- Application Number
- CN202411841520.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-03-21
AI Technical Summary
NAND flash is prone to read interference effects under high frequency read operations, resulting in data loss and performance degradation. The garbage collection mechanism of existing SSD controllers increases the write amplification rate when facing frequent hot-spot data readings, shortens the life of the solid-state drive, and may not be able to keep up with the speed of deterioration of read interference, resulting in data loss.
A cache and query module are added to the storage controller to store some data through the cache, and search for data in the cache through the query module to reduce access to non-volatile storage media. When external devices request data, read from the cache is preferred to avoid read interference effects.
By reducing the read operation of NAND flash memory, the occurrence of read interference effect is reduced, data integrity and storage device reliability and performance are improved, and the service life of the solid-state drive is extended.
Smart Images

Figure CN119668521A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a storage controller, a storage device, and a method for reading and writing data. Background Art
[0002] Solid State Drive (SSD) is widely used in high-performance storage, mainly including NAND flash memory and SSD controller. The SSD controller manages the read and write operations of data in NAND flash memory to ensure efficient and reliable data transmission. However, NAND flash memory will have a read disturbance effect under high-frequency read operations, resulting in data loss and performance degradation.
[0003] To deal with the read disturbance effect, existing SSD controllers use a garbage collection mechanism. When the number of reads of a storage unit in the NAND flash memory reaches a preset threshold, the SSD controller will start garbage collection and move the data of the storage unit to another undamaged storage unit, thereby reducing the impact of read disturbance and ensuring data integrity and reliability.
[0004] However, when the host frequently and quickly reads data in the same block (i.e., hot data), frequent garbage collection increases the write amplification rate and shortens the life of the SSD. In addition, the speed of garbage collection may not keep up with the speed of Read Disturb (read disturbance) deterioration, resulting in data loss and affecting the reliability and performance of the SSD. Summary of the invention
[0005] In view of this, an object of an embodiment of the present invention is to provide a storage controller, a storage device, and a method for reading and writing data to reduce the occurrence of read disturbance and improve data integrity as well as the reliability and performance of the storage device.
[0006] In a first aspect, an embodiment of the present invention provides a storage controller, the storage controller comprising:
[0007] Host interface, used to communicate with external devices;
[0008] A flash memory interface, used to connect to a non-volatile storage medium, wherein the non-volatile storage medium is used to store first data;
[0009] A cache memory, configured to store second data, wherein the second data is a portion of the first data;
[0010] A query module, connected to the cache, for searching data in the cache;
[0011] The main control chip is used to perform corresponding operations on the first data or the second data according to the operation instructions sent by the external device.
[0012] In some embodiments, the host interface is used to receive an operation instruction sent by the external device, and the operation instruction is a read instruction or a write instruction.
[0013] In some embodiments, the main control chip is used to, in response to receiving a read instruction sent by the external device, search the second data stored in the cache by the query module to see whether there is data corresponding to the read instruction;
[0014] The main control chip is further configured to send the corresponding data to the external device through the host interface in response to the presence of data corresponding to the read instruction in the second data.
[0015] In some embodiments, the main control chip is further used to, in response to the absence of data corresponding to the read instruction in the second data, obtain data from the non-volatile storage medium through the flash memory interface, and send the corresponding data to the external device through the host interface;
[0016] The main control chip is also used to store the data acquired from the non-volatile storage medium in the cache.
[0017] In some embodiments, the main control chip is used to write new data into the non-volatile storage medium through the flash memory interface in response to receiving a write instruction sent by the external device;
[0018] The main control chip is also used to search whether there is data corresponding to the write instruction in the second data stored in the cache through the query module, and delete the corresponding data in response to the presence of data corresponding to the write instruction in the second data.
[0019] In a second aspect, an embodiment of the present invention provides a method for reading data, the method being applicable to a storage controller, the storage controller comprising a host interface, a flash memory interface, a cache, a query module and a main control chip, the host interface being used to communicate with an external device, the flash memory interface being used to connect to a non-volatile storage medium, the non-volatile storage medium being used to store first data, the cache being used to store second data, the second data being part of the first data, the query module being connected to the cache, and being used to search for data in the cache, the method comprising:
[0020] The main control chip receives an operation instruction sent by the external device, wherein the operation instruction is a read instruction;
[0021] The main control chip performs corresponding operations on the first data or the second data according to the operation instruction.
[0022] In some embodiments, the performing corresponding operations on the first data or the second data includes:
[0023] The main control chip searches the second data stored in the cache through the query module to see whether there is data corresponding to the read instruction;
[0024] In response to the presence of data corresponding to the read instruction in the second data, the main control chip sends the corresponding data to the external device through the host interface.
[0025] In some embodiments, performing corresponding operations on the first data or the second data further includes:
[0026] In response to the absence of data corresponding to the read instruction in the second data, the main control chip acquires data from the non-volatile storage medium through the flash memory interface;
[0027] sending the data acquired from the non-volatile storage medium to the external device through the host interface;
[0028] The data acquired from the nonvolatile storage medium is stored in the cache.
[0029] In a third aspect, an embodiment of the present invention provides a method for writing data, the method being applicable to a storage controller, the storage controller comprising a host interface, a flash memory interface, a cache, a query module and a main control chip, the host interface being used to communicate with an external device, the flash memory interface being used to connect to a non-volatile storage medium, the non-volatile storage medium being used to store first data, the cache being used to store second data, the second data being part of the first data, the query module being connected to the cache, and being used to search for data in the cache, the method comprising:
[0030] The main control chip receives an operation instruction sent by the external device, wherein the operation instruction is a write instruction;
[0031] The main control chip performs corresponding operations on the first data or the second data according to the operation instruction.
[0032] In some embodiments, the performing corresponding operations on the first data or the second data includes:
[0033] The main control chip writes new data into the non-volatile storage medium through the flash memory interface;
[0034] The main control chip searches the second data stored in the cache through the query module to see whether there is data corresponding to the write instruction;
[0035] In response to the presence of data corresponding to the write instruction in the second data, the main control chip deletes the corresponding data.
[0036] In a fourth aspect, an embodiment of the present invention provides a storage device, the storage device comprising:
[0037] Non-volatile storage media;
[0038] A storage controller as described in the first aspect.
[0039] In a fifth aspect, an embodiment of the present invention provides an electronic device, wherein the electronic device comprises the storage device as described in the fourth aspect.
[0040] In a sixth aspect, an embodiment of the present invention provides a computer program product, wherein the computer program product comprises a computer program. When the computer program runs on a computer, the computer executes the methods described in the second and third aspects above.
[0041] In a seventh aspect, an embodiment of the present invention provides a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the methods described in the second and third aspects are implemented.
[0042] The technical solution of the embodiment of the present invention is to add a cache and a query module in the storage controller of the storage device, store the second data through the cache, search for data in the cache through the query module, and after receiving the operation instruction sent by the external device through the host interface, the main control chip performs corresponding operations on the first data stored in the non-volatile storage medium or the second data stored in the cache according to the operation instruction. Therefore, when the data that the external device wants to obtain is in the cache, it can be read directly from the cache, thereby skipping the access to the non-volatile storage medium, thereby reducing the occurrence of read interference, and improving the integrity of the data and the reliability and performance of the storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0044] Figure 1 It is a schematic diagram of the structure of a solid state hard disk of a comparative proportion;
[0045] Figure 2 is a schematic diagram of a data processing system according to an embodiment of the present invention;
[0046] Figure 3 is a flowchart of reading data according to an embodiment of the present invention;
[0047] Figure 4 is a schematic diagram of data transmission of read data according to an embodiment of the present invention;
[0048] Figure 5 is a flowchart of writing data according to an embodiment of the present invention;
[0049] Figure 6 is a schematic diagram of data transmission of write data according to an embodiment of the present invention;
[0050] Figure 7 is a schematic diagram of a data reading device according to an embodiment of the present invention;
[0051] Figure 8 is a schematic diagram of a data writing device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. It is possible for those skilled in the art to fully understand the present application without the description of these details. In order to avoid confusing the essence of the present application, known methods, processes, flows, components and circuits are not described in detail.
[0053] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.
[0054] At the same time, it should be understood that in the following description, "circuit" refers to a conductive loop composed of at least one element or subcircuit through electrical connection or electromagnetic connection. When an element or circuit is said to be "connected to" another element or an element / circuit is said to be "connected between" two nodes, it can be directly coupled or connected to another element or there can be an intermediate element, and the connection between the elements can be physical, logical, or a combination thereof. On the contrary, when an element is said to be "directly coupled to" or "directly connected to" another element, it means that there is no intermediate element between the two.
[0055] Unless the context clearly requires otherwise, the words "include", "comprising" and similar words throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is "including but not limited to".
[0056] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0057] Solid State Drive (SSD) is a storage device based on semiconductor storage technology for storing and retrieving digital information. Unlike traditional mechanical hard disk drives (HDDs), SSDs do not have rotating disks and moving read / write heads, but use solid-state electronic storage chips to store data. These storage chips are usually based on NAND flash memory technology and have the characteristics of high-speed reading and writing, low power consumption, high reliability and vibration resistance. SSDs are widely used in personal computers, servers, mobile devices and other fields that require high-performance storage solutions.
[0058] Figure 1 It is a schematic diagram of the structure of a comparative solid state hard disk. Figure 1 The solid state drive shown includes an SSD controller and NAND flash memory.
[0059] Among them, the SSD controller is the core component of the SSD, responsible for managing and coordinating various operations of the SSD. Its main functions include data transmission, wear leveling, garbage collection, error detection and correction (ECC), bad block management, encryption and security, etc. Data transmission: Processes data transmission between the host (such as a computer) and the NAND flash memory to ensure efficient and accurate data transmission. Wear leveling: Each block of the NAND flash memory has a limited number of erase and write times. The SSD controller uses a wear leveling algorithm to evenly distribute write operations to avoid overuse of certain blocks, thereby extending the service life of the SSD. Garbage collection: The erase operation of the NAND flash memory must be performed in blocks, while the write operation is performed in pages. The garbage collection mechanism manages storage space and reduces the Read Disturb effect by copying valid data to new blocks and then erasing the old blocks. Error detection and correction (ECC): NAND flash memory may have data errors after long-term use. ECC technology can detect and correct these errors to ensure data integrity. Bad block management: NAND flash memory may have bad blocks that exist at the factory. The SSD controller will record these bad blocks and bypass them when writing data to ensure data security. Encryption and security: Modern SSD controllers support data encryption to protect data security and privacy.
[0060] NAND flash memory is the main storage medium of SSD. The basic storage unit of NAND flash memory is the storage cell (Cell), which can store 1 bit or more than 1 bit of data. According to the amount of data that each cell can store, NAND flash memory can be divided into single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC) and quad-level cell (QLC). Page is the smallest readable and writable unit in NAND flash memory, usually containing several thousand bytes of data. Block is a larger storage unit composed of multiple pages and is the smallest erasable unit in NAND flash memory. A block usually contains dozens to hundreds of pages.
[0061] When the host sends a write request, the SSD controller converts the logical address provided by the host into a physical address in the NAND flash memory. The SSD controller writes the data to the specified page. If there is invalid data in the block where the target page is located, the SSD controller will first start the garbage collection process to move the valid data to the new block area, and then erase the old block area.
[0062] When the host sends a read request, the SSD controller converts the logical address provided by the host into a physical address in the NAND flash memory, and the SSD controller reads data from the specified page.
[0063] In a solid-state drive (SSD), when the host reads the location of the same small area (hot data) frequently and quickly, the Read Disturb effect in the NAND flash memory will be aggravated. Read Disturb refers to the fact that during the read operation of the NAND medium, the threshold voltage (Vt) of the NAND Cell (storage unit) is affected by the weak programming effect and the hot carrier injection effect (Hot Carrier Injection), causing the NAND Cell to shift to the right. When the number of read operations accumulates to a certain level, if a certain voltage is used to read the data on the NAND Cell, the data may no longer be read and the saved data may be lost.
[0064] The traditional approach is to start garbage collection when the number of times the area is read reaches a certain threshold, and move the data in this area to another location. However, this method has the following problems when facing frequent hot data reading: Frequent garbage collection will increase the write amplification of the SSD, causing accelerated wear of the NAND flash memory and shortening the service life of the SSD. If the speed of garbage collection cannot keep up with the speed of Read Disturb deterioration, data may still be lost due to the offset of the threshold voltage.
[0065] Figure 2 Schematic diagram of a data processing system according to an embodiment of the present invention. Figure 2 As shown, the data processing system according to the embodiment of the present invention includes an external device 1 and a storage device 2 .
[0066] The external device 1 is a device with data storage requirements and data processing functions. For example, the external device can be implemented by a personal computer, a server, an industrial control system, a mobile device, and various embedded systems.
[0067] The storage device 2 is used to store data. The external device 1 is connected to the storage device 2 and is used to obtain data from the storage device 2.
[0068] In some embodiments, the storage device 2 may be implemented by a solid state drive (SSD). A solid state drive (SSD) is a storage device based on semiconductor storage technology for storing and retrieving digital information. Unlike a traditional mechanical hard disk drive (HDD), an SSD does not have a rotating disk and a moving read / write head, but uses solid-state electronic storage chips to store data. These storage chips are usually based on NAND flash memory technology and have the characteristics of high-speed reading and writing, low power consumption, high reliability, and vibration resistance.
[0069] Specifically, the storage device 2 includes a storage controller 21 and a non-volatile storage medium 22 .
[0070] The storage controller 21 is a control component of the storage device 2, responsible for managing and coordinating various operations of the storage device 2. Its main functions include data transmission, wear leveling, garbage collection, error detection and correction (ECC), bad block management, encryption and security, etc.
[0071] The nonvolatile storage medium 22 is a storage medium of the storage device 2 and is used to store first data.
[0072] In some embodiments, the non-volatile storage medium 22 is NAND flash memory. NAND flash memory is a non-volatile storage technology for storing and retrieving digital information. Unlike traditional volatile memory (such as DRAM), NAND flash memory can still retain data after power failure. The basic storage unit of NAND flash memory is the storage cell (Cell), and each storage cell can store 1 bit or more than 1 bit of data. The storage cell represents different data states by the difference in its threshold voltage (Vt). The page is the smallest readable and writable unit in NAND flash memory, usually containing several thousand bytes of data. Read and write operations are performed in pages. A block is a larger storage unit composed of multiple pages and is the smallest erasable unit in NAND flash memory. A block usually contains dozens to hundreds of pages. The erase operation must be performed in blocks.
[0073] Furthermore, the storage controller 21 includes a host interface 211 , a main control chip 212 , a query module 213 , a cache 214 and a flash memory interface 215 .
[0074] The host interface 211 is used for communicating with the external device 1 .
[0075] In some embodiments, the host interface can be implemented through interface standards such as SATA (Serial Advanced Technology Attachment), PCIe (Peripheral Component Interconnect Express), and NVMe (Non-Volatile Memory Express).
[0076] The main control chip 212 is the processor of the storage controller 21, and is responsible for processing various operations, such as data transmission management, wear leveling, garbage collection, error detection and correction (ECC), bad block management, cache management, encryption and security, etc. The embodiment of the present invention mainly describes the data transmission management and cache management of the main control chip 212.
[0077] For data transmission management: the main control chip 212 processes the data transmission between the host and the NAND flash memory or cache 214 to ensure efficient and accurate data transmission.
[0078] Regarding cache management: the main control chip 212 is used to manage the data in the cache 214 to improve the read and write performance.
[0079] In some embodiments, the main control chip 212 can be implemented by MCU (Microcontroller Unit), embedded processor (Embedded Processor), PLC (Programmable Logic Controller), FPGA (Field-Programmable Gate Array), DSP (Digital Signal Processor) or ASIC (Application Specific Integrated Circuit), etc.
[0080] The cache 214 is used to store the second data, which is a part of the first data. Specifically, the main control chip 212 selects a part of frequently read data from the second data according to the record of the read data of the external device 1, and stores the frequently read data as the second data in the cache 214.
[0081] Cache is a high-speed memory used to temporarily store frequently accessed data. The main purpose of cache is to reduce the number of times the host accesses the NAND memory, thereby improving the overall performance of the system. Cache is usually composed of static random access memory (SRAM).
[0082] In some embodiments, the cache adopts a (First-In-First-Out) strategy. When the cache is full and new data needs to be loaded, the data item first loaded into the cache will be removed from the cache. When the external device 1 accesses a piece of data, if the data is not in the cache (cache miss), the data is read from the non-volatile storage medium 22 and loaded into the cache. Each piece of data loaded into the cache will be placed in a queue, and the queue is arranged in the order of the time when the data enters the cache. When the cache is full and new data needs to be loaded, the front data in the queue (i.e., the data item that enters the cache earliest) will be removed from the cache to make room for the new data. The implementation of the FIFO strategy is relatively simple, and does not require a complex tracking and recording mechanism. At the same time, the management overhead is low, which is suitable for systems with limited resources. Moreover, the behavior of the FIFO strategy is deterministic, and the result of each replacement operation is predictable.
[0083] The query module 213 is connected to the cache 214 and is used to search for data in the cache 214. Every time the main control chip 212 writes a piece of data from the non-volatile storage medium to the address space of the cache, it records the mapping relationship from the first physical address to the second physical address. The first physical address is the physical address of the data in the non-volatile storage medium, and the second physical address is the physical address of the data in the cache. When the external device wants to read the data, it sends an operation instruction to the storage device. The operation instruction includes a target address, which is a logical address. The main control chip 212 obtains the first physical address corresponding to the target address and provides the first physical address to the query module 213. The query module 213 detects whether the data exists in the cache according to the first physical address.
[0084] Specifically, after receiving the operation instruction sent by the host, the main control chip 212 parses the operation instruction to obtain the target address, and searches the cache 214 for the corresponding target address through the query module 213 .
[0085] The flash memory interface 215 is used to connect the storage controller 21 and the non-volatile storage medium, and is responsible for data transmission between the storage controller 21 and the non-volatile storage medium 22 .
[0086] In some embodiments, the flash memory interface 215 performs parallel data transmission with multiple NAND flash memory channels through protocols such as ONFI (Open NAND Flash Interface) or Toggle mode to improve data transmission efficiency.
[0087] Furthermore, the flash memory interface 215 includes a FTL (Flash Translation Layer), which completes the translation, or mapping, of the logical address of the external device to the first physical address of the non-volatile storage medium 22. Each time the storage device writes a piece of data into the address space of the non-volatile storage medium, it records the mapping relationship between the logical address and the first physical address. When the external device wants to read the data, the SSD will read the data from the non-volatile storage medium according to the mapping and return it to the external device.
[0088] The host interface 211 is used to receive an operation instruction sent by the external device, wherein the operation instruction is a read instruction or a write instruction. The main control chip 212 is used to perform a corresponding operation on the first data or the second data according to the operation instruction sent by the external device.
[0089] Specifically, the main control chip 212 is used to respond to receiving the read instruction sent by the external device and search whether there is data corresponding to the read instruction in the second data stored in the cache 214 through the query module 213. In response to the presence of data corresponding to the read instruction in the second data, the corresponding data is sent to the external device through the host interface 211. At this time, the data that the external device wants to obtain can be directly read from the cache 214, skipping the access to the non-volatile storage medium 22.
[0090] In response to the absence of data corresponding to the read instruction in the second data, the main control chip 212 obtains data from the non-volatile storage medium 22 through the flash memory interface 215, and sends the corresponding data to the external device through the host interface 211. At the same time, the main control chip 212 is also used to store the data obtained from the non-volatile storage medium in the cache. That is, when there is no data corresponding to the read instruction in the second data, through the design of dual-path return data, one path is returned to the external device, and the other path is returned to the cache, which will not affect the delay of data returned to the external device. If it is a single-path return, first returning to the cache and then returning to the external device from the cache will increase the delay of data returned to the external device, resulting in poor performance.
[0091] The main control chip 212 is used to respond to receiving the write instruction sent by the external device and write the new data to the non-volatile storage medium 22 through the flash memory interface 215. And through the query module 213, it searches whether there is data corresponding to the write instruction in the second data stored in the cache 214, and deletes the corresponding data in response to the presence of data corresponding to the write instruction in the second data. In this way, the consistency of data between the cache 214 and the non-volatile storage medium 22 can be guaranteed.
[0092] The embodiment of the present invention adds a cache and a query module to the storage controller of the storage device, stores the second data through the cache, searches for data in the cache through the query module, and after receiving the operation instruction sent by the external device through the host interface, the main control chip performs corresponding operations on the first data stored in the non-volatile storage medium or the second data stored in the cache according to the operation instruction. Therefore, when the data that the external device wants to obtain is in the cache, it can be read directly from the cache, thereby skipping the access to the non-volatile storage medium, thereby reducing the occurrence of read interference, and improving the integrity of the data and the reliability and performance of the storage device.
[0093] Figure 3 FIG. 1 is a flowchart of reading data according to an embodiment of the present invention. Figure 3As shown, the data reading of the embodiment of the present invention includes the following steps:
[0094] Step S110: The main control chip receives an operation instruction sent by the external device, where the operation instruction is a read instruction.
[0095] In this embodiment, the main control chip receives an operation instruction sent by an external device through a host interface, and the operation instruction is a read instruction. The operation instruction includes a target address of the data to be read, and the target address is a logical address. Among them, the logical address is a virtual address assigned to the data by the external device, which is used to identify the location of the data in the virtual address space. The logical address is relative to the address space of the process. Unlike the physical address, the logical address does not directly correspond to the actual physical storage location.
[0096] Step S120: Check whether the data is in the cache.
[0097] In this embodiment, after the main control chip obtains the read instruction, it parses the read instruction to obtain the target address, which is a logical address. The main control chip obtains the first physical address corresponding to the target address, and the first physical address is the physical address of the data in the non-volatile storage medium. And the first physical address is provided to the query module. The query module records the mapping relationship from the first physical address to the second physical address, the first physical address is the physical address of the data in the non-volatile storage medium, and the second physical address is the physical address of the data in the cache. Therefore, the query module can detect whether the data exists in the cache according to the first physical address provided by the main control chip.
[0098] If it exists, go to step S130.
[0099] If not present, proceed to step S140.
[0100] Step S130: read data from the cache and send it to an external device.
[0101] In this embodiment, in response to the presence of data corresponding to the read instruction in the second data, the corresponding data is sent to the external device through the host interface.
[0102] Specifically, in response to detecting the first physical address provided by the main control chip in the cache, that is, detecting that the second data contains data corresponding to the read instruction, the data is obtained from the cache and sent to the external device. At this time, the data that the external device wants to obtain can be directly read from the cache, skipping the access to the non-volatile storage medium.
[0103] Step S140: read data from the non-volatile storage medium and send it to an external device.
[0104] In this embodiment, in response to the absence of data corresponding to the read instruction in the second data, the main control chip obtains data from the non-volatile storage medium through the flash memory interface, and sends the corresponding data to the external device through the host interface.
[0105] Specifically, when the query module does not detect data in the cache according to the first physical address provided by the main control chip, that is, when it detects that there is no data corresponding to the read instruction in the second data, it obtains data from the non-volatile storage medium through the flash memory interface according to the first physical address, and sends the corresponding data to the external device through the host interface.
[0106] Step S150: store the data acquired from the non-volatile storage medium in the cache.
[0107] In this embodiment, the main control chip is also used to store the data obtained from the non-volatile storage medium in the cache.
[0108] Furthermore, the cache adopts a First-In-First-Out (FIFO) strategy. When the cache is full and new data needs to be loaded, the data item first loaded into the cache will be removed from the cache to make room for the new data.
[0109] In the embodiment of the present invention, when there is no data corresponding to the read instruction in the second data, a dual-path data return design is used, one path is returned to the external device, and the other path is returned to the cache, which does not affect the delay of returning the data to the external device. If it is a single-path return, first returning to the cache and then returning to the external device from the cache, the delay of returning the data to the external device will increase, resulting in poor performance.
[0110] Figure 4 Schematic diagram of data transmission of read data according to an embodiment of the present invention. Figure 4 Only the query module and cache of the storage device are shown. As shown in the figure:
[0111] In step S210 , the external device sends a read instruction to the storage device.
[0112] If the data that the external device wants to read is in the cache, step S220 is executed.
[0113] If the data that the external device wants to read is not in the cache, steps S230 - S240 are executed.
[0114] In step S220, the data in the cache is returned to the external device.
[0115] In steps S230 and S240 , the data in the nonvolatile storage medium is returned to the external device, and the data is stored in the cache.
[0116] The embodiment of the present invention adds a cache and a query module to the storage controller of the storage device, stores the second data through the cache, searches for data in the cache through the query module, and after receiving the operation instruction sent by the external device through the host interface, the main control chip performs corresponding operations on the first data stored in the non-volatile storage medium or the second data stored in the cache according to the operation instruction. Therefore, when the data that the external device wants to obtain is in the cache, it can be read directly from the cache, thereby skipping the access to the non-volatile storage medium, thereby reducing the occurrence of read interference, and improving the integrity of the data and the reliability and performance of the storage device.
[0117] Figure 5 FIG. 1 is a flowchart of writing data according to an embodiment of the present invention. Figure 5 As shown, writing data in the embodiment of the present invention includes the following steps:
[0118] Step S310: The main control chip receives an operation instruction sent by the external device, where the operation instruction is a write instruction.
[0119] In this embodiment, the main control chip receives an operation instruction sent by an external device through a host interface, and the operation instruction is a write instruction. The operation instruction includes data to be written and a target address, and the target address is a logical address.
[0120] Step S320: The main control chip writes new data into the non-volatile storage medium through the flash memory interface.
[0121] In this embodiment, the new data is the address to be written. Specifically, after the main control chip obtains the write instruction, it parses the write instruction to obtain the target address and the new data, the target address is a logical address, and the main control chip obtains the first physical address corresponding to the target address, the first physical address is the physical address of the data in the non-volatile storage medium. The new data is written to the non-volatile storage medium through the flash memory interface.
[0122] Step S330: Check whether the data is in the cache.
[0123] In this embodiment, the main control chip provides the first physical address in the write instruction to the query module. The query module records the mapping relationship between the first physical address and the second physical address, where the first physical address is the physical address of the data in the non-volatile storage medium, and the second physical address is the physical address of the data in the cache. Thus, the query module can detect whether the data exists in the cache according to the first physical address provided by the main control chip.
[0124] If it exists, go to step S340.
[0125] If not present, proceed to step S350 and end.
[0126] Step S340: delete the corresponding data.
[0127] In this embodiment, the main control chip deletes the corresponding data in response to the presence of data corresponding to the write instruction in the second data, thereby ensuring the consistency of data between the cache and the non-volatile storage medium.
[0128] Step S350, end.
[0129] Figure 6 Schematic diagram of data transmission of write data according to an embodiment of the present invention. Figure 6 Only the query module and cache of the storage device are shown. As shown in the figure:
[0130] In step S410, the external device sends a write instruction to the storage device.
[0131] In step S420, new data is written into the non-volatile storage medium.
[0132] The query module can detect whether the data exists in the cache according to the first physical address provided by the main control chip.
[0133] If it exists, the process goes to step S430 to delete the corresponding data from the cache.
[0134] The embodiment of the present invention adds a cache and a query module to the storage controller of the storage device, stores the second data through the cache, searches for data in the cache through the query module, and after receiving the operation instruction sent by the external device through the host interface, the main control chip performs corresponding operations on the first data stored in the non-volatile storage medium or the second data stored in the cache according to the operation instruction. Therefore, when the data that the external device wants to obtain is in the cache, it can be read directly from the cache, thereby skipping the access to the non-volatile storage medium, thereby reducing the occurrence of read interference, and improving the integrity of the data and the reliability and performance of the storage device.
[0135] Figure 7 Schematic diagram of a data reading device according to an embodiment of the present invention. Figure 7As shown, the data reading device of the embodiment of the present invention is applicable to a storage controller, the storage controller includes a host interface, a flash memory interface, a cache, a query module and a main control chip, the host interface is used to communicate with an external device, the flash memory interface is used to connect a non-volatile storage medium, the non-volatile storage medium is used to store first data, the cache is used to store second data, the second data is a part of the first data, the query module is connected to the cache, and is used to search for data in the cache, the device includes:
[0136] A first instruction receiving unit, configured to receive an operation instruction sent by the external device, wherein the operation instruction is a read instruction;
[0137] The first operation execution unit is used to perform a corresponding operation on the first data or the second data according to the operation instruction.
[0138] In this embodiment, the operation execution unit is used to:
[0139] Searching, by the query module, whether there is data corresponding to the read instruction in the second data stored in the cache;
[0140] In response to the presence of data corresponding to the read instruction in the second data, the corresponding data is sent to the external device through the host interface.
[0141] In some embodiments, the operation execution unit is further configured to:
[0142] In response to the absence of data corresponding to the read instruction in the second data, acquiring data from a non-volatile storage medium through the flash memory interface;
[0143] sending the data acquired from the non-volatile storage medium to the external device through the host interface;
[0144] The data acquired from the nonvolatile storage medium is stored in the cache.
[0145] The embodiment of the present invention adds a cache and a query module to the storage controller of the storage device, stores the second data through the cache, searches for data in the cache through the query module, and after receiving the operation instruction sent by the external device through the host interface, the main control chip performs corresponding operations on the first data stored in the non-volatile storage medium or the second data stored in the cache according to the operation instruction. Therefore, when the data that the external device wants to obtain is in the cache, it can be read directly from the cache, thereby skipping the access to the non-volatile storage medium, thereby reducing the occurrence of read interference, and improving the integrity of the data and the reliability and performance of the storage device.
[0146] Figure 8 Schematic diagram of a data writing device according to an embodiment of the present invention. Figure 8 As shown, the data writing device of the embodiment of the present invention is applicable to a storage controller, the storage controller includes a host interface, a flash memory interface, a cache, a query module and a main control chip, the host interface is used to communicate with an external device, the flash memory interface is used to connect a non-volatile storage medium, the non-volatile storage medium is used to store first data, the cache is used to store second data, the second data is a part of the first data, the query module is connected to the cache, and is used to search for data in the cache, the device includes:
[0147] A second instruction receiving unit, used for receiving an operation instruction sent by the external device, wherein the operation instruction is a write instruction;
[0148] The second operation execution unit is used to perform a corresponding operation on the first data or the second data according to the operation instruction.
[0149] In some embodiments, the second operation execution unit is used to:
[0150] Writing new data into the non-volatile storage medium through the flash memory interface;
[0151] Searching, by the query module, whether there is data corresponding to the write instruction in the second data stored in the cache;
[0152] In response to the presence of data corresponding to the write instruction in the second data, the corresponding data is deleted.
[0153] The embodiment of the present invention adds a cache and a query module to the storage controller of the storage device, stores the second data through the cache, searches for data in the cache through the query module, and after receiving the operation instruction sent by the external device through the host interface, the main control chip performs corresponding operations on the first data stored in the non-volatile storage medium or the second data stored in the cache according to the operation instruction. Therefore, when the data that the external device wants to obtain is in the cache, it can be read directly from the cache, thereby skipping the access to the non-volatile storage medium, thereby reducing the occurrence of read interference, and improving the integrity of the data and the reliability and performance of the storage device.
[0154] Further, another embodiment of the present invention also provides an electronic device, including the above-mentioned storage device. Various illustrative logic blocks, modules, circuits and algorithm steps described in conjunction with the examples disclosed in the embodiments of the present invention can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits and steps have been generally described above in terms of their functions. Whether this functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the entire system. A technician in the field can implement the described functionality in different ways for each specific application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
[0155] The hardware for implementing the various illustrative logics, logic blocks, modules, and circuits described in conjunction with the examples disclosed in the embodiments of the present invention may be implemented or executed using a general purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor may be a microprocessor, but in an alternative example, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration. Alternatively, some steps or methods may be performed by a circuit system dedicated to a given function.
[0156] In some exemplary instances, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored as one or more instructions or codes on a non-transitory computer-readable storage medium or a non-transitory processor-readable storage medium. The steps of the method or algorithm disclosed herein may be embodied in a processor-executable software module that may reside on a non-transitory computer-readable or processor-readable storage medium. A non-transitory computer-readable or processor-readable storage medium may be any storage medium that can be accessed by a computer or processor. By way of example and not limitation, this non-transitory computer-readable or processor-readable medium may include RAM, ROM, EEPROM, flash memory, CD-ROM or other optical disk storage device, magnetic disk storage device or other magnetic storage device, or any other medium that can be used to store the desired program code in the form of instructions or data structures that can be accessed by a computer. Disks and optical disks as used herein include compact disks (CDs), laser optical disks, optical optical disks, digital versatile disks (DVDs), floppy disks, and Blu-ray disks, where disks typically reproduce data magnetically, and optical disks reproduce data optically with lasers. The above combinations are also included within the scope of non-transitory computer-readable and processor-readable media. Additionally, the operations of a method or algorithm may reside as one or any combination or set of codes and / or instructions on a non-transitory processor-readable storage medium and / or a computer-readable storage medium, which may be incorporated into a computer program product.
[0157] Another embodiment of the present invention relates to a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method of writing data and / or reading data according to the embodiment of the present invention is implemented.
[0158] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A storage controller, characterized in that: The storage controller comprises: Host interface, used to communicate with external devices; A flash memory interface, used to connect to a non-volatile storage medium, wherein the non-volatile storage medium is used to store first data; A cache memory, configured to store second data, wherein the second data is a portion of the first data; A query module, connected to the cache, for searching data in the cache; The main control chip is used to perform corresponding operations on the first data or the second data according to the operation instructions sent by the external device.
2. The storage controller according to claim 1, characterized in that: The host interface is used to receive an operation instruction sent by the external device, and the operation instruction is a read instruction or a write instruction.
3. The storage controller according to claim 2, characterized in that: The main control chip is used for searching whether there is data corresponding to the read instruction in the second data stored in the cache through the query module in response to receiving the read instruction sent by the external device; The main control chip is further configured to send the corresponding data to the external device through the host interface in response to the presence of data corresponding to the read instruction in the second data.
4. The storage controller according to claim 3, characterized in that: The main control chip is further used for acquiring data from a non-volatile storage medium through the flash memory interface in response to the absence of data corresponding to the read instruction in the second data, and sending the corresponding data to the external device through the host interface; The main control chip is also used to store the data acquired from the non-volatile storage medium in the cache.
5. The storage controller according to claim 2, characterized in that: The main control chip is used to write new data into the non-volatile storage medium through the flash memory interface in response to receiving a write instruction sent by the external device; The main control chip is also used to search whether there is data corresponding to the write instruction in the second data stored in the cache through the query module, and delete the corresponding data in response to the presence of data corresponding to the write instruction in the second data.
6. A method for reading data, the method being applicable to a storage controller, characterized in that: The storage controller includes a host interface, a flash memory interface, a cache, a query module and a main control chip, the host interface is used to communicate with an external device, the flash memory interface is used to connect a non-volatile storage medium, the non-volatile storage medium is used to store first data, the cache is used to store second data, the second data is a part of the first data, the query module is connected to the cache, and is used to search for data in the cache, the method includes: The main control chip receives an operation instruction sent by the external device, wherein the operation instruction is a read instruction; The main control chip performs corresponding operations on the first data or the second data according to the operation instruction.
7. The method according to claim 6, characterized in that The performing corresponding operations on the first data or the second data includes: The main control chip searches the second data stored in the cache through the query module to see whether there is data corresponding to the read instruction; In response to the presence of data corresponding to the read instruction in the second data, the main control chip sends the corresponding data to the external device through the host interface.
8. The method according to claim 7, characterized in that The performing corresponding operations on the first data or the second data further includes: In response to the absence of data corresponding to the read instruction in the second data, the main control chip acquires data from the non-volatile storage medium through the flash memory interface; sending the data acquired from the non-volatile storage medium to the external device through the host interface; The data acquired from the nonvolatile storage medium is stored in the cache.
9. A method for writing data, the method being applicable to a storage controller, characterized in that: The storage controller includes a host interface, a flash memory interface, a cache, a query module and a main control chip, the host interface is used to communicate with an external device, the flash memory interface is used to connect a non-volatile storage medium, the non-volatile storage medium is used to store first data, the cache is used to store second data, the second data is a part of the first data, the query module is connected to the cache, and is used to search for data in the cache, the method includes: The main control chip receives an operation instruction sent by the external device, wherein the operation instruction is a write instruction; The main control chip performs corresponding operations on the first data or the second data according to the operation instruction.
10. The method according to claim 9, characterized in that The performing corresponding operations on the first data or the second data includes: The main control chip writes new data into the non-volatile storage medium through the flash memory interface; The main control chip searches the second data stored in the cache through the query module to see whether there is data corresponding to the write instruction; In response to the presence of data corresponding to the write instruction in the second data, the main control chip deletes the corresponding data.
11. A storage device, characterized in that: The storage device comprises: Non-volatile storage media; A storage controller as claimed in any one of claims 1 to 5.
12. An electronic device, characterized in that: The electronic device comprises the storage device according to claim 11.
13. A computer program product, comprising a computer program, characterized in that: When the computer program is executed on a computer, the computer executes the method according to any one of claims 6 to 10.
14. A computer-readable storage medium storing computer program instructions, characterized in that: The computer program instructions implement the method according to any one of claims 6 to 10 when executed by a processor.
Citation Information
Patent Citations
Data reading-writing method, storage controller and computer
CN104142894A
Data compression method and flash memory device
CN114968838A
Transparent management at host interface of flash-memory overhead-bytes using flash-specific DMA having programmable processor-interrupt of high-level operations
US5956743A