A data storage method and device based on wear leveling algorithm
By allocating high-bit data service physical block pools and low-bit data service physical block pools in three-dimensional flash memory, and distributing physical blocks according to the stored charge state of written data, it is solved that traditional wear equalization algorithms are difficult in three-dimensional flash memory and multi-bit storage technologies. The problem of achieving good wear balance improves the reliability of data storage.
Patent Information
- Application Number
- CN202210577137.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-05-25
AI Technical Summary
Traditional wear equalization algorithms are difficult to achieve good wear equalization in three-dimensional flash memory and multi-bit storage technologies, which affects the reliability of data storage.
By obtaining the original error rate threshold of the physical page, the physical block is divided into a high-bit data service physical block pool and a low-bit data service physical block pool. According to the stored charge state of the written data, it is determined as low-bit data or high-bit data, and the When allocating physical blocks, they are selected from the corresponding pools respectively to optimize the page mapping level of logical pages to physical pages.
The balanced use of flash physical blocks is realized, reducing the probability of centralized errors after long-term storage, and improving the reliability of 3DNAND solid-state drives.
Smart Images

Figure CN115061623B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a data storage method and device based on a wear leveling algorithm. Background Art
[0002] Memory is an important memory device in computer systems, which can store operating systems, applications and users' personal data. In the field of semiconductor storage, according to the volatility characteristics (i.e. whether the data can be saved for a long time after power failure), memory can be divided into two categories: one is volatile memory (data becomes invalid after power failure) such as RAM (DRAM), cache (SRAM), etc., and the other is non-volatile memory (data can still be saved after power failure) such as solid-state drives (SSD). Due to the non-volatility and low cost of the latter, solid-state drives are usually used to meet the needs of long-term preservation and large-capacity storage space.
[0003] Before the advent of solid-state drives, computer systems usually used mechanical hard drives to provide long-term data storage services. Compared with mechanical hard drives that use magnetic disks as storage media, solid-state drives use flash memory as storage media, which has the characteristics of fast read and write response speed, high storage density, and light volume. However, since flash memory (NAND) has its own defects as the final storage medium, solid-state drives also have their own shortcomings. For example, compared with magnetic disk storage, the medium of flash memory has an upper limit on the number of erases and writes, that is, the service life of solid-state drives is limited; secondly, its data retention is weaker than that of magnetic disks, that is, the original error rate of data stored in solid-state drives is higher; finally, as the number of erases and writes increases, the data retention capacity of flash memory media will gradually decrease while that of magnetic disks will not, which will lead to a continuous increase in the original error rate, and the increase in the original error rate will cause a decrease in the service life of solid-state drives.
[0004] Based on the above characteristics of flash memory, in order to improve reliability, the current wear leveling algorithm usually uses an address mapping table to record the correspondence between logical addresses and physical addresses, periodically exchanges areas with higher and lower write times, and migrates data to distribute write operations as evenly as possible in the storage area to prevent some storage blocks from being written out prematurely, thereby achieving the purpose of wear leveling.
[0005] However, the inventors of this application found that the above technology has at least the following technical problems in the process of implementing the technical solution of the invention in the embodiment of this application:
[0006] With the development of technology and related research, especially the development of three-dimensional flash memory (3D NAND) and multi-bit storage technology, the factors affecting data storage reliability have become more diversified. Previous research on wear leveling algorithms for physical blocks in traditional flash translation layers has not achieved good wear leveling effects. Summary of the invention
[0007] The embodiments of the present application provide a data storage method and device based on a wear leveling algorithm, so that the physical blocks in the flash memory can be used evenly, avoiding excessive use of certain physical blocks in the flash memory chip, thereby reducing the probability of a large number of concentrated errors after long-term storage.
[0008] The present application provides a data storage method based on a wear leveling algorithm, the method comprising:
[0009] Get the raw error rate threshold of the physical page;
[0010] The physical blocks whose original error rates of currently idle physical pages are lower than the original error rate threshold are divided into a high-order data service physical block pool, and the physical blocks whose original error rates of currently idle physical pages are not lower than the original error rate threshold are divided into a low-order data service physical block pool, wherein the currently idle physical page is the idle physical page with the lowest number in the physical blocks;
[0011] Determine whether the written data is low-state data or high-state data according to the storage charge state of the written data in the storage cells of the physical page, the high-state data being the written data in which the ratio of the number of high-state storage cells in the physical page to the total number of storage cells exceeds a first threshold, and the low-state data being the written data in which the ratio of the total number of high-state storage cells in the physical page to the number of storage cells is lower than or equal to the first threshold;
[0012] If the write data is low-order data, a physical block is selected from the low-order data service physical block pool and allocated to the write data storage; if the write data is high-order data, a physical block is selected from the high-order data service physical block pool and allocated to the write data storage;
[0013] A currently idle physical page is selected from the allocated physical block, and a mapping relationship between the currently idle physical page and the logical page is determined.
[0014] Optionally, the physical blocks whose original error rate of the currently idle physical pages is lower than the original error rate threshold are divided into a high-order data service physical block pool, and the physical blocks whose original error rate of the currently idle physical pages is not lower than the original error rate threshold are divided into a low-order data service physical block pool, including:
[0015] Get the original error rate distribution curve of the physical page;
[0016] Determining a second threshold and a third threshold according to the original error rate threshold and the original error rate distribution curve;
[0017] The physical blocks whose current free physical page numbers are less than or equal to the second threshold are divided into the low page group, the physical blocks whose current free physical page numbers are greater than the second threshold and less than or equal to the third threshold are divided into the middle page group, and the physical blocks whose current free physical page numbers are greater than the third threshold are divided into the high page group;
[0018] Adding the lower page group and the upper page group into the lower data service physical block pool;
[0019] The middle page group is divided into the high data service physical block pool.
[0020] Optionally, the method further comprises:
[0021] Determine the ratio of the storage space of the high-order data to the storage space of the low-order data according to the second threshold and the third threshold, the storage space of the high-order data is the sum of the storage space of the low-order page group and the storage space of the high-order page group, and the storage space of the low-order data is the sum of the storage space of the middle-order page group;
[0022] Determine the ratio of the probability of the low state data to the probability of the high state data according to the ratio of the storage space of the high state data to the storage space of the low state data;
[0023] A first threshold is determined according to the ratio of the low-order data probability to the high-order data probability.
[0024] Optionally, determining the first threshold according to the ratio of the low-state data probability to the high-state data probability includes:
[0025] According to the ratio of the low-state data probability to the high-state data probability, a first threshold is determined using a binomial distribution formula.
[0026] Optionally, a physical page may correspond to m logical pages, a physical page includes N storage cells, each of which may store m bits of data, and the storage charge state of each storage cell is 2 m One of the two positions, present the first 2 m-1 The storage unit in the state of the bit is a low-state storage unit, and the latter 2 m-1 The storage unit in the state is a high-state storage unit.
[0027] Optionally, selecting a physical block from the low-order data service physical block pool and allocating it to the write data storage includes:
[0028] A physical block with the least free physical pages in the low-order page group is selected from the low-order data service physical block pool and allocated to the write data storage.
[0029] Optionally, selecting a physical block from the high-order data service physical block pool and allocating it to the write data storage includes:
[0030] A physical block with the least free physical pages is selected from the middle page group in the high-order data service physical block pool and allocated to the write data storage.
[0031] Optionally, the method further includes updating the low-order data service physical block pool, including:
[0032] Traversing the low-order data service physical block pool, checking the number range of currently free physical pages in the physical block;
[0033] After writing the data in the low-order page group, the physical blocks of the physical pages whose current idle physical page numbers are greater than the second threshold are transferred to the high-order data service physical block pool;
[0034] After the data in the high-order page group is written, the physical block in which the physical page is fully written is kicked out of the low-order data service physical block pool.
[0035] Optionally, the method further includes updating the high-order data service physical block pool, including:
[0036] Traversing the high-order data service physical block pool, checking the number range of currently free physical pages in the physical block;
[0037] After the data in the middle page group is written, the physical blocks of the physical pages whose current free physical page numbers are greater than the third threshold are transferred to the low-order data service physical block pool.
[0038] The present application provides a data storage device based on a wear leveling algorithm, the device comprising:
[0039] An acquisition module, used to obtain an original error rate threshold;
[0040] A physical block pool identification module, used to classify the physical blocks whose original error rate of the current idle physical page is lower than the original error rate threshold into the high-order data service physical block pool, and classify the physical blocks whose original error rate of the current idle physical page is not lower than the original error rate threshold into the low-order data service physical block pool, wherein the current idle physical page is the idle physical page with the lowest number in the physical blocks;
[0041] A bit state discrimination module, for determining whether the written data is low-state data or high-state data according to the storage charge state of the written data in the storage unit of the physical page, wherein the high-state data is the written data in which the ratio of the number of high-state storage units in the physical page to the total number of storage units exceeds a first threshold, and the low-state data is the written data in which the ratio of the total number of high-state storage units in the physical page to the number of storage units is lower than or equal to the first threshold;
[0042] A matching module, configured to select a physical block from the low-order data service physical block pool and allocate it to the write data storage if the write data is low-order data, and select a physical block from the high-order data service physical block pool and allocate it to the write data storage if the write data is high-order data;
[0043] The mapping relationship determination module is used to select a current idle physical page from the allocated physical block and determine a mapping relationship between the current idle physical page and a logical page.
[0044] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0045] The method of the present application utilizes the characteristics that a large offset of the threshold voltage of high-order data is prone to errors, while a small offset of the threshold voltage of low-order data is not prone to errors. The physical blocks are first classified according to the original error rate of the current idle physical page, and then the storage charge state of the write data in the storage unit of the physical page is determined to determine whether the write data is low-order data or high-order data. If the write data is low-order data, a physical block is selected from a low-order data service physical block pool and allocated to the write data storage. If the write data is high-order data, a physical block is selected from a high-order data service physical block pool and allocated to the write data storage. The current idle physical page is selected from the allocated physical blocks, and the mapping relationship between the current idle physical page and the logical page is determined.
[0046] By optimizing the page mapping algorithm from logical pages to physical pages in the flash conversion layer, it is possible to use physical pages with low original error rates in the same physical block to process logical pages with more high-order data, while using physical pages with high original error rates to process logical pages with more low-order data. This allows the physical blocks in the flash memory to be used evenly, thereby reducing the probability of a large number of concentrated errors after long-term storage, avoiding a large number of concentrated errors that make the error correction module unable to handle, and thus reducing the possibility of data loss or errors in user storage, and improving the reliability of 3D NAND solid-state drives. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a schematic diagram of the flash memory chip level;
[0048] Figure 2This is a flow chart of a data storage method based on a wear leveling algorithm in this application;
[0049] Figure 3 This is a flow chart of another data storage method based on a wear leveling algorithm in this application;
[0050] Figure 4 It is the data retention distribution diagram of different physical pages in the physical block in 3D NAND;
[0051] Figure 5 This is a conceptual diagram of the classification of page groups in this application;
[0052] Figure 6 This is a conceptual diagram of the classification of physical blocks in this application;
[0053] Figure 7 A distribution probability diagram of high-state storage cells in a physical page in this application;
[0054] Figure 8 A storage charge state diagram of a storage cell in TLC storage in this application;
[0055] Fig. 9 This is a graph of threshold voltage drift in different states in TLC storage in this application;
[0056] Fig.10 A flowchart of updating a low-order data service physical block pool in this application;
[0057] Fig.11 A flowchart of updating a high-order data service physical block pool in this application;
[0058] Fig.12 is a state periodic transition diagram of a physical block in this application;
[0059] Fig.13 A block diagram of a data storage device based on a wear leveling algorithm. DETAILED DESCRIPTION
[0060] Figure 1 The following is a schematic diagram of the flash memory chip hierarchy: chip - wafer - group - physical block - physical page - storage unit. Figure 1As shown, the chip generally contains an even number of wafers, the wafer generally contains two groups, the group generally contains more than a thousand physical blocks, the physical block generally contains hundreds of physical pages, and the physical page generally contains 4KB or 16KB storage units. The smallest unit of flash memory read and write operations is the physical page, and the smallest unit of erase operation is the physical block. Moreover, when the flash memory writes to the physical pages in a physical block, it must write in order from low to high. At the same time, when updating the original data, the flash memory cannot be updated in situ, and must be updated off-site, that is, new physical pages are used to store data. The original physical page is marked as invalid, and garbage collection operations are performed regularly, that is, invalid physical blocks are erased to turn them into blank physical blocks.
[0061] When writing, the host computer sends data write requests to the SSD. These write requests are parsed according to the communication protocol and cached in the cache of the main control chip. Then they are divided into many sub-requests according to the logical page size. According to the multi-bit storage technology, these logical page numbers are grouped, with multiple logical pages in one group. These grouped logical pages will be cached in the memory according to the page mapping granularity to wait for the allocation of the corresponding physical page number.
[0062] Multi-bit storage technology means that multiple bits of data can be stored in a storage cell (cell) of the memory. At present, the existing multi-bit storage technologies mainly include double-layer storage cells (MLC, Multi-Level Cell), three-layer storage cells (TLC, Trinary-Level Cell), and four-layer storage cells (QLC, Quad-Level Cell). Correspondingly, one cell of MLC stores 2 bits, and the storage space of one physical page stores the write data of 2 logical pages. One cell of TLC stores 3 bits, and the storage space of one physical page stores the write data of 3 logical pages. One cell of QLC stores 4 bits, and the storage space of one physical page stores the write data of 4 logical pages.
[0063] The present application relates to a page mapping level algorithm optimization from logical pages to physical pages in a flash memory translation layer. Figure 2 Flow chart of a data storage method based on a wear leveling algorithm in an embodiment of the present application. Figure 2 As shown, the method includes:
[0064] S101, obtaining an original error rate threshold of a physical page.
[0065] Specifically, the raw error rate threshold of the physical page can be determined according to the importance of the data and the customer's requirements for the data. The higher the raw error rate threshold, the less important the data is and the higher the customer's tolerance for errors is; the lower the raw error rate threshold, the more important the data is and the lower the customer's tolerance for errors is.
[0066] S102, the physical blocks whose original error rate of the current idle physical page is lower than the original error rate threshold are divided into the high-order data service physical block pool, and the physical blocks whose original error rate of the current idle physical page is not lower than the original error rate threshold are divided into the low-order data service physical block pool, and the current idle physical page is the idle physical page with the lowest number in the physical blocks.
[0067] Specifically, the original error rate of the current idle physical page can be determined according to the original error rate of the chip physical page. The original error rate of the chip physical page can be measured by experiment or calculated by simulation based on manufacturer data.
[0068] S103, determining whether the write data is low-state data or high-state data according to the storage charge state of the write data in the storage cells of the physical page, wherein the high-state data is the write data in which the ratio of the number of high-state storage cells in the physical page to the total number of storage cells exceeds a first threshold, and the low-state data is the write data in which the ratio of the total number of high-state storage cells in the physical page to the total number of storage cells is lower than or equal to the first threshold.
[0069] Specifically, in multi-bit storage technology, a physical page can correspond to m logical pages. A physical page contains N storage cells, each of which can store m bits of data. The storage charge state of each storage cell may be 2 m One of the two positions, present the first 2 m-1 The storage unit in the state of the bit is a low-state storage unit, showing the last 2 m-1 The storage unit in the single-bit state is a high-bit state storage unit.
[0070] During implementation, the write data is first encoded according to the commonly used 2-3-2 or 1-2-5 encoding method to determine the storage charge state of the write data in the storage unit of the physical page, and then based on the storage charge state of the write data in the storage unit of the physical page, it is determined whether the write data is low-state data or high-state data.
[0071] A high-order data threshold voltage with a large offset is prone to error, while a low-order data threshold voltage with a small offset is not prone to error. The error probability of the written data can be graded by determining whether the written data is low-order data or high-order data based on the storage charge state of the written data in the storage unit of the physical page.
[0072] S104: If the write data is low-order data, a physical block is selected from the low-order data service physical block pool and allocated to the write data storage; if the write data is high-order data, a physical block is selected from the high-order data service physical block pool and allocated to the write data storage.
[0073] Specifically, physical blocks are selected from the low-order data service physical block pool and allocated to the write data storage, thereby allocating physical pages with high original error rates to low-order data that are not prone to errors; physical blocks are selected from the high-order data service physical block pool and allocated to the write data storage, thereby allocating physical pages with low original error rates to high-order data that are prone to errors, so that the physical blocks in the flash memory can be used evenly, avoiding excessive use of certain physical blocks in the flash memory chip, thereby reducing the probability of a large number of concentrated errors after long-term storage.
[0074] S105, selecting a current idle physical page in the allocated physical block, and determining a mapping relationship between the current idle physical page and the logical page.
[0075] The method of the present application utilizes the characteristics that a large offset of the threshold voltage of high-order data is prone to errors, while a small offset of the threshold voltage of low-order data is not prone to errors. The physical blocks are classified according to the original error rate of the current idle physical page, and then the storage charge state of the write data in the storage unit of the physical page is determined to determine whether the write data is low-order data or high-order data. If the write data is low-order data, a physical block is selected from a low-order data service physical block pool and allocated to the write data storage. If the write data is high-order data, a physical block is selected from a high-order data service physical block pool and allocated to the write data storage. The current idle physical page is selected from the allocated physical blocks, and the mapping relationship between the current idle physical page and the logical page is determined.
[0076] By optimizing the page mapping algorithm from logical pages to physical pages in the flash conversion layer, it is possible to use physical pages with low original error rates in the same physical block to process logical pages with more high-order data, while using physical pages with high original error rates to process logical pages with more low-order data. This allows the physical blocks in the flash memory to be used evenly, thereby reducing the probability of a large number of concentrated errors after long-term storage, avoiding a large number of concentrated errors that make the error correction module unable to handle, and thus reducing the possibility of data loss or errors in user storage, and improving the reliability of 3D NAND solid-state drives.
[0077] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0078] Figure 3 FIG. 1 is a flow chart of another data storage method based on a wear leveling algorithm provided by an embodiment of the present invention. Figure 3 Said method comprises:
[0079] S201, obtaining an original error rate threshold of a physical page.
[0080] Furthermore, the raw error rate threshold of the physical page can be determined according to the importance of the data and the customer's requirements for the data. The higher the raw error rate threshold, the less important the data is and the higher the customer's tolerance for errors is; the lower the raw error rate threshold, the more important the data is and the lower the customer's tolerance for errors is.
[0081] S202, obtaining an original error rate distribution curve of the physical page.
[0082] Furthermore, the raw error rate distribution curve of the physical page can be determined according to the raw error rate of the chip physical page. The raw error rate of the chip physical page can be measured by experiment or calculated by simulation according to manufacturer data.
[0083] Specifically, Figure 4 is the distribution diagram of the original error rate of different physical pages in the physical block in 3D NAND. Figure 4 As shown in the figure, the raw error rates of physical pages at different positions in the same physical block of 3D NAND are significantly different, and this difference exists both in the initial state without erasure and in the aged state after a certain number of erasures. The physical pages in the physical block of the three-dimensional flash memory chip are stacked from low to high, and the numbers are also numbered from low to high. The data retention ability of the physical pages with numbers near the minimum and maximum values is weaker, and the raw error rate is higher, while the data retention ability of the physical pages with numbers in the middle is stronger, and the raw error rate is lower. It can be understood that the raw error rate during the storage process is inversely proportional to the data retention, and the distribution presents an inverse parabolic curve.
[0084] S203: Determine a second threshold and a third threshold according to the original error rate threshold and the original error rate distribution curve.
[0085] refer to Figure 4 The intersection points of the original error rate threshold a and the original error rate distribution curve are the second threshold K1 and the third threshold K2 respectively.
[0086] S204: Classify the physical blocks whose current free physical page numbers are less than or equal to the second threshold into the low page group, classify the physical blocks whose current free physical page numbers are greater than the second threshold and less than or equal to the third threshold into the middle page group, and classify the physical blocks whose current free physical page numbers are greater than the third threshold into the high page group.
[0087] Specifically, since the flash memory must write in ascending order when performing a write operation on the physical pages in a physical block, the physical pages are partially occupied and partially idle. The physical blocks whose current idle physical page numbers are less than or equal to the second threshold value can be divided into the low-order page group, the physical blocks whose current idle physical page numbers are greater than the second threshold value and less than or equal to the third threshold value can be divided into the middle-order page group, and the physical blocks whose current idle physical page numbers are greater than the third threshold value can be divided into the high-order page group. The current idle physical page refers to the idle physical page with the lowest number in the physical block.
[0088] Since the original error rate distribution during the storage process presents an inverse parabolic curve, the physical block is divided into a low-order page group, a middle-order page group and a high-order page group according to the above method. The low-order page group and the high-order page group will have the characteristics of weaker data retention capabilities and higher original error rates, and the middle-order page group will have the characteristics of stronger data retention capabilities and lower original error rates.
[0089] by Figure 5 Taking the physical page shown as an example, the maximum value of the physical page number is 9, the second threshold K1 is 2, and the third threshold K2 is 7. Therefore, the physical blocks whose current free physical page numbers are less than or equal to 2 are divided into the low-order page group, the physical blocks whose current free physical page numbers are greater than 2 and less than or equal to 7 are divided into the middle-order page group, and the physical blocks whose current free physical page numbers are greater than 7 are divided into the high-order page group.
[0090] S205: dividing the lower page group and the upper page group into a lower data service physical block pool;
[0091] In some embodiments, the low-order page group of physical pages whose current free physical page numbers are less than or equal to a second threshold and the high-order page group of physical blocks whose current free physical page numbers are greater than a third threshold can be added to a low-order data service physical block pool to provide storage services for low-order data.
[0092] like Figure 6 As shown, for example, in a physical block, physical page 1 is occupied and physical pages 2-9 are free. Then the current free physical page in the physical block is physical page 2. Figure 5 According to the classification rule shown, since the current idle physical page number is equal to the second threshold, the physical block can be classified as a low-order page group and classified into a low-order data service physical block pool.
[0093] For another example, in a physical block, physical pages 1-8 are occupied and physical page 9 is free. The current free physical page in the physical block is physical page 9. The current free physical page number is greater than the third threshold. The physical block can be classified as a high-order page group and divided into a low-order data service physical block pool.
[0094] S206: Divide the middle page group into the high data service physical block pool.
[0095] In some embodiments, the median page group of physical blocks whose current free physical page numbers are greater than the second threshold and less than or equal to the third threshold can be added to the high-order data service physical block pool to provide storage services for high-order data.
[0096] like Figure 6 As shown, for example, physical pages 1-6 are occupied and physical pages 7-9 are free, then the current free physical page in the physical block is physical page 7. Since the current free physical page number is greater than the second threshold and less than the third threshold, the physical block can be classified as a middle page group and divided into the high-order data service physical block pool.
[0097] For another example, if physical pages 1-3 are occupied and physical pages 4-9 are free, the current free physical page in the physical block is physical page 4. Since the current free physical page number is greater than the second threshold and less than the third threshold, the physical block can be classified as a middle page group and included in the high-order data service physical block pool.
[0098] In some embodiments, the physical blocks providing storage services may also include a pool of free physical blocks that are all blank pages.
[0099] S207: Determine a first threshold according to the second threshold and the third threshold.
[0100] Specifically, S207 may include the following steps:
[0101] S2071: Determine the ratio of the storage space of the high-order data to the storage space of the low-order data according to the second threshold and the third threshold, the storage space of the high-order data being the sum of the storage space of the low-order page group and the storage space of the high-order page group, and the storage space of the low-order data being the sum of the storage space of the middle-order page group;
[0102] Specifically, see Figure 4 , there is the following relationship between the ratio of the storage space of the high-order data to the storage space of the low-order data and the second threshold and the third threshold:
[0103]
[0104] Wherein, k1 and k2 are the second threshold and the third threshold respectively, and Np represents the total number of physical pages in the physical block.
[0105] S2072: Determine the ratio of the probability of the low state data to the probability of the high state data according to the ratio of the storage space of the high state data to the storage space of the low state data;
[0106] Specifically, the storage space of high-order data can be represented by the number of pages in the middle page group, and the storage space of low-order data can be represented by the number of pages in the high and low page groups. The probability of high and low-order data and the number of pages in the high, middle, and low page groups have the following relationship:
[0107]
[0108] The ratio of the storage space of the high-order data to the storage space of the low-order data and the ratio of the probability of the low-order data to the probability of the high-order data can ensure that there is space to store all data and that services will not be unable to be provided due to one storage space being used up prematurely.
[0109] S2073: Determine a first threshold value based on the ratio of the low-state data probability to the high-state data probability.
[0110] Optionally, we can use binomial distribution to describe the possible high-order data probability and low-order data probability of the host computer writing data. The binomial distribution formula is:
[0111]
[0112] in, is the binomial coefficient, P is the probability of k high-state storage cells in the physical page, N represents the total number of storage cells in a physical page, and the current physical page size is 16KB, so the total number of storage cells in a physical page is N=16*1024*8.
[0113] like Figure 7 As shown, assuming that the first threshold is Kth, it can be understood that when Kth=0.5N, half of the data will be judged as high-order data.
[0114] If Kth = Kx, according to the binomial distribution formula, after threshold determination, the probability of the written data being determined as high-order data is
[0115]
[0116] On the contrary, the probability of the written data being judged as low-order data is
[0117]
[0118] Substituting formula (4) and formula (5) into formula (1) and formula (2), we can obtain:
[0119]
[0120] Where Np represents the total number of physical pages in a physical block, and N represents the total number of storage units in a physical page.x is the first threshold, k1 and k2 are the second threshold and the third threshold respectively.
[0121] Optionally, k1 and k2 may be determined according to an original error probability distribution curve and an original error tolerance a of the client.
[0122] S208: Determine whether the written data is low-state data or high-state data based on the storage charge state of the written data in the storage cells of the physical page, wherein the high-state data is the written data in which the ratio of the number of high-state storage cells in the physical page to the total number of storage cells exceeds a first threshold, and the low-state data is the written data in which the ratio of the total number of high-state storage cells in the physical page to the number of storage cells is lower than or equal to the first threshold.
[0123] Specifically, in multi-bit storage technology, a physical page can correspond to m logical pages. A physical page contains N storage cells, each of which can store m bits of data. The storage charge state of each storage cell may be 2 m One of the two positions, present the first 2 m-1 The storage unit in the state of the bit is a low-state storage unit, showing the last 2 m-1 The storage unit in the single-bit state is a high-bit state storage unit.
[0124] The following uses TLC flash memory as an example. Currently, all three-dimensional flash memory adopts a one-shot programming method, which is to combine the three logical pages of data to be written into a physical page and write them through one-shot programming. Therefore, the storage charge state of each storage cell in the physical page is related to the data written into the three logical pages in the storage cell. In actual processing, the written data in the three logical pages is usually encoded in a fixed encoding method, such as Figure 8 As shown in the figure, the storage charge state of each storage cell presents one of 8 states depending on the written data. For example, a TLC physical page has 16kB storage cells, which can store 48kB of data in the logical page. Each storage cell in the physical page stores 3 bits of data in the logical page. The 3 bits of data are encoded in a fixed encoding method and presented in 2 3 one of two different states.
[0125] Fig. 9 This is a graph of the threshold voltage drift of different states in the TLC storage in this application. Fig. 9 As shown, as the bit state number increases, the threshold voltage distribution offset between the ideal state and the actual state increases, and the gap between it and the corresponding judgment voltage decreases. That is to say, data stored in the high state is more prone to errors after long-term storage than data stored in the low state.
[0126] If the storage charge state of the memory cell is one of the four states leaning to the left, the memory cell is defined as a low-state memory cell. If the storage charge state of the memory cell is one of the four states leaning to the right, the memory cell is defined as a high-state memory cell.
[0127] In some embodiments, the storage charge state of each storage cell in the 16kB storage cells of a physical page can be counted. If the proportion of the number of high-state storage cells to the number of storage cells exceeds a first threshold, the write data written into the physical page is high-state data; if the proportion of the number of high-state storage cells to the number of storage cells is less than or equal to the first threshold, the write data written into the physical page is low-state data. High-state data can be used to mark data that is prone to errors, and low-state data can be used to mark data that is not prone to errors.
[0128] During implementation, the flash conversion layer in the main controller can set a high-state threshold judgment module, which counts the high-state quantity distribution of storage cells in each logical page group. If the quantity exceeds the threshold, it will be marked as high-state data, otherwise it will be marked as low-state data.
[0129] In some embodiments, if the written data is low-state data, S209 - S211 are executed; if the written data is high-state data, S2012 - S214 are executed.
[0130] S209: If the write data is low-order data, a physical block is selected from the low-order data service physical block pool and allocated to the write data storage.
[0131] Optionally, the physical blocks selected from the low-order data service physical block pool and allocated to the write data storage may be allocated according to a priority filling principle.
[0132] Specifically, a physical block with the least free physical pages in the low-order page group is selected from the low-order data service physical block pool and allocated to the write data storage, so as to provide sufficient resources for the high-order data service physical block pool, which helps to cope with the situation where there is a large amount of high-order data in the upper computer load request.
[0133] S2010: Select a current idle physical page in the allocated physical block, and determine a mapping relationship between the current idle physical page and the logical page.
[0134] Specifically, a currently idle physical page is selected from the allocated physical block, and a mapping relationship between the currently idle physical page and the logical page is determined, that is, the optimization of the page mapping level algorithm from the logical page to the physical page in the flash translation layer is completed.
[0135] During implementation, the logical page group to which the corresponding physical address is allocated will wait for the flash transaction scheduling module to arrange the writing sequence, and will be written into the specific physical page of the specific physical block of the corresponding flash memory chip through the flash channel controller.
[0136] Since the physical block will continuously move from the free physical block pool to the low-level data storage service physical block pool, then to the high-level data storage service physical block pool according to the consumption of its internal physical pages, and finally return to the low-level data storage service physical block pool until it is full of page data and no longer provides storage services, the range of the low-level data service physical block pool and the high-level data service physical block pool is dynamically adjusted.
[0137] Therefore, the method may further include S211: updating the low-order data service physical block pool.
[0138] Specifically, Fig.10 As shown, updating the low-order data service physical block pool includes:
[0139] S2111: traverse the low-order data service physical block pool to check the number range of currently free physical pages in the physical block;
[0140] S2112: after writing the data in the low-order page group, the physical blocks of the physical pages whose current idle physical page numbers are greater than the second threshold are transferred to the high-order data service physical block pool;
[0141] In some embodiments, updating the low-order data service physical block pool further includes:
[0142] S2113: After the data in the high-order page group is written, the physical blocks in which the physical pages are fully written are kicked out of the low-order data service physical block pool.
[0143] S2114: The idle physical block pool will be supplemented to the low-level data service physical block pool according to the traditional wear leveling principle.
[0144] S212: If the write data is high-order data, a physical block is selected from the high-order data service physical block pool and allocated to the write data storage.
[0145] Optionally, the physical blocks selected from the high-order data service physical block pool and allocated to the write data storage may be allocated according to a priority filling principle.
[0146] Specifically, a physical block with the least free physical pages in the middle page group is selected from the high-order data service physical block pool and allocated to the write data storage, so as to provide resources for the low-order data service physical block pool.
[0147] S213: Select a currently idle physical page in the allocated physical block, and determine a mapping relationship between the physical page and the logical page.
[0148] S214: Update the high-order data service physical block pool.
[0149] Specifically, Fig.11 As shown, updating the high-order data service physical block pool includes:
[0150] S2141: traverse the high-order data service physical block pool to check the number range of currently free physical pages in the physical block;
[0151] S2142: After writing the data in the middle page group, the physical blocks of the physical pages whose current free physical page numbers are greater than a third threshold are transferred to the low-order data service physical block pool.
[0152] Fig.12 The state periodic transition diagram of the physical block, such as Fig.12 As shown in the figure, since the write order of physical pages in a physical block must be executed from low to high, the life cycle of a physical block will be from a member of the free physical block pool to a member of the low-order data storage service physical block pool. As the low-order page group is consumed, it will be transformed into a member of the high-order data storage service physical block pool. As the middle-order page group is consumed, it will be transformed into a member of the low-order data storage service physical block pool. Finally, when all physical pages in the physical block have been written with data, it will continue to save data and not provide write services until the number of invalid pages in its block increases to a certain threshold, and then the garbage collection operation is triggered, and it returns to the free physical block pool.
[0153] Fig.13 The block diagram of a data storage device based on a wear leveling algorithm includes an acquisition module 301 , a physical block pool determination module 302 , a bit state determination module 303 , a matching module 304 and a mapping relationship determination module 305 .
[0154] An acquisition module 301 is used to acquire an original error rate threshold;
[0155] The physical block pool identification module 302 is used to classify the physical blocks whose original error rate of the current idle physical page is lower than the original error rate threshold into the high-order data service physical block pool, and classify the physical blocks whose original error rate of the current idle physical page is not lower than the original error rate threshold into the low-order data service physical block pool, wherein the current idle physical page is the idle physical page with the lowest number in the physical blocks;
[0156] A bit state discrimination module 303 is used to determine whether the written data is low-state data or high-state data according to the storage charge state of the written data in the storage unit of the physical page, wherein the high-state data is the written data in which the ratio of the number of high-state storage units in the physical page to the total number of storage units exceeds a first threshold, and the low-state data is the written data in which the ratio of the total number of high-state storage units in the physical page to the number of storage units is less than or equal to the first threshold;
[0157] The matching module 304 is used to select a physical block from the low-order data service physical block pool and allocate it to the write data storage if the write data is low-order data, and select a physical block from the high-order data service physical block pool and allocate it to the write data storage if the write data is high-order data;
[0158] The mapping relationship determination module 305 is used to select a current idle physical page from the allocated physical block and determine a mapping relationship between the current idle physical page and a logical page.
[0159] Optionally, the physical block pool determination module 302 includes:
[0160] The curve acquisition submodule is used to obtain the original error rate distribution curve of the physical page;
[0161] A threshold determination submodule, used to determine a second threshold and a third threshold according to the original error rate threshold and the original error rate distribution curve;
[0162] A grouping submodule, used to group physical blocks whose current free physical page numbers are less than or equal to a second threshold into a low-order page group, group physical blocks whose current free physical page numbers are greater than the second threshold and less than or equal to a third threshold into a middle-order page group, and group physical blocks whose current free physical page numbers are greater than the third threshold into a high-order page group;
[0163] A first division submodule divides the lower-order page group and the upper-order page group into the lower-order data service physical block pool;
[0164] The first division submodule divides the middle page group into the high-order data service physical block pool.
[0165] Optionally, the device further comprises:
[0166] a storage space calculation module, used to determine the ratio of the storage space of the high-order data to the storage space of the low-order data according to the second threshold and the third threshold, the storage space of the high-order data being the sum of the storage space of the low-order page group and the storage space of the high-order page group, and the storage space of the low-order data being the sum of the storage space of the middle-order page group;
[0167] A ratio determination module, used to determine the ratio of the probability of the low state data to the probability of the high state data according to the ratio of the storage space of the high state data to the storage space of the low state data;
[0168] The first threshold determination module is used to determine a first threshold according to the ratio of the low-state data probability to the high-state data probability.
[0169] Optionally, the first threshold determination module is further used to determine the first threshold according to the ratio of the low-state data probability to the high-state data probability through a binomial distribution formula.
[0170] Optionally, a physical page may correspond to m logical pages, a physical page includes N storage cells, each of which may store m bits of data, and the storage charge state of each storage cell is 2 m One of the two positions, present the first 2 m-1 The storage unit in the state of the bit is a low-state storage unit, and the latter 2 m-1 The storage unit in the state is a high-state storage unit.
[0171] Optionally, the matching module 304 is further configured to select a physical block with the least free physical pages in the low-order page group from the low-order data service physical block pool and allocate it to the write data storage.
[0172] Optionally, the matching module 304 is further configured to select a physical block with the least free physical pages from the middle page group in the high-order data service physical block pool and allocate it to the write data storage.
[0173] Optionally, the device also includes a first update module, which is used to traverse the low-order data service physical block pool and check the number range of currently free physical pages in the physical block; after writing the data in the low-order page group, the physical blocks of the physical pages whose current free physical page numbers are greater than a second threshold are transferred to the high-order data service physical block pool; after writing the data in the high-order page group, the physical blocks whose physical pages are full are kicked out of the low-order data service physical block pool.
[0174] Optionally, the device also includes a second update module, which is used to traverse the high-order data service physical block pool and check the number range of currently free physical pages in the physical block; after writing the data in the middle page group, the physical block of the physical page whose current free physical page number is greater than a third threshold is transferred to the low-order data service physical block pool.
[0175] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
Claims
1. A data storage method based on a wear leveling algorithm, characterized in that: The method comprises: Get the raw error rate threshold of the physical page; The physical blocks whose original error rates of currently idle physical pages are lower than the original error rate threshold are divided into a high-order data service physical block pool, and the physical blocks whose original error rates of currently idle physical pages are not lower than the original error rate threshold are divided into a low-order data service physical block pool, wherein the currently idle physical page is the idle physical page with the lowest number in the physical blocks; Determine whether the written data is low-state data or high-state data according to the storage charge state of the written data in the storage cells of the physical page, the high-state data being the written data in which the ratio of the number of high-state storage cells in the physical page to the total number of storage cells exceeds a first threshold, and the low-state data being the written data in which the ratio of the number of high-state storage cells in the physical page to the total number of storage cells is lower than or equal to the first threshold; If the write data is low-order data, a physical block is selected from the low-order data service physical block pool and allocated to the write data storage; if the write data is high-order data, a physical block is selected from the high-order data service physical block pool and allocated to the write data storage; A currently idle physical page is selected from the allocated physical block, and a mapping relationship between the currently idle physical page and the logical page is determined.
2. The method according to claim 1, characterized in that The method further comprises: dividing the physical blocks whose original error rates of the currently idle physical pages are lower than the original error rate threshold into a high-order data service physical block pool, and dividing the physical blocks whose original error rates of the currently idle physical pages are not lower than the original error rate threshold into a low-order data service physical block pool. Get the original error rate distribution curve of the physical page; Determining a second threshold and a third threshold according to the original error rate threshold and the original error rate distribution curve; The physical blocks whose current free physical page numbers are less than or equal to the second threshold are divided into the low page group, the physical blocks whose current free physical page numbers are greater than the second threshold and less than or equal to the third threshold are divided into the middle page group, and the physical blocks whose current free physical page numbers are greater than the third threshold are divided into the high page group; Adding the lower page group and the upper page group into the lower data service physical block pool; The middle page group is divided into the high data service physical block pool.
3. The method according to claim 2, characterized in that The method further comprises: Determine the ratio of the storage space of the high-order data to the storage space of the low-order data according to the second threshold and the third threshold, the storage space of the high-order data is the sum of the storage space of the low-order page group and the storage space of the high-order page group, and the storage space of the low-order data is the sum of the storage space of the middle-order page group; Determine the ratio of the probability of low-state data to the probability of high-state data according to the ratio of the storage space of the high-state data to the storage space of the low-state data; A first threshold is determined according to a ratio of the low-state data probability to the high-state data probability.
4. The method according to claim 3, characterized in that The determining of the first threshold according to the ratio of the low-state data probability to the high-state data probability includes: According to the ratio of the low-state data probability to the high-state data probability, a first threshold is determined using a binomial distribution formula.
5. The method according to claim 1, characterized in that A physical page corresponds to m logical pages. A physical page contains N storage cells. Each storage cell stores m bits of data. The storage charge state of each storage cell is 2 m One of the two positions, present the first 2 m-1 The storage unit in the state of the bit is a low-state storage unit, and the latter 2 m-1 The storage unit in the state is a high-state storage unit.
6. The method according to claim 2, characterized in that The selecting a physical block from the low-order data service physical block pool and allocating it to the write data storage comprises: A physical block with the least free physical pages in the low-order page group is selected from the low-order data service physical block pool and allocated to the write data storage.
7. The method according to claim 2, characterized in that The selecting a physical block from the high-order data service physical block pool and allocating it to the write data storage comprises: A physical block with the least free physical pages is selected from the middle page group in the high-order data service physical block pool and allocated to the write data storage.
8. The method according to claim 2, characterized in that The method further includes updating the low-order data service physical block pool, including: Traversing the low-order data service physical block pool, checking the number range of currently free physical pages in the physical block; After writing the data in the low-order page group, the physical blocks of the physical pages whose current idle physical page numbers are greater than the second threshold are transferred to the high-order data service physical block pool; After the data in the high-order page group is written, the physical block in which the physical page is fully written is kicked out of the low-order data service physical block pool.
9. The method according to claim 2, characterized in that The method further includes updating the high-order data service physical block pool, including: Traversing the high-order data service physical block pool, checking the number range of currently free physical pages in the physical block; After the data in the middle page group is written, the physical blocks of the physical pages whose current free physical page numbers are greater than the third threshold are transferred to the low-order data service physical block pool.
10. A data storage device based on a wear leveling algorithm, characterized in that: The device comprises: An acquisition module, used to obtain an original error rate threshold; A physical block pool identification module, used to classify the physical blocks whose original error rate of the current idle physical page is lower than the original error rate threshold into the high-order data service physical block pool, and classify the physical blocks whose original error rate of the current idle physical page is not lower than the original error rate threshold into the low-order data service physical block pool, wherein the current idle physical page is the idle physical page with the lowest number in the physical blocks; A bit state discrimination module, for determining whether the written data is low-state data or high-state data according to the storage charge state of the written data in the storage unit of the physical page, wherein the high-state data is the written data in which the ratio of the number of high-state storage units in the physical page to the total number of storage units exceeds a first threshold, and the low-state data is the written data in which the ratio of the number of high-state storage units in the physical page to the total number of storage units is lower than or equal to the first threshold; A matching module, configured to select a physical block from the low-order data service physical block pool and allocate it to the write data storage if the write data is low-order data, and select a physical block from the high-order data service physical block pool and allocate it to the write data storage if the write data is high-order data; The mapping relationship determination module is used to select a current idle physical page from the allocated physical block and determine a mapping relationship between the current idle physical page and a logical page.
Citation Information
Patent Citations
Method for reducing solid-state-disc abrasion through programming-error perception
CN107391035A
Coder, decoder, coding method and decoding method lowering flash bit error rate
CN107590021A