Wear leveling control method, device, equipment and readable storage medium

文档序号:1888622 发布日期:2021-11-26 浏览:4次 中文

阅读说明:本技术 一种磨损均衡控制方法、装置、设备及可读存储介质 (Wear leveling control method, device, equipment and readable storage medium ) 是由 张乾坤 刘哲 王鑫 于 2021-07-21 设计创作,主要内容包括:本申请公开了一种磨损均衡控制方法、装置、设备及可读存储介质,该方法包括:从空闲block中选出擦写次数大于擦写阈值的block,并将block加入自平衡二叉树;接收数据写入请求后,判断在自平衡二叉树之外是否存在空闲block;若是,则从自平衡二叉树之外的空闲block中选出目标block;若否,则从自平衡二叉树中选出目标block;将数据写入请求对应的数据写入目标block。如此,SSD内部可以根据擦写阈值这一条件,自动控制稳态时的free block数量,动态调整对block磨损均衡的保护能力。即,以动态调整对block的保护能力,从而保障block的PE保持均衡,使得SSD的使用寿命最佳。(The application discloses a wear leveling control method, a device, equipment and a readable storage medium, wherein the method comprises the following steps: selecting a block with the erasing times larger than an erasing threshold value from the idle block, and adding the block into a self-balancing binary tree; after receiving a data write request, judging whether an idle block exists outside a self-balancing binary tree; if yes, selecting a target block from the idle blocks outside the self-balancing binary tree; if not, selecting a target block from the self-balancing binary tree; and writing the data corresponding to the data writing request into the target block. Therefore, the SSD can automatically control the free block quantity in a steady state according to the condition of the erasing threshold value, and dynamically adjust the protection capability of block abrasion balance. Namely, the protection capability of the block is dynamically adjusted, so that the PE of the block is ensured to keep balance, and the service life of the SSD is optimal.)

1. A wear leveling control method, comprising:

selecting a block with the erasing times larger than an erasing threshold value from the idle block, and adding the block into a self-balancing binary tree;

after receiving a data write request, judging whether an idle block exists outside the self-balancing binary tree or not;

if yes, selecting a target block from the idle blocks outside the self-balancing binary tree;

if not, selecting the target block from the self-balancing binary tree;

and writing the data corresponding to the data writing request into the target block.

2. The wear leveling control method of claim 1, wherein adding the block to a self-balancing binary tree comprises:

judging whether the number of idle blocks of the self-balancing binary tree is greater than a preset number threshold value or not; the preset quantity threshold value is a maximum threshold value of a steady-state idle block set according to the maximum performance reduction allowed when the abrasion is unbalanced;

if not, directly adding the block into the self-balancing binary tree;

if so, replacing the block with the minimum erasing frequency in the self-balancing binary tree under the condition that the erasing frequency of the block is greater than the block with the minimum erasing frequency in the self-balancing binary tree.

3. The method of claim 1, wherein selecting the block with the number of erasures greater than the erasures threshold from the free block comprises:

acquiring the erasing times of each idle block, the average erasing times of each block and the upper limit of the difference value between the preset maximum erasing times and the average erasing times;

determining the sum of the average erasing times and the upper limit of the difference value as the erasing threshold value;

and selecting the block with the erasing times larger than the erasing threshold value from the free block.

4. The wear leveling control method of claim 3, further comprising:

monitoring the average erasing times;

after the average erasing times are changed, updating the erasing threshold value by using the sum of the average erasing times and the difference upper limit;

and eliminating blocks with the erasing times smaller than the erasing threshold value in the self-balancing binary tree.

5. The wear leveling control method of claim 1, wherein selecting a target block from free blocks outside the self-balancing binary tree comprises:

sorting the idle blocks outside the self-balancing binary tree based on the erasing times;

and selecting the idle block with the minimum erasing times by using the sorting result, and determining the idle block as the target block.

6. The wear leveling control method of claim 1, wherein selecting the target block from the self-balancing binary tree comprises:

determining the left sub-leaf node of the self-balancing binary tree as the target block; and storing the self-balancing binary tree based on the erasing times.

7. The wear leveling control method according to any one of claims 1 to 6, further comprising:

