NAND Flash wear balance management method and device based on data classification, equipment and storage medium

By detecting and classifying wear value of physical blocks in NAND Flash memory and placing data partitions, the wear aggregation problem caused by frequent rewrittening is solved, and the life of the storage medium is extended.

CN119987655APending Publication Date: 2025-05-13HEFEI ZHICUN MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411940037.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

NAND Flash memory has reduced reliability and shortened service life due to frequent rewrittening, mainly due to the randomness of data, some areas are frequently rewritten, causing wear and aggregation.

Method used

By detecting the wear value of all physical blocks in the hard disk, dividing it into static intervals and dynamic intervals, and data partitioning is performed according to the wear difference, unnecessary erasing and transfer operations are reduced, thereby extending the storage life.

Benefits of technology

By reducing frequent rewrittening and wear in static intervals, the wear rate of the full disk memory is balanced and the service life of NAND Flash storage media is extended.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987655A_ABST
    Figure CN119987655A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data storage, in particular to an NAND Flash wear balance management method and device based on data classification, equipment and a storage medium. Comprising the following steps: detecting wear values of all physical blocks, and determining a maximum wear value; if the maximum wear value reaches a preset trigger value, classifying all the physical blocks based on the wear value of each physical block to obtain a static interval and a dynamic interval; comparing the data volume between the static interval and the dynamic interval; determining a data partition based on the static interval and the dynamic interval according to a comparison result; and calculating an average wear difference value between the partitions until the average wear difference value reaches a corresponding wear upper limit, updating the physical blocks in the static data partition to the dynamic data partition, and updating the physical blocks in the dynamic data partition to the static data partition. According to the method, the physical blocks are reasonably allocated, and unnecessary erasing and moving operations are reduced, so that storage resources are reasonably utilized, and the effect of prolonging the storage life is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular to a NAND Flash wear leveling management method, device, equipment and storage medium based on data classification. Background Art

[0002] As a non-volatile storage medium, NAND Flash is widely used in electronic devices because of its characteristics of page-based reading and writing and physical block-based erasure. However, each erasure will inevitably reduce its reliability, and frequent erasure will also shorten the service life of the memory. The current technical architecture has the problem of uneven data distribution, which causes some physical data blocks to be frequently erased, resulting in wear accumulation and shortened memory life.

[0003] This problem stems from the randomness of data. Since data is written and accessed randomly, frequent high-frequency erase and write operations will cause the physical blocks of NAND Flash memory to wear out more, accelerating the decline of its reliability. This causes the performance of some areas of the storage device to rapidly decline during use, or even fail to operate normally, thereby shortening the service life of the entire storage device.

[0004] Therefore, there is an urgent need for an effective technical means to alleviate the reliability degradation problem of NAND Flash memory caused by frequent erasure and writing, and to extend its service life. Summary of the invention

[0005] In order to overcome the shortcomings of the prior art, the present application provides a NAND Flash wear leveling management method, device, equipment and storage medium based on data classification. Through data analysis, wear monitoring, data classification and reasonable allocation, unnecessary erasing and moving operations of the hard disk are reduced during use, thereby rationally utilizing storage resources and achieving the effect of extending storage life.

[0006] The technical solution adopted by this application to solve its technical problem is: In a first aspect, the present application provides a NAND Flash wear leveling management method based on data classification, the method comprising: Detecting the wear values ​​of all physical blocks in the target hard disk, and determining the maximum wear value among all the wear values; If the maximum wear value reaches a preset trigger value, all the physical blocks are classified based on the wear value of each physical block to obtain a static interval and a dynamic interval; the wear value of the physical block in the dynamic interval is greater than the wear value of the physical block in the static interval; Comparing the data volume between the static interval and the dynamic interval to obtain a comparison result; Data is partitioned on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions. When the average wear difference between any two data partitions reaches a corresponding wear upper limit, physical blocks in the two data partitions are exchanged for use.

[0007] Optionally, the step of performing data partitioning on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions, and when the average wear difference between any two data partitions reaches a corresponding wear upper limit, exchanging the use of physical blocks in the two data partitions comprises: If the data volume of the static interval is equal to the data volume of the dynamic interval, the static interval is used as a static data partition, and the dynamic interval is used as a dynamic data partition; Calculate the average wear difference between the static data partition and the dynamic data partition, and update the physical blocks in the static data partition to the dynamic data partition and update the physical blocks in the dynamic data partition to the static data partition until the average wear difference reaches the corresponding wear upper limit.

