Flash memory data storage method and device, electronic equipment and storage medium

By generating the erase allocation table and allocation storage solution, the problem of shortening the life of flash memory in the solid-state drive used by the server is solved, and the wear balance of memory blocks is achieved, which reduces cold data migration and extends the service life of flash memory.

CN120371719APending Publication Date: 2025-07-25XIONGAN BAIXIN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510390305.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

Existing flash memory data storage methods lead to a shortening of overall life in server-based solid-state drives, especially due to frequent cold data migrations that increase unnecessary erases.

Method used

By acquiring the first cycle and a plurality of first erases, an erase number allocation table is generated, and a storage scheme is allocated to the memory block based on the predicted effective time and erase number allocation table of the memory block, thereby reducing cold data migration and realizing the wear equalization of the memory block.

Benefits of technology

Under the premise of balanced wear of memory blocks, unnecessary cold data migration is reduced and the overall life of flash memory is extended.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371719A_ABST
    Figure CN120371719A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of flash memory data storage, in particular to a flash memory data storage method and device, electronic equipment and a storage medium. Then generating an erasure frequency allocation table according to the predicted total erasure frequency of the memory from the end of the first period and the plurality of first erasure frequencies; allocating a storage scheme for a plurality of memory blocks according to the erasing frequency allocation table and a plurality of first effective durations; and finally, according to the predicted effective duration of the data block and the storage scheme, storing the data block requested to be stored on the matched target block. According to the method, the purpose of distributing the data block storage according to the erasing times is achieved, the unnecessary cold data migration process is reduced on the premise that the abrasion of the memory block is balanced, and the influence of the abrasion balancing process on the overall service life is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of flash memory data storage, and in particular, to a flash memory data storage method, device, electronic device, and storage medium. Background Art

[0002] A solid state drive (SSD), which is a storage medium made of solid state electronic storage chips, mainly consists of a storage unit and a control unit. The common types of its core storage component, flash memory particles, include SLC, MLC, TLC, QLC, etc. Different types have differences in storage density, read / write speed, erase / write life, etc.

[0003] The service life of flash memory particles is closely related to the number of erasures. In order to extend the service life of flash memory particles, various major manufacturers have developed a variety of data storage methods. However, these methods are usually for personal or commercial computers, and the data read / write randomness of personal or commercial computers is relatively strong. Therefore, relatively simple data storage methods are usually adopted. For example, a dynamic wear leveling storage method or a static wear leveling method is adopted.

[0004] The above methods have various drawbacks. For example, in the static wear leveling storage method, some data that is not used for a long time needs to be migrated from one memory block to another memory block, that is, cold data migration. Although this can achieve the purpose of wear leveling and protect some memory blocks from premature aging, overall, cold data migration will increase unnecessary erasure times and reduce the life of the memory.

[0005] The frequency of data update of solid state drives used in servers is more frequent than that of personal or commercial computers, and the drawbacks of existing data storage methods are particularly significant.

[0006] Based on this, it is necessary to develop and design a flash memory data storage method. Summary of the Invention

[0007] Embodiments of the present invention provide a flash memory data storage method, device, electronic device, and storage medium, which are used to solve the problem that the existing data storage methods in the prior art will affect the life of the flash memory as a whole.

[0008] In a first aspect, embodiments of the present invention provide a flash memory data storage method, including:

[0009] Obtain a first period and a plurality of first erasure times, where the first erasure times are determined according to the erasure times of a memory block;

[0010] Generate an erasure count distribution table based on the predicted total erasure count of the memory by the end of the first cycle and the multiple first erasure counts, where the erasure count distribution table records the erasure count of each memory block by the end of the first cycle;

[0011] Allocate storage schemes for multiple memory blocks according to the erasure count distribution table and multiple first effective durations, where the multiple first effective durations are determined according to the effective duration distribution of multiple first data blocks generated within the first cycle;

[0012] Store the data block requested to be stored on a matching target block according to the predicted effective duration of the data block and the storage scheme.

[0013] In a possible implementation manner, the generating an erasure count distribution table based on the predicted total erasure count of the memory by the end of the first cycle and the multiple first erasure counts includes:

[0014] Calculate the sum of the multiple first erasure counts as the first erasure sum;

[0015] Take the sum of the first erasure sum and the predicted total erasure count by the end of the first cycle as the second erasure sum;

[0016] Take the quotient of the second erasure sum and the total number of multiple memory blocks as the average erasure count;