selecting a target block from the free blocks outside the self-balancing binary tree under the condition that all data corresponding to the data writing request cannot be written into the target block;

and writing the data which is not written into the target block selected from the self-balancing binary tree.

8. A wear leveling control apparatus, comprising:

the Block adding module is used for selecting a Block with the erasing times larger than an erasing threshold value from the idle Block and adding the Block into the self-balancing binary tree;

the judging module is used for judging whether an idle block exists outside the self-balancing binary tree or not after receiving a data writing request;

the target block selecting module is used for selecting a target block from the idle blocks outside the self-balancing binary tree if the idle blocks exist outside the self-balancing binary tree; if no free block exists outside the self-balancing binary tree, selecting the target block from the self-balancing binary tree;

and the data writing module is used for writing the data corresponding to the data writing request into the target block.

9. An electronic device, comprising:

a memory for storing a computer program;

a processor for implementing the steps of the wear leveling control method of any one of claims 1 to 7 when executing the computer program.

10. A readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the wear leveling control method according to any one of claims 1 to 7.

Technical Field

The present application relates to the field of storage technologies, and in particular, to a wear leveling control method, device, and apparatus, and a readable storage medium.

Background

A NAND Flash (a nonvolatile Flash memory, which adopts a nonlinear macro cell mode inside) is used as a storage medium inside an SSD (Solid State Drive), and the number of times of PE (Program Erase) of the storage medium is limited. That is, when the number of PE times exceeds a certain number, a block (minimum storage and processing unit) storing data in the NAND is damaged, and cannot be used continuously. Therefore, the SSD firmware needs to ensure that the PE times of all blocks in the NAND Flash are basically balanced, so that the service life of the SSD can reach the best.

The dynamic wear balancing mode is that blocks in the NAND are sequenced according to the PEs, and when data needs to be written, the block with the minimum written PE is selected for use, so that the use times of the blocks with larger PEs are reduced. The NAND block has the characteristics that the block can only be written according to pages and erased according to the block, usually, one block internally comprises a plurality of pages, and due to the characteristic, garbage recovery is required to be carried out inside the SSD, so that the inside of the SSD is ensured to have sufficient space for data writing. When a random write enters steady state, the number of free blocks inside the SSD may fluctuate around a certain value. The protection capability of the blocks by dynamic wear balance is affected, the protection capability of the blocks is reduced, and the PE difference between the blocks is larger and larger.

In summary, how to effectively improve the protection capability of the block and the like is a technical problem that needs to be solved urgently by those skilled in the art at present.

Disclosure of Invention

The application aims to provide a wear leveling control method, a wear leveling control device, wear leveling equipment and a readable storage medium, so that the protection capability of a block is dynamically adjusted, and therefore the PE of the block is guaranteed to keep balance.

In order to solve the technical problem, the application provides the following technical scheme:

a wear leveling control method, comprising:

selecting a block with the erasing times larger than an erasing threshold value from the idle block, and adding the block into a self-balancing binary tree;

after receiving a data write request, judging whether an idle block exists outside the self-balancing binary tree or not;

if yes, selecting a target block from the idle blocks outside the self-balancing binary tree;

if not, selecting the target block from the self-balancing binary tree;

and writing the data corresponding to the data writing request into the target block.

Preferably, adding the block to a self-balancing binary tree includes:

judging whether the number of idle blocks of the self-balancing binary tree is greater than a preset number threshold value or not; the preset quantity threshold value is a maximum threshold value of a steady-state idle block set according to the maximum performance reduction allowed when the abrasion is unbalanced;

if not, directly adding the block into the self-balancing binary tree;

if so, replacing the block with the minimum erasing frequency in the self-balancing binary tree under the condition that the erasing frequency of the block is greater than the block with the minimum erasing frequency in the self-balancing binary tree.

Preferably, the selecting the block with the erasing times larger than the erasing threshold from the free block includes:

acquiring the erasing times of each idle block, the average erasing times of each block and the upper limit of the difference value between the preset maximum erasing times and the average erasing times;

determining the sum of the average erasing times and the upper limit of the difference value as the erasing threshold value;

and selecting the block with the erasing times larger than the erasing threshold value from the free block.