[0008] Optionally, the step of performing data partitioning on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions, and when the average wear difference between any two data partitions reaches a corresponding wear upper limit, exchanging the use of physical blocks in the two data partitions comprises: Divide the static data. If the amount of data in the static interval is greater than the amount of data in the dynamic interval, divide the static interval into multiple static data partitions, use the dynamic interval as a dynamic data partition, and calculate the wear value of each static data partition and the dynamic data partition; Determine a partition to be exchanged, and select a static data partition with the lowest wear value in the static interval as the partition to be exchanged; Deploy the partitions, calculate the average wear difference between the dynamic data partition and the partition to be exchanged, until the average wear difference reaches the corresponding wear upper limit, update the physical blocks of the partition to be exchanged to the dynamic data partition, update the physical blocks of the dynamic data partition to the partition to be exchanged, and return to the step of determining the partition to be exchanged.

[0009] Optionally, the step of performing data partitioning on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions, and when the average wear difference between any two data partitions reaches a corresponding wear upper limit, exchanging the use of physical blocks in the two data partitions comprises: Divide the dynamic data. If the amount of data in the static interval is smaller than the amount of data in the dynamic interval, divide the dynamic interval into a plurality of dynamic data partitions, use the static interval as a static data partition, and calculate the wear value of each dynamic data partition and the static data partition; Determine a partition to be exchanged, and select the dynamic data partition with the highest wear value in the dynamic interval as the partition to be exchanged; Deploy the partitions, calculate the average wear difference between the partition to be exchanged and the static data partition, until the average wear difference reaches the corresponding wear upper limit, update the physical blocks of the partition to be exchanged to the static data partition, update the physical blocks of the static data partition to the partition to be exchanged, and return to the step of determining the partition to be exchanged.

[0010] Optionally, the two data partitions include a static data partition and a dynamic data partition, and the wear value of the physical blocks in the static data partition is less than the wear value of the physical blocks in the dynamic data partition; the step of when the average wear difference between any two data partitions reaches the corresponding wear upper limit further includes: Determine a first average wear value of the static data partition according to the total wear value of the static data partition and the number of physical blocks in the static data partition; the total wear value of the static data partition is the sum of the wear values ​​of all physical blocks in the static data partition; Determine a second average wear value of the dynamic data partition according to the total wear value of the dynamic data partition and the number of physical blocks in the dynamic data partition; the total wear value of the dynamic data partition is the sum of the wear values ​​of all physical blocks in the dynamic data partition; An average wear difference between the two data partitions is determined according to the first average wear value and the second average wear value.

[0011] Optionally, if the maximum wear value reaches a preset trigger value, after classifying all the physical blocks based on the wear value of each physical block to obtain a static interval and a dynamic interval, the method further includes: Obtaining a logical address corresponding to each of the physical blocks; Determine the logical address ranges corresponding to the static interval and the dynamic interval respectively based on the logical addresses corresponding to each of the physical blocks in the static interval and the dynamic interval; According to the logical address range, a data writing block of the data to be written is determined based on the logical address of the data to be written.

[0012] Optionally, the step of determining the data write block of the data to be written based on the logical address of the data to be written according to the logical address range includes: Acquire a wear boundary value; the wear boundary value is a wear value of a boundary between the dynamic interval and the static interval; Determining whether the data to be written should be written into the dynamic interval according to the logical address of the data to be written and the logical address range; If the data to be written should be written into the dynamic interval, determining the physical block whose wear value is closest to the wear boundary value as the write block of the data to be written; Otherwise, any physical block whose wear value is less than the wear boundary value is determined as the write block for the data to be written.

[0013] In a second aspect, the present application provides a NAND Flash wear leveling management device based on data classification, comprising: A wear state detection module, used for detecting the wear values ​​of all physical blocks in the target hard disk, and determining the maximum wear value among all the wear values; A data partitioning module, configured to classify all the physical blocks based on the wear value of each physical block to obtain a static interval and a dynamic interval if the maximum wear value reaches a preset trigger value; the wear value of the physical blocks in the dynamic interval is greater than the wear value of the physical blocks in the static interval; A data volume comparison module, used to compare the data volume between the static interval and the dynamic interval to obtain a comparison result; A physical block allocation module is used to perform data partitioning on the static interval and the dynamic interval according to the comparison result to obtain multiple data partitions, and when the average wear difference between any two data partitions reaches the corresponding wear upper limit, the physical blocks in the two data partitions are exchanged for use.

[0014] In a third aspect, the present application provides an electronic device, including: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions, which, when executed by the one or more processors, enable the electronic device to perform the above method.

[0015] In a fourth aspect, the present application provides a storage medium, in which a program or instruction is stored. When the program or instruction is executed, the above method is implemented.

[0016] By adopting the above technical solution, when the target hard disk starts to be used, the current number of wear times of the target hard disk is detected to determine whether the current number of wear times reaches the percentage threshold of the corresponding maximum number of wear times (for example, half of the maximum number of wear times). If it reaches the percentage threshold, the physical blocks are divided into static intervals and dynamic intervals based on the wear value of each physical block, wherein the wear value of the physical blocks in the dynamic interval is higher than the wear value and wear speed of the physical blocks in the static interval; then, the wear balancing strategy is only applied to the physical blocks in the dynamic interval, and the use partition allocation mode for the target hard disk is determined based on the comparison result between the static interval and the dynamic interval.