[0017] For each memory block, take the difference between the average erasure count and the corresponding first erasure count as the count allocation, and add the count allocation to the erasure count distribution table.

[0018] In a possible implementation manner, the allocating storage schemes for multiple memory blocks according to the erasure count distribution table and multiple first effective durations includes:

[0019] Arrange the multiple first effective durations in ascending order of duration to obtain a first queue;

[0020] For each memory block, construct a first equation according to the erasure count allocated in the erasure count distribution table, where the first equation expresses the relationship between the memory block storage scheme and the first total duration representing the total effective duration of the data stored in the memory block;

[0021] Construct multiple first equations into a first system of equations;

[0022] Generate multiple storage schemes according to the first system of equations;

[0023] Evaluate the applicability of the multiple storage schemes according to the first system of equations to generate multiple evaluation results;

[0024] If there is an evaluation result that meets the target among the multiple evaluation results, the storage scheme that meets the target is used as the storage scheme for allocating a memory block;

[0025] Otherwise, the multiple evaluation results are respectively added to multiple evaluation result queues, the multiple storage schemes are modified according to the multiple evaluation results and the multiple evaluation result queues, and the process jumps to the step of evaluating the applicability of the multiple storage schemes according to the first set of equations to generate multiple evaluation results, where each evaluation result queue corresponds to a storage scheme.

[0026] In a possible implementation manner, the first equation is:

[0027]

[0028] In the formula, t n is the first total duration of the nth memory block, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure times allocation table, Sch n (i) is the sequence number of the ith first effective duration allocated to the nth memory block in the storage scheme in the first queue, and QD(x) is the xth first effective duration in the first queue.

[0029] In a possible implementation manner, the step of evaluating the applicability of the multiple storage schemes according to the first set of equations to generate multiple evaluation results includes:

[0030] For each storage scheme, the following steps are respectively executed:

[0031] Substitute the storage scheme into the first set of equations to obtain multiple first total durations, where each first total duration corresponds to a memory block;

[0032] Generate an evaluation result according to the first formula, the erasure times allocation table, and the multiple first total durations, where the first formula is:

[0033]

[0034] In the formula, EV is the evaluation result, nmax is the total number of memory blocks, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure times allocation table, tt total is the predicted total number of erasure times of the memory by the end of the first cycle, tt n is the number of erasure times of the nth memory block determined according to the storage scheme, t p is the first cycle duration, t n is the first total duration of the nth memory block determined according to the storage scheme.

[0035] In a possible implementation manner, modifying the multiple storage schemes according to the multiple evaluation result queues includes:

[0036] Selecting the best evaluation result from the multiple evaluation results as the first target evaluation result;

[0037] For each storage scheme, the following steps are respectively executed:

[0038] Selecting the best evaluation result from the evaluation result queue corresponding to the storage scheme as the second target evaluation result;

[0039] Modifying the storage scheme according to the storage scheme corresponding to the first target evaluation result and the storage scheme corresponding to the second target evaluation result.

[0040] In a possible implementation manner, storing the data block to be stored on a matching target block according to the predicted effective duration of the data block and the storage scheme includes:

[0041] Obtaining multiple attributes of the data block, where the multiple attributes include at least one of the following: data structure, source application, size of the data to which the data block belongs, and source user;

[0042] Determining the probabilities of multiple typical effective durations according to the second formula and the multiple attribute dimensions, where the second formula is:

[0043]

[0044] In the formula, P(tf k |a1a2…a m ) is the probability that the effective duration of the data block is tf k under multiple attribute conditions, P(a1a2…a m |tf k ) is the probability that the multiple attributes of the data block are a1a2…a k respectively under the condition that the effective duration is tf m , P(tf k ) is the probability that the effective duration is tf k , P(a1a2…a m ) is the probability that the multiple attributes of the data block are a1a2…a m respectively, a m is the mth attribute;

[0045] Determining the predicted effective duration of the data block according to the third formula, multiple typical effective durations, and the probabilities of the multiple typical effective durations, where the third formula is:

[0046]

[0047] Wherein, tf is the predicted effective duration of the data block, kmax is the number of typical effective durations, and tf k is the k-th typical effective duration;

[0048] Find the duration closest to the predicted effective duration of the data block from the storage scheme as the replaced duration;

[0049] Store the predicted effective duration of the data block into the memory block corresponding to the replaced duration.

