Flash memory data storage method and system and storage medium

By obtaining the attribute parameters of free good blocks in the flash memory, and selecting suitable free good blocks for data storage, the stability and lifespan issues of flash memory storage are solved, and intelligent data storage management is realized.

CN121900699APending Publication Date: 2026-04-21SHENZHEN DOUDAN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN DOUDAN TECHNOLOGY CO LTD
Filing Date
2026-01-04
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing flash memory storage technology fails to intelligently manage idle blocks, affecting the stability and lifespan of flash memory.

Method used

By obtaining the memory size of the data to be stored, the available good blocks in the flash memory are determined. The attribute parameters of each free good block are obtained, including read/write speed and remaining erase/write cycles. Based on these parameters, the target free good block corresponding to the data size is selected for storage.

Benefits of technology

It improves the stability and lifespan of flash memory and optimizes the data storage process by intelligently managing the performance and characteristics of free good blocks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121900699A_ABST
    Figure CN121900699A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of flash memory storage, and particularly discloses a flash memory data storage method and system and a storage medium, and the method comprises the following steps: obtaining a first memory size of to-be-stored data; idle good blocks in the flash memory are determined, m idle good blocks are obtained, and m is a positive integer; determining the number of first idle good blocks according to the first memory size, wherein the number of the first idle good blocks is smaller than m; attribute parameters of each idle good block in the m idle good blocks are obtained, m attribute parameters are obtained, and each attribute parameter comprises the read-write rate and the remaining erasing frequency; selecting target idle good blocks with the same quantity as the first idle good blocks from the m idle good blocks according to the m attribute parameters; and storing the to-be-stored data to the target idle good block. The storage stability and consistency of the flash memory data can be improved, and the service life of the flash memory can be protected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, specifically to a flash memory data storage method, system, and storage medium. Background Technology

[0002] Flash memory is a form of electronically erasable programmable read-only memory, specifically a type of memory that can be erased or written multiple times during operation. Typically, flash memory is a special type of erasable programmable read-only memory (EPROM) that is written in macroblocks.

[0003] Flash memory, as a non-volatile memory, can retain data for up to 25 years after power failure. Flash memory typically uses floating-gate transistors to store charge, avoiding the data loss defect of traditional volatile memory (such as Dynamic Random Access Memory, DRAM) when power is off. However, during data storage, flash memory often randomly allocates some free blocks for data storage. Since the characteristics of the free blocks themselves are not considered, the stability and lifespan of flash memory are affected. Therefore, how to intelligently implement flash memory data storage to improve the stability and lifespan of flash memory is an urgent problem to be solved. Summary of the Invention

[0004] This invention provides a flash memory data storage method, system, and storage medium that can address the aforementioned deficiencies. It can not only determine the number of free blocks based on the memory size of the data to be stored, but also select corresponding free blocks based on their performance and characteristics to store the data to be stored. In this way, flash memory data storage is intelligently realized, thereby improving the stability and lifespan of flash memory.

[0005] In a first aspect, embodiments of the present invention provide a flash memory data storage method, the method comprising: Get the initial memory size of the data to be stored; Identify the free good blocks in the flash memory, and obtain m free good blocks, where m is a positive integer; The number of first free good blocks is determined based on the first memory size, and the number of first free good blocks is less than m; Obtain the attribute parameters of each of the m free good blocks to get m attribute parameters, each of which includes read / write rate and remaining erase / write count; Based on the m attribute parameters, select a target free good block from the m free good blocks, the number of which is equal to the number of the first free good blocks; The data to be stored is stored in the target free block.

[0006] Optionally, in conjunction with the first aspect, selecting a target free good block from the m free good blocks according to the m attribute parameters, with a number equal to the number of the first free good blocks, includes: The maximum number of remaining erase / write cycles is determined based on the m attribute parameters, where k is greater than or equal to the number of the first free good blocks; Based on the k remaining erase / write counts, a combinations of remaining erase / write counts are determined, and each combination of remaining erase / write counts includes the same number of remaining erase / write counts as the number of the first free good blocks from the k remaining erase / write counts. Determine the combinations of read and write rates corresponding to the combinations of a remaining erase / write cycles; The target read / write rate combination is determined based on the a read / write rate combinations; Based on the target read / write rate combination, select a number of target free blocks from the m free blocks that are equal to the number of the first free blocks.