[0017] If the data volume of the two areas is the same, the dynamic interval is regarded as a dynamic data partition, and the static interval is regarded as a static data partition. Wear balancing is performed only in the dynamic data partition and the average wear difference between the dynamic data partition and the static data partition is calculated. When the average wear difference reaches the corresponding wear limit, the two blocks are exchanged for use, thereby avoiding unnecessary wear caused by frequent erasing of the static interval and extending the storage life. If the amount of data in the static interval is larger than that in the dynamic interval, the dynamic interval is used as a dynamic data partition, and the static interval is divided into multiple static data partitions. When the average wear difference between the dynamic data partition and any static data partition reaches the corresponding wear limit, the two blocks are exchanged for use; If the amount of data in the dynamic interval is larger than that in the static interval, the static interval is used as a static data partition, and the dynamic interval is divided into multiple dynamic data partitions. When the average wear difference between the static data partition and any dynamic data partition reaches the corresponding wear limit, the two blocks are exchanged for use.

[0018] Combined with the above scheme description, it can be seen that the beneficial effect of the present application is: by partitioning the wear condition of each physical block, selecting the appropriate block management mode based on the number of partitions, performing wear balancing only on the parts with higher wear, reducing the frequent erasing and moving operations of static physical blocks, and balancing the wear rate of the entire disk storage, thereby extending the service life of the storage medium. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a schematic diagram of the overall process of the NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application; Figure 2 It is a first flow chart of a NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application; Figure 3 It is a second flow chart of the NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application; Figure 4It is a third flow chart of the NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application; Figure 5 It is a virtual structural diagram of a NAND Flash wear leveling management device based on data classification provided by the present application; Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] The present application is further described below in conjunction with the accompanying drawings and embodiments.

[0021] The following will clearly and completely describe the concept, specific structure and technical effects of the present application in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of them. Based on the embodiments of the present application, other embodiments obtained by technicians in this field without creative work are all within the scope of protection of the present application. In addition, all the connection / connection relationships involved in the patent do not simply refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features created in this application can be combined interactively without conflicting with each other.

[0022] Reference Figure 1 , Figure 1 This is a schematic diagram of the overall process of the NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application, which specifically includes the following steps, which are specifically described below: In step S1, the wear values ​​of all physical blocks in the target hard disk are detected, and the maximum wear value among all the wear values ​​is determined.

[0023] Specifically, when the target hard disk starts to be used, the PE table (Program / Erase Count Table) is used to record the wear values ​​(or wear times) of all physical blocks, and the wear value of the physical block with the highest wear value among all physical blocks is determined as the maximum wear value. The maximum wear value is used to trigger the following steps to perform partition allocation.

[0024] In step S2, if the maximum wear value reaches a preset trigger value, all the physical blocks are classified based on the wear value of each physical block to obtain a static interval and a dynamic interval.

[0025] The wear value of the physical block in the dynamic interval is greater than the wear value of the physical block in the static interval.

[0026] Specifically, the preset trigger value can be configured by the user according to the usage scenario of the target hard disk. Specifically, the ratio of static data volume to dynamic data volume can be preliminarily configured based on the usage scenario of the target hard disk, and then the preset trigger value is adaptively selected based on the ratio of dynamic data volume, and is 1 / 4Max PE (the upper limit of wear of the physical block) to 3 / 4Max PE. The larger the ratio of dynamic data volume, the smaller the threshold should be selected to enter the wear leveling management algorithm as soon as possible. In the embodiment of the present application, the preferred preset trigger value is 1 / 2Max PE.

[0027] More specifically, if the physical block with the greatest wear among all physical blocks reaches the above-mentioned preset trigger value, the classification step is entered. In this case, according to the wear value of each physical block and the proportion of static data volume to dynamic data volume allocated by the user in the above step, the wear values ​​of all physical blocks in the target hard disk are sorted, and the physical blocks with smaller wear values ​​are divided into the static interval, and the physical blocks with higher wear values ​​are divided into the dynamic interval.

[0028] More specifically, the dynamic interval and the static interval are provided with their own independent OP blocks (Open Block, an empty block to which data has not been written). Before the average wear difference value described below is reached, independent OP blocks are used in each interval to independently perform data writing operations, thereby avoiding mutual interference and improving the parallel processing capability and efficiency of the system.

[0029] More specifically, if the maximum wear value reaches a preset trigger value and is divided into a dynamic interval and a static interval, a P2L table (Physical to Logical, physical block corresponds to logical address) can be used to obtain a logical address range for determining which interval the newly written data is updated to. If the maximum wear value reaches the preset trigger value, all the physical blocks are classified based on the wear value of each physical block to obtain the static interval and the dynamic interval, and further includes: The logical address corresponding to each of the physical blocks is obtained.

[0030] Specifically, each physical block corresponds to a logical address, and the logical address is an address space provided by the storage system.