[0050] In a second aspect, an embodiment of the present invention provides a flash memory data storage device for implementing the flash memory data storage method described in the first aspect above or any one of the possible implementation manners of the first aspect. The flash memory data storage device includes:

[0051] A data acquisition module for acquiring a first period and a plurality of first erasure counts, wherein the first erasure count is determined according to the erasure count of a memory block;

[0052] An erasure count allocation module for generating an erasure count allocation table according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts, wherein the erasure count allocation table records the erasure count of each memory block by the end of the first period;

[0053] A storage scheme generation module for allocating storage schemes for a plurality of memory blocks according to the erasure count allocation table and a plurality of first effective durations, wherein the plurality of first effective durations are determined according to the effective duration distribution of a plurality of first data blocks generated during the first period;

[0054] And,

[0055] A data storage module for storing the data block to be stored into a matching target block according to the predicted effective duration of the data block and the storage scheme.

[0056] In a third aspect, an embodiment of the present invention provides an electronic device including a memory and a processor. A computer program is stored in the memory and can run on the processor. When the processor executes the computer program, the steps of the method described in the first aspect above or any one of the possible implementation manners of the first aspect are implemented.

[0057] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the steps of the method described in the first aspect above or any one of the possible implementation manners of the first aspect are implemented.

[0058] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows:

[0059] An embodiment of the present invention discloses a method for storing data in a flash memory. First, a first period and a plurality of first erasure counts are obtained, where the first erasure count is determined according to the erasure count of a memory block. Then, according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts, an erasure count distribution table is generated, where the erasure count distribution table records the erasure count of each memory block by the end of the first period. Next, according to the erasure count distribution table and a plurality of first effective durations, a storage scheme is allocated for a plurality of memory blocks, where the plurality of first effective durations are determined according to the effective duration distribution of a plurality of first data blocks generated during the first period. Finally, according to the predicted effective duration of the data block and the storage scheme, the data block to be stored in the request is stored on the matching target block. By predicting the total erasure count, the erasure count table is allocated for a plurality of memory blocks in the embodiment of the present invention, and then the data blocks are allocated for the memory blocks according to the effective duration of the data blocks generated during the cycle duration for storage, achieving the purpose of allocating data block storage according to the erasure count, reducing the unnecessary cold data migration process on the premise of wear leveling of the memory blocks, and reducing the impact of the wear leveling process on the overall lifespan. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0061] Figure 1 is a flowchart of the method for storing data in a flash memory provided by the embodiment of the present invention;

[0062] Figure 2 is a schematic diagram of the principle of the method for storing data in a flash memory provided by the embodiment of the present invention;

[0063] Figure 3 is a functional block diagram of the device for storing data in a flash memory provided by the embodiment of the present invention;

[0064] Figure 4 is a functional block diagram of the electronic device provided by the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0065] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present invention. However, those skilled in the art should clearly understand that the present invention can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, and methods are omitted to avoid unnecessary details from interfering with the description of the present invention.

[0066] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will be described through specific embodiments with reference to the accompanying drawings.

[0067] The following provides a detailed description of the embodiments of the present invention. These embodiments are implemented on the premise of the technical solutions of the present invention, and detailed implementation manners and specific operation processes are given. However, the protection scope of the present invention is not limited to the following embodiments.

[0068] Figure 1 It is a flowchart of a flash memory data storage method provided for an embodiment of the present invention.

[0069] As Figure 1 shown, it shows an implementation flowchart of the flash memory data storage method provided for an embodiment of the present invention, which is described in detail as follows:

[0070] In step 101, a first period and a plurality of first erasure counts are obtained, where the first erasure counts are determined according to the erasure count of a memory block.

[0071] In step 102, an erasure count distribution table is generated according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts, where the erasure count distribution table records the erasure count of each memory block by the end of the first period.

[0072] In some embodiments, the generating an erasure count distribution table according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts includes:

[0073] Calculating the sum of the plurality of first erasure counts as the first erasure sum;

[0074] Taking the sum of the first erasure sum and the predicted total erasure count by the end of the first period as the second erasure sum;

[0075] Taking the quotient of the second erasure sum and the total number of memory blocks as the erasure count average;

[0076] For each memory block, taking the difference between the erasure count average and the corresponding first erasure count as the count distribution, and adding the count distribution to the erasure count distribution table.