Preferably, the method further comprises the following steps:

monitoring the average erasing times;

after the average erasing times are changed, updating the erasing threshold value by using the sum of the average erasing times and the difference upper limit;

and eliminating blocks with the erasing times smaller than the erasing threshold value in the self-balancing binary tree.

Preferably, selecting a target block from free blocks outside the self-balancing binary tree includes:

sorting the idle blocks outside the self-balancing binary tree based on the erasing times;

and selecting the idle block with the minimum erasing times by using the sorting result, and determining the idle block as the target block.

Preferably, selecting the target block from the self-balancing binary tree includes:

determining the left sub-leaf node of the self-balancing binary tree as the target block; and storing the self-balancing binary tree based on the erasing times.

Preferably, the method further comprises the following steps:

selecting a target block from the free blocks outside the self-balancing binary tree under the condition that all data corresponding to the data writing request cannot be written into the target block;

and writing the data which is not written into the target block selected from the self-balancing binary tree.

A wear leveling control device comprising:

the Block adding module is used for selecting a Block with the erasing times larger than an erasing threshold value from the idle Block and adding the Block into the self-balancing binary tree;

the judging module is used for judging whether an idle block exists outside the self-balancing binary tree or not after receiving a data writing request;

the target block selecting module is used for selecting a target block from the idle blocks outside the self-balancing binary tree if the idle blocks exist outside the self-balancing binary tree; if no free block exists outside the self-balancing binary tree, selecting the target block from the self-balancing binary tree;

and the data writing module is used for writing the data corresponding to the data writing request into the target block.

An electronic device, comprising:

a memory for storing a computer program;

and the processor is used for realizing the steps of the wear leveling control method when executing the computer program.

A readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the wear leveling control method described above.

By applying the method provided by the embodiment of the application, the block with the erasing times larger than the erasing threshold value is selected from the idle blocks, and the block is added into the self-balancing binary tree; after receiving a data write request, judging whether an idle block exists outside a self-balancing binary tree; if yes, selecting a target block from the idle blocks outside the self-balancing binary tree; if not, selecting a target block from the self-balancing binary tree; and writing the data corresponding to the data writing request into the target block.

And selecting the block with the erasing times larger than the erasing threshold value from the free block, and adding the block into the self-balancing binary tree. And after receiving a data write request, preferentially selecting free blocks outside the self-balancing binary tree. Specifically, whether an idle block exists outside a self-balancing binary tree is judged firstly; if so, selecting a target block from the idle blocks outside the self-balancing binary tree; and if not, selecting the target block from the self-balancing binary tree. And writing the data corresponding to the data writing request into the target block. Therefore, by the method, according to the condition of the erasing threshold value, the SSD can automatically control the free block (free block) number in a steady state, and dynamically adjust the protection capability for block wear balance. That is, if the block wear degree in the SSD is balanced, the free block number in the random write steady state is small, and the wear leveling protection capability is weak, and when the wear is unbalanced, the free block number in the random write steady state is large, and the wear leveling protection capability is strong. Namely, the protection capability of the block is dynamically adjusted, so that the PE of the block is ensured to keep balance, and the service life of the SSD is optimal.

Accordingly, embodiments of the present application further provide a wear leveling control apparatus, a device, and a readable storage medium corresponding to the wear leveling control method, which have the above technical effects and are not described herein again.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments or related technologies of the present application, the drawings needed to be used in the description of the embodiments or related technologies are briefly introduced below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.

Fig. 1 is a flowchart illustrating an implementation of a wear leveling control method according to an embodiment of the present application;

fig. 2 is a schematic structural diagram of a wear leveling control device in an embodiment of the present application;

fig. 3 is a schematic structural diagram of an electronic device in an embodiment of the present application;

fig. 4 is a schematic structural diagram of an electronic device in an embodiment of the present application.

Detailed Description

In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

Referring to fig. 1, fig. 1 is a flowchart illustrating a wear leveling control method according to an embodiment of the present application, the method including the following steps:

s101, selecting the block with the erasing times larger than the erasing threshold value from the free block, and adding the block into the self-balancing binary tree.

In this embodiment, a self-balancing binary tree may be constructed in advance.