[0007] Optionally, in conjunction with the first aspect, determining the target read / write rate combination based on the a read / write rate combinations includes: Determine a standard deviation based on the a combinations of read and write rates; Select the minimum value among the a standard deviations, and combine the remaining erase / write counts corresponding to the minimum value as the target read / write rate combination.

[0008] Optionally, in conjunction with the first aspect, selecting a target free good block from the m free good blocks according to the m attribute parameters, with a number equal to the number of the first free good blocks, includes: Determine m evaluation values ​​based on the m attribute parameters; Select a target evaluation value that is equal to the number of the first free good blocks based on the m evaluation values; Determine the target free block corresponding to the target evaluation value.

[0009] Optionally, in conjunction with the first aspect, determining the m evaluation values ​​based on the m attribute parameters includes: A first reference evaluation value is determined based on the remaining number of erase / write cycles in the first attribute parameter; the first attribute parameter is any one of the m attribute parameters. The second reference evaluation value is determined based on the read / write rate in the first attribute parameter; Obtain the first weight corresponding to the remaining number of erase / write cycles and the second weight corresponding to the read / write rate, wherein the first weight is greater than the second weight, and the sum of the first weight and the second weight is 1; The evaluation value corresponding to the first attribute parameter is determined based on the first reference evaluation value, the second reference evaluation value, the first weight, and the second weight.

[0010] In a second aspect, embodiments of the present invention provide a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the first aspect of the present invention.

[0011] Thirdly, embodiments of the present invention provide a flash memory data storage system, the system comprising: The acquisition unit is used to acquire the first memory size of the data to be stored. The determining unit is used to determine the free good blocks in the flash memory, and obtain m free good blocks, where m is a positive integer; and to determine the first number of free good blocks according to the first memory size, wherein the first number of free good blocks is less than m; The acquisition unit is used to acquire the attribute parameters of each of the m free good blocks, and obtain m attribute parameters, each attribute parameter including read / write rate and remaining erase / write count; The selection unit is used to select a target free block from the m free blocks according to the m attribute parameters, the number of which is equal to the number of the first free blocks; A storage unit is used to store the data to be stored into the target free block.

[0012] Optionally, in conjunction with the third aspect, the step of selecting a target free block from the m free blocks according to the m attribute parameters, equal to the number of the first free blocks, includes: The maximum number of remaining erase / write cycles is determined based on the m attribute parameters, where k is greater than or equal to the number of the first free good blocks; Based on the k remaining erase / write counts, a combinations of remaining erase / write counts are determined, and each combination of remaining erase / write counts includes the same number of remaining erase / write counts as the number of the first free good blocks from the k remaining erase / write counts. Determine the combinations of read and write rates corresponding to the combinations of a remaining erase / write cycles; The target read / write rate combination is determined based on the a read / write rate combinations; Based on the target read / write rate combination, select a number of target free blocks from the m free blocks that are equal to the number of the first free blocks.

[0013] Optionally, in conjunction with the third aspect, determining the target read / write rate combination based on the a read / write rate combinations includes: Determine a standard deviation based on the a combinations of read and write rates; Select the minimum value among the a standard deviations, and combine the remaining erase / write counts corresponding to the minimum value as the target read / write rate combination.

[0014] Optionally, in conjunction with the third aspect, the step of selecting a target free block from the m free blocks according to the m attribute parameters, equal to the number of the first free blocks, includes: Determine m evaluation values ​​based on the m attribute parameters; Select a target evaluation value that is equal to the number of the first free good blocks based on the m evaluation values; Determine the target free block corresponding to the target evaluation value.

[0015] Optionally, in conjunction with the third aspect, determining the m evaluation values ​​based on the m attribute parameters includes: A first reference evaluation value is determined based on the remaining number of erase / write cycles in the first attribute parameter; the first attribute parameter is any one of the m attribute parameters. The second reference evaluation value is determined based on the read / write rate in the first attribute parameter; Obtain the first weight corresponding to the remaining number of erase / write cycles and the second weight corresponding to the read / write rate, wherein the first weight is greater than the second weight, and the sum of the first weight and the second weight is 1; The evaluation value corresponding to the first attribute parameter is determined based on the first reference evaluation value, the second reference evaluation value, the first weight, and the second weight.