[0031] Further, based on the logical address corresponding to each of the physical blocks in the static interval and the dynamic interval, the logical address ranges corresponding to the static interval and the dynamic interval are determined respectively; According to the logical address range, a data writing block of the data to be written is determined based on the logical address of the data to be written.

[0032] The data to be written refers to new data that needs to be written into a certain physical block.

[0033] Specifically, according to the logical address corresponding to each physical block in the static interval, it can be determined that the physical block whose logical address is in the corresponding interval should be written into the static interval; similarly, according to the logical address corresponding to each physical block in the dynamic interval, it can be determined that the physical block whose logical address is in the corresponding interval should be written into the dynamic interval. It is worth noting that the following steps also involve further dividing the dynamic interval or the static interval into multiple partitions, and the logical address range of each partition can be calculated in the same way to facilitate determining the write position of the subsequent new data.

[0034] More specifically, after determining through the above steps whether the data to be written should be written into the static interval or the dynamic interval, the present application proposes that the selection of physical blocks in different intervals can be determined through the following steps, which are specifically described below: Gets the wear boundary value.

[0035] Specifically, the wear boundary value is a wear value at a boundary between the dynamic interval and the static interval.

[0036] Whether the data to be written should be written into the dynamic interval is determined according to the logical address of the data to be written and the logical address range.

[0037] Specifically, based on the logical address range obtained in the above steps, it can be determined whether the current data to be written should be written into the dynamic interval. If there are multiple dynamic data partitions in the dynamic interval, it can also be determined which dynamic data partition the data to be written should be written into based on the logical address range and the logical address corresponding to the data to be written.

[0038] Furthermore, if the data to be written should be written into the dynamic interval, a physical block whose wear value is closest to the wear boundary value is determined as a write block for the data to be written.

[0039] Specifically, when it is determined that the data to be written should be written into the dynamic interval, a physical block whose wear value is closest to the wear boundary value in a dynamic interval is determined to be used for writing the data to be written, that is, as the write block for the data to be written. For example, assuming that the wear boundary value is X, and when it is determined that the data to be written belongs to the static interval, a physical block whose wear value is closest to X is selected from the physical blocks whose wear values ​​are greater than or equal to the wear boundary value. For example, if there are three physical blocks X, X+1 and X+3, the physical block whose wear value is X is selected as the write block for the data to be written.

[0040] Otherwise, any physical block whose wear value is less than the wear boundary value is determined as the write block for the data to be written.

[0041] Specifically, if the data to be written should be written into the static interval, it is only necessary to select any physical block whose wear value is lower than the wear boundary value for writing.

[0042] Furthermore, the above-mentioned wear boundary value can be redefined as a new wear boundary value when the number of erase times of the storage device reaches the corresponding preset threshold, thereby preventing certain physical blocks from being damaged prematurely due to excessive use, thereby affecting the reliability and life of the entire storage system, so as to ensure the balanced distribution of data and the long-term stability of the storage device, wherein the corresponding preset threshold can be the number of dynamic interval blocks, the number of static interval blocks, or the number of valid blocks on the entire disk.

[0043] In step S3, the data volume between the static interval and the dynamic interval is compared to obtain a comparison result.

[0044] Among them, in this application, the wear leveling strategy is only executed on the wear leveling target, and in this application, the wear leveling strategy is only executed on the dynamic interval or the partition in the dynamic interval.

[0045] Specifically, the data volume of the static interval is compared with the data volume of the dynamic interval. In this case, there are three situations where the data volume between the two is greater than, less than, or equal to each other. For these three situations, this application provides three allocation methods, which will be specifically described in the following steps. It is worth noting that the three data volume comparison results between the static interval and the dynamic interval proposed in this application should not be regarded as just three independent solutions. In specific application scenarios, the appropriate combination of these three situations should also be regarded as a variation of the technical solution provided by this application.

[0046] In step S4, there are two sub-steps, namely step S41 and step S42. In step S41, data partitioning is performed on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions.

[0047] The data partitions include one or more dynamic data partitions and one or more static data partitions.

[0048] Specifically, if the amount of data between the static interval and the dynamic interval is equal, the dynamic interval is directly used as a dynamic data partition, and the static interval is used as a static data partition, without further division of the static interval or the dynamic interval, that is: In step S411, if the data volume of the static interval is equal to the data volume of the dynamic interval, the static interval is used as a static data partition, and the dynamic interval is used as a dynamic data partition.

[0049] Furthermore, if the amount of data in the static interval is greater than that in the dynamic interval, that is, when there is more static data, the wear leveling strategy is also only used in the dynamic interval, and the static interval is divided into multiple parts. Specifically: In step S412, the static data is divided. If the data volume of the static interval is larger than the data volume of the dynamic interval, the static interval is divided into multiple static data partitions, the dynamic interval is used as a dynamic data partition, and the wear value of each static data partition and the dynamic data partition is calculated.