In order to ensure normal writing of data, in the SSD, a write flow control method is used to make the SSD enter a steady state, that is, a consumed space is substantially the same as a recycled space, that is, there will always be a plurality of free blocks in the SSD.

In order to improve the wear leveling protection capability, a block with the erasing times larger than the erasing threshold value can be selected from the idle blocks, and the block is added into the self-balancing binary tree for protection (namely, when data needs to be written, the data is prevented from being written into the block as much as possible, so that the erasing times of the block are basically kept unchanged). That is, each node of the self-balancing binary tree corresponds to one free block (i.e., free block).

The erasing threshold may be set in advance according to user experience, or may be dynamically adjusted based on the actual usage of the SSD.

In order to optimize the dynamic wear leveling capability, a dynamic erasure threshold may be preferably used. Specifically, the specific implementation process of selecting the idle block to be protected based on the dynamically changing erasing threshold includes:

acquiring the erasing times of each idle block, the average erasing times of each block and the upper limit of the difference value between the preset maximum erasing times and the average erasing times;

step two, determining the sum of the average erasing times and the difference upper limit as an erasing threshold;

and step three, selecting the block with the erasing times larger than the erasing threshold value from the idle block.

For convenience of description, the above three steps will be described in combination.

Firstly, the erasing times of each free block, the average erasing times of each block, and the upper limit of the difference value between the preset maximum erasing times and the average erasing times need to be obtained.

And determining the sum of the average erasing times and the upper limit of the difference value as an erasing threshold value. That is, if the erasure threshold is expressed as PEprotectAverage number of times of erasing is represented as PEaverageThe upper limit of the difference between the preset maximum erasing times and the average erasing times is expressed as PEprotectThen PEprotect=PEaverage+PEprotect. That is, when a free block of PEs>PEaverage+PEprotectWhen the block needs to be added into the self-balancing binary tree for protection.

Preferably, the number of free blocks in the steady state affects an OP (Over Provision) space inside the SSD, and further affects the steady state performance of random writing of the SSD. Therefore, the maximum threshold value of the steady state free block can be set according to the maximum performance reduction allowed when the wear is unbalancedFBmaxThat is, the total number of nodes of the self-balancing binary tree needs to be limited within a preset number threshold. Specifically, adding the block to the self-balancing binary tree may specifically include:

step one, judging whether the number of idle blocks of a self-balancing binary tree is greater than a preset number threshold value or not; the preset quantity threshold value is a maximum threshold value of a steady-state idle block set according to the maximum performance reduction allowed when the abrasion is unbalanced;

step two, if not, directly adding the block into the self-balancing binary tree;

and step three, if so, replacing the block with the minimum erasing times in the self-balancing binary tree with the block under the condition that the erasing times of the block are larger than the block with the minimum erasing times in the self-balancing binary tree.

For convenience of description, the above three steps will be described in combination.

That is, when the number of queries with free blocks is found to be greater than the erasure threshold, it is also necessary to consider whether the number of blocks in the current self-balancing binary tree is greater than a preset number threshold. That is, it is determined whether the number of blocks in the self-balancing binary tree is greater than a maximum threshold for setting a steady-state idle block based on a maximum performance degradation allowed when wear is unbalanced. If the capacity of the self-balancing binary tree is not larger than the upper limit of the capacity, the self-balancing binary tree does not reach the upper limit of the capacity, and the OP space inside the SSD cannot be influenced by continuously adding the idle block in an increasing mode, so that the corresponding idle block can be directly added into the self-balancing binary tree; if the number of times of erasing is larger than the erasing number of times of the existing block of the self-balancing binary tree, replacing the block in the self-balancing binary tree or not processing the block based on a comparison result. I.e. when a free block of PEs>PEaverage+PEprotectThis block needs to be added to the self-balancing binary tree, but when bl on the self-balancing binary tree is addedThe ock number is greater than FBmaxAnd comparing the block with the minimum PE in the self-balancing binary tree with the PE of the block to be put in, and keeping the block with the large PE in the tree.

And S102, after receiving the data writing request, judging whether an idle block exists outside the self-balancing binary tree.