[0016] Implementing the embodiments of the present invention has the following beneficial effects: As can be seen, the flash memory data storage method, system, and storage medium described in this embodiment of the invention firstly determines the number of free blocks in the flash memory by obtaining the first memory size of the data to be stored, where m is a positive integer. Then, the number of first free blocks is determined according to the first memory size, and the number of first free blocks is less than m. Next, the attribute parameters of each of the m free blocks are obtained, resulting in m attribute parameters. Each attribute parameter includes read / write speed and remaining erase / write cycles. Finally, a target free block equal to the number of first free blocks is selected from the m free blocks according to the m attribute parameters, and the data to be stored is stored in the target free block. In this way, not only is the number of free blocks determined based on the memory size of the data to be stored, but also the performance and characteristics of the free blocks are used to select the corresponding number of free blocks to store the data to be stored. This can intelligently realize flash memory data storage, thereby improving the stability and lifespan of flash memory. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of another electronic device provided in an embodiment of the present invention; Figure 3 This is a schematic flowchart of a flash memory data storage method provided in an embodiment of the present invention; Figure 4 This is a functional unit block diagram of a flash memory data storage device provided in an embodiment of the present invention. Detailed Implementation

[0019] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0021] It should be understood that the term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this document indicates that the preceding and following related objects are in an "or" relationship. In the embodiments of this invention, "multiple" refers to two or more.

[0022] In this invention, "at least one item" or similar expressions refer to any combination of these items, including any combination of a single item or multiple items. "One or more" means one or more, while "multiple" means two or more. For example, "at least one item" of a, b, or c can represent the following seven cases: a, b, c, a and b, a and c, b and c, a, b, and c. Each of a, b, and c can be an element or a set containing one or more elements.

[0023] In the embodiments of this invention, "connection" refers to various connection methods such as direct connection or indirect connection to achieve communication between devices. The embodiments of this invention do not impose any limitations on this.

[0024] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0025] In this solution, the flash memory can include multiple storage blocks, which may include some good blocks and some bad blocks. Good blocks are generally understood as those that can be read or written normally. Bad blocks, in contrast to good blocks, are those that cannot be read or written normally. Free good blocks are a special case of good blocks; they are good blocks that have not been allocated to any data storage task. Please see Figure 1 , Figure 1 This is a schematic diagram of the structure of an electronic device provided by the present invention. The electronic device may include a flash memory, which is used to implement data storage function.

[0026] Among them, the electronic device can be any computer device including flash memory, which can include smartphones, tablets, smart hard drives, smart USB flash drives, desktop computers, servers, wearable devices, smart base stations, smart gateways, smart cars, robots (lawn mowing robots, sweeping robots, pedestrian robots, wind-driving robots, etc.), etc.

[0027] Electronic devices may also include smart flash memory, which is equivalent to a stand-alone computer device.

[0028] Furthermore, such as Figure 2As shown, the electronic device may also include at least one processor, at least one memory, at least one communication interface, and at least one program, wherein the processor is communicatively connected to the memory and the communication interface via an internal communication bus.

[0029] The processor can also be a combination of components that perform computing functions. Specifically, it can include one or more microprocessor combinations, DSPs, combinations of microprocessors, etc.

[0030] The processor can be a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The processor can implement or execute the various exemplary logic blocks, cells, and circuits described in conjunction with the disclosure of this application.

[0031] The communication unit can be a communication interface, transceiver, transceiver circuit, etc., and the memory can include flash memory, or the memory can be independent of flash memory.

[0032] The memory can be volatile memory or non-volatile memory, or it can include both volatile and non-volatile memory.

[0033] The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory.

[0034] The volatile memory can be random access memory (RAM), which serves as an external cache. Volatile memory can include at least one of the following: random access memory (RAM), static random access memory (SRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), dynamic random access memory (DRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0035] The at least one program is stored in the aforementioned memory and configured to be executed by the aforementioned processor. The at least one program may include instructions for performing some or all of the steps in any embodiment of the method of the present invention.

