The present invention relates to a flash memory, and more particularly, to a method for managing a flash memory module and a related flash memory controller and an electronic device.
When a flash memory controller needs to read data in a flash memory module, the flash memory controller needs to search for one or more logical address to physical address (L2P) mapping tables to find the physical address of the required information. In order to speed up finding the correct L2P mapping table and searching for the physical address, a buffer memory is provided in the flash memory controller to temporarily store multiple L2P mapping tables. However, since the buffer memory has limited space and therefore cannot access too many L2P mapping table. If for some applications with smaller address management units, for example, using 4 KB as a unit to record the logical addresses and the physical addresses, it will seriously reduce the number of the L2P mapping table that can be stored in the buffer, and this will result in that the flash memory controller needs to frequently read the required L2P mapping tables from external components (for example, DRAM or the flash memory module), and the read efficiency is reduced.
Therefore, one of the objectives of the present invention is to provide a method for managing a flash memory module, which can improve the reading efficiency with a limited buffer memory capacity, to solve the above-mentioned problem.
According to a first aspect of the present invention, an exemplary method for managing a flash memory module is disclosed. The method comprises: reading a logical address to physical address (L2P) mapping table from the flash memory module; compressing the L2P mapping table to generate a compressed mapping table, wherein the compressed mapping table records a reference physical address and whether a corresponding physical address of each logical address is the reference physical address plus an offset value; when receiving a read command asking for reading data corresponding to a specific logical address, referring to the compressed mapping table to determine a specific physical address corresponding to the specific logical address, and reading the data from the flash memory module according to the specific physical address.
According to a second aspect of the present invention, an exemplary flash memory controller is disclosed, wherein the flash memory controller is utilized for accessing a flash memory module, and the flash memory controller comprises: a read-only memory (ROM) and a microprocessor. The ROM is utilized for storing a code. The microprocessor is utilized for executing the code to control access to the flash memory module, wherein the microprocessor reads a logical address to physical address (L2P) mapping table from the flash memory module, and compresses the L2P mapping table to generate a compressed mapping table, wherein the compressed mapping table records a reference physical address and whether a corresponding physical address of each logical address is the reference physical address plus an offset value; and when receiving a read command asking for reading data corresponding to a specific logical address, the microprocessor refers to the compressed mapping table to determine a specific physical address corresponding to the specific logical address, and reads the data from the flash memory module according to the specific physical address.
According to a third aspect of the present invention, an exemplary electronic device is disclosed. The electronic device comprises: a flash memory module and a flash memory controller. The flash memory controller is utilized for accessing the flash memory module, wherein the flash memory controller reads a logical address to physical address (L2P) mapping table from the flash memory module, and compresses the L2P mapping table to generate a compressed mapping table, wherein the compressed mapping table records a reference physical address and whether a corresponding physical address of each logical address is the reference physical address plus an offset value; and when receiving a read command asking for reading data corresponding to a specific logical address, the flash memory controller refers to the compressed mapping table to determine a specific physical address corresponding to the specific logical address, and reads the data from the flash memory module according to the specific physical address.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Please refer to
In a typical situation, the flash memory module 120 comprises a plurality of flash memory chips, and each flash memory chip comprises a plurality of blocks, and the data erasing operation for the flash memory module 120 by the controller (e.g., the flash memory controller 110 executing the code 112C via the microprocessor 112) is performed in units of blocks. In addition, a block can record a specific number of data pages (data pages) in which the data writing operation for the flash memory module 120 by the controller (e.g., the flash memory controller 110 executing the code 112C via the microprocessor 112) is performed to write in units of data pages. In this embodiment, the flash memory module 120 is a three-dimensional NAND type flash memory (3D NAND-type flash).
In practice, the flash memory controller 110 executing the code 112C via the microprocessor 112, can perform a number of control operations by using its own internal components, such as controlling the flash memory module 120 by using the control logic 114 (especially the access operations for at least one block or at least one data page), buffering the required buffering operations by using the buffer memory 116, and using the interface logic 118 to communicate with a host device 130. The buffer memory 116 is implemented in a random access memory (RAM). For example, the buffer memory 116 can be a static random access memory (SRAM), but the present invention is not limited thereto.
In an embodiment, the memory device 100 can be a portable memory device (e.g., a memory card that complies with to the SD/MMC, CF, MS, XD standard), and the host device 130 can be an electronic device capable of connecting to the memory device, such as cell phones, laptops, desktops, etc. In another embodiment, the memory device 100 can be a solid-status hard disk or an embedded storage that complies with Universal Flash Storage (UFS) or Embedded Multi Media Card (EMMC) specification, which is provided in an electronic device, such as in a mobile phone, a notebook computer, a desktop computer, and the host device 130 can be a processor of the electronic device.
Please refer to
In the step 212, the microprocessor 112 compresses the read L2P mapping table to generate a compressed mapping table, wherein the compressed mapping table records a reference physical address and whether the corresponding physical address of each logical address is the reference physical address plus an offset value. Referring to
In the compressed mapping table 400 shown in
Next, in the step 214, the microprocessor 112 can use the compressed mapping table 400 or the L2P mapping table 300 to determine the physical address corresponding to the specific logical address of the read command. Assuming that the specific logical address is LBA2, since the sequence bit corresponding to the logical address LBA2 in the compressed mapping table 400 is 1, the microprocessor 112 can simply set the reference physical address (the fourth data page of the second block) plus the corresponding offset value (2 data pages) of the logical address LBA2 to quickly obtain the physical address of the logical address LBA2 (the sixth data page of the second block) without searching the L2P mapping table 300, so as to improve the efficiency of the flash memory controller 110.
In the step 216, the microprocessor 112 uses the determined physical address to read the data from the flash memory module 120, and transmits the read data back to the host device 130. After that, the flow returns to the step 202.
Next, assuming that the flash memory controller 110 receives another read command from the host device to request to read the data having the logical addresses LBA6, LBA7 from the flash memory module 120, the relevant information (that is, the L2P mapping table 300 and the compressed mapping table 400) of the logical addresses LBA6 and LBA7 already exists in the current buffer memory 116. Therefore, the flow proceeds from the step 204 to the step 206. In the step 206, the microprocessor 112 firstly refers to the compressed mapping table 400 to determine the physical addresses corresponding to the logical addresses LBA6 and LBA7. If the physical address can not be determined through the compressed mapping table 400, then the L2P mapping table 300 will be utilized again. Specifically, since the sequence bit corresponding to the logical address LBA6 recorded in the compressed mapping table 400 is 1, the microprocessor 112 can simply set the reference physical address (the fourth data page of the second block) plus the corresponding offset value (6 data pages) of the logical address LBA6 to quickly obtain the physical address of the logical address LBA6 (the tenth data page of the second block). In addition, since the compressed mapping table 400 records that the sequence bit corresponding to the logical address LBA7 is 0, so the microprocessor 112 needs to search the L2P mapping table 300 for the physical address corresponding to the logical address LBA7.
In the step 208, the microprocessor 112 uses the determined physical address to read the data from the flash memory module 120, and transmits the read data back to the host device 130. After that, the flow returns to the step 202.
In the above embodiments of
Referring to
In the step 512, the microprocessor 112 compresses the read L2P mapping table to generate a compressed mapping table and a random data mapping table. The compressed mapping table records a reference physical address and whether the corresponding physical address of each logical address is the reference physical address plus an offset value, and the compressed mapping table can be the compressed mapping table 400 shown in
In this embodiment, the compressed mapping table 400 and the random data mapping table 600 are stored in the buffer memory 116, and since the compressed mapping table 400 and the random data mapping table 600 can completely replace the function of the L2P mapping table 300, the L2P mapping table 300 can be removed from the buffer memory 116 after the compressed mapping table 400 and the random data mapping table 600 are successfully generated, so as to release the space of the buffer memory 116.
Next, in the step 514, the microprocessor 112 can use the compressed mapping table 400 or the L2P mapping table 300 to determine the physical address corresponding to the specific logical address of the read command. Assuming that the specific logical address is LBA1, since the sequence bit corresponding to the logical address LBA1 in the compressed mapping table 400 is 1, the microprocessor 112 can simply set the reference physical address (the fourth data page of the second block) plus the corresponding offset value (1 data page) of the logical address LBA2 to quickly obtain the physical address of the logical address LBA1 (the fifth data page of the second block). In addition, suppose The specific logical address is LBA3, then the microprocessor 112 can search out the physical address corresponding to the logical address LBA3 from the random data mapping table 600, and since the data amount in the random data mapping table 600 is small, the amount of time that the microprocessor 112 spends in searching can also be significantly reduced.
In the step 516, the microprocessor 112 uses the determined physical address to read the data from the flash memory module 120, and transmits the read data to the host device 130. Next, the flow returns to the step 502.
Next, assuming that the flash memory controller 110 receives another read command from the host device to request that the data having the logical addresses LBA6 and LBA7 to read from the flash memory module 120, since the current buffer memory 116 already has the related information of the logical addresses LBA6 and LBA7 (i.e. the compressed mapping table 400 and the random map 600), the flow will proceed from the step 504 to the step 506. Since the operations of the steps 506 and 508 are respectively the same as the steps 514 and 516, the details are not described herein again.
In the above embodiment of
On the other hand, since the compressed mapping table 400 and the random data mapping table 600 have a small capacity, a plurality of compressed mapping tables 400 and random data mapping tables 600 generated by different L2P mapping tables can reside on the buffer memory 116, so that when a read command is received, the required physical address can be quickly and directly obtained from the buffer memory 116 to speed up the reading efficiency.
Briefly summarized the present invention, in the method for managing a flash memory module of the present invention, by setting up a compressed mapping table and a random data mapping table, it is possible to make the flash memory controller temporarily store many L2P mapping tables with a limited buffer memory capacity, in order to further increase the reading efficiency and solve the problems in the prior art.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method can be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
107100464 | Jan 2018 | TW | national |