Computer readable storage medium, data storage method and device for flash memory
By dividing the SLC area and the non-SLC area and selecting the write mode according to the data characteristics, the problem of low NAND flash storage is solved, and more efficient data storage is achieved.
Patent Information
- Application Number
- CN202011056071.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2040-09-29
AI Technical Summary
The effective utilization of NAND flash memory storage space is limited, and data cannot be accessed randomly like NOR flash memory, and serial operations are required, resulting in low data storage efficiency.
By dividing the storage space of the flash memory module into SLC area and non-SLC area, according to the characteristics of different types of host data, data is written in the corresponding blocks using single-layer or non-single-layer unit mode to achieve efficient data storage .
It improves the storage space utilization of flash memory modules, enhances data storage efficiency, and adapts to different types of host data storage needs.
Smart Images

Figure CN114327240B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a storage device, and in particular to a computer-readable storage medium, a data storage method and a device for a flash memory. Background Art
[0002] Flash memory is usually divided into NOR flash memory and NAND flash memory. NOR flash memory is a random access device. The central processing unit (Host) can provide any address to access NOR flash memory on the address pin and obtain the data stored at the address from the data pin of NOR flash memory in a timely manner. In contrast, NAND flash memory is not random access, but serial access. NAND flash memory cannot access any random address like NOR flash memory. Instead, the central processing unit needs to write serial byte values to NAND flash memory to define the type of request command (such as read, write, erase, etc.) and the address used in this command. The address can point to a page (the smallest data block for write operation in flash memory) or a block (the smallest data block for erase operation in flash memory).
[0003] Effectively using NAND flash memory space to store different types of host data has always been an important issue in flash memory controllers. Therefore, the present invention provides a computer-readable storage medium, a flash memory data storage method and device, which are suitable for different types of host data. Summary of the invention
[0004] In view of this, how to alleviate or eliminate the above-mentioned defects in related fields is indeed a problem to be solved.
[0005] The present invention relates to a data storage method for a flash memory, which is implemented when a processing unit loads and executes a program code of a flash conversion layer, comprising: dividing the storage space of a flash memory module into a first area and a second area; writing data belonging to a first partition type received from a host end into only a first physical block in the first area; and writing data belonging to a second partition type received from the host end into a first physical block in the first area and a second physical block in the second area.
[0006] The present invention also relates to a computer-readable storage medium for storing program codes that can be executed by a processing unit, and the program codes implement the following steps when executed by the processing unit: dividing the storage space of a flash memory module into a first zone and a second zone; writing data belonging to a first partition type received from a host side into only a first physical block in the first zone; and writing data belonging to a second partition type received from the host side into a first physical block in the first zone and a second physical block in the second zone.
[0007] The present invention also relates to a data storage device of a flash memory, comprising a flash memory interface, a host interface and a processing unit. The processing unit divides the storage space of the flash memory module into a first area and a second area; drives the flash memory interface to write data belonging to the first partition type received from the host end through the host interface into only a first physical block in the first area; and drives the flash memory interface to write data belonging to the second partition type received from the host end through the host interface into the first physical block in the first area and the second physical block in the second area.
[0008] The first area includes a plurality of first physical blocks, the second area includes a plurality of second physical blocks, each of the first physical blocks can only use a single-level cell mode to write data, and each of the second physical blocks can use a single-level cell mode or a non-single-level cell mode to write data. The single-level cell mode is used to program a memory cell to store one of two states, and the non-single-level cell mode is used to program a memory cell to store one of four or more states.
[0009] One of the advantages of the above embodiment is that the storage space of the flash memory module can be used more efficiently by the above-mentioned partial partitioning of the flash memory module and the policy of writing data according to the data characteristics of different partition types.
[0010] Other advantages of the present invention will be explained in more detail with reference to the following description and accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.
[0012] Figure 1 FIG. 4 is a system architecture diagram of an electronic device according to an embodiment of the present invention.
[0013] Figure 2 FIG. 4 is a schematic diagram of a flash memory module according to an embodiment of the present invention.
[0014] Figure 3 A schematic diagram of the comparison between host partitions and storage locals according to some implementation modes.
[0015] Figure 4 FIG. 4 is a schematic diagram showing a comparison between a host partition and a storage local area according to an embodiment of the present invention.
[0016] Figure 5 The figure is a flow chart of a method for writing data according to an embodiment of the present invention.
[0017] Figure 6 The figure is a flow chart of a method for organizing storage space according to an embodiment of the present invention.
[0018] Figure 74 is a flow chart of a method for cross-zone wear averaging according to an embodiment of the present invention.
[0019] Figure 8 The figure is a flow chart of a method for cross-zone read refresh according to an embodiment of the present invention.
[0020] Fig. 9 The figure is a flow chart of a method for cross-region reading and regeneration according to an embodiment of the present invention.
[0021] Among them, the simple description of the symbols in the accompanying drawings is as follows:
[0022] 10: electronic device; 110: host end; 130: flash memory controller; 131: host interface; 132: bus; 134: processing unit; 136: random access memory; 138: direct storage access controller; 139: flash memory interface; 150: flash memory module; 151: interface; 153#0~153#15: NAND flash memory unit; CH#0~CH#3: channel; CE#0~CE#3: start signal; 300: file system; 310#1~310#8: partition; 350, 450: flash translation layer; 155#1: single-layer unit area; 155#3: non-single-layer unit area; 400: native write command queue; S510~S560: method steps; S610~S640: method steps; S710~S760: method steps; S810~S840: method steps; S910~S930: method steps. DETAILED DESCRIPTION
[0023] The embodiments of the present invention will be described below with reference to the accompanying drawings. In these drawings, the same reference numerals represent the same or similar components or method flows.
[0024] It must be understood that the words "comprise", "include" and the like used in this specification are used to indicate the existence of specific technical features, values, method steps, operations, components and / or assemblies, but do not exclude the addition of more technical features, values, method steps, operations, components, assemblies, or any combination of the above.
[0025] The words "first", "second", "third", etc. used in the present invention are used to modify the components in the claims, and are not used to indicate a priority order, a prior relationship, or that one component precedes another, or a time sequence when executing method steps. They are only used to distinguish components with the same name.
[0026] It should be understood that when a component is described as being "connected" or "coupled" to another component, it can be directly connected or coupled to the other component, and there may be intervening components. Conversely, when a component is described as being "directly connected" or "directly coupled" to another component, there are no intervening components. Other words used to describe the relationship between components can also be interpreted in a similar manner, such as "between" versus "directly between", or "adjacent" versus "directly adjacent", etc.
[0027] refer to Figure 1. The electronic device 10 includes a host side (Host Side) 110, a flash memory controller 130 and a flash memory module 150, and the flash memory controller 130 and the flash memory module 150 can be collectively referred to as a device side (Device Side). The electronic device 10 can be implemented in electronic products such as personal computers, laptop computers (Laptop PC), tablet computers, mobile phones, digital cameras, digital video cameras, etc. The host side 110 and the host interface (Host Interface) 131 of the flash memory controller 130 can communicate with each other using communication protocols such as Universal Serial Bus (USB), Advanced Technology Attachment (ATA), Serial Advanced Technology Attachment (SATA), Peripheral Component Interconnect Express (PCI-E), Universal Flash Storage (UFS), Embedded Multi-Media Card (eMMC), etc. The flash interface 139 of the flash controller 130 and the flash module 150 can communicate with each other using a double data rate (DDR) communication protocol, such as an open NAND flash interface (ONFI), a double data rate switch (DDR Toggle), or other communication protocols. The flash controller 130 includes a processing unit 134, which can be implemented in a variety of ways, such as using general hardware (e.g., a single processor, a multi-processor with parallel processing capabilities, a graphics processor, or other processors with computing capabilities), and provides the functions described later when executing software and / or firmware instructions. The processing unit 134 receives host commands, such as read commands, write commands, erase commands, etc., through the host interface 131, and schedules and executes these commands.The flash controller 130 further includes a random access memory (RAM) 136, which can be implemented as a dynamic random access memory (DRAM), a static random access memory (SRAM) or a combination of the two, and is used to configure space as a data buffer to store user data (also referred to as host data) read from the host 110 and to be written to the flash module 150, and user data read from the flash module 150 and to be output to the host 110. The random access memory 136 can also store data required during the execution process, such as variables, data tables, host-to-flash (H2F Table), flash-to-host (F2H Table), etc. The flash memory interface 139 includes a NAND Flash Controller (NFC) that provides functions required for accessing the flash memory module 150, such as a command serializer (Command Sequencer) and a low-density parity check (LDPC).
[0028] The flash memory controller 130 may be configured with a bus architecture 132 for coupling components to each other to transfer data, addresses, control signals, etc. These components include a host interface 131, a processing unit 134, a RAM 136, a direct memory access (DMA) controller 138, a flash memory interface 139, etc. The DMA controller 138 may migrate data between components through the bus architecture 132 according to instructions from the processing unit 134, for example, moving data from a specific data buffer in the host interface 131 or the flash memory interface 139 to a specific address in the RAM 136, or moving data from a specific address in the RAM 136 to a specific data buffer in the host interface 131 or the flash memory interface 139, etc.
[0029] The flash memory module 150 provides a large amount of storage space, usually hundreds of gigabytes (GB) or even multiple terabytes (TB), for storing a large amount of user data, such as high-resolution pictures, videos, etc. The flash memory module 150 includes a control circuit and a memory array. The memory cells in the memory array can be configured as single-level cells (SLCs), multiple-level cells (MLCs), triple-level cells (TLCs), quad-level cells (QLCs) or any combination thereof after being erased. The processing unit 134 writes user data to a specified address (destination address) in the flash memory module 150 and reads user data from a specified address (source address) in the flash memory module 150 through the flash memory interface 139. The flash memory interface 139 uses multiple electronic signals to coordinate the data and command transmission between the flash memory controller 130 and the flash memory module 150, including a data line, a clock signal, and a control signal. The data lines can be used to transmit commands, addresses, read and write data; the control signal lines can be used to transmit control signals such as chip enable (CE), address latch enable (ALE), command latch enable (CLE), and write enable (WE).
[0030] refer to Figure 2 The interface 151 in the flash memory module 150 may include four input / output channels (I / O channels, hereinafter referred to as channels) CH#0 to CH#3, each of which is connected to four NAND flash memory units. For example, channel CH#0 is connected to NAND flash memory units 153#0, 153#4, 153#8, and 153#12, and so on. Each NAND flash memory unit may be packaged as an independent chip (die). The flash memory interface 139 may send one of the start signals CE#0 to CE#3 through the interface 151 to start the NAND flash memory units 153#0 to 153#3, 153#4 to 153#7, 153#8 to 153#11, or 153#12 to 153#15, and then read user data from the started NAND flash memory unit in parallel, or write user data to the started NAND flash memory unit.
[0031] In order to store different types of host data, each of the NAND flash memory units 153#0 to 153#15 may include multiple physical blocks, and each physical block may be set as an SLC block or a non-SLC block. All SLC blocks in the NAND flash memory units 153#0 to 153#15 may be collected together and referred to as an SLC region, and all non-SLC blocks therein may be collected together and referred to as a non-SLC region. Each storage cell in the SLC block can only be programmed in SLC mode after being erased, while each storage cell in the non-SLC block can be programmed in SLC, MLC, TLC, or QLC modes after being erased. MLC, TLC, and QLC modes may be collectively referred to as non-SLC modes. Each MLC, TLC, or QLC can store more bits of data than one SLC, but the data retention and access speed of SLC are better than those of MLC, TLC, or QLC. Each memory cell in an SLC block, an MLC block, a TLC block, and a QLC block can store one of two, four, eight, and sixteen states, respectively. Each word line in an SLC block can store one page of data. Each word line in an MLC block can store two pages of data, including a Most Significant Bit (MSB Page) and a Least Significant Bit (LSB Page). Each word line in a TLC block can store three pages of data, including a Most Significant Bit (MSB) Page, a Center Significant Bit (CSB Page), and a Least Significant Bit (LSB) Page. Each word line in a QLC block can store four pages of data, including a Top Significant Bit (TSB Page), a Most Significant Bit (MSB) Page, a Center Significant Bit (CSB) Page, and a Least Significant Bit (LSB) Page.
[0032] refer to Figure 3, the host end 110 executes the file system 300 to implement operations such as data storage, hierarchical organization and access. For example, the file system 300 can logically divide the storage space provided by the device end into the first and second boot partitions (Boot Partitions) 310#1 and 310#2, the replay protected memory block partition (Replay Protected Memory Block, RPMB Partition) 310#3, the first to fourth general purpose partitions (General Purpose Partitions) 310#4 to 310#7 and the user data partition (User Data Partition) 310#8. The file system 300 transmits the logical partition information to the flash translation layer (FTL) 350 executed in the flash controller 130. This information includes the number and length of each partition, and the length of the partition is usually expressed in the number of logical block addresses (Logical Block Address, LBA). An LBA number can correspond to fixed-length data, such as 512 bytes of data. Through the file system 300, the host 110 can store system configuration and boot programs in the first boot partition 310#1, and store drivers and operating systems in the second boot partition 310#2. The host 110 can also store various application programs in the first to fourth general purpose partitions 310#4 to 310#7, and various data files in the user data partition 310#8. For example, when the host 110 wants to write the boot program to the device, it can issue a host write command to the flash controller 130, which includes the number, starting LBA number, length and other information of the first boot partition 310#1. When the host 110 wants to write a video stream file to the device, it can also issue a host write command to the flash controller 130, which includes the number, starting LBA number, length and other information of the user data partition 310#8. For ease of management, in some embodiments, the FTL 350 stores data of a portion of the partitions in the SLC area 155#1 and stores data of other partitions in the non-SLC area 155#3 according to the characteristics of the host data. The FTL 350 can write the data received from the host 110 to one or more physical blocks in the SLC area 155#1 or the non-SLC area 155#3 in the flash memory module 150 according to the partition number in the host write command.For example, the FTL 350 writes data corresponding to the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 into the SLC area 155#1, and writes data corresponding to the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8 into the non-SLC area 155#3. Therefore, the SLC block can be used to store important and error-free system data that is frequently accessed, such as operating systems, drivers, key values, etc. The non-SLC block can be used to store large-capacity system data and user data, such as various applications, word processing, spreadsheets, presentations, images, audio, video, and other files.
[0033] Usually, at the initialization, the FTL 350 may allocate space that exceeds the length of the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 to the SLC area 155#1. For example, although the logical partition information indicates that the total length of the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 is 8 megabytes (MB), the FTL 350 allocates 10MB of storage space to the SLC area 155#1. However, because the data of the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 usually rarely changes, the SLC area 155#1 has a lot of spare space that will not be used. Even if the data of the first to fourth general purpose partitions (General Purpose Partitions) 310#4 to 310#7 and the user data partition (UserData Partition) 310#8 is about to fill up the non-SLC area 155#3, the spare space of the SLC area 155#1 cannot be used.
[0034] In order to solve the problems of the above-mentioned implementation methods, the embodiment of the present invention proposes a new configuration method for more effectively using the storage space of the flash memory module 150. Figure 4, FTL 450 allows data of a part of the partitions to be stored only in SLC area 155#1 according to the characteristics of the host data, and allows data of other partitions to be stored in SLC area 155#1 or non-SLC area 155#3. For example, FTL 450 allows data corresponding to the first and second boot partitions 310#1 and 310#2 and RPMB partition 310#3 to be written only in SLC area 155#1, and allows data corresponding to the first to fourth general partitions 310#4 to 310#7 and user data partition 310#8 to be written in SLC area 155#1 and non-SLC area 155#3. In detail, when the processing unit 134 loads and executes the program code of the FTL 450, a data storage method of the flash memory is implemented, including: dividing the storage space of the flash memory module 150 into an SLC area 155#1 and a non-SLC area 155#3; driving the flash memory interface 139 to write the data belonging to the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3 received from the host end 110 through the host interface 131 into only the physical block in the SLC area 155#1; and driving the flash memory interface 139 to write the data belonging to the first to fourth general partitions 310#4 to 310#7 and the user data partition 10#8 received from the host end 110 through the host interface 131 into the physical block in the SLC area 155#1 and the second physical block in the non-SLC area 155#3.
[0035] In some embodiments, the FTL 450 may allow random data corresponding to the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8 to be written into the SLC area 155#1, and allow continuous data corresponding to the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8 to be written into the non-SLC area 155#3. Figure 5 The flowchart of the data writing method is shown in FIG. 1 . The method is implemented when the processing unit 134 loads and executes the program code of the FTL 450, and is described in detail as follows:
[0036] Step S510 : receiving a host write command from the host end 110 through the host interface 131 .
[0037] Step S520: Determine whether the data to be written belongs to a specific partition type (Partition-type). If so, the process continues with the processing of step S530; otherwise, the process continues with the processing of step S540. For example, FTL 450 divides all partitions into two types: the first partition type includes the first and second boot partitions 310#1 and 310#2 and the RPMB partition 310#3; the second partition type includes the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8. The specific partition type mentioned above refers to the first partition type. The processing unit 134 can complete the judgment by checking the partition number carried in the host write command.
[0038] Step S530: Write data to one or more physical pages of the current block (Current Block) in SLC area 155#1. Each physical block in SLC area 155#1 can be marked as one of three states: spare blocks, current blocks, and data blocks. Any physical block can become a spare block after it contains no valid data. For each NAND flash memory unit, the flash memory controller 130 can select one from the spare blocks of each data plane as the current block, which is used to write the data requested to be stored by the host write command. When the data fills the current block, the flash memory controller 130 closes this physical block and no longer writes but can only read data. At this time, this physical block is called a data block. Then, the flash memory controller 130 selects one from the spare blocks as the new current block and continues to write new data. The FTL 450 may maintain a physical-to-logical mapping table (P2L Mapping Table) for each current block in the RAM 136, which is used to store information about which LBA number the data of each physical page belongs to in the order of physical pages. Once the current block is closed and becomes a data block, the FTL 450 may drive the flash memory interface 139 to write the P2L mapping table to a specified location of the flash memory module 150. In addition, the FTL 450 also needs to update the corresponding content in the logical-to-physical mapping table (L2PMapping Table). The L2P mapping table stores information about which physical address the data of each LBA number is stored in in the order of LBA numbers, and the physical address may include information such as the physical block number and the physical page number. The FTL 450 updates the physical address of the updated LBA number in the L2P mapping table to point to the corresponding physical address in the SLC area 155#1.
[0039] It should be noted here that each LBA number in the L2P comparison table corresponds to a partition number, which is used to indicate which partition the LBA number data belongs to. In addition, according to the initial configuration, each physical address in the L2P comparison table belongs to the SLC area 155#1 or the non-SLC area 155#3. In some embodiments, the FTL 450 can scan the physical addresses of the LBA numbers in the L2P comparison table belonging to the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8 to know whether the data of each LBA number in the first to fourth general partitions 310#4 to 310#7 and the user data partition 310#8 is stored in the SLC area 155#1 or the non-SLC area 155#3.
[0040] In some embodiments, in order to distinguish which partition type the data of each physical page of each physical block or data block in SLC area 155#1 belongs to, FTL 450 may maintain a partition type bit table (Partition-type Bit Table) for each physical block or data block in SLC area 155#1 in RAM 136, which includes at least one bit of the number of all pages of a physical block, and records the information of which partition type each physical page belongs to in the order of physical addresses. For example, when a bit records "1", it means that the data of the corresponding physical page belongs to the second partition type; when a bit records "0", it means that the data of the corresponding physical page belongs to the first partition type. When the data writing is completed, FTL 450 updates the bit value corresponding to the written physical page in the partition type bit table to "0".
[0041] Step S540: Determine whether the host write command is a random write command. If so, the process continues with the processing of step S550; otherwise, the process proceeds to the processing of step S560. FTL 450 can determine whether it is a random write command based on the length of the data to be written by the host write command. Assuming that the minimum unit of data managed by the host end 110 is 4 kilobytes (KB), and the length of data that can be stored in each physical page is 16KB: when the host write command indicates to write data shorter than 16KB, FTL 450 can determine that this host write command is a random write command. On the contrary, it indicates that this host write command is a continuous write command, which may be combined with the previous and / or subsequent host write commands to indicate the writing of a long continuous data.
[0042] Step S550: Write data to a physical page of the current block in SLC area 155#1. The technical details of updating the P2L comparison table and the L2P comparison table after writing the data can be inferred by those skilled in the art based on the description of step S530, and will not be repeated for the sake of simplicity. In some embodiments, the FTL 450 can update the bit value corresponding to the written physical page in the partition type bit table to "1", indicating that the data of this physical page belongs to the second partition type.
[0043] Step S560: Write data to a physical page of the current block in the non-SLC area 155#3. Similarly, each physical block in the non-SLC area 155#3 can be marked as one of three states: an idle block, a current block, and a data block. Regarding the technical details of changing the state of each physical block in the non-SLC area 155#3, those skilled in the art can infer it based on the description of step S530, and will not be repeated for the sake of brevity. In addition, regarding the technical details of updating the P2L comparison table and the L2P comparison table after writing data to the current block in the non-SLC area, those skilled in the art can infer it based on the description of step S530, and will not be repeated for the sake of brevity.
[0044] It should be noted here that the data write operations referred to in steps S530, S550 and S560 do not necessarily drive the flash memory interface 139 to immediately write data into the flash memory module 150, but first store the appropriate write instructions in the queue of the flash memory interface 139, and then let the flash memory interface 139 decide the execution time of these write instructions. The present invention is not limited to this.
[0045] After a period of access to the flash memory module 150, the number of idle blocks in the SLC area 155#1 will change. The FTL 450 can maintain an idle counter to indicate the total number of idle blocks currently in the SLC area 155#1. Whenever an idle block in the SLC area 155#1 becomes a current block, the idle counter is reduced by one. Whenever a data block in the SLC area 155#1 becomes an idle block, the idle counter is increased by one. In addition, after a period of access to the flash memory module 150, many physical pages in the SLC area 155#1 may include valid segments and invalid segments (also called expired segments), wherein the valid segments store valid data and the invalid segments store invalid (old) data. When the FTL 450 detects that the counter is lower than a threshold, it can read and collect data in a valid segment of a data block belonging to the second partition type, and then drive the flash memory interface 139 to re-write the collected valid data to the empty physical page of the current block in the non-SLC area 155#3 in MLC, TLC or QLC mode. In addition, the FTL 450 can read and collect data in a valid segment of the first partition type in this data block, and then drive the flash memory interface 139 to re-write the collected valid data to the empty physical page of the current block in the SLC area 155#1 in SLC mode, so that these data blocks containing invalid user data in the SLC area 155#1 can become idle blocks for other data to use after being erased. The above-mentioned procedure is called a cross-region garbage collection procedure (Cross-region Garbage Collection, GC Process). It is worth noting that when the cross-zone garbage collection procedure writes valid data to the physical page in the non-SLC area 155#3 in MLC, TLC or QLC mode, the storage space of two or more physical pages (also called SLC pages) in the SLC area 155#1 can be released. In the cross-zone garbage collection procedure, the FTL 450 updates the contents of the P2L comparison table and the L2P comparison table according to the execution result of the write operation.
[0046] refer to Figure 6 The flowchart of the storage space arrangement method shown in FIG. 1 is implemented when the processing unit 134 loads and executes the program code of the FTL 450. The details are as follows:
[0047] Step S610: Detecting a trigger signal. This trigger signal may represent that the device is about to enter a sleep mode, reaches a preset time point, or receives a host write command, or represents that other preset trigger conditions for starting detection have been met.
[0048] Step S620: Read the value of the idle counter to obtain the number of currently idle blocks in SLC area 155#1.
[0049] Step S630: Determine whether the number of currently idle blocks is lower than the threshold value. If yes, the process continues to process at step S640; otherwise, the process continues to process at step S610.
[0050] Step S640: Execute the cross-region garbage collection procedure as described above.
[0051] In the cross-zone garbage collection procedure, in order to determine whether the data stored in each physical page of a data block in SLC area 155#1 belongs to the first partition type or the second partition type, in some embodiments, FTL 450 may search the partition type bit table of this data block to obtain which physical pages of data in this data block belong to the second partition type. For example, when a bit in the partition type bit table of this data block is "1", it means that the data of the corresponding physical page belongs to the second partition type, and FTL 450 may collect valid data in the corresponding physical page.
[0052] In other embodiments, FTL 450 may search the physical addresses of the LBA numbers belonging to the second partition type in the L2P lookup table to know which LBA numbers are stored in SLC area 155#1, and collect valid data of the qualified physical addresses in SLC area 155#1.
[0053] In order to make the physical blocks in SLC area 155#1 have similar wear levels to extend their service life, FTL 450 can perform data migration procedures in a timely manner. FTL 450 can record an erase counter for each physical block, which is initially 0. After each physical block is erased, the corresponding erase counter is incremented by one. Figure 7 4. The flowchart of the cross-region wear leveling method shown in FIG. 4 is shown in FIG. 4. The method is implemented when the processing unit 134 loads and executes the program code of the FTL 450. The details are as follows:
[0054] Step S710: Detecting a trigger signal. The trigger signal may represent that the device is about to enter a sleep mode, or that a preset time point has been reached, or that other preset trigger conditions for starting detection have been met.
[0055] Step S720: Read the value of the erase counter of the first or next data block in SLC area 155 # 1, which represents the number of times the data block has been erased.
[0056] Step S730: Determine whether the value of the erase counter is higher than a threshold value. If yes, it means that the data block is overused, and the process continues to process step S740; otherwise, it means that the data block is used normally, and the process continues to process step S750.
[0057] Step S740: Mark the data block as a migration source block. The FTL 450 may record the marking information of the data block in the RAM 136.
[0058] Step S750: Determine whether all data blocks in the SLC area have been detected. If yes, the process continues with step S760; otherwise, the process continues with step S720.
[0059] Step S760: Execute the data migration procedure.
[0060] In some embodiments of the data migration procedure as described in step S760, the FTL 450 may drive the flash memory interface 139 to write the data of multiple physical pages belonging to the second partition type in the migration source block in the SLC area 155#1 intactly in the MLC, TLC or QLC mode to a physical page of a current block in the non-SLC area 155#3, and the number of erases of this current block is relatively low in the non-SLC area 155#3. In addition, the FTL 450 may drive the flash memory interface 139 to write the data of each physical page belonging to the first partition type in the migration source block in the SLC area 155#1 intactly in the SLC mode to a physical page of a current block in the SLC area 155#1, and the number of erases of this current block is relatively low in the SLC area 155#1. It is worth noting that when the data migration program writes data of two, three or four physical pages of the migration source block in SLC area 155#1 to the non-SLC page in non-SLC area 155#3 in MLC, TLC or QLC mode respectively, the storage space of two or more physical pages in SLC area 155#1 can be released.
[0061] In some other embodiments of the data migration procedure as described in step S760, the FTL 450 may drive the flash memory interface 139 to collect valid data of multiple physical pages belonging to the second partition type in the migration source block in the SLC area 155#1 and write them to a physical page of a current block in the non-SLC area 155#3 in MLC, TLC or QLC mode, and the number of erases of this current block is relatively low in the non-SLC area 155#3. In addition, the FTL 450 may drive the flash memory interface 139 to collect valid data of multiple physical pages belonging to the first partition type in the migration source block in the SLC area 155#1 and write them to a physical page of a current block in the SLC area 155#1 in SLC mode, and the number of erases of this current block is relatively low in the SLC area 155#1. In this way, not only can the purpose of wear leveling be achieved, but garbage collection can also be performed, so that the storage space of the flash memory module 150 is used more efficiently.
[0062] In the data migration procedure described in step S760 , after the data of the migration source block is written into the non-SLC area 155 # 3 , the FTL 450 may mark the migration source block as a temporarily unused physical block to avoid being erased and becoming an idle block in a short period of time.
[0063] In order to prevent the physical block in SLC area 155#1 from being damaged due to excessive reading times, FTL 450 can perform a data migration procedure in a timely manner. FTL 450 can record a read counter for each data block, and set it to 0 each time it is erased and becomes an idle block. After each data stored in a data block is read, the corresponding read counter is incremented by one. Figure 8 The flowchart of the cross-region read refresh method is shown in FIG. 1 . The method is implemented when the processing unit 134 loads and executes the program code of the FTL 450, and is described in detail as follows:
[0064] Step S810: Read data in a physical page of a data block in SLC area 155#1.
[0065] Step S820: Increment the read counter of the data block by one.
[0066] Step S830: Determine whether the value of the read counter is higher than the threshold value. If yes, it means that the data block is read too much, and the process continues to process step S840; otherwise, it means that the use of the data block is normal, and the process continues to process step S810.
[0067] Step S840: Execute the data migration procedure.
[0068] In some embodiments of the data migration procedure as described in step S840, the FTL 450 may drive the flash memory interface 139 to write the data of multiple physical pages belonging to the second partition type in the data block to a physical page of a current block in the non-SLC area 155#3 intactly in the MLC, TLC or QLC mode. In addition, the FTL 450 may drive the flash memory interface 139 to write the data of each physical page belonging to the first partition type in the data block to a physical page of a current block in the SLC area 155#1 intactly in the SLC mode. It is worth noting that when the data migration procedure writes the data of two, three or four physical pages of the migrated data block in the SLC area 155#1 to the non-SLC page in the non-SLC area 155#3 in the MLC, TLC or QLC mode respectively, the storage space of two or more physical pages in the SLC area 155#1 can be released.
[0069] In some other embodiments of the data migration procedure as described in step S840, the FTL 450 can drive the flash memory interface 139 to collect valid data of multiple physical pages belonging to the second partition type in the data block and write them to a physical page of a current block in the non-SLC area 155#3 in MLC, TLC or QLC mode. In addition, the FTL 450 can drive the flash memory interface 139 to collect valid data of multiple physical pages belonging to the first partition type in the data block and write them to a physical page of a current block in the SLC area 155#1 in SLC mode. In this way, not only can the purpose of read refresh be achieved, but garbage collection can also be performed, and the storage space of the flash memory module 150 is used more efficiently.
[0070] In addition, when a data block has read disturbance due to some reasons, the data stored therein may contain too many error bits. Once it is detected that one or more physical pages in a data block contain too many error bits, the FTL 450 can perform a data migration procedure for the data block in a timely manner. Fig. 9 The flowchart of the cross-region read reclaim method is shown in FIG. 1 . The method is implemented when the processing unit 134 loads and executes the program code of the FTL 450, and is described in detail as follows:
[0071] Step S910: Read data in a physical page of a data block in SLC area 155#1.
[0072] Step S920: Determine whether the error correction rate is higher than the threshold. If so, it means that read interference may occur in this data block, and the process continues to process step S930; otherwise, it means that the use of this data block is normal, and the process continues to process step S910. When reading data, the flash memory interface 139 can use the corresponding error correction code (Error-Correcting Code, ECC) to correct the error bits contained in the data in this physical page. The error correction code can be a low-density parity check code (Low-Density Parity Check Code, LDPC), BCH code (Bose–Chaudhuri–Hocquenghem Code), etc. Taking every 1KB of data as an example, the BCH code can provide a correction capability of up to 72 error bits, while the LDPC can provide a correction capability of up to 128 error bits. The threshold can be set to between 50% and 80% of the maximum correction capability of the error correction code used.
[0073] Step S930: Execute the data migration procedure. The details of the data migration procedure in step S930 can be found in the description of step S840, which will not be described again for the sake of brevity.
[0074] In the data migration procedure as described in steps S760, S840 and S930, in order to determine whether the data stored in each physical page of a migration source block in SLC area 155#1 belongs to the first partition type or the second partition type, FTL 450 can search the partition type bit table of this migration source block to obtain whether the data of each physical page therein belongs to the first partition type or the second partition type.
[0075] All or part of the steps in the method described in the present invention can be implemented by a computer program, such as a firmware translation layer (Firmware Translation Layer, FTL) in a storage device, a driver for specific hardware in a computer, etc. In addition, it can also be implemented in other types of programs as shown above. A technician in the relevant technical field can write the method of the embodiment of the present invention into a program code, which will not be described for the sake of simplicity. The computer program implemented according to the method of the embodiment of the present invention can be stored in an appropriate computer-readable storage medium, such as a DVD, CD-ROM, U disk, hard disk, or can be placed in a network server that can be accessed through a network (e.g., the Internet, or other appropriate media).
[0076] Although Figure 1 , Figure 2 The above-described components are included, but it does not exclude the use of more additional components to achieve better technical effects without violating the spirit of the invention. Figures 5 to 9 The flowchart is executed in a specified order, but without violating the spirit of the invention, a person skilled in the art can modify the order of these steps while achieving the same effect, so the present invention is not limited to using only the order described above. In addition, a person skilled in the art can also integrate several steps into one step, or execute more steps sequentially or in parallel in addition to these steps, and the present invention should not be limited thereto.
[0077] The above description is only a preferred embodiment of the present invention, but it is not intended to limit the scope of the present invention. Any person familiar with this technology can make further improvements and changes on this basis without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be based on the scope defined by the claims of this application.
Claims
1. A data storage method of a flash memory, implemented by a processing unit when loading and executing a program code of a flash translation layer, characterized in that: The data storage method of the flash memory comprises: Receive logical partition information from a file system executed on a host, for describing storage contents of a first partition type and a second partition type, wherein the logical partition information includes a length of the first partition type and a length of the second partition type, the length of the first partition type and the length of the second partition type being expressed as a number of logical block addresses, the host defining the first partition type and the second partition type, the host specifying that a file of a first type is stored in a storage space of the first partition type, and a file of a second type is stored in a storage space of the second partition type; Dividing the storage space of the flash memory module into a first area and a second area, wherein the first area includes a plurality of first physical blocks, the second area includes a plurality of second physical blocks, each of the first physical blocks can only use a single-layer cell mode to write data, and each of the second physical blocks can use the single-layer cell mode or a non-single-layer cell mode to write data, the single-layer cell mode is used to program a storage cell to store one of two states, and the non-single-layer cell mode is used to program a storage cell to store one of four or more states; Writing data belonging to the first partition type received from the host into only the first physical block in the first zone; and The data belonging to the second partition type received from the host side is written into the first physical block in the first zone and the second physical block in the second zone.
2. The data storage method of the flash memory as claimed in claim 1, characterized in that: Also includes: receiving a host write command from the host end; When the host write command indicates writing first data belonging to the first partition type, writing the first data to a current block in the first zone; When the host write command indicates to write second data belonging to the second partition type and the host write command is a random write command, write the second data to the current block in the first area; as well as When the host write command indicates writing third data belonging to the second partition type and the host write command is a continuous write command, the third data is written to the current block in the second area.
3. The data storage method of the flash memory as claimed in claim 2, characterized in that: The length of the second data is shorter than the length of one physical page storing data, and the length of the third data is equal to or longer than the length of one physical page storing data.
4. The data storage method of the flash memory as claimed in claim 2, characterized in that: Also includes: The partition number carried by the host write command is checked to determine whether the host write command indicates writing data belonging to the first partition type or the second partition type.
5. The data storage method of the flash memory as claimed in claim 1, characterized in that: Also includes: When the number of idle blocks in the first zone is lower than a threshold, reading and collecting data in a plurality of first valid sections of the data block belonging to the first partition type, and writing the data in the first valid sections to the current block in the first zone using the single-level cell mode; as well as When the number of idle blocks in the first zone is lower than the threshold, data in a second valid section of the data block belonging to the second partition type is read and collected, and the data in the second valid section is written to the current block in the second zone using the non-single-level cell mode.
6. The data storage method of the flash memory as claimed in claim 1, characterized in that: Also includes: When the number of erase times or read times of the data block in the first zone is higher than a threshold, reading all data or valid data in a plurality of first physical pages belonging to the first partition type in the data block, and writing all data or valid data in the first physical pages to the current block in the first zone using the single-layer cell mode; as well as When the number of erase times or the number of read times of the data block in the first zone is higher than the threshold, all data or valid data of multiple second physical pages belonging to the second partition type in the data block are read, and all data or valid data of the second physical pages are written to the current block in the second zone using the non-single-layer cell mode.
7. The data storage method of the flash memory as claimed in claim 1, characterized in that: Also includes: Reading data of a physical page in a data block of the first zone; When the error correction rate of the physical page is higher than a threshold, reading all data or valid data of a plurality of first physical pages belonging to the first partition type in the data block, and writing all data or valid data of the first physical pages to a current block in the first zone using the single-layer cell mode; as well as When the error correction rate of the physical page is higher than the threshold, all data or valid data of multiple second physical pages belonging to the second partition type in the data block are read, and all data or valid data of the second physical pages are written to the current block in the second zone using the non-single-layer cell mode.
8. The data storage method of the flash memory as claimed in claim 6 or 7, characterized in that: Also includes: Search the partition type bit table of the data block to obtain information of the first physical page belonging to the first partition type and the second physical page belonging to the second partition type in the data block, wherein the partition type bit table comprises a plurality of bits, each of which records information that the corresponding physical page belongs to the first partition type or the second partition type.
9. A computer-readable storage medium for storing program code executable by a processing unit, characterized in that: When the program code is executed by the processing unit, the following steps are implemented: Receive logical partition information from a file system executed on a host, for describing storage contents of a first partition type and a second partition type, wherein the logical partition information includes a length of the first partition type and a length of the second partition type, the length of the first partition type and the length of the second partition type being expressed as a number of logical block addresses, the host defining the first partition type and the second partition type, the host specifying that a file of a first type is stored in a storage space of the first partition type, and a file of a second type is stored in a storage space of the second partition type; Dividing the storage space of the flash memory module into a first area and a second area, wherein the first area includes a plurality of first physical blocks, the second area includes a plurality of second physical blocks, each of the first physical blocks can only use a single-layer cell mode to write data, and each of the second physical blocks can use the single-layer cell mode or a non-single-layer cell mode to write data, the single-layer cell mode is used to program a storage cell to store one of two states, and the non-single-layer cell mode is used to program a storage cell to store one of four or more states; Writing data belonging to the first partition type received from the host into only the first physical block in the first zone; and The data belonging to the second partition type received from the host side is written into the first physical block in the first zone and the second physical block in the second zone.
10. A data storage device of a flash memory, characterized in that: include: A flash memory interface, coupled to the flash memory module; A host interface, coupled to a host end; as well as A processing unit is coupled to the flash memory interface and the host interface, and receives logical partition information from a file system executed on the host side, which is used to describe the storage content of a first partition type and a second partition type, wherein the logical partition information includes the length of the first partition type and the length of the second partition type, and the length of the first partition type and the length of the second partition type are expressed as the number of logical block addresses. The host side defines the first partition type and the second partition type, and the host side specifies that a first type of file is stored in the storage space of the first partition type, and a second type of file is stored in the storage space of the second partition type; the storage space of the flash memory module is divided into a first area and a second area, wherein the first area includes a plurality of first physical blocks, and the second physical blocks are stored in the storage space of the second partition type. The second zone includes multiple second physical blocks, each of the first physical blocks can only be written with data using a single-layer cell mode, and each of the second physical blocks can be written with data using the single-layer cell mode or a non-single-layer cell mode, the single-layer cell mode is used to program a storage cell to store one of two states, and the non-single-layer cell mode is used to program a storage cell to store one of four or more states; the flash memory interface is driven to write the data belonging to the first partition type received from the host end through the host interface into only the first physical block in the first zone; and the flash memory interface is driven to write the data belonging to the second partition type received from the host end through the host interface into the first physical block in the first zone and the second physical block in the second zone.
11. The data storage device of the flash memory as claimed in claim 10, characterized in that: The processing unit receives a host write command from the host end through the host interface; when the host write command indicates writing first data belonging to the first partition type, drives the flash memory interface to write the first data to the current block in the first area; when the host write command indicates writing second data belonging to the second partition type and the host write command is a random write command, drives the flash memory interface to write the second data to the current block in the first area; and when the host write command indicates writing third data belonging to the second partition type and the host write command is a continuous write command, drives the flash memory interface to write the third data to the current block in the second area.
12. The data storage device of the flash memory as claimed in claim 11, characterized in that: The length of the second data is shorter than the length of one physical page storing data, and the length of the third data is equal to or longer than the length of one physical page storing data.
13. The data storage device of the flash memory as claimed in claim 11, characterized in that: The processing unit checks the partition number carried by the host write command to determine whether the host write command indicates writing data belonging to the first partition type or the second partition type.
14. The data storage device of the flash memory as claimed in claim 10, characterized in that: When the number of idle blocks in the first zone is lower than a threshold value, the processing unit drives the flash memory interface to read and collect data in multiple first valid segments of the data block belonging to the first partition type, and uses the single-layer unit mode to write the data in the first valid segments to the current block in the first zone; and when the number of idle blocks in the first zone is lower than the threshold value, the processing unit drives the flash memory interface to read and collect data in a second valid segment of the data block belonging to the second partition type, and uses the non-single-layer unit mode to write the data in the second valid segment to the current block in the second zone.
15. The data storage device of the flash memory as claimed in claim 10, characterized in that: When the number of erase times or read times of the data block in the first zone is higher than a threshold value, the processing unit drives the flash memory interface to read all data or valid data in multiple first physical pages of the data block belonging to the first partition type, and uses the single-layer cell mode to write all data or valid data of the first physical page to the current block in the first zone; and when the number of erase times or the number of read times of the data block in the first zone is higher than the threshold value, the processing unit drives the flash memory interface to read all data or valid data of multiple second physical pages of the data block belonging to the second partition type, and uses the non-single-layer cell mode to write all data or valid data of the second physical page to the current block in the second zone.
16. The data storage device of the flash memory as claimed in claim 10, characterized in that: The processing unit drives the flash memory interface to read data of a physical page in a data block of the first zone; when an error correction rate of the physical page is higher than a threshold, the processing unit drives the flash memory interface to read all data or valid data of multiple first physical pages belonging to the first partition type in the data block, and writes all data or valid data of the first physical page to a current block in the first zone using the single-layer unit mode; and when the error correction rate of the physical page is higher than the threshold, the processing unit drives the flash memory interface to read all data or valid data of multiple second physical pages belonging to the second partition type in the data block, and writes all data or valid data of the second physical page to the current block in the second zone using the non-single-layer unit mode.