[0036] Furthermore, electronic devices may also include more or fewer structural elements than those shown in the above block diagram, such as physical buttons, wireless fidelity (Wi-Fi) modules, power modules (e.g., batteries), speakers, Bluetooth modules, sensors (such as proximity sensors, ultrasonic sensors, infrared sensors, laser sensors, etc.), display modules (such as displays, touch screens, projection devices, etc.).

[0037] In practice, this electronic device can be used to achieve the following functions: Get the initial memory size of the data to be stored; Identify the free good blocks in the flash memory, and obtain m free good blocks, where m is a positive integer; The number of first free good blocks is determined based on the first memory size, and the number of first free good blocks is less than m; Obtain the attribute parameters of each of the m free good blocks to get m attribute parameters, each of which includes read / write rate and remaining erase / write count; Based on the m attribute parameters, select a target free good block from the m free good blocks, the number of which is equal to the number of the first free good blocks; The data to be stored is stored in the target free block.

[0038] In this solution, the electronic device not only determines the number of free blocks based on the memory size of the data to be stored, but also selects free blocks corresponding to the number of free blocks based on the performance and characteristics of the free blocks to store the data to be stored. This can intelligently realize flash memory data storage and improve the stability and lifespan of flash memory. Please see Figure 3 , Figure 3 This is a flowchart illustrating a flash memory data storage method provided by the present invention, which includes: S31. Obtain the first memory size of the data to be stored.

[0039] The electronic device may include a flash memory, which can be used to store data to be stored. The data to be stored may include at least one of the following: images, videos, audio, log data, text data, program code, etc., without limitation.

[0040] In the specific implementation, the memory size required to store the data to be stored can be obtained to get the first memory size.

[0041] S32. Determine the free good blocks in the flash memory to obtain m free good blocks, where m is a positive integer.

[0042] In a specific implementation, the flash memory may include multiple storage blocks, and corresponding free good blocks are obtained from these multiple storage blocks to obtain m free good blocks, where m is a positive integer.

[0043] In practical implementation, the data type of the data to be stored can be obtained to obtain a first data type. A pre-stored mapping relationship between preset data types and the block identifiers of free good blocks can also be used. The block identifier of a free good block can be used to uniquely identify it; for example, the block identifier can include a block number or a block index. Based on this mapping relationship, the block identifier of the free good block corresponding to the first data type can be determined, obtaining a corresponding set of block identifiers. Then, based on this set of block identifiers, the corresponding block identifiers can be obtained, resulting in m free good blocks. Since different blocks are better suited to storing different data types, the corresponding free good block can be obtained based on the data type of the data to be stored, which helps ensure the stability and lifespan of flash memory.

[0044] S33. Determine the number of first free good blocks based on the first memory size, wherein the number of first free good blocks is less than m.

[0045] In the specific implementation, since different data sizes require different storage spaces, the number of free good blocks that meet the required storage space can be determined based on the first memory size, and the number of first free good blocks corresponding to the first memory size can be obtained. The number of first free good blocks is less than m.

[0046] S34. Obtain the attribute parameters of each of the m free good blocks to get m attribute parameters. Each attribute parameter includes read / write rate and remaining erase / write count.

[0047] Among them, the attribute parameters of the free good block are used to characterize the characteristics of the free good block. Each attribute parameter of the free good block may include read / write rate and remaining erase / write cycles.

[0048] The read / write rate of the free block can reflect the performance of the free block. This read / write rate can be determined based on the historical read / write rate of the free block. For example, the historical read / write rate of the free block can be determined, and its corresponding average value can be determined to obtain the read / write rate in the attribute parameters.

[0049] The remaining number of erase / write cycles for a free block is related to its remaining lifetime. The more remaining erase / write cycles a block has, the longer its remaining lifetime will be; conversely, the fewer remaining erase / write cycles a block has, the shorter its remaining lifetime will be.

[0050] Specifically, we can obtain the read / write rate and remaining erase / write count for each of the m free blocks, thus obtaining the read / write rate and remaining erase / write count for the m free blocks. In other words, we obtain m attribute parameters, each of which includes the read / write rate and remaining erase / write count.

[0051] S35. Select a target free block from the m free blocks according to the m attribute parameters, the number of which is equal to the number of the first free blocks.