[0077] Exemplarily, as described above, different blocks in a flash memory store different data, such that some blocks are erased more frequently and some are erased less frequently, resulting in premature wear of a part of the blocks in the flash memory, thus affecting the overall lifespan. In some current technologies, in order to equalize the flash memory, the strategy adopted is to transfer the data stored in some blocks with long-unupdated data to the blocks with more erasure times, so that these blocks are put into use.

[0078] A block of the memory contains multiple pages. When writing data, it is necessary to ensure that the page has been erased. However, when erasing, the entire block needs to be erased. In this way, when the block is reused after data migration, the entire block needs to be erased. That is to say, in order to achieve the purpose of block wear equalization, it is necessary to erase a part of the blocks in advance. Actually, such an operation will result in more overall erasure count. When this operation is relatively frequent, the impact will be non-negligible.

[0079] For the flash memory used in servers, the read / write frequency of data is high and the data volume is large. Therefore, it has a certain statistical significance.

[0080] The embodiment of the present invention aims to balance the data write volume by combining the predicted data write volume over a period with the existing erasure times of the memory blocks, and strive to make the erasure times of the memory blocks consistent at the end of this period, thereby avoiding unnecessary data erasure caused by data migration.

[0081] Figure 2 Shows the application principle diagram of the embodiment of the present invention.

[0082] In the figure, the current erasure times 201 of multiple memory blocks are shown as solid bars. We can predict the total erasure times after a time period 202 based on the erasure times in a previous period, and then allocate the erasure times 203 at the end of this time period based on this total erasure times and the current erasure times 201 of each memory block, and generate an erasure times allocation table according to these allocated times. In this way, the erasure times of each memory block can be equalized, and cold data migration is not required.

[0083] In step 103, according to the erasure times allocation table and multiple first effective durations, a storage scheme is allocated for multiple memory blocks, wherein the multiple first effective durations are determined according to the effective duration distribution of multiple first data blocks generated in the first period.

[0084] In some embodiments, the allocating a storage scheme for multiple memory blocks according to the erasure times allocation table and multiple first effective durations includes:

[0085] Arrange the multiple first effective durations according to their durations to obtain a first queue;

[0086] For each memory block, construct a first equation according to the number of erasure times allocated in the erasure times allocation table, where the first equation expresses the relationship between the memory block storage scheme and the first total duration characterizing the total effective duration of the data stored in the memory block;

[0087] Construct multiple first equations into a first system of equations;

[0088] Generate multiple storage schemes according to the first system of equations;

[0089] Evaluate the applicability of the multiple storage schemes according to the first system of equations to generate multiple evaluation results;

[0090] If there is an evaluation result that meets the target among the multiple evaluation results, use the storage scheme that meets the target as the storage scheme allocated to each memory block;

[0091] Otherwise, add the multiple evaluation results to multiple evaluation result queues respectively, modify the multiple storage schemes according to the multiple evaluation results and the multiple evaluation result queues, and jump to the step of evaluating the applicability of the multiple storage schemes according to the first system of equations to generate multiple evaluation results, where each evaluation result queue corresponds to a storage scheme.

[0092] In some embodiments, the first equation is:

[0093]

[0094] In the formula, t n is the first total duration of the nth memory block, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure times allocation table, Sch n (i) is the serial number of the ith first effective duration allocated to the nth memory block in the storage scheme in the first queue, and QD(x) is the xth first effective duration in the first queue.

[0095] In some embodiments, the evaluating the applicability of the multiple storage schemes according to the first system of equations to generate multiple evaluation results includes:

[0096] For each storage scheme, perform the following steps respectively:

[0097] Substitute the storage scheme into the first system of equations to obtain multiple first total durations, where each first total duration corresponds to a memory block;

[0098] Generate an evaluation result according to the first formula, the erasure count distribution table, and the multiple first total durations, where the first formula is:

[0099]

[0100] In the formula, EV is the evaluation result, nmax is the total number of memory blocks, Tab(n) is the erasure count assigned to the nth memory block in the erasure count distribution table, tt total is the predicted total erasure count of the memory by the end of the first cycle, tt n is the erasure count of the nth memory block determined according to the storage scheme, t p is the duration of the first cycle, t n is the first total duration of the nth memory block determined according to the storage scheme.

[0101] In some embodiments, modifying the multiple storage schemes according to the multiple evaluation result queues includes:

[0102] Select the best evaluation result from the multiple evaluation results as the first target evaluation result;

[0103] For each storage scheme, perform the following steps respectively:

[0104] Select the best evaluation result from the evaluation result queue corresponding to the storage scheme as the second target evaluation result;

[0105] Modify the storage scheme according to the storage scheme corresponding to the first target evaluation result and the storage scheme corresponding to the second target evaluation result.

[0106] Exemplarily, the effective duration means that after data is generated, it may be deleted or updated and overwritten. Then the duration from the generation of the data to its deletion or to being updated and overwritten is the effective duration. According to the statistics of the previous operation of the memory data, the number of data blocks generated in the next time period and the corresponding effective durations of these data blocks can be determined (multiple first effective durations are statistically generated according to the previous operation statistics of the memory). By reasonably allocating the memory blocks for storing these durations, the erasure counts of multiple memory blocks can be made close at the end of the next time period. That is to say, the embodiments of the present invention are intended to allocate a storage scheme for memory blocks according to the erasure count distribution table and the duration of the data blocks predicted to be generated in the next time period. The storage scheme records the effective durations of the data blocks that each memory block should store. For example, for a memory block with an erasure count of E1, two data blocks are allocated to it, and the effective durations of these two data blocks are T1 and T2. For a memory block with an erasure count of E2, three data blocks are allocated to it, and the effective durations of these two data blocks are T3, T4, and T5.

[0107] To achieve the above object, the embodiments of the present invention sort multiple first effective durations, for example, sort them in ascending order of duration, and then construct an equation expressing the relationship between the effective duration and the number of erasure times:

[0108]

[0109] In the formula, t n is the first total duration of the nth memory block, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure times allocation table, Sch n (i) is the sequence number of the ith first effective duration allocated to the nth memory block in the first queue in the storage scheme, and QD(x) is the xth first effective duration in the first queue.

[0110] The above equation converts the selection of the number of erasure times and the first effective duration to the duration experienced by the memory after reaching the preset number of erasure times. According to this equation, we can know the applicability of the storage scheme.

[0111] In evaluating the applicability of the storage scheme, the embodiments of the present invention are carried out according to the first formula:

[0112]

[0113] In the formula, EV is the evaluation result, nmax is the total number of memory blocks, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure times allocation table, t total is the predicted total number of erasure times of the memory by the end of the first cycle, tt n is the number of erasure times of the nth memory block determined according to the storage scheme, t p is the first cycle duration, t n is the first total duration of the nth memory block determined according to the storage scheme.

[0114] In fact, the above formula is a formula for calculating the consistency of the storage duration of multiple memory blocks. When the storage duration consistency is better, the purpose of the number of erasure times of each memory block being close at the end of the time period is achieved.

[0115] The present invention adopts a method of parallel optimization of multiple storage schemes. Specifically, multiple storage schemes are randomly generated, and each of these schemes is substituted into the first equation. Since there are detailed storage method entries for multiple memory blocks in each scheme, when each scheme is substituted into the first equation, a system of equations is obtained. This system of equations is then evaluated for applicability through the first equation. If the evaluation result reaches the preset goal, then this storage scheme is retained as the final storage scheme. Otherwise, the globally optimal scheme (the storage scheme corresponding to the first target evaluation result) is selected from the multiple storage schemes, combined with the historical optimal scheme (the scheme corresponding to the second target evaluation result) during the previous modification processes of this scheme, and this scheme is adjusted. This process is repeated until the preset goal is met.

[0116] In step 104, according to the predicted effective duration of the data block and the storage scheme, the data block to be stored upon request is stored on the matching target block.

[0117] In some embodiments, the storing the data block to be stored upon request on the matching target block according to the predicted effective duration of the data block and the storage scheme includes:

[0118] Obtain multiple attributes of the data block, where the multiple attributes include at least one of the following: data structure, source application, size of the data to which the data block belongs, and source user;

[0119] According to the second formula and the multiple attribute dimensions, determine the probabilities of multiple typical effective durations, where the second formula is:

[0120]

[0121] In the formula, P(tf k |a1a2…a m ) is the probability that the effective duration of the data block is tf k under multiple attribute conditions, P(a1a2…a m |tf k ) is the probability that the multiple attributes of the data block are respectively a1a2…a k under the condition that the effective duration is tf m , p(tf k ) is the probability that the effective duration is tf k , p(a1a2…a m ) is the probability that the multiple attributes of the data block are respectively a1a2…a m , a m is the m-th attribute;

[0122] According to the third formula, multiple typical effective durations, and the probabilities of the multiple typical effective durations, determine the predicted effective duration of the data block, where the third formula is:

[0123]

[0124] wherein, tf is the predicted valid duration of the data block, kmax is the number of typical valid durations, and tf k is the k-th typical valid duration;

[0125] Find the duration closest to the predicted valid duration of the data block from the storage scheme as the replaced duration;

[0126] Store the predicted valid duration of the data block into the memory block corresponding to the replaced duration.

[0127] Exemplarily, in terms of data block storage, the embodiment of the present invention predicts the valid duration of a data block according to multiple attributes of the data block, and then finds the memory block corresponding to the closest valid duration from the storage scheme according to the valid duration, and stores it into the memory block.

[0128] Specifically, the valid duration of a data block is affected by multiple factors. Among them, the main factors include: data structure, source application, the size of the data to which the data block belongs, and the source user. According to these factors and the results of probability statistics, the application formula can predict its valid duration.

[0129] In the probability statistics of the valid duration of the present invention, the valid duration is divided. For example, the valid duration distribution interval is from tf1 to tf M , which is divided into several sub-intervals, and the middle value of the sub-interval is used as the typical valid duration. For example, if it is divided into kmax sub-intervals, then it can be foreseen that each factor combination may be in multiple sub-intervals. Therefore, it is necessary to calculate the probability of these factor combinations in the sub-intervals. Combining the probabilities of multiple sub-intervals and the middle value (typical valid duration) of the sub-intervals, the predicted valid duration can be calculated:

[0130]

[0131] wherein, tf is the predicted valid duration of the data block, kmax is the number of typical valid durations, and tf k is the k-th typical valid duration.

[0132] In calculating the probability of the sub-interval, the embodiment of the present invention adopts the second formula:

[0133]

[0134] wherein, P(tf k |a1a2…a m ) is the probability that the valid duration of the data block is tf under multiple attribute conditions kThe probability, P(a1a2…a m |tf k ) is the probability that the multiple attributes of the data block are a1a2…a respectively under the condition that the effective duration is tf k , P(tf m ) is the probability that the effective duration is tf k , P(a1a2…a k ) is the probability that the multiple attributes of the data block are a1a2…a respectively m , and a m is the m-th attribute. m In this way, the implementation mode of the present invention completes the process of predicting the effective duration of the data block by combining the attributes of the data block. After the effective duration of the data block is determined, the closest effective duration can be found from the storage scheme, and the data block is stored in the memory block corresponding to the closest effective duration.

[0135] In the implementation mode of the data storage method of the flash memory of the present invention, first, a first period and a plurality of first erasure times are obtained, wherein the first erasure times are determined according to the erasure times of a memory block; then, according to the predicted total erasure times of the memory to the end of the first period and the plurality of first erasure times, an erasure times allocation table is generated, wherein the erasure times allocation table records the erasure times of each memory block to the end of the first period; then, according to the erasure times allocation table and a plurality of first effective durations, a storage scheme is allocated to a plurality of memory blocks, wherein the plurality of first effective durations are determined according to the effective duration distribution of a plurality of first data blocks generated in the first period; finally, according to the predicted effective duration of the data block and the storage scheme, the data block to be stored is stored on the matching target block. The implementation mode of the present invention allocates an erasure times table to a plurality of memory blocks by predicting the total erasure times, and then allocates data blocks to the memory blocks for storage according to the effective duration of the data blocks generated during the cycle duration, achieving the purpose of allocating data block storage according to the erasure times, reducing the unnecessary cold data migration process on the premise of wear leveling of the memory blocks, and reducing the impact of the wear leveling process on the overall life.

[0136] It should be understood that the magnitudes of the sequence numbers of the steps in the above implementation modes do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the implementation mode of the present invention.

[0137] The following is the implementation mode of the device of the present invention. For the details not described in detail, reference can be made to the corresponding method implementation mode above.

[0138]

[0139] Figure 3 ​It is a functional block diagram of a flash memory data storage device provided by an embodiment of the present invention. Referring to Figure 3 , the flash memory data storage device includes: a data acquisition module 301, an erasure count allocation module 302, a storage scheme generation module 303, and a data storage module 304, where:

[0140] The data acquisition module 301 is configured to acquire a first period and a plurality of first erasure counts, where the first erasure count is determined according to the erasure count of one memory block;

[0141] The erasure count allocation module 302 is configured to generate an erasure count allocation table according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts, where the erasure count allocation table records the erasure count of each memory block by the end of the first period;