A data write request is received indicating that data needs to be written to the block. At this time, a block needs to be selected from the free blocks for use.

As can be seen from the above, there may be idle blocks in the self-balancing binary tree, and there may also be idle blocks outside the self-balancing binary tree. Because the erasing times of the block in the self-balancing binary tree are at least larger than the erasing threshold, even if the block larger than the erasing threshold exists outside the self-balancing binary tree, the erasing times of the block are also smaller than the block corresponding to the latest erasing times in the self-balancing binary tree. Therefore, when selecting the free block, the free blocks outside the self-balancing binary tree need to be preferentially selected, so as to balance the erasing times of each block.

Specifically, the idle blocks outside the self-balancing binary tree may be preferentially used to be used by determining whether there is an idle block outside the self-balancing binary tree. After the determination result of whether there is an idle block outside the self-balancing binary tree is obtained, the subsequent execution step can be determined based on the determination result, specifically, if the determination result is yes, the step S103 is executed, and if the determination result is no, the step S104 is executed.

S103, selecting a target block from the idle blocks outside the self-balancing binary tree.

And when determining that the idle blocks exist outside the self-balancing binary tree, directly selecting a target block from the idle blocks outside the self-balancing binary tree. For the sake of distinction only, the selected free block to be used is referred to as a target block, and in practical applications, the number of target blocks may be determined according to the actual data write request. For example, when the data write request needs to occupy 1 block corresponding to the data to be written, the target block is 1; when the data write request corresponding to the data to be written needs to occupy 2 blocks, the target blocks are 2.

Preferably, selecting a target block from free blocks outside the self-balancing binary tree specifically includes:

step one, sequencing idle blocks outside a self-balancing binary tree based on erasing times;

and step two, selecting the idle block with the minimum erasing times by using the sorting result, and determining the idle block as the target block.

In order to effectively protect the idle block with a large erasing frequency, the idle block with the smallest erasing frequency can be preferentially selected when the target block is selected. Specifically, the idle blocks outside the self-balancing binary tree may be sorted based on the erasing times, and then the idle block with the smallest erasing times is selected based on the sorting result and determined as the target block to be used.

And S104, selecting a target block from the self-balancing binary tree.

When no free block is found out of the self-balancing binary tree, the target block can be selected from the self-balancing binary tree. Specifically, the manner of selecting the target block from the self-balancing binary tree may specifically refer to a specific implementation process of selecting the target block from idle blocks outside the self-balancing binary tree.

Preferably, considering that when the idle block meeting the condition is added to the self-balancing binary tree, the node position may be determined according to the erasing times, and when the target block is selected, the target block may be quickly determined based on the structure of the self-balancing binary tree. Specifically, selecting a target block from a self-balancing binary tree includes: determining a left sub-leaf node of the self-balancing binary tree as a target block; and the self-balancing binary tree is stored based on the erasing times. That is, the erase/write times of the left child leaf node of the self-balancing binary tree are the smallest in the whole self-balancing binary tree.

And S105, writing the data corresponding to the data writing request into the target block.

And after the target block is selected, writing the data corresponding to the data writing request into the target block.

By applying the method provided by the embodiment of the application, the block with the erasing times larger than the erasing threshold value is selected from the idle blocks, and the block is added into the self-balancing binary tree; after receiving a data write request, judging whether an idle block exists outside a self-balancing binary tree; if yes, selecting a target block from the idle blocks outside the self-balancing binary tree; if not, selecting a target block from the self-balancing binary tree; and writing the data corresponding to the data writing request into the target block.

And selecting the block with the erasing times larger than the erasing threshold value from the free block, and adding the block into the self-balancing binary tree. And after receiving a data write request, preferentially selecting free blocks outside the self-balancing binary tree. Specifically, whether an idle block exists outside a self-balancing binary tree is judged firstly; if so, selecting a target block from the idle blocks outside the self-balancing binary tree; and if not, selecting the target block from the self-balancing binary tree. And writing the data corresponding to the data writing request into the target block. Therefore, by the method, according to the condition of the erasing threshold value, the SSD can automatically control the free block (free block) number in a steady state, and dynamically adjust the protection capability for block wear balance. That is, if the block wear degree in the SSD is balanced, the free block number in the random write steady state is small, and the wear leveling protection capability is weak, and when the wear is unbalanced, the free block number in the random write steady state is large, and the wear leveling protection capability is strong. Namely, the protection capability of the block is dynamically adjusted, so that the PE of the block is ensured to keep balance, and the service life of the SSD is optimal.