[0050] Specifically, static data refers to the amount of data in the static interval, while dynamic data refers to the amount of data in the dynamic interval. When the static data is larger than the dynamic data, wear balancing is also performed only on the dynamic data. However, the difference is that in order to distribute data writing more evenly in this case, thereby avoiding some areas from reaching the wear limit too early, the static interval can be further divided into multiple static data partitions, and the dynamic interval is used as a dynamic data partition in this case. Then, after the partitions are divided, the average wear value of all physical blocks in all partitions (including all static data partitions and dynamic data partitions) is calculated for the subsequent calculation of the average wear difference between the dynamic data partition and each static data partition.

[0051] More specifically, the static interval can be divided according to the ratio of the amount of static data to the amount of dynamic data. For example, assuming that the ratio of static data to dynamic data is ≈3:1, the static interval can be divided into three static data partitions in equal proportion to facilitate more even writing of subsequent data. Similarly, if the ratio of static data to dynamic data is ≈2:1, the static interval can be divided into two static data partitions, and so on. In addition, once it is determined that the ratio of static data to dynamic data is greater than 1:1, the static interval can be divided into two static data partitions to reduce the amount of calculation, through user presets, factory default settings, etc.

[0052] Furthermore, if the amount of data in the dynamic interval is greater than that in the static interval, that is, when there is more dynamic data, the wear leveling strategy is also only used in the dynamic interval, and the dynamic interval is divided into multiple parts. Specifically: In step S413, the dynamic data is divided. If the data volume of the static interval is smaller than the data volume of the dynamic interval, the dynamic interval is divided into multiple dynamic data partitions, the static interval is used as the static data partition, and the wear value of each dynamic data partition and the static data partition is calculated.

[0053] Specifically, similar to the processing idea when the static data is larger than the dynamic data in the above steps, when the dynamic data is larger than the static data, the dynamic interval can be divided into multiple dynamic data partitions, and the static interval can be used as a static data partition to facilitate the uniform writing of data, thereby rationally utilizing space and reducing the number of wear times. The division method of the interval can refer to the above description of the static data partition division, which will not be repeated here. Then, after the division is completed, the wear values ​​of all partitions are calculated, that is, the average wear value of all physical blocks in each partition, so as to be used for the subsequent calculation of the average wear difference between each dynamic physical partition and the static physical partition.

[0054] Furthermore, after performing data partitioning on the static interval and the dynamic interval based on the comparison result to obtain multiple data partitions, step S42 is also included: in step S42, when the average wear difference between any two data partitions reaches the corresponding wear upper limit, the physical blocks in the two data partitions are exchanged for use.

[0055] Specifically, the average wear difference refers to the difference between the average wear value of one partition and the average wear value of another partition. In layman's terms, each data partition includes multiple physical blocks, each physical block has a corresponding wear value, and the average wear value of each data partition is the average wear value of all physical blocks in the data partition, and the average wear difference between each two data partitions is the difference between the two average wear values ​​between the two data partitions.

[0056] Specifically, after the division of data partitions is completed, it is determined whether the average wear difference between any two data partitions in all data partitions reaches the corresponding wear upper limit. For the convenience of description, any two data partitions can be defined as static data partitions and dynamic data partitions. The steps of determining include: A first average wear value of the static data partition is determined according to the total wear value of the static data partition and the number of physical blocks in the static data partition; the total wear value of the static data partition is the sum of the wear values ​​of all physical blocks in the static data partition.

[0057] In the embodiment of the present application, the static data partition is taken as an example, and the formula used is: ; in, is the average wear value of the static data partition, is the total wear value of the static data partition, The number of physical blocks in the static data partition.

[0058] Determine a second average wear value of the dynamic data partition according to the total wear value of the dynamic data partition and the number of physical blocks in the dynamic data partition; the total wear value of the dynamic data partition is the sum of the wear values ​​of all physical blocks in the dynamic data partition; Specifically, based on the above example, the dynamic data partition may be a dynamic data partition, and the formula used is: ; in, is the average wear value of the dynamic data partition, is the total wear value of the dynamic data partition, The number of physical blocks in the dynamic data partition.

[0059] An average wear difference between the two data partitions is determined according to the first average wear value and the second average wear value.

[0060] For ease of explanation, an optional calculation method is provided in the embodiment of the present application, and the formula is: ; in, is the average wear difference.

[0061] For ease of explanation, in one embodiment provided in the present application, it is assumed that there are 100 physical blocks in the static data partition, and the wear value of each block is 10, 20, 30, ..., 400 (unit is PE, i.e., Program / Erase cycle number), and the total wear value of the static data partition is the sum of the wear values ​​of all 100 physical blocks in the static data partition. Substitute the sum of the wear values ​​of all 100 physical blocks in the static data partition into the following formula: , substitute the total number of physical blocks in the static data partition 100 into the following formula , to obtain the average wear value of the static physical partition (first average wear value) : ; Furthermore, assuming that the dynamic data partition also has 100 physical blocks, and the wear value of each block is 500, 600, 700, ..., 1500, similar to the average wear value of the static data partition above, the total wear value of the dynamic data partition is: ; Substituting the following formula into the average wear value of the dynamic physical partition (second average wear value) : ; Furthermore, based on the second average wear value obtained in the above steps and the first average wear value After the difference is made, the average wear difference between the static data partition and the dynamic data partition can be obtained.