[0142] The storage scheme generation module 303 is configured to allocate a storage scheme for a plurality of memory blocks according to the erasure count allocation table and a plurality of first effective durations, where the plurality of first effective durations are determined according to the effective duration distribution of a plurality of first data blocks generated during the first period;

[0143] The data storage module 304 is configured to store the data block to be stored on a matching target block according to the predicted effective duration of the data block and the storage scheme.

[0144] Figure 4 It is a functional block diagram of an electronic device provided by an embodiment of the present invention. As Figure 4 shown, the electronic device 4 of this embodiment includes: a processor 400 and a memory 401, and a computer program 402 that can run on the processor 400 is stored in the memory 401. When the processor 400 executes the computer program 402, the steps in the above various flash memory data storage methods and embodiments are implemented, such as Figure 1 the steps 101 to 104 shown.

[0145] Exemplarily, the computer program 402 can be divided into one or more modules / units, and the one or more modules / units are stored in the memory 401 and executed by the processor 400 to complete the present invention.

[0146] The electronic device 4 can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The electronic device 4 may include, but is not limited to, a processor 400 and a memory 401. Those skilled in the art can understand that Figure 4It is only an example of the electronic device 4 and does not constitute a limitation on the electronic device 4. It may include more or fewer components than those shown in the figure, or combine certain components, or different components. For example, the electronic device 4 may further include input / output devices, network access devices, buses, etc.

[0147] The so-called processor 400 may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0148] The memory 401 may be an internal storage unit of the electronic device 4, such as the hard disk or memory of the electronic device 4. The memory 401 may also be an external storage device of the electronic device 4, such as a plug-in hard disk equipped on the electronic device 4, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 401 may also include both the internal storage unit and the external storage device of the electronic device 4. The memory 401 is used to store the computer program 402 and other programs and data required by the electronic device 4. The memory 401 may also be used to temporarily store data that has been output or is to be output.

[0149] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above system can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.

[0150] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0151] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0152] In the embodiments provided by the present invention, it should be understood that the disclosed device / electronic device and method can be implemented in other ways. For example, the device / electronic device embodiments described above are only illustrative. For example, the division of the module or unit is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.

[0153] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0154] In addition, each functional unit in various embodiments of the present invention may be integrated into a processing unit, may exist physically separately for each unit, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.

[0155] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on such an understanding, all or part of the processes in the above-mentioned method of implementing the embodiments of the present invention may also be completed by instructing relevant hardware through a computer program. The computer program may be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned various method and apparatus embodiments may be implemented. Among them, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc.

[0156] The above-mentioned embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A method for storing data in a flash memory, characterized in that, Including: Obtaining a first period and a plurality of first erasure counts, where the first erasure count is determined according to the erasure count of a memory block; Generating an erasure count distribution table according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts, where the erasure count distribution table records the erasure count of each memory block by the end of the first period; Allocating storage schemes for a plurality of memory blocks according to the erasure count distribution table and a plurality of first effective durations, where the plurality of first effective durations are determined according to the effective duration distribution of a plurality of first data blocks generated during the first period; Storing the data block to be stored into a matching target block according to the predicted effective duration of the data block and the storage scheme.

2. The flash memory data storage method according to claim 1, characterized in that The generating an erasure count distribution table according to the predicted total erasure count of the memory by the end of the first period and the plurality of first erasure counts includes: Calculating the sum of the plurality of first erasure counts as the first erasure sum; Taking the sum of the first erasure sum and the predicted total erasure count by the end of the first period as the second erasure sum; Taking the quotient of the second erasure sum and the total number of a plurality of memory blocks as the erasure count mean; For each memory block, taking the difference between the erasure count mean and the corresponding first erasure count as the count allocation, and adding the count allocation to the erasure count distribution table.

3. The flash memory data storage method according to claim 1, wherein The allocating storage schemes for a plurality of memory blocks according to the erasure count distribution table and a plurality of first effective durations includes: Arranging the plurality of first effective durations in descending order of duration to obtain a first queue; For each memory block, constructing a first equation according to the erasure count allocated in the erasure count distribution table, where the first equation expresses the relationship between the memory block storage scheme and the first total duration representing the total effective duration of the data stored in the memory block; Constructing a plurality of first equations into a first system of equations; Generating a plurality of storage schemes according to the first system of equations; Evaluating the applicability of the plurality of storage schemes according to the first system of equations to generate a plurality of evaluation results; If there is an evaluation result that meets the target among the plurality of evaluation results, taking the storage scheme that meets the target as the storage scheme allocated to each memory block; Otherwise, adding the plurality of evaluation results to a plurality of evaluation result queues respectively, modifying the plurality of storage schemes according to the plurality of evaluation results and the plurality of evaluation result queues, and jumping to the step of evaluating the applicability of the plurality of storage schemes according to the first system of equations to generate a plurality of evaluation results, where each evaluation result queue corresponds to a storage scheme.