[0052] In the specific implementation, since the m attribute parameters characterize the performance and characteristics of the m free good blocks, the target free good blocks can be selected from the m free good blocks based on these m attribute parameters, which is equal to the number of the first free good blocks. This can include prioritizing the selection of free good blocks with large remaining erase / write cycles and fast read / write speeds for data storage, thus ensuring the stability and lifespan of the flash memory.

[0053] S36. Store the data to be stored in the target free block.

[0054] In practice, the data to be stored can be stored in a free block. Since the number of free blocks is determined not only by the memory size of the data to be stored, but also by the performance and characteristics of the free blocks, the corresponding free blocks are selected to store the data to be stored. This can intelligently realize flash memory data storage and improve the stability and lifespan of flash memory.

[0055] Optionally, the step of selecting a target free block from the m free blocks based on the m attribute parameters, with the number of such free blocks equal to the number of the first free blocks, may specifically include the following steps: The maximum number of remaining erase / write cycles is determined based on the m attribute parameters, where k is greater than or equal to the number of the first free good blocks; Based on the k remaining erase / write counts, a combinations of remaining erase / write counts are determined, and each combination of remaining erase / write counts includes the same number of remaining erase / write counts as the number of the first free good blocks from the k remaining erase / write counts. Determine the combinations of read and write rates corresponding to the combinations of a remaining erase / write cycles; The target read / write rate combination is determined based on the a read / write rate combinations; Based on the target read / write rate combination, select a number of target free blocks from the m free blocks that are equal to the number of the first free blocks.

[0056] In the specific implementation, the remaining erase / write counts can be obtained based on m attribute parameters, resulting in m remaining erase / write counts. Then, the largest k remaining erase / write counts among these m remaining erase / write counts are obtained, where k is greater than or equal to the number of first free good blocks. Since the remaining erase / write counts are related to the lifespan of the flash memory storage blocks, priority can be given to allocating storage to blocks with larger remaining erase / write counts, i.e., smaller free blocks are used for storage in normal times. This balanced utilization of flash memory storage blocks helps to ensure the lifespan of the flash memory.

[0057] In practice, when k is greater than the number of first free good blocks, some redundancy can be reserved to ensure that the decision on the appropriate number of first free good blocks is made, so as to ensure the stability and consistency of data access.

[0058] Accordingly, we can determine a combinations of remaining erase / write counts based on k remaining erase / write counts. Specifically, a can be determined as follows: Where b = the number of first free good blocks, C represents the permutation and combination algorithm, k represents k remaining erase / write times, and each combination of remaining erase / write times includes the same number of remaining erase / write times as the number of first free good blocks from the k remaining erase / write times.

[0059] Next, we can determine the a read / write rate combinations corresponding to the a remaining erase / write cycles, and determine the target read / write rate combinations based on the a read / write rate combinations. Finally, we can select a number of target free blocks from the m free blocks that are equal to the number of first free blocks, based on the target read / write rate combinations. In this way, based on the performance and characteristics of the free blocks, we can select the corresponding number of free blocks to store the data to be stored, which can intelligently realize flash memory data storage and improve the stability and lifespan of flash memory.

[0060] Optionally, the step of determining the target read / write rate combination based on the a read / write rate combinations may specifically include the following steps: Determine a standard deviation based on the a combinations of read and write rates; Select the minimum value among the a standard deviations, and combine the remaining erase / write counts corresponding to the minimum value as the target read / write rate combination.

[0061] In practice, the standard deviation can be calculated for each of the a read / write rate combinations to obtain a standard deviations. The standard deviation represents the stability and consistency of the corresponding a free good blocks when storing data to be stored. The smaller the standard deviation, the better the stability and consistency when storing data to be stored. Conversely, the larger the standard deviation, the worse the stability and consistency when storing data to be stored.

[0062] Next, select the minimum value among a standard deviations, and use the combination of remaining erase / write cycles corresponding to the minimum value as the target read / write rate combination. The minimum value indicates that the stability and consistency when storing data to be stored are the best. That is, by combining the stability and consistency when storing data to be stored, the most suitable free blocks can be selected, which helps to improve the stability and lifespan of flash memory.