[0062] More specifically, when detecting the average wear difference between any static data partition and any dynamic data partition, priority should be given to the static data partition with the smallest average wear value and / or the dynamic data partition with the largest average wear value, so as to reduce detection targets, improve detection efficiency, and reduce detection computing power consumption.

[0063] In the embodiment of the present application, the average wear difference is used to compare the static data partition with the dynamic data partition to determine whether the dynamic data partition is about to reach the wear limit. When the dynamic data partition reaches the wear limit, the two compared are positioned and exchanged, the original dynamic data partition is updated to a new static data partition to reduce writing and wear, and the original static data partition is updated to a new dynamic data partition to use the static data partition with a smaller wear value to replace the original dynamic data partition for data writing, thereby evenly distributing the usage interval, avoiding reaching the wear limit too early, and thus increasing the service life.

[0064] More specifically, the present application considers three embodiments, each of which is described below in detail. When the static data is close to or equal to the dynamic data, refer to Figure 2 , Figure 2 This is a first flow chart of a NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application, combined with Figure 2 It can be seen that the specific steps in this case are as follows: In step S421, the average wear difference between the static data partition and the dynamic data partition is calculated, and when the average wear difference reaches the corresponding wear upper limit, the physical blocks in the static data partition are updated to the dynamic data partition, and the physical blocks in the dynamic data partition are updated to the static data partition.

[0065] Specifically, in step S411, the static interval has been updated as a static data interval, and the dynamic interval has been updated as a dynamic data interval. Based on the wear values ​​of all physical blocks calculated in the above step S1, the average wear value (average wear value) of all physical blocks in each data partition can be calculated. The average wear difference between the static data partition and the dynamic data partition can be determined based on the difference between the average wear values ​​of each partition. The average wear difference corresponds to a wear upper limit. When the wear upper limit is reached, it is determined that the dynamic data partition needs to be replaced, that is, the positions of the dynamic data partition and the static data partition are exchanged, and the original static data partition is used as the new dynamic data partition for data writing. Among them, the wear upper limit can be preset by relevant personnel according to needs, and is not limited here.

[0066] Further, refer to Figure 3 , Figure 3 This is a second flow chart of the NAND Flash wear leveling management method based on data classification provided by an embodiment of the present application, which embodies the process steps when static data is more than dynamic data, and is specifically described below: In step S422, the partition to be exchanged is determined, and the static data partition with the lowest wear value in the static interval is used as the partition to be exchanged; the partitions are allocated and used, and the average wear difference between the dynamic data partition and the partition to be exchanged is calculated until the average wear difference reaches the corresponding wear upper limit, and then the physical blocks of the partition to be exchanged are updated to the dynamic data partition, and the physical blocks of the dynamic data partition are updated to the partition to be exchanged, and the process returns to the step of determining the partition to be exchanged.

[0067] Specifically, in this case, the wear values ​​of each static data partition are sorted, and the static data partition with the lowest wear value is determined as the partition to be exchanged. Then, the average wear value between the partition to be exchanged and the dynamic data partition is calculated. The calculation method can refer to the formula in the above step S42. When the average difference between the two reaches the corresponding preset wear limit, the physical blocks with less wear in the partition to be exchanged are moved to the dynamic data partition, and the physical blocks with more wear in the dynamic data partition are moved to the static data partition. Then, return to the above step of determining the partition to be exchanged to determine the new partition to be exchanged.

[0068] Furthermore, in another embodiment provided by the present application, it is also possible to not establish the partition to be exchanged in advance, but to calculate the average wear difference between the dynamic data partition and each static data partition respectively, until any average wear difference reaches the corresponding wear upper limit, the physical blocks in the two intervals that reach the wear upper limit are exchanged to achieve a uniform distribution effect.

[0069] Further, refer to Figure 4 , Figure 4 : is a third flow chart of the NAND Flash wear leveling management method based on data classification provided in an embodiment of the present application, which embodies the process steps when dynamic data is more than static data, specifically including: In step S423, the partition to be exchanged is determined, and the dynamic data partition with the highest wear value in the dynamic interval is used as the partition to be exchanged; the partitions are allocated and used, and the average wear difference between the partition to be exchanged and the static data partition is calculated until the average wear difference reaches the corresponding wear upper limit, and then the physical blocks of the partition to be exchanged are updated to the static data partition, and the physical blocks of the static data partition are updated to the partition to be exchanged, and the process returns to the step of determining the partition to be exchanged.

