Method for reading data from flash memory, related memory controller and storage system
By introducing a pre-reading mechanism into flash memory, data that may be required is read in advance and stored in the buffer, which solves the problem that the interleaved architecture cannot be fully utilized and improves reading efficiency and performance.
Patent Information
- Application Number
- CN202410180277.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-03-13
- Filing Date
- 2024-02-18
- Publication Date
- 2024-09-13
AI Technical Summary
In flash memory, the interleaved architecture cannot be fully utilized, resulting in the memory controller being unable to process as many host commands at the same time, limiting read performance.
By anticipating whether the host will require a sequential read, the memory controller performs a pre-read operation before receiving a host read command, stores the data in a pre-read buffer, and reads the data from the buffer when the host read command arrives. Send data to avoid reading directly from flash memory.
It improves the reading efficiency of flash memory, makes full use of the interleaved architecture, enhances the processing capabilities of the memory controller, and improves data reading performance.
Smart Images

Figure CN118642647A
Abstract
Description
Technical Field
[0001] The present invention relates to a flash memory, and more particularly to a method for reading data from a flash memory and a related memory controller and storage system. Background Art
[0002] When reading data from a flash memory, an interleaving architecture may be used to improve read performance. For example, each channel of a multi-channel flash memory can be accessed in parallel to respond to multiple host read command requests. In some cases, the depth of the command queue for storing host read commands may be low, thereby limiting the memory controller from processing as many host commands as possible at the same time, resulting in the interleaving architecture not being fully utilized. In view of this, an innovative host read command processing mechanism is needed in the art. Summary of the invention
[0003] In view of this, one of the purposes of the present invention is to provide a mechanism for predicting and processing sequential reads. An embodiment of the present invention determines whether the host device requires sequential reads of the flash memory. If so, the memory controller will perform a pre-read operation to pre-read data that may be required to be read later. And, the pre-read data is stored in a pre-read buffer. Subsequently, the memory controller determines whether the logical address required to be read by the new host read command matches the logical address corresponding to the data in the pre-read buffer. If it matches, the memory controller will send data from the pre-read buffer to the host device to complete the new host read command, so there is no need to read the flash memory.
[0004] An embodiment of the present invention provides a method for reading data from a flash memory. The method includes: determining whether a host device requires a sequential read access to the flash memory; if the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, performing a pre-read operation according to a pre-read logical block address (LBA) to read data from the flash memory; storing the data read by the pre-read operation in a pre-read buffer; and after receiving the first host read command issued by the host device, if a starting LBA of the first host read command corresponds to one of a plurality of starting LBAs of the data stored in the pre-read buffer, sending a part or all of the data read by the pre-read operation to the host device.
[0005] An embodiment of the present invention provides a memory controller for controlling a flash memory and reading data from the flash memory in a flash memory. The memory controller includes: a storage unit and a processing unit. The storage unit is used to store information and program code. The processing unit is used to execute the program code to perform the following operations: determine whether a host device requires a sequential read access to the flash memory; if the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, perform a pre-read operation according to a pre-read LBA to read data from the flash memory; store the data read by the pre-read operation in a pre-read buffer area; and after receiving the first host read command issued by the host device, if a starting LBA of the first host read command corresponds to one of a plurality of starting LBAs of the data stored in the pre-read buffer area, send part or all of the data read by the pre-read operation to the host device.
[0006] An embodiment of the present invention provides a storage system. The storage system includes: a flash memory and a memory controller. The memory controller is used to control the flash memory in the flash memory and read data from the flash memory. The memory controller is used to: determine whether a host device requires a sequential read access to the flash memory; if the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, perform a pre-read operation according to a pre-read LBA to read data from the flash memory; store the data read by the pre-read operation in a pre-read buffer area; and after receiving the first host read command issued by the host device, if a starting LBA of the first host read command corresponds to one of multiple starting LBAs of the data stored in the pre-read buffer area, send part or all of the data read by the pre-read operation to the host device. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 A schematic diagram of the architecture of a storage system including a memory controller according to an embodiment of the present invention is shown.
[0008] Figure 2 A flow chart for reading data from a flash memory device according to an embodiment of the present invention is shown.
[0009] Figure 3 It illustrates how to manage the pre-read data cache according to an embodiment of the present invention.
[0010] Figure 4A and Figure 4BIt shows how to manage the starting LBA of data in different chunk locations and how to determine the pre-reading starting LBA in an embodiment of the present invention.
[0011] Figure 5A and Figure 5B How to send pre-read data to a host device according to an embodiment of the present invention is illustrated.
[0012] Figure 6 A method for reading data from a flash memory according to an embodiment of the present invention is illustrated.
[0013]
Explanation of symbols
[0014] 10 Electronic devices
[0015] 50 Host device
[0016] 52 Processors
[0017] 100 Storage System
[0018] 110 Memory Controller
[0019] 112 Processing Units
[0020] 112M ROM
[0021] 112C Program code
[0022] 113 Internal Memory
[0023] 114 Control Logic
[0024] 118 Transmission interface circuit
[0025] 120 NV memory
[0026] 122_1 to 122_N memory elements
[0027] 130 Pre-read cache area
[0028] Steps S310 to S319, S210 to S240 DETAILED DESCRIPTION
[0029] In the following text, many specific details are described to provide readers with a thorough understanding of the embodiments of the present invention. However, those skilled in the art will understand how to implement the present invention without one or more specific details, or using other methods, components, materials, etc. In other cases, well-known structures, materials, or operations will not be shown or described in detail to avoid obscuring the core concepts of the present invention.
[0030] The reference to "an embodiment" in the specification means that the specific features, structures or characteristics described in the embodiment may be included in at least one embodiment of the present invention. Therefore, the "in an embodiment" that appears in various places in this specification does not necessarily mean the same embodiment. In addition, the aforementioned specific features, structures or characteristics may be combined in one or more embodiments in any suitable form.
[0031] Figure 1 Schematic diagram of the structure of the electronic device 10 of an embodiment of the present invention. The electronic device 10 includes a host device 50 and a storage system 100. The host device 50 may include: at least one processor 52 for controlling the operation of the host device 50. Examples of the host device 50 may include but are not limited to: a smart phone, a tablet computer, a wearable device, a personal computer (e.g., a desktop computer and a notebook computer), an image generating device (e.g., a digital camera or a video camera), a game console, a car navigation system, a printer, a scanner, or a server system. Examples of the storage system 100 may include but are not limited to: a portable memory device (e.g., a memory card that complies with the SD / MMC, CF, MS, XD or UFS specifications), a solid state drive (SSD) and various embedded storage devices (e.g., an embedded storage device that complies with the UFS or EMMC specifications).
[0032] In various embodiments of the present invention, the storage system 100 may include a controller (e.g., a memory controller 110), and may further include a non-volatile (NV) memory 120. The NV memory 120 is used to store information. The NV memory 120 may include one or more NV memory elements, for example, NV memory elements 122_1 to 122_N. In one embodiment, the NV memory 120 may be a flash memory, and the NV memory elements 122_1 to 122_N may be a plurality of flash memory chips or a plurality of flash memory dies, respectively, but the present invention is not limited thereto. In addition, the NV memory 120 may include a memory cell having a two-dimensional structure, or may also include a memory cell having a three-dimensional structure.
[0033] like Figure 1As shown, the memory controller 110 may include: a processing circuit (e.g., a microprocessor 112), a storage element (e.g., a read-only memory (ROM)) 112M, an internal memory 113, a control logic circuit 114, a transmission interface circuit 118, and a pre-read buffer (Read-ahead Buffer) 130. At least a portion of these elements may be interconnected via a bus. The internal memory 113 may be implemented by one or more random-access memories (RAM). For example, the internal memory 113 may include a static RAM (SRAM) and / or a dynamic RAM (DRAM). The internal memory 113 may be used to provide internal storage space for the memory controller 110, such as temporarily storing information (e.g., parameters, commands, data, addresses, and / or mapping tables). In addition, the ROM 112M of this embodiment is used to store program code 112C, and the microprocessor 112 is used to execute the program code 112C, thereby controlling the access of the NV memory 120. In addition, the program code 112C may also be stored in the NV memory 120.
[0034] In addition, the memory controller 110 can perform the writing of user data according to the host command from the host device 50, and can also perform the writing of valid data read out by garbage collection and / or wear-leveling at the same time. The control logic circuit 114 can also be used to control the NV memory 120, and includes an error correction code (Error Correction Code, ECC) circuit (not shown) to perform data protection and / or error correction, but the present invention is not limited to this. The transmission interface circuit 118 may comply with a specific communication specification (for example: Serial Advanced Technology Attachment (Serial Advanced Technology Attachment, SATA) specification, Universal Serial Bus (Universal Serial Bus, USB) specification, Peripheral Component Interconnect Express (Peripheral Component Interconnect Express, PCIE) specification, embedded Multi Media Card (embedded Multi Media Card, eMMC) specification, or Universal Flash Storage (UFS) specification), and communicate with the host device 50 according to the above-mentioned specific communication specification.
[0035] Generally speaking, the host device 50 can access the storage system 100 indirectly by transmitting host read / write commands and corresponding logical addresses to the memory controller 110. The memory controller 110 receives the host commands and the logical addresses, and translates the host commands into memory operation commands to further control the NV memory 120 using the memory operation commands to perform read, write or erase operations on memory cells or data pages (pages) with physical addresses in the NV memory 120. Among them, the physical address corresponds to the logical address. When the memory controller 110 performs an erase operation on any one of the multiple NV memory elements 122_1 to 122_N NV memory elements 122_k, at least one block of the NV memory element 122_k may be erased. In addition, each block of the NV memory element 122_k may include multiple pages, and the access operation may be performed on one or more pages (e.g., read or write).
[0036] In one embodiment, each of the NV memory elements 122_1 to 122_N can be an NV memory chip (or die). Each NV memory die 122_1 to 122_N has a control circuit for executing a memory operation command issued by the memory controller 110. In addition, each of the NV memory die 122_1 to 122_N can include multiple planes. Each plane can include multiple memory cell blocks and related row and column control circuits. The memory cells in each plane can be arranged in a two-dimensional or three-dimensional memory structure. According to a multi-plane operation command, multiple operations (such as reading, programming, erasing) can be performed in parallel (i.e., simultaneously) on memory blocks in different planes. That is, the multi-plane operation command allows multiple processing operations to be performed simultaneously on different planes.
[0037] In one embodiment, the memory controller 110 performs a pre-read operation on the NV memory 120 to improve the efficiency of sequential read access. The memory controller 110 determines whether the host read command issued by the host device 50 requests to read data with consecutive logical block addresses (LBAs) from the NV memory 120. If so, the pre-read operation is started to read the NV memory 120 according to the predicted starting LBA to obtain the pre-read data (i.e., the data that the host device 50 may request later).
[0038] The obtained pre-read data will be stored in the pre-read buffer 130. The pre-read buffer 130 can be provided by a portion of the system memory (not shown) allocated to the host device 50, or provided as a portion of the internal memory 113. In one embodiment, the size of the pre-read buffer 130 is associated with the amount of data that can be obtained from one of the NV memory dies 122_1~122_N through a multi-plane read operation. For example, if each NV memory die 122_1~122_N has four planes, the amount of data that can be obtained from one of the NV memory dies 122_1~122_N through a single multi-plane read operation will be 64K bytes (i.e., 4*16K bytes). Therefore, the minimum capacity of the pre-read buffer 130 can be 2*64K bytes, so that the pre-read buffer 130 can have enough space to simultaneously store: new data obtained through the pre-read operation, and data waiting to be transmitted back to the host device 50. In one embodiment, the maximum capacity of the pre-read buffer 130 is associated with the number of interleaving sets of the storage system 100. For example, if the storage system 100 has a 4-channel, 1-way interleaving architecture, the total amount of data simultaneously acquired from the 4 channels through 4 multi-plane read operations may be 256K bytes (4*64K bytes), which may be used as the maximum capacity of the pre-read buffer 130.
[0039] Please refer to Figure 2, which is a flow chart of a method for reading data from a flash memory device according to an embodiment of the present invention. The process starts at step S310, where it is determined whether the host device 50 requests a sequential read access to the NV memory 120. Further, the memory controller 110 needs to check whether a predetermined number of consecutive host read commands issued by the host device 50 correspond to a sequential read access of the NV memory 120. For example, the memory controller 110 may need to check whether three consecutive host read commands issued by the host device 50 correspond to a sequential read access. That is, if the starting LBA (i.e., SLBA) of a second host read command is equal to the starting LBA of a first host read command plus the sum of the number of logical blocks requested to be read by the first host read command (i.e., the number of logical blocks (NLBN)), the starting LBA of a third host read command is equal to the starting LBA of the second host read command plus the sum of the NLBN requested to be read by the second host read command, and the starting LBA of a fourth host read command is equal to the starting LBA of the third host read command plus the sum of the NLBN requested to be read by the third host read command, then it is determined that the host device 50 is requesting sequential read access to the NV memory 120; otherwise, the memory controller 110 will determine that the host device 50 is not requesting sequential read access.
[0040] If the result of the check in step S310 is yes, the process proceeds to step S311; otherwise, the process proceeds to step S312 and the pre-read operation is abandoned. In step S311, it is checked whether a new host read command issued by the host device 50 is received. If the result of the judgment in step S311 is yes, the process proceeds to S314; otherwise, the process proceeds to step S313.
[0041] In step S313, since the host device 50 has not issued a new host read command, it is checked whether the pre-read buffer 130 is full. If the pre-read buffer 130 is not full, the process enters step S315, performs a pre-read operation to obtain pre-read data, and stores the obtained pre-read data in the pre-read buffer 130. Preferably, in the pre-read operation, data will be read from the NV memory 120 according to a pre-read start LBA. The pre-read start LBA is usually equal to the start LBA of the previous host read command, plus the sum of the number of multiple logical blocks requested to be read by the previous host read command. However, in some cases, the pre-read start LBA will be equal to the start LBA of the previous pre-read operation, plus the sum of the number of logical blocks requested to be read by the previous pre-read operation.
[0042] In a preferred embodiment, in a pre-read operation, a chunk of data is obtained from the NV memory 120 each time and stored in the pre-read buffer 130. In the case where each NV memory die (or chip) 122_1-122_N has four planes, the size of a chunk of data is 64K bytes, which is the amount of data that can be read in a multi-plane read operation. On the other hand, if the pre-read buffer 130 is full, the process returns to step S311 to wait for a new host read command.
[0043] In step S314, the memory controller 110 receives a new host read command issued by the host device 50. Therefore, it is checked whether the starting LBA of the new host read command is continuous with the previous host read command (i.e., by checking whether the starting LBA of the new host read command is the same as: the starting LBA of the previous host read command plus the sum of the number of logical blocks requested to be read by the previous host read command). If so, the process proceeds to step S316; otherwise, the process returns to step S312. In step S316, it is checked whether the starting LBA of the new host read command matches one of the multiple starting LBAs corresponding to the pre-read data. If so, the process proceeds to step S317; otherwise, the process returns to step S312. In step S317, since the starting LBA of the new host read command matches one of the multiple starting LBAs corresponding to the pre-read data, it can be determined that the data requested to be read by the new host read command has been read from the NV memory 120 to the pre-read buffer 130. Therefore, a portion or all of a data block will be sent from the pre-read buffer 130 to the host device 50 (depending on the number of logical blocks requested to be read by the new host read command).
[0044] Accordingly, the process proceeds to step S318 to check whether there is any remaining pre-read data in the pre-read buffer 130 and whether there is any logical block that needs to be transmitted. Further, the memory controller 110 uses the counter value “RdAhAccSctrCnt” to record the total sector count of the pre-read data stored in the pre-read buffer 130, and uses the counter value “RLBN” to record the sector count of the data that needs to be sent to the host device 50.
[0045] If there is still pre-read data in the pre-read buffer 130 (i.e., RdAhAccSctrCnt≠0) and there are still logical blocks to be transmitted (i.e., RLBN≠0), the process returns to step S317 to transmit part or all of another data block in the pre-read buffer 130 to the host device 50. If all pre-read data in the pre-read buffer 130 has been sent to the host device 50 (i.e., RdAhAccSctrCnt=0), but there are still logical blocks to be transmitted (i.e., RLBN≠0), this means that all pre-read data in the pre-read buffer 130 has been sent to the host device 50. However, part of the data requested to be read by the new host read command has not been read by the pre-read operation. In view of this, the process enters step S319. Among them, the memory controller 110 will perform a normal read operation to read the NV memory 120, thereby obtaining the data requested by the new host read command but not read by the pre-read operation. On the other hand, if there is still pre-read data in the pre-read buffer 130 (i.e., RdAhAccSctrCnt≠0), but there is no logical block to be transmitted (i.e., RLBN=0), it means that the pre-read data has satisfied the data requested by the new host read command, and thus the new host read command has been completed. Accordingly, the process enters step S311 to wait for the next new host read command.
[0046] refer to Figure 3 , which illustrates how an embodiment of the present invention manages the pre-read data cache. In one embodiment, the memory controller 110 uses the index (index) "Head", the index "Tail" and the counter value "RdAhAccSctrCnt" to manage the pre-read data cache and record the cache status. The purpose of the index "Head" is to indicate the data block storage position in the pre-read cache 130, which indicates the location where the next data block obtained from the NV memory 120 through the pre-read operation should be stored. The purpose of the index "Tail" is to indicate the data block read position of the pre-read cache 130, which indicates the location of the first part of the data that is ready to be sent to the host device 50. The counter value "RdAhAccSctrCnt" indicates the total number of magnetic sectors of the data stored in the pre-read cache 130, which is used to reflect how much pre-read data is left in the pre-read cache 130. In Figure 3 In the illustrated embodiment, it is assumed that the data block read by a single pre-read operation is 64K bytes, and the capacity of the pre-read buffer 130 is 4 times the size of the data block (i.e., 4*64K bytes=256K bytes). In view of this, the index "Head" can be [0,1,2,3], and the index "Tail" can also be [0,1,2,3]. Figure 3Example (a) shows an initial state, in which no pre-read data is stored in the pre-read buffer 130. Therefore, the index “Head” and the index “Tail” are both 0, and the counter value “RdAhAccSctrCnt” is also 0. Figure 3 Example (b) shows a situation where a first data block is read through a pre-read operation and stored in the pre-read buffer 130. At this time, the index "Head" will increase by 1 (to indicate that the data block position "1" is a position in the pre-read buffer 130 that can be used to store the next data block). In addition, the index "Tail" remains at 0 (to indicate that the data that is ready to be transmitted to the host device 50 is stored in the block position "0"). In addition, since the magnetic sector size is 512 bytes, the counter value "RdAhAccSctrCnt" will be 0x80. Figure 3 Example (c) shows a situation where 4 data chunks are read through 4 pre-read operations and stored in the pre-read buffer 130. At this time, the index "Head" will return 0, and the index "Tail" will also return 0. Furthermore, the counter value "RdAhAccSctrCnt" will be 0x200 (i.e., the number of magnetic sectors corresponding to 256K bytes). Although the indexes "Head" and "Tail" in examples (a) and (c) are both 0, they can be distinguished by the counter value "RdAhAccSctrCnt". Example (d) shows a situation where the first data chunk stored in the pre-read buffer 130 has been sent to the host device 50. Therefore, the index "Head" remains at 0, and the index "Tail" increases by 1 (indicating that the next piece of data ready to be sent to the host device 50 is located at chunk position "1"). Furthermore, the counter value “RdAhAccSctrCnt” will decrease to 0x180 because 0x80 sectors are sent to the host device 50 .
[0047] Please refer to Figure 4A and Figure 4B , these diagrams show how to manage the starting LBA of the data read by the pre-read operation at different block positions and how to determine the pre-read starting LBA of the next pre-read operation in an embodiment of the present invention. In this embodiment, the memory controller 110 uses the array StartLBA[i], the array AccSctrCnt[i] and the value LeadLBA to record the starting LBA. Specifically, the array StartLBA[i] records the starting LBA corresponding to the data at the block position (i) stored in the pre-read buffer 130. The array AccSctrCnt[i] records the number of magnetic sectors of the data currently stored at the block position (i) of the pre-read buffer 130. The value LeadLBA represents the predicted starting LBA corresponding to the next pre-read operation.
[0048] Based on the start LBA of the pre-read data recorded by the array StartLBA[i], the memory controller 110 can determine whether the start LBA of a new host read command corresponds to the start LBA of one of the pre-read data. In addition, based on the value LeadLBA, the memory controller can determine the pre-read start LBA "RdAhLBA" of the next pre-read operation. Figure 4A In the illustrated scenario, four chunks of data are read from the NV memory 120 to the pre-read buffer 130. The starting LBAs corresponding to the four chunks of data (four pre-read data) are 0x0100, 0x0180, 0x0200, and 0x0280, respectively. Therefore, the LeadLBA value will be updated to 0x300. This value is determined based on the sum of the starting LBA of the most recent chunk of data (i.e., 0x280) and the number of sectors of the most recent chunk of data (i.e., 0x080), so the LeadLBA value will be 0x300. Then, a new host read command with a starting LBA (CmdLBA) of 0x100 matches the starting LBA (0x100) of the first chunk of data. Therefore, the memory controller 110 transmits the pre-read data back to the host device 50. On the other hand, since the starting LBA CmdLBA of the new host read command is 0x100, which is less than the value LeadLBA (0x300), the memory controller 110 uses the value LeadLBA as the pre-read starting LBA of the next pre-read operation. This is because the data whose LBA is less than 0x300 in the NV memory 120 has been read and stored in the pre-read buffer 130.
[0049] exist Figure 4BIn the illustrated case, the pre-read operation reads four data blocks (four pre-read block data) from the NV memory 120 to the pre-read buffer 130. The starting LBAs corresponding to these four data blocks are 0x100, 0x180, 0x200, and 0x280, respectively. Therefore, the value LeadLBA will be updated to 0x300, which is determined by the sum of the starting LBA of the most recent data block (i.e., 0x280) and the number of sectors of the most recent data block (i.e., 0x080). After a period of time, the host device 50 begins to send a series of host read commands, whose starting LBA CmdLBAs are 0x0100, 0x0180, 0x200, 0x280, 0x300, 0x380, 0x400, and 0x0480, respectively (each read command requires reading data of 0x80 sectors). In this case, since the LeadLBA value (i.e., 0x300) is less than the start LBA of the most recent host read command, the memory controller 110 will not use the LeadLBA value as the pre-read start LBA RdAhLBA. Instead, the memory controller 110 will determine the subsequent pre-read start LBA RdAhLBA (i.e., 0x0500) based on the sum of the start LBA of the data requested to be read by the last host read command (i.e., 0x0480) and the number of sectors (i.e., 0x080).
[0050] In one embodiment, the array StartLBA[i] can also be used by the memory controller 110 to determine whether the starting LBA of the new host read command matches any of the multiple starting LBAs corresponding to the pre-read data. Specifically, by setting i to the index "Tail", the starting LBA of the first part of the data ready to be sent to the host device 50 can be obtained. Therefore, the memory controller 110 can compare the value of "StartLBA[Tail]" with the starting LBA of the new host read command to determine whether there is a pre-read hit. Only in the case of a pre-read hit, the memory controller 110 will send the pre-read data whose starting LBA matches the LBA of the new host read command to the host device 50 in response to the new host read command. Otherwise, the memory controller 110 will perform a normal read operation on the NV memory 120 in response to the new host read command.
[0051] Figure 5A and Figure 5B More examples of how the embodiments of the present invention send pre-read data to the host device 50 are further explained. Figure 5AIn the example shown, a host read command with a starting LBA of 0x0100 is received, which requires reading data of 0x40 sectors (i.e., NLBN=0x40). On the other hand, the pre-read buffer 130 is full, so the index "Head" and the index "Tail" both point to the chunk position "0", and the counter value "RdAhAccSctrCnt" is 0x200. Since the starting LBA of the host read command hits the value of StartLBA[Tail(=0)], which points to the starting LBA of the data stored at the chunk position "0", the memory controller 110 sends the data in the pre-read buffer 130 to the host device 50 in response to the host read command. Since the NLBN (i.e., 0x40 sectors) is smaller in data size than the value of AccSctrCnt[0] (i.e., 0x80 sectors), only half of the data in the data chunk at the chunk position "0" of the pre-read buffer 130 will be sent to the host device 50. After a transaction, all sectors requested by the host read command have been sent, so the sector number RestSctr of the data that needs to be sent to the host device 50 is reduced from 0x40 to 0, and the total sector number "RdAhAccSctrCnt" in the pre-read buffer 130 is reduced to 0x1C0. After the host read command is completed, the indexes "Head" and "Tail" still point to the chunk position "0" because there is still data remaining in the chunk position "0". In addition, the value of StartLBA[Tail] (representing the starting LBA of the data pointed to by the index "Tail") will become 0x140 (i.e., StartLBA[Tail]+NLBN), and the value of AccSctrCnt[Tail] (representing the sector number of the data pointed to by the index "Tail") will become 0x040 (i.e., AccSctrCnt[Tail]-NLBN).
[0052] exist Figure 5BIn the example shown, a host read command with a starting LBA of 0x0100 is received, which requires reading data of 0xC0 magnetic sectors (i.e., NLBN=0xC0). On the other hand, the pre-read buffer 130 is full, so the index "Head" and the index "Tail" both point to the block position "0", and the counter value "RdAhAccSctrCnt" is 0x200. Since the starting LBA of the host read command hits the value of the array StartLBA[Tail(=0)] (which indicates the starting LBA of the data stored in the block position "0"), the memory controller 110 sends the data in the pre-read buffer 130 to the host device 50 in response to the host read command. Since NLBN (i.e., 0xC0 sectors) is larger in data size than the value of AccSctrCnt[0] (i.e., 0x80 sectors), the first block data at block position "0" of the pre-read buffer 130 and half of the second block data at block position "1" will be sent to the host device 50. After the first transaction, all sectors of the first block data are sent to the host device 50. Therefore, the number of sectors RestSctr of the data to be sent to the host device 50 will be reduced from 0xC0 to 0x40. Furthermore, the total number of sectors "RdAhAccSctrCnt" in the pre-read buffer 130 is reduced to 0x180. At this time, since all of the first block data in block position "0" has been sent, the index "Tail" will be increased by 1 to point to block position "1", thereby indicating that the block data in block position "1" has become the first part of the data ready to be sent to the host device 50. In addition, the index "Head" remains at the chunk position "0", and the value of StartLBA[Tail] (representing the starting LBA of the data pointed to by the index "Tail") becomes 0x180 (ie, StartLBA[1] = 0x0180).
[0053] After the second transaction, half of the sectors of the data chunk at chunk position "1" are sent to the host device 50, so the number of sectors RestSctr that needs to be sent to the host device 50 is reduced from 0x40 to 0. Also, the total number of sectors "RdAhAccSctrCnt" in the pre-read buffer 130 is reduced to 0x100. After the host read command is completed, the index "Tail" points to chunk position "1" because there is still data remaining in chunk position "1", while the index "Head" points to chunk position "0". In addition, the value of StartLBA[Tail(=1)] (representing the starting LBA of the data pointed to by the index "Tail") becomes 0x1C0. The value of AccSctrCnt[Tail] (representing the number of sectors of the data pointed to by the index "Tail") becomes 0x040.
[0054] Figure 6 A method for reading data from a flash memory in an embodiment of the present invention is shown. As shown in the figure, the method of the present invention includes the following simplified process:
[0055] Step S210: Determine whether a host device requires a sequential read access to the flash memory;
[0056] Step S220: If the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, a pre-read operation is performed according to a pre-read logical block address to read data from the flash memory;
[0057] Step S230: storing the data read by the pre-read operation in a pre-read buffer; and
[0058] Step S240: After receiving the first host read command issued by the host device, if a starting logical block address of the first host read command corresponds to one of multiple starting logical block addresses of the data stored in the pre-read buffer area, a part or all of the data read by the pre-read operation is sent to the host device.
[0059] Since the principles and specific details of the above steps have been explained in detail through the above embodiments, they will not be repeated here. It should be noted that the above process can be further improved in flexibility and read performance of the flash memory by adding other additional steps or making appropriate modifications and adjustments. In addition, all operations mentioned in the above embodiments can be performed by FIG. Figure 1 The memory controller shown in FIG. 1 is implemented as 110 .
[0060] The embodiments of the present invention may be specifically implemented as an apparatus, method or computer program product. Accordingly, the embodiments of the present invention may take the form of an entity implemented entirely by hardware, an entity implemented entirely by software (including firmware, resident software, microcode, etc.), or an entity combining software and hardware, which may be generally referred to as a "module" or "system". In addition, the embodiments of the present invention may take the form of a computer program product embodied in any tangible expression medium, and the medium has a computer-usable program code embodied in the medium. In terms of hardware, the present invention may be implemented by applying any of the following technologies or related combinations: separate operation logic of a logic gate capable of executing a logic function according to a data signal, and an application specific integrated circuit (ASIC), a programmable gate array (PGA) or a field programmable gate array (FPGA) with appropriate combinational logic.
[0061] The flow chart and block diagram illustrate the architecture, function and operation of the system, method and computer program product of different possible implementation methods of the embodiment of the present invention. In this regard, each block in the flow chart or block diagram may represent a module, section or a portion of the program code, which includes one or more executable commands to implement a specific logic function. It should also be noted that each block in the block diagram and / or flow chart, and the block combination in the block diagram and / or flow chart can be implemented by a special-purpose hardware base system, or a combination of special hardware and computer program commands. These computer program commands can be stored in a readable computer medium to command a computer or other programmable data processing device to operate in a specific manner so that the commands stored in the readable computer medium generate functions / operations specified in the blocks or block combinations that implement the flow chart and / or block diagram.
[0062] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A method for reading data from a flash memory, comprising: Determining whether a host device requires a sequential read access to the flash memory; If the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, a pre-read operation is performed according to a pre-read logical block address (LBA) to read data from the flash memory; storing the data read by the pre-read operation in a pre-read buffer; as well as After receiving the first host read command issued by the host device, if a starting LBA of the first host read command corresponds to one of multiple starting LBAs of the data stored in the pre-read cache area, part or all of the data read by the pre-read operation will be sent to the host device.
2. The method according to claim 1, characterized in that The step of performing the pre-read operation to read data from the flash memory comprises: The pre-read operation is performed to read a chunk of data from the flash memory and store the chunk of data in the pre-read buffer, wherein the size of the chunk of data is the same as the amount of data obtained when a multi-plane read operation is performed on the flash memory unit.
3. The method according to claim 1, characterized in that Also includes: Recording a starting LBA value of each piece of data at the block position stored in the pre-read buffer area to indicate a starting LBA of each piece of data in the pre-read buffer area; as well as A sector count value of each piece of data stored in the block position in the pre-read buffer is recorded to indicate a sector count value of each piece of data in the pre-read buffer.
4. The method according to claim 3, characterized in that Also includes: After receiving the first host read command, determining whether to send the data stored in the pre-read buffer area; and If the starting LBA of the data stored at a first block location in the pre-read buffer matches the starting LBA of the first host read command, at least a portion of the data stored at the first block location is sent.
5. The method according to claim 4, characterized in that Also includes: If the data size corresponding to the logical block required to be read by the first host read command is smaller than the data size corresponding to the number of magnetic sectors of the data at the first group block position, modifying the starting LBA value of the data stored at the first group block position in the pre-read cache area according to the sum of the starting LBA value of the data stored at the first group block position and the number of logical blocks required to be read by the first host read command; as well as If the data size corresponding to the logical block required to be read by the first host read command is smaller than the data size corresponding to the number of magnetic sectors of the data at the first group block position, the value of the number of magnetic sectors of the data stored at the first group block position is modified according to the difference between the value of the number of magnetic sectors of the data stored at the first group block position and the number of logical blocks required by the first host read command.
6. The method according to claim 1, characterized in that Also includes: Determine a predicted starting LBA according to a starting LBA of data at a most recent block location stored in the pre-read buffer and a number of magnetic sectors; If a sum of a starting LBA of a second host read command and the number of logical blocks required to be read by the second host read command is less than the predicted starting LBA, determining the pre-read starting LBA according to the predicted starting LBA; as well as If the sum of the starting LBA of the second host read command and the number of logical blocks required to be read by the second host read command is greater than the predicted starting LBA, determining the pre-read starting LBA according to the sum of the starting LBA of the second host read command and the number of logical blocks required to be read by the second host read command; The second host read command precedes the first host read command.
7. A memory controller for controlling a flash memory and reading data from the flash memory in a flash memory, comprising: a storage unit for storing information and program codes; A processing unit, configured to execute the program code to perform the following operations: Determining whether a host device requires a sequential read access to the flash memory; If the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, a pre-read operation is performed according to a pre-read logical block address (LBA) to read data from the flash memory; storing the data read by the pre-read operation in a pre-read buffer; as well as After receiving the first host read command issued by the host device, if a starting LBA of the first host read command corresponds to one of multiple starting LBAs of the data stored in the pre-read cache area, part or all of the data read by the pre-read operation will be sent to the host device.
8. The memory controller according to claim 7, wherein: The processing unit is used to: The pre-read operation is performed to read a chunk of data from the flash memory and store the chunk of data in the pre-read buffer, wherein the size of the chunk of data is the same as the amount of data obtained when a multi-plane read operation is performed on the flash memory unit.
9. The memory controller according to claim 7, wherein: The processing unit is used to: Recording a starting LBA value of each piece of data at the block position stored in the pre-read buffer area to indicate a starting LBA of each piece of data in the pre-read buffer area; as well as A sector count value of each piece of data stored in the block position in the pre-read buffer is recorded to indicate a sector count of each piece of data in the pre-read buffer.
10. The memory controller according to claim 9, wherein: The processing unit is used to: After receiving the first host read command, determining whether to send the data stored in the pre-read buffer area; and If the starting LBA of the data stored at a first block location in the pre-read buffer matches the starting LBA of the first host read command, at least a portion of the data stored at the first block location is sent.
11. The memory controller according to claim 10, wherein: The processing unit is used to: If the data size corresponding to the logical block required to be read by the first host read command is smaller than the data size corresponding to the number of magnetic sectors of the data at the first group block position, modifying the starting LBA value of the data stored at the first group block position in the pre-read cache area according to the sum of the starting LBA value of the data stored at the first group block position and the number of logical blocks required to be read by the first host read command; as well as If the data size corresponding to the logical block required to be read by the first host read command is smaller than the data size corresponding to the number of magnetic sectors of the data at the first group block position, the value of the number of magnetic sectors of the data stored at the first group block position is modified according to the difference between the value of the number of magnetic sectors of the data stored at the first group block position and the number of logical blocks required by the first host read command.
12. The memory controller according to claim 7, wherein: The processing unit is used to: Determine a predicted starting LBA according to a starting LBA of data at a most recent block location stored in the pre-read buffer and a number of magnetic sectors; If a sum of a starting LBA of a second host read command and the number of logical blocks required to be read by the second host read command is less than the predicted starting LBA, determining the pre-read starting LBA according to the predicted starting LBA; as well as If the sum of the starting LBA of the second host read command and the number of logical blocks required to be read by the second host read command is greater than the predicted starting LBA, determining the pre-read starting LBA according to the sum of the starting LBA of the second host read command and the number of logical blocks required to be read by the second host read command; The second host read command precedes the first host read command.
13. A storage system comprising: a flash memory; and A memory controller is used to control the flash memory and read data from the flash memory in the flash memory, wherein the memory controller is used to: Determining whether a host device requires a sequential read access to the flash memory; If the host device requires the sequential read access to the flash memory, before receiving a first host read command issued by the host device, a pre-read operation is performed according to a pre-read logical block address (LBA) to read data from the flash memory; storing the data read by the pre-read operation in a pre-read buffer; as well as After receiving the first host read command issued by the host device, if a starting LBA of the first host read command corresponds to one of multiple starting LBAs of the data stored in the pre-read cache area, part or all of the data read by the pre-read operation will be sent to the host device.
Citation Information
Cited By
Test method and test device for memory chip
CN119479769A
Memory controller and three-dimensional stacked memory
CN120407468A