[0063] Optionally, the step of selecting a target free block from the m free blocks based on the m attribute parameters, with the number of such free blocks equal to the number of the first free blocks, may specifically include the following steps: Determine m evaluation values ​​based on the m attribute parameters; Select a target evaluation value that is equal to the number of the first free good blocks based on the m evaluation values; Determine the target free block corresponding to the target evaluation value.

[0064] In the specific implementation, m attribute parameters characterize the performance of m free good blocks, the remaining erase / write cycles characterize the lifespan of the storage block, and the read / write rate characterizes the stability of the storage block. That is, the quality of the storage block can be evaluated from two dimensions: lifespan and stability. In other words, m evaluation values ​​can be determined based on the m attribute parameters. The evaluation values ​​characterize the performance of the storage block. For example, the larger the evaluation value, the better the storage block. Then, a target evaluation value equal to the number of first free good blocks is selected based on the m evaluation values. For example, the evaluation value with the larger value can be selected first. Then, the target free good blocks corresponding to the target evaluation value are determined. That is, good free storage blocks can be selected based on the performance of the storage blocks, which helps to ensure the stability of flash data storage and the lifespan of flash memory.

[0065] Optionally, the step of determining m evaluation values ​​based on the m attribute parameters may specifically include the following steps: A first reference evaluation value is determined based on the remaining number of erase / write cycles in the first attribute parameter; the first attribute parameter is any one of the m attribute parameters. The second reference evaluation value is determined based on the read / write rate in the first attribute parameter; Obtain the first weight corresponding to the remaining number of erase / write cycles and the second weight corresponding to the read / write rate, wherein the first weight is greater than the second weight, and the sum of the first weight and the second weight is 1; The evaluation value corresponding to the first attribute parameter is determined based on the first reference evaluation value, the second reference evaluation value, the first weight, and the second weight.

[0066] In a specific implementation, a first mapping relationship between the remaining number of erase / write cycles and the evaluation value can be pre-stored, as well as a second mapping relationship between the pre-set read / write rate and the evaluation value.

[0067] Specifically, taking the first attribute parameter as an example, the first attribute parameter is any one of the m attribute parameters. Based on the first mapping relationship, the first reference evaluation value corresponding to the remaining number of erase / write cycles in the first attribute parameter can be obtained, and the second reference evaluation value corresponding to the read / write rate in the first attribute parameter can be determined based on the second mapping relationship.

[0068] Furthermore, a first weight corresponding to the remaining number of erase / write cycles and a second weight corresponding to the read / write rate can be obtained. The first weight is greater than the second weight, and the sum of the first weight and the second weight is 1. The first weight and the second weight can be preset or defaulted to by the system. The first weight and the second weight can be related to the performance of the flash memory, or the first weight and the second weight can be related to the usage time of the flash memory, or the first weight and the second weight can be related to the data type of the data to be stored or the memory size.

[0069] Finally, a weighted calculation can be performed based on the first reference evaluation value, the second reference evaluation value, the first weight, and the second weight to obtain the evaluation value corresponding to the first attribute parameter. In this way, the remaining erase / write cycles characterize the lifespan of the storage block, and the read / write rate characterizes the stability of the storage block. That is, the quality of the storage block can be evaluated from two dimensions: lifespan and stability. In other words, the evaluation value with the larger evaluation value can be selected first. Furthermore, the target free block corresponding to the target evaluation value can be determined. That is, good free storage blocks can be selected based on the performance of the storage blocks, which helps to ensure the stability of flash memory data storage and the lifespan of flash memory.

[0070] As can be seen, the flash memory data storage method described in this embodiment of the invention firstly determines the number of free blocks in the flash memory by obtaining the first memory size of the data to be stored, where m is a positive integer. Then, the number of first free blocks is determined according to the first memory size, and the number of first free blocks is less than m. Next, the attribute parameters of each of the m free blocks are obtained, resulting in m attribute parameters. Each attribute parameter includes read / write speed and remaining erase / write cycles. Finally, a target free block equal to the number of first free blocks is selected from the m free blocks according to the m attribute parameters, and the data to be stored is stored in the target free block. In this way, not only is the number of free blocks determined based on the memory size of the data to be stored, but also the performance and characteristics of the free blocks are used to select the corresponding number of free blocks to store the data to be stored. This can intelligently realize flash memory data storage, thereby improving the stability and lifespan of flash memory.