[0070] Specifically, similar to the above step S422, all dynamic data partitions in the dynamic interval are sorted according to their average wear values, and the static data partition with the largest wear value is selected as the partition to be exchanged, and then the average wear difference between the partition to be exchanged and the static data partition is calculated. If the average wear difference reaches the corresponding wear upper limit, the physical blocks in the partition to be exchanged and the physical blocks in the static data partition are exchanged with each other, and the physical blocks with smaller wear values ​​are used for data writing, thereby achieving the effect of reducing the number of wear times and increasing the service life.

[0071] Reference Figure 5 , Figure 5 : is a virtual structural diagram of a NAND Flash wear leveling management device based on data classification provided by the present application. A second aspect of the present application provides a NAND Flash wear leveling management device based on data classification, including: A wear state detection module 100 is used to detect the wear values ​​of all physical blocks in the target hard disk and determine the maximum wear value among all the wear values; The data partition module 200 is configured to classify all the physical blocks based on the wear value of each physical block to obtain a static interval and a dynamic interval if the maximum wear value reaches a preset trigger value; the wear value of the physical blocks in the dynamic interval is greater than the wear value of the physical blocks in the static interval; A data volume comparison module 300 is used to compare the data volume between the static interval and the dynamic interval to obtain a comparison result; The physical block allocation module 400 is used to perform data partitioning on the static interval and the dynamic interval according to the comparison result to obtain multiple data partitions, and when the average wear difference between any two data partitions reaches the corresponding wear upper limit, exchange the physical blocks in the two data partitions for use.

[0072] The NAND Flash wear leveling management device based on data classification described in the embodiment of the present application can execute the NAND Flash wear leveling management method based on data classification provided in the above embodiment. The NAND Flash wear leveling management device based on data classification has the corresponding functional steps and beneficial effects of the NAND Flash wear leveling management method based on data classification described in the above embodiment. Please refer to the embodiment of the NAND Flash wear leveling management method based on data classification for details. The embodiment of the present application will not be repeated here.

[0073] The present application also provides an electronic device. Figure 6 , Figure 6 It is a structural diagram of an electronic device provided in an embodiment of the present application, and the electronic device may include a processor and a memory, wherein the processor and the memory may be connected via a bus or other means. The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned types of chips. The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the NAND Flash wear leveling management method based on data classification in the embodiment of the present application. The processor executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory, that is, the NAND Flash wear leveling management method based on data classification in the above method embodiment is implemented.

[0074] The memory may include a program storage area and a storage interval, wherein the program storage area may store an operating system, an application required by at least one function; the storage interval may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. The one or more modules are stored in the memory, and when executed by the processor, the NAND Flash wear leveling management method based on data classification in the above method embodiment is executed. The specific details of the above electronic device can be understood by corresponding to the corresponding descriptions and effects in the above method embodiment, and will not be repeated here. Those skilled in the art can understand that all or part of the processes in the above embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the embodiments of the above methods. Among them, the storage medium can be an embedded multimedia storage card (Embedded MultiMediaCard, e.MMC), universal flash storage (Universal FlashStorage, UFS), universal serial bus (Universal Serial Bus, USB), micro flash card (TransFlashCard, TF Card) or solid-state drive (Solid-State Drive, SSD) and other storage media using NAND FLASH; the storage medium can also include a combination of the above types of memory.

[0075] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0076] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: the claimed application requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims, the inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present application.

[0077] It should be noted that the above-mentioned embodiments illustrate rather than limit the invention and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims.

Claims

1. A NAND Flash wear leveling management method based on data classification, characterized in that: The method comprises: Detecting the wear values ​​of all physical blocks in the target hard disk, and determining the maximum wear value among all the wear values; If the maximum wear value reaches a preset trigger value, all the physical blocks are classified based on the wear value of each physical block to obtain a static interval and a dynamic interval; the wear value of the physical block in the dynamic interval is greater than the wear value of the physical block in the static interval; Comparing the data volume between the static interval and the dynamic interval to obtain a comparison result; Data is partitioned on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions. When the average wear difference between any two data partitions reaches a corresponding wear upper limit, physical blocks in the two data partitions are exchanged for use.

2. The NAND Flash wear leveling management method based on data classification according to claim 1, characterized in that: The step of performing data partitioning on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions, and exchanging the use of physical blocks in the two data partitions when the average wear difference between any two data partitions reaches the corresponding wear upper limit, comprises: If the data volume of the static interval is equal to the data volume of the dynamic interval, the static interval is used as a static data partition, and the dynamic interval is used as a dynamic data partition; Calculate the average wear difference between the static data partition and the dynamic data partition, and update the physical blocks in the static data partition to the dynamic data partition and update the physical blocks in the dynamic data partition to the static data partition until the average wear difference reaches the corresponding wear upper limit.