It should be noted that, based on the above embodiments, the embodiments of the present application also provide corresponding improvements. In the preferred/improved embodiment, the same steps as those in the above embodiment or corresponding steps may be referred to each other, and corresponding advantageous effects may also be referred to each other, which are not described in detail in the preferred/improved embodiment herein.

Preferably, if the dynamically changing erasure threshold is selected to be added to the self-balancing binary tree, the erasure threshold changes with the use of the SSD, which may cause that the block originally added to the self-balancing binary tree does not satisfy the addition condition that the number of erasures is greater than the erasure threshold in the self-balancing binary tree, which is not favorable for performing the erasure balance protection on the block. In order to solve the problem, the self-balancing binary tree can be effectively monitored, and blocks which do not meet the conditions are eliminated. The specific implementation process comprises the following steps:

monitoring the average erasing frequency;

step two, after the average erasing times change, updating the erasing threshold value by using the sum of the average erasing times and the difference upper limit;

and step three, removing blocks with the erasing times smaller than the erasing threshold value in the self-balancing binary tree.

For convenience of explanation, the above three steps will be explained in combination.

After the average erasing times of each block are changed, the sum of the average erasing times and the upper limit of the difference value is the erasing threshold value. That is, after the average erasing times is increased, the erasing threshold is also increased, so that the block originally added to the self-balancing binary tree may no longer meet the adding condition. At this time, blocks with the erasing times smaller than the erasing threshold value in the self-balancing binary tree can be directly eliminated.

Preferably, considering that in practical application, the number of blocks required by data corresponding to the data read-write request may exceed the number of free blocks outside the self-balancing binary tree, in this case, the target block may be continuously selected from the self-balancing binary tree to meet the data write requirement. That is to say, when a target block is selected from free blocks outside the self-balancing binary tree and data corresponding to the data write request cannot be completely written into the target block, the target block is selected from the self-balancing binary tree; and writing the data which is not written into the target block selected from the self-balancing binary tree. For example, the following steps are carried out: when the data corresponding to the data write request needs 5 idle blocks for storage, but the idle blocks outside the self-balancing binary tree are only 3, all the 3 idle blocks can be determined as target blocks, and 2 blocks are continuously selected from the self-balancing binary tree as the target blocks. And finally, jointly storing the data corresponding to the data write request by 3 target blocks outside the self-balancing binary tree and 2 target blocks in the self-balancing binary tree.

Corresponding to the above method embodiment, the present application embodiment further provides a wear leveling control device, and the wear leveling control device described below and the wear leveling control method described above may be referred to in correspondence with each other.

Referring to fig. 2, the apparatus includes the following modules:

the Block adding module 101 is used for selecting a Block with the erasing times larger than an erasing threshold value from the idle blocks and adding the Block into the self-balancing binary tree;

the judging module 102 is configured to judge whether an idle block exists outside the self-balancing binary tree after receiving the data write request;

the target block selecting module 103 is configured to select a target block from the idle blocks outside the self-balancing binary tree if the idle blocks exist outside the self-balancing binary tree; if no free block exists outside the self-balancing binary tree, selecting a target block from the self-balancing binary tree;

and the data writing module 104 is configured to write data corresponding to the data writing request into the target block.

By applying the device provided by the embodiment of the application, the block with the erasing times larger than the erasing threshold value is selected from the idle blocks, and the block is added into the self-balancing binary tree; after receiving a data write request, judging whether an idle block exists outside a self-balancing binary tree; if yes, selecting a target block from the idle blocks outside the self-balancing binary tree; if not, selecting a target block from the self-balancing binary tree; and writing the data corresponding to the data writing request into the target block.

