Storage controller, storage management method and storage device
By grouping the physical block pages of the memory module and updating the count, selecting sorting and recycling blocks, the problem of low garbage collection efficiency in the storage device is solved and the storage efficiency is improved.
Patent Information
- Application Number
- CN201911325172.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-20
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2039-12-20
AI Technical Summary
The existing storage devices have low efficiency in garbage collection operations in rewriteable nonvolatile memory modules, resulting in reduced storage device performance.
Select and sort the recycled entity blocks to perform garbage collection by grouping the entity pages of multiple entity blocks and updating the section valid data count, block valid data count and valid segment count according to the write instructions. operate.
It improves the efficiency of garbage collection operations, enhances the overall access efficiency of the storage device, and effectively frees up the space of the rewriteable non-volatile memory module.
Smart Images

Figure CN113010444B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a memory management method, and in particular to a storage device equipped with a rewritable non-volatile memory module, a storage controller of the storage device, and a memory management method used therein. Background Art
[0002] Generally speaking, when the free space of the rewritable non-volatile memory module of the storage device is insufficient, the controller of the storage device will perform a garbage collection operation on multiple physical blocks (also known as recycled physical blocks) of the rewritable non-volatile memory module to release the available space of the multiple recycled physical blocks.
[0003] The garbage collection operation needs to consume a lot of time to identify the physical addresses of the valid data stored in the plurality of recycled physical blocks, thereby reducing the performance of the rewritable non-volatile memory module when performing the garbage collection operation.
[0004] Therefore, how to effectively increase the speed of garbage collection operations to improve the performance of storage devices is one of the research topics of those skilled in the art. Summary of the invention
[0005] An embodiment of the present invention provides a storage controller for controlling a storage device configured with a rewritable non-volatile memory module. The storage controller includes a connection interface circuit, a memory interface control circuit, a block management circuit unit, and a processor. The connection interface circuit is used to couple to a host system. The memory interface control circuit is used to couple to the rewritable non-volatile memory module, wherein the rewritable non-volatile memory module has a plurality of physical blocks, and each of the plurality of physical blocks has a plurality of physical pages. The processor is coupled to the connection interface circuit, the memory interface control circuit, and the block management circuit unit. The block management circuit unit is used to group the plurality of physical pages of each of the plurality of physical blocks into a plurality of physical segments. The processor is used to execute a write instruction, wherein the write instruction is used to instruct to store a data in one or more logical pages, wherein the one or more logical pages have been mapped to one or more target physical pages of a target physical block, and the one or more target physical pages belong to a first target physical segment among a plurality of target physical segments of the target physical block. In addition, the block management circuit unit is also used to update a first target segment valid data count corresponding to the first target physical segment among a plurality of target segment valid data counts of the plurality of target physical segments according to the write instruction, wherein the block management circuit unit is also used to update a target block valid data count corresponding to the target physical block among a plurality of block valid data counts of the plurality of physical blocks according to the updated first target segment valid data count, wherein the block management circuit unit is also used to update a target valid segment count corresponding to the target physical block among a plurality of valid segment counts of the plurality of physical blocks according to the plurality of target segment valid data counts of the target physical block, wherein each of the plurality of valid segment counts is used to record the total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero.
[0006] An embodiment of the present invention provides a memory management method for a storage controller used to control a storage device configured with a rewritable non-volatile memory module, wherein the rewritable non-volatile memory module has a plurality of physical blocks, and each of the plurality of physical blocks has a plurality of physical pages. The method comprises: grouping the plurality of physical pages of each of the plurality of physical blocks into a plurality of physical sections; executing a write instruction, wherein the write instruction is used to instruct to store a data in one or more logical pages, wherein the one or more logical pages have been mapped to one or more target physical pages of a target physical block, and the one or more target physical pages belong to a first target physical section among a plurality of target physical sections of the target physical block; updating a first target section corresponding to the first target physical section in a plurality of target section valid data counts of the plurality of target physical sections according to the write instruction; a target block valid data count of a target physical block in a plurality of block valid data counts of the plurality of physical blocks according to the updated first target segment valid data count; and a target valid segment count of a target physical block in a plurality of valid segment counts of the plurality of physical blocks corresponding to the target physical block according to the plurality of target segment valid data counts of the target physical block, wherein each of the plurality of valid segment counts is used to record the total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero.
[0007] One embodiment of the present invention provides a storage device. The storage device includes a rewritable non-volatile memory module and a storage controller, wherein the rewritable non-volatile memory module has a plurality of physical blocks, and each of the plurality of physical blocks has a plurality of physical pages. The storage controller is coupled to the rewritable non-volatile memory module. The storage controller is used to group the plurality of physical pages of each physical block in the plurality of physical blocks into a plurality of physical segments, wherein the storage controller is also used to execute a write instruction, wherein the write instruction is used to instruct to store a data in one or more logical pages, wherein the one or more logical pages have been mapped to one or more target physical pages of a target physical block, and the one or more target physical pages belong to a first target physical segment among a plurality of target physical segments of the target physical block. The storage controller is further used to update a first target segment valid data count corresponding to the first target physical segment among multiple target segment valid data counts of the multiple target physical segments according to the write instruction, wherein the storage controller is further used to update a target block valid data count corresponding to the target physical block among multiple block valid data counts of the multiple physical blocks according to the updated first target segment valid data count, wherein the storage controller is further used to update a target valid segment count corresponding to the target physical block among multiple valid segment counts of the multiple physical blocks according to the multiple target segment valid data counts of the target physical block, wherein each of the multiple valid segment counts is used to record the total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero.
[0008] Based on the above, the storage controller, memory management method and storage device provided by the embodiments of the present invention can group the multiple physical pages of each physical block in the multiple physical blocks of the rewritable non-volatile memory module into multiple physical segments, update the corresponding segment valid data count, the corresponding valid data count and the corresponding valid segment count according to the write instruction, and use the block valid data count and the valid segment count to select and sort multiple recycled physical blocks, so as to perform garbage collection operations on the multiple garbage physical blocks in sequence according to the concentration of valid data, thereby efficiently releasing the space of the rewritable non-volatile memory module and improving the overall access performance of the storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 is a block diagram of a host system and a storage device according to an embodiment of the present invention;
[0010] Figure 2is a flowchart of a memory management method according to an embodiment of the present invention;
[0011] Figure 3 is a flowchart of a garbage collection operation according to an embodiment of the present invention;
[0012] Figure 4A is a schematic diagram of a codeword, a physical page, a physical block and a rewritable non-volatile memory module according to an embodiment of the present invention;
[0013] Figure 4B is a schematic diagram showing a plurality of physical pages of a grouped physical block into a plurality of physical sections according to an embodiment of the present invention;
[0014] FIG. 5A to FIG. 5B A schematic diagram of updating a valid data count according to a write instruction according to an embodiment of the present invention;
[0015] Fig. 6A A schematic diagram of a valid data count and a valid segment count of a recording segment according to an embodiment of the present invention;
[0016] Figure 6B FIG. 4 is a schematic diagram showing selecting and sorting a plurality of recycled physical blocks according to a block valid data count and a valid section count according to an embodiment of the present invention.
[0017] Description of Reference Numerals
[0018] 10: Host system
[0019] 20: Storage device
[0020] 110, 211: Processor
[0021] 120: Host memory
[0022] 130: Data transmission interface circuit
[0023] 210: Storage controller
[0024] 212: Data management circuit
[0025] 213: Memory interface control circuit
[0026] 214: Error checking and correction circuit
[0027] 215: Block management circuit unit
[0028] 2151: Valid data counting circuit
[0029] 2152: Valid Segment Management Circuit
[0030] 216: Buffer memory
[0031] 217: Power Management Circuit
[0032] 220: Rewritable non-volatile memory module
[0033] 230: Connecting interface circuit
[0034] S210, S220, S230, S240, S250: Process steps of the memory management method
[0035] S310, S320, S330: Process steps of garbage collection operation
[0036] CW(1)~CW(M): codeword
[0037] WC: Write command
[0038] P(1)~P(NP), 51(1)~54(2): Entity pages
[0039] B(1)~B(Q), 50, 60, 70, 80: physical blocks
[0040] S(1), S(2) to S(N), 51, 52, 53, 54: physical segments
[0041] L51(1)~L54(2): Logical page
[0042] A51, A52, A61, A62, A63: Arrow
[0043] T60: Table DETAILED DESCRIPTION
[0044] In this embodiment, the storage device includes a rewritable non-volatile memory module and a storage device controller (also called a storage controller or a storage control circuit). In addition, the storage device is used together with a host system so that the host system can write data to the storage device or read data from the storage device.
[0045] Figure 1 is a block diagram of a host system and a storage device according to an embodiment of the present invention.
[0046] Please refer to Figure 1The host system 10 includes a processor 110, a host memory 120, and a data transfer interface circuit 130. In this embodiment, the data transfer interface circuit 130 is coupled (also known as electrically connected) to the processor 110 and the host memory 120. In another embodiment, the processor 110, the host memory 120, and the data transfer interface circuit 130 are coupled to each other using a system bus.
[0047] The storage device 20 includes a storage controller 210, a rewritable non-volatile memory module 220 and a connection interface circuit 230. The storage controller 210 includes a processor 211, a data management circuit 212 and a memory interface control circuit 213.
[0048] In this embodiment, the host system 10 is coupled to the storage device 20 through the data transmission interface circuit 130 and the connection interface circuit 230 of the storage device 20 to perform data access operations. For example, the host system 10 can store data to the storage device 20 or read data from the storage device 20 via the data transmission interface circuit 130.
[0049] In this embodiment, the processor 110, the host memory 120 and the data transmission interface circuit 130 can be arranged on the mainboard of the host system 10. The number of the data transmission interface circuit 130 can be one or more. Through the data transmission interface circuit 130, the mainboard can be coupled to the storage device 20 via wired or wireless means. The storage device 20 can be, for example, a USB flash drive, a memory card, a solid state drive (SSD) or a wireless memory storage device. The wireless memory storage device can be, for example, a near field communication (NFC) memory storage device, a wireless fax (WiFi) memory storage device, a Bluetooth memory storage device or a low power consumption Bluetooth memory storage device (e.g., iBeacon) and other memory storage devices based on various wireless communication technologies. In addition, the mainboard can also be coupled to various I / O devices such as a global positioning system (GPS) module, a network interface card, a wireless transmission device, a keyboard, a screen, a speaker, etc. through the system bus.
[0050] In this embodiment, the data transmission interface circuit 130 and the connection interface circuit 230 are interface circuits compatible with the high-speed peripheral component interconnect interface (Peripheral Component Interconnect Express, PCI Express) standard. In addition, the data transmission interface circuit 130 and the connection interface circuit 230 use the fast non-volatile memory interface standard (Non-Volatile Memory express, NVMe) communication protocol to transmit data.
[0051] However, it should be understood that the present invention is not limited thereto, and the data transmission interface circuit 130 and the connection interface circuit 230 may also comply with the Parallel Advanced Technology Attachment (PATA) standard, the Institute of Electrical and Electronic Engineers (IEEE) 1394 standard, the Serial Advanced Technology Attachment (SATA) standard, the Universal Serial Bus (USB) standard, the SD interface standard, the Ultra High Speed-I (UHS-I) interface standard, the Ultra High Speed-II (UHS-II) interface standard, the Memory Stick (MS) interface standard, the Multi-Chip Package (MCP) interface standard, the Multi Media Card (MMC) interface standard, the eMMC interface standard, the Universal Flash Storage (UFS) interface standard, the eMCP interface standard, the CF interface standard, the Integrated Device Electronics (IDE) standard or other suitable standards. Furthermore, in another embodiment, the connection interface circuit 230 and the memory controller 210 may be packaged in one chip, or the connection interface circuit 230 may be disposed outside a chip including the memory controller 210 .
[0052] In this embodiment, the host memory 120 is used to temporarily store instructions or data executed by the processor 110. For example, in this exemplary embodiment, the host memory 120 can be a dynamic random access memory (DRAM), a static random access memory (SRAM), etc. However, it should be understood that the present invention is not limited thereto, and the host memory 120 can also be other suitable memories.
[0053] The storage controller 210 is used to execute a plurality of logic gates or control instructions implemented in hardware or firmware and to perform operations such as writing, reading and erasing data in the rewritable non-volatile memory module 220 according to instructions of the host system 10 .
[0054] More specifically, the processor 211 in the storage controller 210 is hardware with computing capabilities, which is used to control the overall operation of the storage controller 210. Specifically, the processor 211 has a plurality of control instructions, and when the storage device 20 operates, these control instructions are executed to perform operations such as writing, reading and erasing data.
[0055] It is worth mentioning that in the present embodiment, the processor 110 and the processor 211 are, for example, a central processing unit (CPU), a microprocessor, or other programmable processing units (Microprocessor), a digital signal processor (DSP), a programmable controller, an application specific integrated circuit (ASIC), a programmable logic device (PLD) or other similar circuit elements, but the present invention is not limited thereto.
[0056] In one embodiment, the storage controller 210 also has a read-only memory (not shown) and a random access memory (not shown). In particular, the read-only memory has a boot code, and when the storage controller 210 is enabled, the processor 211 first executes the boot code to load the control instructions stored in the rewritable non-volatile memory module 220 into the random access memory of the storage controller 210. Afterwards, the processor 211 runs these control instructions to perform operations such as writing, reading and erasing data. In another embodiment, the control instructions of the processor 211 can also be stored in a specific area of the rewritable non-volatile memory module 220 in the form of program code, for example, in a physical storage unit in the rewritable non-volatile memory module 220 dedicated to storing system data.
[0057] In this embodiment, as described above, the storage controller 210 further includes a data management circuit 212 and a memory interface control circuit 213. It should be noted that the operations performed by the components of the storage controller 210 can also be regarded as the operations performed by the storage controller 210.
[0058] The data management circuit 212 is coupled to the processor 211, the memory interface control circuit 213 and the connection interface circuit 230. The data management circuit 212 is used to receive instructions from the processor 211 to transmit data. For example, data is read from the host system 10 (e.g., the host memory 120) via the connection interface circuit 230, and the read data is written to the rewritable non-volatile memory module 220 via the memory interface control circuit 213 (e.g., the write operation is performed according to the write instruction from the host system 10). For another example, data is read from one or more physical units of the rewritable non-volatile memory module 220 via the memory interface control circuit 213 (the data can be read from one or more storage units in the one or more physical units), and the read data is written to the host system 10 (e.g., the host memory 120) via the connection interface circuit 230 (e.g., the read operation is performed according to the read instruction from the host system 10). In another embodiment, the data management circuit 212 can also be integrated into the processor 211.
[0059] The memory interface control circuit 213 is used to receive instructions from the processor 211 and cooperate with the data management circuit 212 to perform a write (also called programming) operation, a read operation or an erase operation on the rewritable non-volatile memory module 220 .
[0060] For example, the processor 211 may execute a write instruction sequence to instruct the memory interface control circuit 213 to write data into the rewritable non-volatile memory module 220; the processor 211 may execute a read instruction sequence to instruct the memory interface control circuit 213 to read data from one or more physical units (also known as target physical units) of the rewritable non-volatile memory module 220 corresponding to the read instruction; the processor 211 may execute an erase instruction sequence to instruct the memory interface control circuit 213 to perform an erase operation on the rewritable non-volatile memory module 220. The write instruction sequence, the read instruction sequence, and the erase instruction sequence may each include one or more program codes or instruction codes and are used to instruct the execution of corresponding write, read, and erase operations on the rewritable non-volatile memory module 220. In one embodiment, the processor 211 may also issue other types of instruction sequences to the memory interface control circuit 213 to execute corresponding operations on the rewritable non-volatile memory module 220.
[0061] In addition, the data to be written to the rewritable non-volatile memory module 220 will be converted into a format acceptable to the rewritable non-volatile memory module 220 via the memory interface control circuit 213. Specifically, if the processor 211 wants to access the rewritable non-volatile memory module 220, the processor 211 will transmit a corresponding instruction sequence to the memory interface control circuit 213 to instruct the memory interface control circuit 213 to perform a corresponding operation. For example, these instruction sequences may include a write instruction sequence indicating writing data, a read instruction sequence indicating reading data, an erase instruction sequence indicating erasing data, and corresponding instruction sequences for indicating various memory operations (for example, changing a plurality of preset read voltage values of a preset read voltage group to perform a read operation, or executing a garbage collection program, etc.). These instruction sequences may include one or more signals, or data on the bus. These signals or data may include instruction codes or program codes. For example, in the read instruction sequence, information such as a read identification code and a memory address may be included.
[0062] The rewritable non-volatile memory module 220 is coupled to the memory controller 210 (memory interface control circuit 213 ) and is used to store data written by the host system 10 . The rewritable non-volatile memory module 220 may be a single level cell (SLC) NAND flash memory module (i.e., a flash memory module in which one storage cell can store one bit), a multi level cell (MLC) NAND flash memory module (i.e., a flash memory module in which one storage cell can store two bits), a triple level cell (TLC) NAND flash memory module (i.e., a flash memory module in which one storage cell can store three bits), a quadruple level cell (QLC) NAND flash memory module (i.e., a flash memory module in which one storage cell can store four bits), a 3D NAND flash memory module, a vertical NAND flash memory module, or other flash memory modules or other memory modules with the same characteristics. The storage cells in the rewritable non-volatile memory module 220 are arranged in an array.
[0063] In this embodiment, the rewritable non-volatile memory module 220 has a plurality of word lines, wherein each of the plurality of word lines is coupled to a plurality of memory cells. The plurality of memory cells on the same word line will form one or more physical programming units. In addition, the plurality of physical programming units may form a physical unit (physical block or physical erasing unit).
[0064] In this embodiment, the memory cell is used as the minimum unit for writing (programming) data. The physical unit is the minimum unit for erasing, that is, each physical unit contains the minimum number of memory cells that are erased together.
[0065] Each physical unit may have a plurality of physical subunits. The physical subunit may be a physical page or a physical sector. In the present embodiment, the physical subunit includes a data bit area and a redundancy bit area. The data bit area is used to store user data, and the redundancy bit area is used to store system data. The system data may be, for example, an error correction code, an error checking code, or metadata. However, the present invention is not limited thereto. For example, in another embodiment, the data transmission method described in the present embodiment may also be varied and applied to a rewritable non-volatile memory module 220 that uses a physical unit as the minimum storage unit for writing data.
[0066] It should be noted that in this embodiment, the system data for recording the information of a physical unit can be recorded by using one or more physical sub-units in the physical unit, or by using one or more physical sub-units of a specific physical unit in a system area for recording all system data. In this embodiment, the system data corresponding to a physical unit includes information such as the program erase cycle (PEC) value of the physical unit, a block valid data count (Block Valid Data Count), multiple segment valid data counts (Segment Valid Data Count), and a valid segment count (Valid Segment Count) (also known as the total number of valid segments).
[0067] In the following embodiments, a physical block is used as an example of a physical unit. However, in another embodiment, a physical unit may also refer to any number of storage units, depending on practical needs. In addition, it must be understood that when the storage controller 210 groups the storage units (or physical units) in the rewritable non-volatile memory module 220 to perform corresponding management operations, these storage units (or physical units) are logically grouped, and their actual positions are not changed.
[0068] The storage controller 210 configures a plurality of logical units to the rewritable non-volatile memory module 220. The host system 10 accesses the user data stored in the plurality of physical units through the configured logical units. Here, each logical unit may be composed of one or more logical addresses. For example, the logical unit may be a logical block, a logical page, or a logical sector. A logical unit may be mapped to one or more physical units, wherein the physical unit may be one or more physical addresses, one or more physical sectors, one or more physical programming units, or one or more physical erasure units. In the present embodiment, the logical unit is a logical block, and the logical sub-unit is a logical page. Each logical unit has a plurality of logical sub-units.
[0069] In addition, the storage controller 210 will establish a logical to physical address mapping table (Logical To Physical address mapping table) and a physical to logical address mapping table (Physical To Logical address mapping table) to record the address mapping relationship between the logical unit (e.g., logical block, logical page or logical sector) configured for the rewritable non-volatile memory module 220 and the physical unit (e.g., physical erase unit, physical programming unit, physical sector). In other words, the storage controller 210 can use the logical to physical address mapping table to find the physical unit mapped by a logical unit, and the storage controller 210 can use the physical to logical address mapping table to find the logical unit mapped by a physical unit. However, the above-mentioned technical concepts related to the mapping of logical units and physical units are conventional technical means of those skilled in the art and are not the technical solutions to be described in the present invention, and will not be repeated here. For example, the host system 10 can be configured with multiple logical pages, and the multiple logical pages can be mapped to multiple physical pages.
[0070] In the present embodiment, the error checking and correction circuit 214 is coupled to the processor 211 and is used to perform an error checking and correction procedure to ensure the correctness of the data. Specifically, when the processor 211 receives a write instruction from the host system 10, the error checking and correction circuit 214 generates a corresponding error correction code (ECC) and / or an error detecting code (EDC) for the data corresponding to the write instruction, and the processor 211 writes the data corresponding to the write instruction and the corresponding error correction code and / or error checking code into the rewritable non-volatile memory module 220. Afterwards, when the processor 211 reads data from the rewritable non-volatile memory module 220, the error correction code and / or error checking code corresponding to the data will be read at the same time, and the error checking and correction circuit 214 will perform an error checking and correction procedure on the read data according to the error correction code and / or error checking code.
[0071] In one embodiment, the storage controller 210 further includes a buffer memory 216 and a power management circuit 217. The buffer memory is coupled to the processor 211 and is used to temporarily store data and instructions from the host system 10, data from the rewritable non-volatile memory module 220, or other system data used to manage the storage device 20, so that the processor 211 can quickly access the data, instructions or system data from the buffer memory 216. The power management circuit 217 is coupled to the processor 211 and is used to control the power of the storage device 20.
[0072] In this embodiment, the block management circuit unit 215 includes a valid data counting circuit 2151 and a valid segment management circuit 2152. The block management circuit unit 215 is used to manage the information of multiple physical blocks in the rewritable non-volatile memory module 220. The operation of each component of the block management circuit unit 215 can also represent the operation of the block management circuit unit 215. Figure 2 The function of the block management circuit unit 215 and the corresponding memory management method provided by this embodiment are described.
[0073] Figure 2 is a flow chart of a memory management method according to an embodiment of the present invention. Figure 2 In step S210, the block management circuit unit 215 groups multiple physical pages of each physical block of the multiple physical blocks of the rewritable non-volatile memory module 220 into multiple physical segments. Figure 4A , Figure 4B To explain.
[0074] Figure 4Ais a schematic diagram of a codeword, a physical page, a physical block, and a rewritable non-volatile memory module according to an embodiment of the present invention. Figure 4B FIG. 4 is a schematic diagram showing a grouping of multiple physical pages of a physical block into multiple physical sections according to an embodiment of the present invention.
[0075] Please refer to Figure 4A In the present embodiment, the data received from the host system 10 is stored in a physical page in units of codewords, such as codewords CW(1) to CW(M), where M is a positive integer. Depending on the specifications of each rewritable non-volatile memory module 220, the number of codewords stored in each physical page is different. Multiple physical pages P(1) to P(NP) are divided into a physical block, where N and P are positive integers (NP represents the product of N times P). Multiple physical blocks B(1) to B(Q) belong to the rewritable non-volatile memory module 220, where Q is a positive integer.
[0076] It should be noted that the present invention is not limited to specific values of M, N, P, and Q. The specific values of M, N, P, and Q are pre-set according to the specifications of the rewritable non-volatile memory module 220 or the requirements of the manufacturer.
[0077] Please refer to Figure 4B In this embodiment, the block management circuit unit 215 groups the multiple physical pages of each physical block. For example, the block management circuit unit 215 groups the multiple physical pages P(1) to P(NP) of the physical block B(1) into multiple physical segments S(1) to S(N). Each P physical pages are grouped into one physical segment, such as the physical segment S(1) includes physical pages P(1) to P(P), the physical segment S(2) includes physical pages P(P+1) to P(2P), the physical segment S(N) includes physical pages P(NP-P+1) to P(NP), and so on. After obtaining the grouped multiple physical segments S(1) to S(N), the block management circuit unit 215 can correspondingly record / maintain / update various information related to the multiple physical segments S(1) to S(N) (such as valid data count, segment valid data count, block valid data count, valid segment count, etc.).
[0078] Please return to Figure 2In step S220, the processor 211 executes a write instruction, wherein the write instruction is used to instruct to store a data in one or more logical pages of a logical block, wherein the logical block has been mapped to a target physical block among the multiple physical blocks, wherein the one or more logical pages have been mapped to one or more target physical pages of the target physical block, and the one or more target physical pages belong to a first target physical segment among multiple target physical segments of the target physical block. Specifically, the write instruction may be a write instruction received from the host system 10, or an instruction for updating / moving / copying data already stored in the rewritable non-volatile memory module 220.
[0079] In this embodiment, if one or more physical pages (also known as target physical pages) mapped by one or more logical pages corresponding to the write instruction already store data, the processor 211 will select other physical pages to store the write data corresponding to the write instruction, and the valid data stored in the one or more physical pages will become invalid data, thereby updating / reducing the valid data count of the one or more physical pages (based on the total number of all codewords that become invalid data in the one or more physical pages) via the block management circuit unit 215 (or the valid data counting circuit 2151).
[0080] On the other hand, if one or more physical pages (also referred to as target physical pages) mapped to one or more logical pages corresponding to the write instruction are blank (no data is stored), the processor 211 directly uses the one or more target physical pages to store the write data corresponding to the write instruction, and the write data stored in the one or more physical pages becomes valid data, and the valid data count of the one or more physical pages is updated / increased via the block management circuit unit 215 (or the valid data counting circuit 2151) (based on the total number of all code words that are valid data in the one or more physical pages). On the other hand, if the one or more logical pages corresponding to the write instruction have not been mapped to one or more physical pages, the processor 211 selects one or more blank target physical pages to store the write data corresponding to the write instruction, and the write data stored in the one or more target physical pages becomes valid data, and the valid data count of the one or more target physical pages is updated / increased via the block management circuit unit 215 (or the valid data counting circuit 2151) (based on the total number of all code words that are valid data in the one or more physical pages). For example, assuming that a blank target physical page can store up to 4 codewords, in response to the write data corresponding to the write instruction stored in the target physical page just filling up the target physical page, the valid data count of the target physical page will increase from 0 to 4.
[0081] In step S230 , the block management circuit unit 215 (or the valid data counting circuit 2151 ) updates a first target sector valid data count corresponding to the first target physical sector among a plurality of target sector valid data counts of the plurality of target physical sectors according to the write command.
[0082] Next, in step S240 , the block management circuit unit 215 (or the valid data counting circuit 2151 ) updates the target block valid data count corresponding to the target physical block among the multiple block valid data counts of the multiple physical blocks according to the updated first target sector valid data count.
[0083] Next, in step S250, the block management circuit unit 215 (or the valid segment management circuit 2152) updates the target valid segment count corresponding to the target physical block in the multiple valid segment counts of the multiple physical blocks according to the multiple target segment valid data counts of the target physical block, wherein each of the multiple valid segment counts is used to record the total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero. FIG. 5A to FIG. 5B The details of steps S220 to S250 will be described.
[0084] FIG. 5A to FIG. 5B FIG. 1 is a schematic diagram showing updating a valid data count according to a write instruction according to an embodiment of the present invention. Figure 5A , assuming that multiple physical pages 51(1), 51(2), 52(1), 52(2), 53(1), 53(2), 54(1), 54(2) of physical block 50 have been mapped to logical pages L51(1), L51(2), L52(1), L52(2), L53(1), L53(2), L54(1), L54(2), and multiple codewords (also called invalid codewords) in the physical pages 51(1), 51(2) all store invalid data; and the codewords (also called valid codewords) in the physical pages 52(1), 52(2), 53(1), 53(2), 54(1), 54(2) all store valid data. In addition, in this example, every two physical pages are grouped into one physical segment, for example, physical pages 51(1) and 51(2) are grouped into physical segment 51; physical pages 52(1) and 52(2) are grouped into physical segment 52; physical pages 53(1) and 53(2) are grouped into physical segment 53; and physical pages 54(1) and 54(2) are grouped into physical segment 54.
[0085] Based on the total number of valid codewords in each physical page, the block management circuit unit 215 can identify that the valid data count of the physical page 51(1) is "0", the valid data count of the physical page 51(2) is "0", and the valid data counts of the physical pages 52(1) to 54(2) are all "4". In addition, the block management circuit unit 215 can calculate that the sum of the valid data counts of all the physical pages 51(1) to 51(2) in the physical segment 51 is "0" (e.g., 0+0=0), the sum of the valid data counts of all the physical pages 52(1) to 52(2) in the physical segment 52 is "8" (e.g., 4+4=8), the sum of the valid data counts of all the physical pages 53(1) to 53(2) in the physical segment 53 is "8" (e.g., 4+4=8), and the sum of the valid data counts of all the physical pages 54(1) to 54(2) in the physical segment 54 is "8" (e.g., 4+4=8).
[0086] Next, the block management circuit unit 215 (or the valid segment management circuit 2152) can further identify that the physical segment 51 corresponding to the segment valid data count of "0" is an invalid physical segment and the physical segments 52-54 corresponding to the segment valid data count of non-"0" are valid physical segments, and the block management circuit unit 215 calculates the total number of valid physical segments of the physical block 50 as the valid block count (e.g., the valid block count corresponding to the three valid physical segments 52-54 is "3"). In addition, the block management circuit unit 215 can also calculate the sum of all the segment valid data counts of all the physical segments 51-54 of the physical block 50 as the block valid data count of the physical block 50 (e.g., 0+8+8+8=24).
[0087] In this example, the processor 211 executes the write command WC, and as shown by arrow A51, the four codewords (write data) corresponding to the write command WC are written to the logical page L52(1). The block management circuit unit 215 (or the processor 211) can identify the physical page 52(1) mapped to the logical page L52(1) as the target physical page.
[0088] Please refer to Figure 5BAs shown by arrow A52, in response to the fact that the logical page L52(1) has stored the 4 codewords corresponding to the write instruction WC, the block management circuit unit 215 (or the processor 211) will recognize that the data of the 4 codewords originally stored in the target physical page 52(1) become invalid data, and the valid data count of the target physical page 52(1) is reduced by 4 (the valid data count of the target physical page 52(1) is reduced to "0" (i.e., 4-4=0)), and the segment valid data count of the physical segment 52 is updated from "8" to "4" (0+4=4). At this time, the block management circuit unit 215 (or the valid segment management circuit 2152) will recognize that the total number of valid physical segments of the physical block 50 is still 3 (the total number of valid physical segments with segment valid data counts greater than "0" is "3") based on the segment valid data counts of the latest identified physical segments 51-54, that is, the valid segment count is "3".
[0089] In one embodiment, the block management circuit unit 215 (or the processor 211) may record the valid data counts of the multiple segments corresponding to the multiple physical blocks and the valid segment counts. For example, the block management circuit unit 215 (or the processor 211) records the valid data counts of the multiple segments corresponding to the multiple physical blocks and the valid segment counts in a valid data count table.
[0090] Fig. 6A FIG. 1 is a schematic diagram showing a valid data count and a valid segment count of a recording segment according to an embodiment of the present invention. Fig. 6A As shown in Table T60, for the sake of convenience, it is assumed that the rewritable non-volatile memory module 220 has 4 physical blocks 50, 60, 70, and 80, each physical block has 4 physical segments, each physical segment has 2 physical pages, and each physical page can store 4 codewords (the maximum valid data count of each physical page is "4", and the maximum segment valid data count of each physical segment is "8"), and each entry in Table T60 corresponds to a physical segment.
[0091] The block management circuit unit 215 (or the processor 211) may record the segment valid data count of each of the identified / updated physical segments 51-84 in a field (also called the first field) of the table T60 (also called the valid data count table), such as the segment valid data counts "0", "4"-"2", "8" corresponding to the physical segments 51, 52-83, 84 recorded in the table T60. In addition, the block management circuit unit 215 (or the processor 211) may further record the valid segment count of each of the identified / updated physical blocks 50-80 in another field (also called the second field) of the table T60, such as the valid segment counts "3", "3", "1", "3" corresponding to the physical blocks 50, 60, 70, 80 recorded in the table T60.
[0092] In addition, in one embodiment, the block management circuit unit 215 (or the processor 211) can also calculate the block valid data count of each of the physical blocks 50-80 in real time based on the recorded segment valid data count. In another embodiment, the block management circuit unit 215 (or the processor 211) can also record the calculated block valid data count of each of the physical blocks 50-80 in another field (also called the third field).
[0093] In this embodiment, via Figure 2 The provided memory management method can obtain / update the segment valid data count of each physical segment and the block valid data count and valid segment count of each physical block in real time through the block management circuit unit 215. The processor 211 can further be used to perform a garbage collection operation based on the multiple block valid data counts and the multiple valid segment counts. In other words, the garbage collection operation provided by the implementation of the present invention can improve the efficiency of execution (efficiently identify and recycle valid data in the physical block) through the multiple block valid data counts and the multiple valid segment counts.
[0094] Figure 3 is a flowchart of a garbage collection operation according to an embodiment of the present invention. Figure 3 In step S310, the block management circuit unit 215 (or the processor 211) may select multiple recycled physical blocks from the multiple physical blocks according to the recycled block valid data count threshold value and the multiple block valid data counts. The multiple block valid data counts are each used to record the sum of the segment valid data counts of all valid physical segments of the physical block to which they belong, and the segment valid data count is used to record the total number of all valid codewords stored in all physical pages of the physical segment to which they belong. The block valid data counts of the multiple recycled physical blocks are each less than the recycled block valid data count threshold value.
[0095] Next, in step S320 , the block management circuit unit 215 (or the processor 211 ) may sort the plurality of recycled physical blocks from small to large according to the valid segment counts of the respective plurality of recycled physical blocks.
[0096] Next, in step S330 , the processor 211 may perform the garbage collection operation according to the sorted plurality of recycled physical blocks, wherein the first recycled physical block sorted at the front of the sorted plurality of recycled physical blocks may be firstly subjected to the garbage collection operation by the processor 211 .
[0097] Specifically, the processor 211 only checks whether valid data is stored in one or more first valid physical segments of the first recycled physical block, and identifies the physical address of the valid data to move the valid data. In one embodiment, the processor 211 does not check whether the valid data is stored in one or more second valid physical segments other than the one or more first valid physical segments in the first recycled physical block. In this way, because the mapping relationship between the physical page and the logical page of one or more first valid physical segments is only checked through the logical-to-physical address mapping table and the physical-to-logical address mapping table to confirm the physical address of the valid data in one or more first valid physical segments, a large amount of time can be saved (because there is no need to check the invalid physical segments in the first recycled physical block, and avoid consuming a lot of time to check all the physical segments in the first recycled physical block).
[0098] The following use Figure 6B The details of steps S310 to S330 will be described below.
[0099] Figure 6B FIG. 1 is a schematic diagram showing how to select and sort multiple recycled physical blocks according to block valid data count and valid segment count according to an embodiment of the present invention. Figure 6B , assuming that the valid data count threshold value of the recycled block is "14". Fig. 6AFor example, as shown by arrow A61, the block management circuit unit 215 (or the processor 211) can select the physical blocks 60, 70, 80 corresponding to the block valid data counts "7", "7", "13" less than the recovery block valid data count threshold value "14" as the multiple recovered physical blocks (step S310) according to the recovery block valid data count threshold value "14" and the multiple block valid data counts "21", "7", "7", "13" of the corresponding physical blocks 50, 60, 70, 80. Then, as shown by arrow A62, the block management circuit unit 215 (or the processor 211) can sort the recovered physical blocks 60, 70, 80 from small to large according to the multiple valid block counts "3", "1", "3" of the corresponding physical blocks 60, 70, 80 (step S320) to form the sorted multiple recovered physical blocks 70, 60, 80. The sorted multiple recycled physical blocks 70 , 60 , 80 can be identified / added as a garbage collection array. According to the recycling order / arrangement order, the recycled physical blocks in the garbage collection array are the physical block 70 , the physical block 60 , and the physical block 80 .
[0100] The processor 211 may perform garbage collection operations in sequence according to the sorted plurality of recycled physical blocks 70, 60, 80 (step S330). For example, as shown by arrow A63, among the sorted plurality of recycled physical blocks 70, 60, 80, the recycled physical block 70 will be first subjected to garbage collection operations. In addition, referring to Table T60, the processor 211 may identify valid physical segments and invalid physical segments in the recycled physical block 70, and only check whether the physical segment 74 (valid physical segment) in the recycled physical block 70 stores valid data (without checking the invalid physical segments 71-73).
[0101] It is worth mentioning that in this embodiment, the valid segment count of each physical block can also be used to represent the concentration of valid data in the corresponding physical block. In simple terms, the physical block with a smaller valid segment count has a higher concentration of valid data; the physical block with a larger valid segment count has a lower concentration of valid data. Using this concept, the memory management method provided in this embodiment can sort all the recovered physical blocks according to the valid segment count, so as to effectively determine the order of garbage collection operations performed on all the recovered physical blocks according to the concentration of all the recovered physical blocks. In this way, even if the block valid data counts of two recycled physical blocks (e.g., recycled physical blocks 60 and 70) are equal, the processor 211 can also select the recycled physical block with higher concentration (smaller valid segment count) (e.g., recycled physical block 70) to perform the garbage collection operation based on the concentration of valid data (valid segment count) of the two recycled physical blocks. As a result, since only fewer valid physical segments are checked, the physical addresses of the valid data therein can be identified more quickly, thereby achieving the effect of quickly recycling the recycled physical block.
[0102] In summary, the storage controller, memory management method and storage device provided by the embodiments of the present invention can group the multiple physical pages of each physical block in the multiple physical blocks of the rewritable non-volatile memory module into multiple physical segments, update the corresponding segment valid data count, the corresponding valid data count and the corresponding valid segment count according to the write instruction, and use the block valid data count and the valid segment count to select and sort multiple recycled physical blocks, so as to perform garbage collection operations on the multiple garbage physical blocks in sequence according to the concentration of valid data, thereby efficiently releasing the space of the rewritable non-volatile memory module and improving the overall access performance of the storage device.
Claims
1. A storage controller for controlling a storage device equipped with a rewritable non-volatile memory module, the storage controller comprising: A connection interface circuit for coupling to a host system; A memory interface control circuit, coupled to the rewritable non-volatile memory module, wherein the rewritable non-volatile memory module has a plurality of physical blocks, and each of the plurality of physical blocks has a plurality of physical pages; A block management circuit unit, and a processor, coupled to the connection interface circuit, the memory interface control circuit and the block management circuit unit, wherein the block management circuit unit is used to group the plurality of physical pages of each of the plurality of physical blocks into a plurality of physical segments, wherein the processor is used to execute a write instruction, wherein the write instruction is used to instruct to store data in one or more logical pages, wherein the one or more logical pages have been mapped to one or more target physical pages of a target physical block, and the one or more target physical pages belong to a first target physical segment among a plurality of target physical segments of the target physical block, wherein the block management circuit unit is further configured to update a first target segment valid data count corresponding to the first target physical segment among a plurality of target segment valid data counts of the plurality of target physical segments according to the write instruction, wherein the block management circuit unit is further configured to update a target block valid data count corresponding to the target physical block among a plurality of block valid data counts of the plurality of physical blocks according to the updated first target segment valid data count, wherein the block management circuit unit is further used to update a target valid segment count corresponding to the target physical block among a plurality of valid segment counts of the plurality of physical blocks according to the plurality of target segment valid data counts of the target physical block, wherein each of the plurality of valid segment counts is used to record a total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero, The processor is further configured to perform a garbage collection operation according to the plurality of block valid data counts and the plurality of valid segment counts.
2. The storage controller according to claim 1, wherein in the operation of performing a garbage collection operation according to the plurality of block valid data counts and the plurality of valid segment counts, The block management circuit unit selects a plurality of recycled physical blocks from the plurality of physical blocks according to a recycled block valid data count threshold value and the plurality of block valid data counts, wherein the plurality of block valid data counts are each used to record the sum of the segment valid data counts of all valid physical segments of the physical block to which they belong, and the segment valid data count is used to record the total number of all valid codewords stored in all physical pages of the physical segment to which they belong, The block valid data count of each of the plurality of recycled physical blocks is smaller than the recycled block valid data count threshold value.
3. The storage controller according to claim 2, wherein in the operation of performing a garbage collection operation according to the plurality of block valid data counts and the plurality of valid segment counts, The block management circuit unit sorts the plurality of recycled physical blocks from small to large according to the valid segment counts of the respective plurality of recycled physical blocks, The processor performs the garbage collection operation according to the sorted plurality of recycled physical blocks, wherein the first recycled physical block sorted at the front of the sorted plurality of recycled physical blocks is firstly subjected to the garbage collection operation by the processor.
4. The storage controller according to claim 3, wherein in the garbage collection operation performed on the first reclaimed physical block in the sorted plurality of reclaimed physical blocks, The processor only checks whether valid data is stored in one or more first valid physical sections of the first recycled physical block, and identifies the physical addresses of the valid data to move the valid data.
5. The storage controller of claim 4 , wherein in the garbage collection operation performed on the first reclaimed physical block of the sorted plurality of reclaimed physical blocks, The processor does not check whether the valid data is stored in one or more first invalid physical segments other than the one or more first valid physical segments in the first reclaimed physical block, wherein a segment valid data count of each of the one or more first invalid physical segments is zero.
6. The storage controller according to claim 1, wherein The block management circuit unit records the valid data counts of the multiple sections corresponding to the multiple physical blocks and the valid section count in a valid data count table. wherein the valid data count table comprises a plurality of entries corresponding to the plurality of physical sections of the plurality of physical units, respectively, wherein the plurality of entries each comprises a first field and a second field, The first field is used to record the segment valid data count of the corresponding physical segment, and the second field is used to record the valid segment count of the corresponding physical segment.
7. A memory management method, applicable to a memory controller for controlling a memory device equipped with a rewritable non-volatile memory module, wherein the rewritable non-volatile memory module has a plurality of physical blocks, and each of the plurality of physical blocks has a plurality of physical pages, the method comprising: grouping the plurality of physical pages of each of the plurality of physical blocks into a plurality of physical sections; Executing a write instruction, wherein the write instruction is used to instruct to store data in one or more logical pages, wherein the one or more logical pages have been mapped to one or more target physical pages of a target physical block, and the one or more target physical pages belong to a first target physical segment among a plurality of target physical segments of the target physical block; updating, according to the write instruction, a first target segment valid data count corresponding to the first target physical segment among a plurality of target segment valid data counts of the plurality of target physical segments; updating a target block valid data count corresponding to the target physical block among a plurality of block valid data counts of the plurality of physical blocks according to the updated first target segment valid data count; as well as updating a target valid segment count corresponding to the target physical block among a plurality of valid segment counts of the plurality of physical blocks according to the plurality of target segment valid data counts of the target physical block, wherein each of the plurality of valid segment counts is used to record a total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero, A garbage collection operation is performed according to the plurality of block valid data counts and the plurality of valid section counts.
8. The memory management method according to claim 7, wherein the step of performing a garbage collection operation according to the plurality of block valid data counts and the plurality of valid segment counts comprises: A plurality of recycled physical blocks from the plurality of physical blocks are selected according to a recycled block valid data count threshold value and the plurality of block valid data counts, wherein each of the plurality of block valid data counts is used to record the sum of the segment valid data counts of all valid physical segments of the physical block to which it belongs, and the segment valid data count is used to record the total number of all valid codewords stored in all physical pages of the physical segment to which it belongs, The block valid data count of each of the plurality of recycled physical blocks is smaller than the recycled block valid data count threshold value.
9. The memory management method according to claim 8, wherein the step of performing a garbage collection operation according to the plurality of block valid data counts and the plurality of valid segment counts further comprises: sorting the plurality of recycled physical blocks from small to large according to the valid segment counts of the respective plurality of recycled physical blocks; Execute the garbage collection operation according to the sorted plurality of recycling physical blocks, The garbage collection operation is performed first on the first reclaimed physical block that is sorted at the front of the sorted plurality of reclaimed physical blocks.
10. The memory management method according to claim 9, wherein the garbage collection operation performed on the first reclaimed physical block comprises: Only one or more first valid physical sections of the first recycled physical block are checked to see whether valid data is stored, and the physical addresses of the valid data are identified to move the valid data.
11. The memory management method according to claim 10, wherein the garbage collection operation performed on the first reclaimed physical block further comprises: It is not checked whether the valid data is stored in one or more first invalid physical segments other than the one or more first valid physical segments in the first reclaimed physical block, wherein the one or more first invalid physical segments each have a segment valid data count of zero.
12. The memory management method according to claim 7, further comprising: Recording valid data counts of multiple segments corresponding to the multiple physical blocks and the valid segment count in a valid data count table, wherein the valid data count table comprises a plurality of entries corresponding to the plurality of physical sections of the plurality of physical units, respectively, wherein the plurality of entries each comprises a first field and a second field, The first field is used to record the segment valid data count of the corresponding physical segment, and the second field is used to record the valid segment count of the corresponding physical segment.
13. A storage device, comprising: A rewritable non-volatile memory module, wherein the rewritable non-volatile memory module has a plurality of physical blocks, and each of the plurality of physical blocks has a plurality of physical pages; as well as A storage controller coupled to the rewritable non-volatile memory module, wherein the storage controller is used to group the plurality of physical pages of each physical block of the plurality of physical blocks into a plurality of physical segments, The storage controller is further used to execute a write instruction, wherein the write instruction is used to instruct to store data in one or more logical pages, wherein the one or more logical pages have been mapped to one or more target physical pages of a target physical block, and the one or more target physical pages belong to a first target physical segment among a plurality of target physical segments of the target physical block, wherein the storage controller is further configured to update a first target segment valid data count corresponding to the first target physical segment among a plurality of target segment valid data counts of the plurality of target physical segments according to the write instruction, wherein the storage controller is further configured to update a target block valid data count corresponding to the target physical block among a plurality of block valid data counts of the plurality of physical blocks according to the updated first target sector valid data count, wherein the storage controller is further configured to update a target valid segment count corresponding to the target physical block among a plurality of valid segment counts of the plurality of physical blocks according to the plurality of target segment valid data counts of the target physical block, wherein each of the plurality of valid segment counts is configured to record a total number of one or more valid physical segments of the corresponding physical block, wherein the segment valid data count of each of the one or more valid physical segments is greater than zero, The storage controller is further configured to perform a garbage collection operation according to the plurality of block valid data counts and the plurality of valid segment counts.