3. The NAND Flash wear leveling management method based on data classification according to claim 1, characterized in that: The step of performing data partitioning on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions, and exchanging the use of physical blocks in the two data partitions when the average wear difference between any two data partitions reaches the corresponding wear upper limit, comprises: Divide the static data. If the amount of data in the static interval is greater than the amount of data in the dynamic interval, divide the static interval into multiple static data partitions, use the dynamic interval as a dynamic data partition, and calculate the wear value of each static data partition and the dynamic data partition; Determine a partition to be exchanged, and select a static data partition with the lowest wear value in the static interval as the partition to be exchanged; Deploy the partitions, calculate the average wear difference between the dynamic data partition and the partition to be exchanged, until the average wear difference reaches the corresponding wear upper limit, update the physical blocks of the partition to be exchanged to the dynamic data partition, update the physical blocks of the dynamic data partition to the partition to be exchanged, and return to the step of determining the partition to be exchanged.

4. The NAND Flash wear leveling management method based on data classification according to claim 1, characterized in that: The step of performing data partitioning on the static interval and the dynamic interval according to the comparison result to obtain a plurality of data partitions, and exchanging the use of physical blocks in the two data partitions when the average wear difference between any two data partitions reaches the corresponding wear upper limit, comprises: Divide the dynamic data. If the amount of data in the static interval is smaller than the amount of data in the dynamic interval, divide the dynamic interval into a plurality of dynamic data partitions, use the static interval as a static data partition, and calculate the wear value of each dynamic data partition and the static data partition; Determine a partition to be exchanged, and select the dynamic data partition with the highest wear value in the dynamic interval as the partition to be exchanged; Deploy the partitions, calculate the average wear difference between the partition to be exchanged and the static data partition, until the average wear difference reaches the corresponding wear upper limit, update the physical blocks of the partition to be exchanged to the static data partition, update the physical blocks of the static data partition to the partition to be exchanged, and return to the step of determining the partition to be exchanged.

5. The NAND Flash wear leveling management method based on data classification according to claim 1, characterized in that: The two data partitions include a static data partition and a dynamic data partition, and the wear value of the physical block in the static data partition is smaller than the wear value of the physical block in the dynamic data partition; The step of when the average wear difference between any two data partitions reaches the corresponding wear upper limit also includes: Determine a first average wear value of the static data partition according to the total wear value of the static data partition and the number of physical blocks in the static data partition; the total wear value of the static data partition is the sum of the wear values ​​of all physical blocks in the static data partition; Determine a second average wear value of the dynamic data partition according to the total wear value of the dynamic data partition and the number of physical blocks in the dynamic data partition; the total wear value of the dynamic data partition is the sum of the wear values ​​of all physical blocks in the dynamic data partition; An average wear difference between the two data partitions is determined according to the first average wear value and the second average wear value.

6. The NAND Flash wear leveling management method based on data classification according to claim 1, characterized in that: After the step of classifying all the physical blocks based on the wear value of each physical block to obtain static intervals and dynamic intervals if the maximum wear value reaches a preset trigger value, the method further includes: Obtaining a logical address corresponding to each of the physical blocks; Determine the logical address ranges corresponding to the static interval and the dynamic interval respectively based on the logical addresses corresponding to each of the physical blocks in the static interval and the dynamic interval; According to the logical address range, a data writing block of the data to be written is determined based on the logical address of the data to be written.

7. The NAND Flash wear leveling management method based on data classification according to claim 6, characterized in that: The step of determining the data writing block of the data to be written based on the logical address of the data to be written according to the logical address range comprises: Acquire a wear boundary value; the wear boundary value is a wear value of a boundary between the dynamic interval and the static interval; Determining whether the data to be written should be written into the dynamic interval according to the logical address of the data to be written and the logical address range; If the data to be written should be written into the dynamic interval, determining the physical block whose wear value is closest to the wear boundary value as the write block of the data to be written; Otherwise, any physical block whose wear value is less than the wear boundary value is determined as the write block for the data to be written.

8. A NAND Flash wear leveling management device based on data classification, characterized in that: include: A wear state detection module, used for detecting the wear values ​​of all physical blocks in the target hard disk, and determining the maximum wear value among all the wear values; A data partitioning module, configured to classify all the physical blocks based on the wear value of each physical block to obtain a static interval and a dynamic interval if the maximum wear value reaches a preset trigger value; the wear value of the physical blocks in the dynamic interval is greater than the wear value of the physical blocks in the static interval; A data volume comparison module, used to compare the data volume between the static interval and the dynamic interval to obtain a comparison result; A physical block allocation module is used to perform data partitioning on the static interval and the dynamic interval according to the comparison result to obtain multiple data partitions, and when the average wear difference between any two data partitions reaches the corresponding wear upper limit, the physical blocks in the two data partitions are exchanged for use.

9. An electronic device, characterized in that: include: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions, which, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The storage medium stores a program or an instruction, and when the program or the instruction is executed, the method according to any one of claims 1 to 7 is implemented.