And selecting the block with the erasing times larger than the erasing threshold value from the free block, and adding the block into the self-balancing binary tree. And after receiving a data write request, preferentially selecting free blocks outside the self-balancing binary tree. Specifically, whether an idle block exists outside a self-balancing binary tree is judged firstly; if so, selecting a target block from the idle blocks outside the self-balancing binary tree; and if not, selecting the target block from the self-balancing binary tree. And writing the data corresponding to the data writing request into the target block. Therefore, by the method, according to the condition of the erasing threshold value, the SSD can automatically control the free block (free block) number in a steady state, and dynamically adjust the protection capability for block wear balance. That is, if the block wear degree in the SSD is balanced, the free block number in the random write steady state is small, and the wear leveling protection capability is weak, and when the wear is unbalanced, the free block number in the random write steady state is large, and the wear leveling protection capability is strong. Namely, the protection capability of the block is dynamically adjusted, so that the PE of the block is ensured to keep balance, and the service life of the SSD is optimal.

In a specific embodiment of the present application, the Block adding module 101 is specifically configured to determine whether the number of idle blocks of the self-balancing binary tree is greater than a preset number threshold; the preset quantity threshold value is a maximum threshold value of a steady-state idle block set according to the maximum performance reduction allowed when the abrasion is unbalanced; if not, directly adding the block into the self-balancing binary tree; if so, replacing the block with the minimum erasing times in the self-balancing binary tree with the block under the condition that the erasing times of the block are larger than the block with the minimum erasing times in the self-balancing binary tree.

In a specific embodiment of the present application, the Block adding module 101 is specifically configured to obtain the erase times of each idle Block, an average erase time of each Block, and an upper limit of a difference between a preset maximum erase time and an average erase time; determining the sum of the average erasing times and the upper limit of the difference value as an erasing threshold value; and selecting the block with the erasing times larger than the erasing threshold value from the free block.

In one embodiment of the present application, the method further includes:

the self-balancing binary tree supervision module is used for monitoring the average erasing times; updating the erasing threshold value by using the sum of the average erasing times and the difference upper limit after the average erasing times are changed; and eliminating blocks with the erasing times smaller than the erasing threshold value in the self-balancing binary tree.

In a specific embodiment of the present application, the target block selecting module 103 is specifically configured to sort idle blocks outside the self-balancing binary tree based on the erasing times; and selecting the idle block with the minimum erasing times by using the sorting result, and determining the idle block as the target block.

In a specific embodiment of the present application, the target block selecting module 103 is specifically configured to determine a left sub-leaf node of a self-balancing binary tree as a target block; and the self-balancing binary tree is stored based on the erasing times.

In one embodiment of the present application, the method further includes:

the target block cross-tree selection module is specifically used for selecting a target block from free blocks outside the self-balancing binary tree and selecting the target block from the self-balancing binary tree under the condition that all data corresponding to the data writing request cannot be written into the target block; and writing the data which is not written into the target block selected from the self-balancing binary tree.

Corresponding to the above method embodiment, the present application further provides an electronic device, and the electronic device described below and the wear leveling control method described above may be referred to in correspondence.

Referring to fig. 3, the electronic device includes:

a memory 332 for storing a computer program;

a processor 322 for implementing the steps of the wear leveling control method of the above-described method embodiments when executing the computer program.

Specifically, referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device provided in this embodiment, which may generate relatively large differences due to different configurations or performances, and may include one or more processors (CPUs) 322 (e.g., one or more processors) and a memory 332, where the memory 332 stores one or more computer applications 342 or data 344. Memory 332 may be, among other things, transient or persistent storage. The program stored in memory 332 may include one or more modules (not shown), each of which may include a sequence of instructions operating on a data processing device. Still further, the central processor 322 may be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.

The electronic device 301 may also include one or more power sources 326, one or more wired or wireless network interfaces 350, one or more input-output interfaces 358, and/or one or more operating systems 341.

The steps in the wear leveling control method described above may be implemented by the structure of the electronic device.

Corresponding to the above method embodiment, the present application further provides a readable storage medium, and a readable storage medium described below and a wear leveling control method described above may be referred to in correspondence with each other.

A readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the wear leveling control method of the above-mentioned method embodiment.

The readable storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various other readable storage media capable of storing program codes.

Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种超融合系统及其IO请求下发方法、物理服务器

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类