[0071] Figure 4 This is a functional unit block diagram of a flash memory data storage system 400 according to an embodiment of the present invention. The flash memory data storage device 400 includes: an acquisition unit 401, a determination unit 402, a selection unit 403, and a storage unit 404, wherein... Acquisition unit 401 is used to acquire the first memory size of the data to be stored; The determining unit 402 is used to determine the free good blocks in the flash memory, and obtain m free good blocks, where m is a positive integer; and to determine the first number of free good blocks according to the first memory size, wherein the first number of free good blocks is less than m; The acquisition unit 401 is used to acquire the attribute parameters of each of the m free good blocks to obtain m attribute parameters, each attribute parameter including read / write rate and remaining erase / write count; The selection unit 403 is used to select a target free block from the m free blocks according to the m attribute parameters, the number of which is equal to the number of the first free blocks; Storage unit 404 is used to store the data to be stored into the target free block.

[0072] Optionally, selecting a target free good block from the m free good blocks according to the m attribute parameters, with the number equal to the number of the first free good blocks, includes: The maximum number of remaining erase / write cycles is determined based on the m attribute parameters, where k is greater than or equal to the number of the first free good blocks; Based on the k remaining erase / write counts, a combinations of remaining erase / write counts are determined, and each combination of remaining erase / write counts includes the same number of remaining erase / write counts as the number of the first free good blocks from the k remaining erase / write counts. Determine the combinations of read and write rates corresponding to the combinations of a remaining erase / write cycles; The target read / write rate combination is determined based on the a read / write rate combinations; Based on the target read / write rate combination, select a number of target free blocks from the m free blocks that are equal to the number of the first free blocks.

[0073] Optionally, determining the target read / write rate combination based on the a read / write rate combinations includes: Determine a standard deviation based on the a combinations of read and write rates; Select the minimum value among the a standard deviations, and combine the remaining erase / write counts corresponding to the minimum value as the target read / write rate combination.

[0074] Optionally, selecting a target free good block from the m free good blocks according to the m attribute parameters, with the number equal to the number of the first free good blocks, includes: Determine m evaluation values ​​based on the m attribute parameters; Select a target evaluation value that is equal to the number of the first free good blocks based on the m evaluation values; Determine the target free block corresponding to the target evaluation value.

[0075] Optionally, determining the m evaluation values ​​based on the m attribute parameters includes: A first reference evaluation value is determined based on the remaining number of erase / write cycles in the first attribute parameter; the first attribute parameter is any one of the m attribute parameters. The second reference evaluation value is determined based on the read / write rate in the first attribute parameter; Obtain the first weight corresponding to the remaining number of erase / write cycles and the second weight corresponding to the read / write rate, wherein the first weight is greater than the second weight, and the sum of the first weight and the second weight is 1; The evaluation value corresponding to the first attribute parameter is determined based on the first reference evaluation value, the second reference evaluation value, the first weight, and the second weight.

[0076] It is understood that the functions of each program module of the above-mentioned flash memory data storage system 400 can be specifically implemented according to the methods in the above-mentioned method embodiments. The specific implementation process can be referred to the relevant descriptions in the above-mentioned method embodiments, which will not be repeated here.

[0077] This invention also provides a computer storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the methods described in the above method embodiments.

[0078] This invention also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments. This computer program product can be a software installation package.

[0079] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0080] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0081] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.

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

[0083] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0084] If the aforementioned integrated units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0085] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage device, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0086] The embodiments of the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A flash memory data storage method, characterized in that, The method includes: Get the initial memory size of the data to be stored; Identify the free good blocks in the flash memory, and obtain m free good blocks, where m is a positive integer; The number of first free good blocks is determined based on the first memory size, and the number of first free good blocks is less than m; Obtain the attribute parameters of each of the m free good blocks to get m attribute parameters, each of which includes read / write rate and remaining erase / write count; Based on the m attribute parameters, select a target free good block from the m free good blocks, the number of which is equal to the number of the first free good blocks; The data to be stored is stored in the target free good block.