4. The method for storing flash memory data according to claim 3, wherein The first equation is: where t n is the first total duration of the nth memory block, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure count distribution table, and Sch n (i) is the sequence number of the ith first effective duration allocated to the nth memory block in the storage scheme in the first queue, and QD(x) is the xth first effective duration in the first queue.

5. The method for storing data in a flash memory according to claim 3, wherein The evaluating the applicability of the plurality of storage schemes according to the first system of equations to generate a plurality of evaluation results includes: For each storage scheme, respectively performing the following steps: Substituting the storage scheme into the first system of equations to obtain a plurality of first total durations, where each first total duration corresponds to a memory block; Generate an evaluation result according to the first formula, the erasure count distribution table, and the multiple first total durations, where the first formula is: Wherein, EV is the evaluation result, nmax is the total number of memory blocks, Tab(n) is the number of erasure times allocated to the nth memory block in the erasure times allocation table, tt total is the predicted total number of erasure times of the memory by the end of the first period, tt n is the number of erasure times of the nth memory block determined according to the storage scheme, t p is the duration of the first period, t n is the first total duration of the nth memory block determined according to the storage scheme.

6. The method for storing flash memory data according to claim 3, wherein Modifying the multiple storage schemes according to the multiple evaluation result queues includes: Select the best evaluation result from the multiple evaluation results as the first target evaluation result; For each storage scheme, perform the following steps respectively: Select the best evaluation result from the evaluation result queue corresponding to the storage scheme as the second target evaluation result; Modify the storage scheme according to the storage scheme corresponding to the first target evaluation result and the storage scheme corresponding to the second target evaluation result.

7. The flash memory data storage method according to any one of claims 1-6, characterized in that, Storing the data block to be stored in a matching target block according to the predicted effective duration of the data block and the storage scheme includes: Obtain multiple attributes of the data block, where the multiple attributes include at least one of the following: data structure, source application, size of the data to which the data block belongs, and source user; Determine the probabilities of multiple typical effective durations according to the second formula and the multiple attribute dimensions, where the second formula is: Wherein, P(tf k |a1a2…a m ) is the probability that the effective duration of the data block is tf k under multiple attribute conditions, P(a1a2…a m |tf k ) is the probability that the multiple attributes of the data block are a1a2…a k respectively under the condition that the effective duration is tf m , P(tf k ) is the probability that the effective duration is tf k , P(a1a2…a m ) is the probability that the multiple attributes of the data block are a1a2…a m respectively, and a m is the m-th attribute; Determine the predicted effective duration of the data block according to the third formula, the multiple typical effective durations, and the probabilities of the multiple typical effective durations, where the third formula is: where tf is the predicted effective duration of the data block, kmax is the number of typical effective durations, and tf k is the k-th typical effective duration; Find the duration closest to the predicted effective duration of the data block from the storage scheme as the replacement duration; Store the predicted effective duration of the data block into the memory block corresponding to the replacement duration.

8. A flash memory data storage device, characterized in that, For implementing the flash memory data storage method according to any one of claims 1-7, the flash memory data storage device includes: A data acquisition module for acquiring a first period and multiple first erasure counts, where the first erasure count is determined according to the erasure count of a memory block; An erasure count distribution module for generating an erasure count distribution table according to the predicted total erasure count of the memory to the end of the first period and the multiple first erasure counts, where the erasure count distribution table records the erasure count of each memory block to the end of the first period; A storage scheme generation module for allocating storage schemes for multiple memory blocks according to the erasure count distribution table and multiple first effective durations, where the multiple first effective durations are determined according to the effective duration distribution of multiple first data blocks generated during the first period; And, A data storage module for storing the data block to be stored in a matching target block according to the predicted effective duration of the data block and the storage scheme.

9. An electronic device, comprising a memory and a processor, wherein a computer program that can run on the processor is stored in the memory, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7 above.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 7 above.