2. The method as described in claim 1, characterized in that, The step of selecting a target free good block from the m free good blocks according to the m attribute parameters, with the number equal to the number of the first free good blocks, includes: The maximum number of remaining erase / write cycles is determined based on the m attribute parameters, where k is greater than or equal to the number of the first free good blocks; Based on the k remaining erase / write counts, a combinations of remaining erase / write counts are determined, and each combination of remaining erase / write counts includes the same number of remaining erase / write counts as the number of the first free good blocks from the k remaining erase / write counts. Determine the combinations of read and write rates corresponding to the combinations of a remaining erase / write cycles; The target read / write rate combination is determined based on the a read / write rate combinations; Based on the target read / write rate combination, select a number of target free blocks from the m free blocks that are equal to the number of the first free blocks.

3. The method as described in claim 2, characterized in that, The step of determining the target read / write rate combination based on the a read / write rate combinations includes: Determine a standard deviation based on the a combinations of read and write rates; Select the minimum value among the a standard deviations, and combine the remaining erase / write counts corresponding to the minimum value as the target read / write rate combination.

4. The method as described in claim 1, characterized in that, The step of selecting a target free good block from the m free good blocks according to the m attribute parameters, with the number equal to the number of the first free good blocks, includes: Determine m evaluation values ​​based on the m attribute parameters; Select a target evaluation value that is equal to the number of the first free good blocks based on the m evaluation values; Determine the target free block corresponding to the target evaluation value.

5. The method as described in claim 4, characterized in that, The process of determining m evaluation values ​​based on the m attribute parameters includes: A first reference evaluation value is determined based on the remaining number of erase / write cycles in the first attribute parameter; the first attribute parameter is any one of the m attribute parameters. The second reference evaluation value is determined based on the read / write rate in the first attribute parameter; Obtain the first weight corresponding to the remaining number of erase / write cycles and the second weight corresponding to the read / write rate, wherein the first weight is greater than the second weight, and the sum of the first weight and the second weight is 1; The evaluation value corresponding to the first attribute parameter is determined based on the first reference evaluation value, the second reference evaluation value, the first weight, and the second weight.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the method of any one of claims 1-5.

7. A flash memory data storage system, characterized in that, The system includes: The acquisition unit is used to acquire the first memory size of the data to be stored. The determining unit is used to determine the free good blocks in the flash memory, and obtain m free good blocks, where m is a positive integer; and to determine the first number of free good blocks according to the first memory size, wherein the first number of free good blocks is less than m; The acquisition unit is used to acquire the attribute parameters of each of the m free good blocks, and obtain m attribute parameters, each attribute parameter including read / write rate and remaining erase / write count; The selection unit is used to select a target free block from the m free blocks according to the m attribute parameters, the number of which is equal to the number of the first free blocks; A storage unit is used to store the data to be stored into the target free block.

8. The system as described in claim 7, characterized in that, The step of selecting a target free good block from the m free good blocks according to the m attribute parameters, with the number equal to the number of the first free good blocks, includes: The maximum number of remaining erase / write cycles is determined based on the m attribute parameters, where k is greater than or equal to the number of the first free good blocks; Based on the k remaining erase / write counts, a combinations of remaining erase / write counts are determined, and each combination of remaining erase / write counts includes the same number of remaining erase / write counts as the number of the first free good blocks from the k remaining erase / write counts. Determine the combinations of read and write rates corresponding to the combinations of a remaining erase / write cycles; The target read / write rate combination is determined based on the a read / write rate combinations; Based on the target read / write rate combination, select a number of target free blocks from the m free blocks that are equal to the number of the first free blocks.

9. The system as described in claim 8, characterized in that, The step of determining the target read / write rate combination based on the a read / write rate combinations includes: Determine a standard deviation based on the a combinations of read and write rates; Select the minimum value among the a standard deviations, and combine the remaining erase / write counts corresponding to the minimum value as the target read / write rate combination.

10. The system as described in claim 7, characterized in that, The step of selecting a target free good block from the m free good blocks according to the m attribute parameters, with the number equal to the number of the first free good blocks, includes: Determine m evaluation values ​​based on the m attribute parameters; Select a target evaluation value that is equal to the number of the first free good blocks based on the m evaluation values; Determine the target free block corresponding to the target evaluation value.