A wear leveling processing method, device, equipment and medium

By scanning erase counts and shutdown times in the solid-state drive (SSD), target blocks and free blocks are identified, and data is migrated in idle mode. This addresses the impact of the static wear leveling process on SSD read and write performance, improving the overall performance and efficiency of the SSD.

CN119718212BActive Publication Date: 2026-08-04INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2024-12-30
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

The static wear leveling process in current solid-state drives (SSDs) occurs during the input/output process, affecting read/write performance and processing efficiency.

Method used

By scanning the erase count and shutdown time of each block, the corresponding thresholds are obtained to determine the target block and free block. In idle mode, data is migrated to the free block according to the migration priority to avoid occupying the bandwidth speed of the IO process.

Benefits of technology

Wear leveling was completed before the SSD was put into operation, which improved read and write performance, reduced the impact of wear leveling on the overall performance of the SSD, and enabled a more reasonable block data migration order.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718212B_ABST
    Figure CN119718212B_ABST
Patent Text Reader

Abstract

The application discloses a wear leveling processing method and device, equipment and medium, and relates to the technical field of storage. According to the application, the erase count and the shutdown time of each block are calculated, and the target block and the idle block are determined in all blocks according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold. When the SSD enters the idle mode, the data in each target block is migrated to the corresponding idle block according to the migration priority of each target block, so that the wear leveling is completed before the formal operation of the SSD, the bandwidth speed of the IO process of the SSD is avoided, and the read-write performance of the SSD is improved. Meanwhile, the application takes into account the different wear degrees of different target blocks, migrates the data of the target blocks according to the migration priority of each target block, so that the block data migration sequence is more reasonable, and the influence of the wear leveling on the overall read-write performance of the SSD is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, and in particular to a wear leveling method, apparatus, device, and medium. Background Technology

[0002] In solid-state drives (SSDs), each flash memory cell has a limited write lifespan. Once a cell is full of data, it is marked as a "bad block" and no longer used for data storage, leading to performance degradation or even SSD failure. To address this issue, wear leveling technology was introduced. Static wear leveling considers not only the age of the flash memory cells but also the frequency of data access. During data erasure and writing, the system prioritizes migrating long-unused cold data from newer cells to older cells, and then writes new data to newer cells, thus achieving wear leveling.

[0003] Static wear leveling technology is designed specifically to optimize static data. It can run continuously in the background, monitoring the usage of each flash memory cell and proactively migrating data from cells with low wear to other cells, while returning the original cells to the free pool, thus improving the security and durability of static data. However, current static wear leveling typically occurs during normal SSD input / output (IO) processes, consuming bandwidth that is typically used for IO, impacting SSD read / write performance and processing efficiency, and also affecting overall system performance.

[0004] Given the above, how to address the issue that the static wear leveling process of current SSDs occurs during the I / O process, thus affecting the read / write performance and processing efficiency of SSDs, is a problem that urgently needs to be solved by technical personnel in this field. Summary of the Invention

[0005] The purpose of this invention is to provide a wear leveling method, apparatus, device, and medium to solve the problem that the current static wear leveling process of SSDs is performed during the I / O process, which affects the read / write performance and processing efficiency of SSDs.

[0006] To address the aforementioned technical problems, this invention provides a wear leveling method applied to solid-state drives (SSDs); the method includes:

[0007] Scan each block and calculate the erase count and shutdown time for each block;

[0008] Obtain the erase count threshold and the off time threshold;

[0009] Based on the erase count, shutdown time, erase count threshold, and shutdown time threshold, target blocks and free blocks are determined in each block; among them, the target block is the block containing cold data;

[0010] After entering idle mode, the data in each target block is migrated to the corresponding idle block according to the migration priority of each target block.

[0011] On the one hand, obtaining the erase count threshold includes:

[0012] Get the total erase count and the total number of blocks;

[0013] Determine the quotient of the total erase count and the total number of blocks to determine the average erase count;

[0014] The first erase count threshold, the second erase count threshold, and the third erase count threshold are generated based on the average erase count.

[0015] The first erase count threshold is less than the second erase count threshold, and the second erase count threshold is less than the third erase count threshold.

[0016] On the other hand, obtaining the shutdown time threshold includes:

[0017] Get the total close time and the number of valid blocks; where valid blocks are readable and writable blocks.

[0018] Determine the quotient of the total shutdown time and the number of valid blocks to determine the average shutdown time;

[0019] A first shutdown time threshold, a second shutdown time threshold, and a third shutdown time threshold are generated based on the average shutdown time.

[0020] Among them, the first closing time threshold is less than the second closing time threshold, and the second closing time threshold is less than the third closing time threshold.

[0021] On the other hand, based on the erase count, shutdown time, erase count threshold, and shutdown time threshold, target blocks are determined within each block, including:

[0022] Identify the candidate blocks that have reached their capacity limits from among the existing blocks;

[0023] Determine the erase count and shutdown time for the candidate blocks;

[0024] When the erase count of the candidate block is not greater than the first erase count threshold, the shutdown time of the candidate block is not less than the first shutdown time threshold, and less than the second shutdown time threshold, the candidate block is determined to be the first target block;

[0025] Place the first target block into the first queue;

[0026] When the erase count of the candidate block is greater than the first erase count threshold and not greater than the second erase count threshold, and the closing time of the candidate block is not less than the second closing time threshold and less than the third closing time threshold, the candidate block is determined to be the second target block.

[0027] Place the second target block into the second queue;

[0028] When the erase count of the candidate block is greater than the second erase count threshold and not greater than the third erase count threshold, and the shutdown time of the candidate block is not less than the third shutdown time threshold, the candidate block is determined to be the third target block.

[0029] Place the third target block into the third queue.

[0030] On the other hand, based on the erase count, shutdown time, erase count threshold, and shutdown time threshold, free blocks are determined within each block, including:

[0031] Iterate through the erase count and close time of each block;

[0032] Blocks whose corresponding erase count is greater than the third erase count threshold and whose corresponding shutdown time is less than the first shutdown time threshold are identified as free blocks.

[0033] On the other hand, based on the migration priority corresponding to each target block, the data in each target block is migrated to the corresponding free block, including:

[0034] Set the power consumption value for performing wear leveling in idle mode;

[0035] Determine the priority order of the first, second, and third queues; wherein the priority of the first queue is lower than that of the second queue, and the priority of the second queue is lower than that of the third queue.

[0036] Based on priority and power consumption, the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue are written into the corresponding free blocks in sequence.

[0037] On the other hand, the data in each target block is migrated to the corresponding free block, including:

[0038] Obtain the pre-set first bandwidth speed, second bandwidth speed, and third bandwidth speed;

[0039] The data of the first target block in the first queue is migrated to the corresponding free block using the first bandwidth speed;

[0040] The data of the second target block in the second queue is migrated to the corresponding free block using the second bandwidth speed;

[0041] The data of the third target block in the third queue is migrated to the corresponding free block using the third bandwidth speed;

[0042] Among them, the first bandwidth speed is less than the second bandwidth speed, and the second bandwidth speed is less than the third bandwidth speed.

[0043] On the other hand, it also includes:

[0044] When a read / write command is received, determine whether data migration to the target block is currently in progress;

[0045] If it is confirmed that a data migration to the target block is in progress, reduce the bandwidth speed for performing the data migration to the target block;

[0046] Determine whether the data migration of the target block is complete;

[0047] If the data migration of the target block is confirmed to be complete, the data migration process is stopped.

[0048] To address the aforementioned technical problems, the present invention also provides a wear leveling device for use in solid-state drives; the device includes:

[0049] The scan calculation module is used to scan each block and calculate the erase count and shutdown time for each block;

[0050] The acquisition module is used to obtain the erase count threshold and the shutdown time threshold;

[0051] The determination module is used to determine the target block and free block in each block based on the erase count, shutdown time, erase count threshold, and shutdown time threshold; wherein, the target block is the block containing cold data;

[0052] The migration module is used to migrate the data in each target block to the corresponding idle block according to the migration priority of each target block after entering idle mode.

[0053] To address the aforementioned technical problems, the present invention also provides a wear leveling treatment device, comprising:

[0054] Memory, used to store computer programs;

[0055] The processor is used to implement the wear leveling process described above when executing a computer program.

[0056] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the wear leveling processing method described above.

[0057] The wear leveling method provided by this invention is applied to solid-state drives (SSDs). Specifically, it involves scanning each block and calculating the erase count and shutdown time for each block; obtaining erase count thresholds and shutdown time thresholds; determining target blocks and free blocks among all blocks based on the erase count, shutdown time, erase count threshold, and shutdown time threshold; wherein, the target block is a block containing cold data; after entering the idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority corresponding to each target block.

[0058] The beneficial effects of this invention are as follows: by calculating the erase count and shutdown time of each block, and based on the erase count, shutdown time, erase count threshold, and shutdown time threshold, target blocks and free blocks are determined among all blocks; when the SSD enters idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority of each target block, thereby completing wear leveling before the SSD is officially running, avoiding the occupation of the SSD's IO bandwidth speed, and improving the SSD's read and write performance; at the same time, the solution takes into account the different wear levels of different target blocks, and performs data migration of target blocks according to the migration priority of each target block, making the block data migration order more reasonable and reducing the impact of wear leveling on the overall read and write performance of the SSD.

[0059] On the other hand, this invention specifically obtains the total erase count and the total number of blocks, determines the quotient of the total erase count and the total number of blocks to determine the average erase count, and generates a first erase count threshold, a second erase count threshold, and a third erase count threshold based on the average erase count, thus achieving the acquisition of erase count thresholds. Similarly, it obtains the total shutdown time and the number of valid blocks, determines the quotient of the total shutdown time and the number of valid blocks to determine the average shutdown time, and generates a first shutdown time threshold, a second shutdown time threshold, and a third shutdown time threshold based on the average shutdown time, thus achieving the acquisition of shutdown time thresholds. This allows for accurate identification of free blocks in the target block using two thresholds. Executing different priority wear leveling algorithms on the SSD in idle mode can complete the migration of the target block in advance, thereby reducing the performance loss caused by traditional wear leveling during read / write processes.

[0060] In addition, the present invention also provides a wear equalization treatment device, equipment and medium, with the same effect as above. Attached Figure Description

[0061] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments 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.

[0062] Figure 1A flowchart of a wear leveling process provided in an embodiment of the present invention;

[0063] Figure 2 This is a schematic diagram of a wear equalization treatment device provided in an embodiment of the present invention;

[0064] Figure 3 This is a schematic diagram of a wear leveling treatment device provided in an embodiment of the present invention. Detailed Implementation

[0065] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. 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 of ordinary skill in the art without creative effort are within the protection scope of the present invention.

[0066] The core of this invention is to provide a wear leveling method, apparatus, device, and medium to solve the problem that the current static wear leveling process of SSDs is performed during the I / O process, which affects the read and write performance and processing efficiency of SSDs.

[0067] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0068] In SSDs, each flash memory cell has a limited write lifespan. When a cell is full of data, it is marked as a "bad block" and no longer used for data storage, leading to SSD performance degradation or even failure. To address this issue, WearLeveling technology was introduced. Static wear leveling considers not only the age of the flash memory cells but also the frequency of data access. During data erasure and writing, the system prioritizes migrating long-unused cold data from newer cells to older cells, and then writes new data to newer cells, achieving wear leveling. Specifically designed to optimize static data, static wear leveling can run continuously in the background, monitoring the usage of each flash memory cell, proactively migrating data from cells with low wear to other cells, and reassigning the original cells to an idle pool, thus improving the security and durability of static data.

[0069] However, current static wear leveling typically occurs during normal SSD I / O operations, consuming bandwidth and impacting SSD read / write performance and processing efficiency, as well as overall system performance. Therefore, to address these issues, this invention provides a wear leveling method. It is understood that this method is applied to solid-state drives (SSDs).

[0070] Figure 1This is a flowchart illustrating a wear leveling method provided in an embodiment of the present invention. Figure 1 As shown, the method includes:

[0071] S10: Scan each block and calculate the erase count and shutdown time for each block.

[0072] First, the SSD scans each block, calculating the erase count and close time for each block. It's important to note that in an SSD, a block is a storage unit composed of several pages, and it's the smallest unit for erasure operations. Each block contains multiple pages, typically 4KB in size. Due to the characteristics of flash memory, data cannot be directly overwritten after being written; an erase operation is required first, and the smallest unit for erasure is the block. In the SSD's garbage collection mechanism, blocks are used to store valid data and for data migration and block erasure to create new usable blocks.

[0073] Furthermore, the erase count refers to the number of times a block has been erased. Because the flash memory in an SSD has a limited write / erase lifespan, each block can only be erased a certain number of times (typically between several thousand and tens of thousands). Exceeding this number may cause the block to fail or experience performance degradation. The erase count is an important indicator of block lifespan and is usually obtained from the SSD's Self-Monitoring Analysis and Reporting Technology (SMART) information.

[0074] Close time refers to the time required for a block to transition from an active state to an idle state. Close time is an important metric for SSD performance optimization because it directly affects SSD throughput and latency. In this embodiment, the erase count, in conjunction with the close time, determines whether the corresponding block requires wear leveling.

[0075] S11: Get the erase count threshold and the shutdown time threshold.

[0076] S12: Determine the target block and free block in each block based on the erase count, shutdown time, erase count threshold, and shutdown time threshold.

[0077] The target block is the block containing cold data.

[0078] Further, the erase count threshold and the shutdown time threshold are obtained. It should be noted that this embodiment does not limit the specific method for obtaining the erase count threshold and the shutdown time threshold, and it depends on the specific implementation.

[0079] It's worth noting that in this embodiment, the erase count threshold and the close time threshold are used as thresholds for the erase count and close time, respectively, to determine the blocks in the SSD that require wear leveling. Specifically, based on the erase count, close time, erase count threshold, and close time threshold, target blocks and free blocks are determined within each block. It's important to note that target blocks are blocks containing cold data. In simple terms, cold data is data with low access frequency and not crucial to business and applications. Free blocks are blocks that are in an idle state and do not contain data.

[0080] In this embodiment, there are no restrictions on the method for determining the target block and the free block; it depends on the specific implementation.

[0081] S13: After entering idle mode, the data in each target block is migrated to the corresponding idle block according to the migration priority of each target block.

[0082] Finally, to prevent wear leveling from affecting the normal I / O of the SSD, after the SSD enters idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority of each target block, thereby achieving wear leveling of the SSD.

[0083] It should be noted that this embodiment does not restrict the specific method for determining the migration priority of each target block, but depends on the specific implementation.

[0084] In this embodiment, by calculating the erase count and shutdown time of each block, target blocks and free blocks are determined among all blocks based on the erase count, shutdown time, erase count threshold, and shutdown time threshold. When the SSD enters idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority of each target block. This completes wear leveling before the SSD is officially running, avoiding the occupation of the SSD's I / O bandwidth and improving the SSD's read and write performance. At the same time, the solution takes into account the different wear levels of different target blocks and performs data migration of target blocks according to the migration priority of each target block, making the block data migration order more reasonable and reducing the impact of wear leveling on the overall read and write performance of the SSD.

[0085] Based on the above embodiments, in some embodiments, obtaining the erase count threshold includes:

[0086] S111: Get the total erase count and the total number of blocks;

[0087] S112: Determine the quotient of the total erase count and the total number of blocks to determine the average erase count;

[0088] S113: Generate a first erase count threshold, a second erase count threshold, and a third erase count threshold based on the average erase count;

[0089] The first erase count threshold is less than the second erase count threshold, and the second erase count threshold is less than the third erase count threshold.

[0090] Specifically, first, the total erase count (Total EraseCnt) and the total number of blocks are obtained. Then, the quotient of the total erase count (Total EraseCnt) and the total number of blocks is determined to establish the average erase count (Ave_erase count). Finally, based on the average erase count (Ave_erase count), a first erase count threshold (EraseCntLow), a second erase count threshold (EraseCntMiddle), and a third erase count threshold (EraseCntHigh) are generated.

[0091] It should be noted that this embodiment does not impose restrictions on the specific values ​​of the three erase count thresholds. However, it is necessary to ensure that the first erase count threshold, EraseCntLow, is less than the second erase count threshold, EraseCntMiddle, and the second erase count threshold, EraseCntMiddle, is less than the third erase count threshold, EraseCntHigh. For example, the first erase count threshold, EraseCntLow, is equal to Ave_erase count - 30; the second erase count threshold, EraseCntMiddle, is equal to Ave_erase count - 20; and the third erase count threshold, EraseCntHigh, is equal to Ave_erase count - 10.

[0092] Furthermore, because each block in an SSD undergoes continuous read, write, and erase operations, the erase count thresholds in this embodiment are actually dynamically changing.

[0093] Based on the above embodiments, in some embodiments, obtaining the shutdown time threshold includes:

[0094] S114: Get the total close time and the number of valid blocks; where valid blocks are readable and writable blocks;

[0095] S115: Determine the quotient of the total shutdown time and the number of valid blocks to determine the average shutdown time;

[0096] S116: Generate a first closing time threshold, a second closing time threshold, and a third closing time threshold based on the average closing time.

[0097] Among them, the first closing time threshold is less than the second closing time threshold, and the second closing time threshold is less than the third closing time threshold.

[0098] Specifically, first, the total close time (Total Time) and the number of valid blocks are obtained. Valid blocks are readable and writable blocks, meaning blocks that can be used normally. Then, the quotient of the total close time (Total Time) and the number of valid blocks is determined to calculate the average close time (CloseTimeTH). Finally, based on the average close time (CloseTimeTH), a first close time threshold (CloseTimeLow), a second close time threshold (CloseTimeMiddle), and a third close time threshold (CloseTimeHigh) are generated.

[0099] It should be noted that this embodiment does not impose restrictions on the specific values ​​of the three closing time thresholds. However, it is necessary to ensure that the first closing time threshold, CloseTimeLow, is less than the second closing time threshold, CloseTimeMiddle, and the second closing time threshold, CloseTimeMiddle, is less than the third closing time threshold, CloseTimeHigh. For example, the first closing time threshold, CloseTimeLow, is equal to CloseTimeTH - 30, the second closing time threshold, CloseTimeMiddle, is equal to CloseTimeTH - 20, and the third closing time threshold, CloseTimeHigh, is equal to CloseTimeTH - 10.

[0100] Furthermore, because each block in an SSD undergoes continuous read, write, and erase operations, the shutdown time thresholds in this embodiment are actually dynamically changing.

[0101] In summary, by obtaining the total erase count and the total number of blocks, the quotient of the total erase count and the total number of blocks is determined to determine the average erase count. Based on the average erase count, a first erase count threshold, a second erase count threshold, and a third erase count threshold are generated, thus achieving the acquisition of the erase count threshold. Similarly, by obtaining the total shutdown time and the number of valid blocks, the quotient of the total shutdown time and the number of valid blocks is determined to determine the average shutdown time. Based on the average shutdown time, a first shutdown time threshold, a second shutdown time threshold, and a third shutdown time threshold are generated, thus achieving the acquisition of the shutdown time threshold. This allows for the accurate determination of free blocks in the target block using two thresholds.

[0102] Based on the above embodiments, in some embodiments, a target block is determined in each block according to the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold, including:

[0103] S121: Identify the candidate blocks that have reached their capacity limits among all blocks;

[0104] S122: Determine the erase count and shutdown time for the candidate blocks;

[0105] S123: When the erase count of the candidate block is not greater than the first erase count threshold, the shutdown time of the candidate block is not less than the first shutdown time threshold, and less than the second shutdown time threshold, the candidate block is determined to be the first target block;

[0106] S124: Place the first target block into the first queue;

[0107] S125: When the erase count of the candidate block is greater than the first erase count threshold and not greater than the second erase count threshold, and the shutdown time of the candidate block is not less than the second shutdown time threshold and less than the third shutdown time threshold, the candidate block is determined to be the second target block;

[0108] S126: Place the second target block into the second queue;

[0109] S127: When the erase count of the candidate block is greater than the second erase count threshold and not greater than the third erase count threshold, and the shutdown time of the candidate block is not less than the third shutdown time threshold, the candidate block is determined to be the third target block;

[0110] S128: Add the third target block to the third queue.

[0111] To determine the target block, it is first necessary to identify the candidate blocks that have reached their capacity limits among all blocks, and then determine the erase count and close time of the candidate blocks.

[0112] Furthermore, when the erase count of the candidate block is not greater than the first erase count threshold EraseCntLow, and the close time of the candidate block is not less than the first close time threshold CloseTimeLow and less than the second close time threshold CloseTimeMiddle, the candidate block is determined to be the first target block, and the first target block is placed in the first queue.

[0113] When the erase count of the candidate block is greater than the first erase count threshold EraseCntLow and not greater than the second erase count threshold EraseCntMiddle, and the close time of the candidate block is not less than the second close time threshold CloseTimeMiddle and less than the third close time threshold CloseTimeHigh, the candidate block is determined as the second target block and placed in the second queue.

[0114] When the erase count of the candidate block is greater than the second erase count threshold EraseCntMiddle and not greater than the third erase count threshold EraseCntHigh, and the close time of the candidate block is not less than the third close time threshold CloseTimeHigh, the candidate block is determined as the third target block and placed in the third queue.

[0115] It is worth noting that in this embodiment, three queues are set up to store different types of target blocks. The urgency of data migration for the target blocks in each queue varies, that is, their migration priorities differ. The target blocks in each queue are migrated in a different order, thereby enabling more reasonable wear leveling of the SSD. In this embodiment, there is no restriction on the migration priority of the target blocks in each queue; it depends on the specific implementation.

[0116] Based on the above embodiments, in some embodiments, free blocks are determined in each block according to the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold, including:

[0117] S129: Iterate through the erase count and close time of each block;

[0118] S130: Blocks whose corresponding erase count is greater than the third erase count threshold and whose corresponding shutdown time is less than the first shutdown time threshold are identified as free blocks.

[0119] To determine free blocks, the erase count and close time of each block are first traversed. Blocks whose corresponding erase count is greater than the third erase count threshold EraseCntHigh and whose corresponding close time is less than the first close time threshold CloseTimeLow are determined to be free blocks.

[0120] In summary, the target block and the free block were determined separately, so that the data in the target block could be migrated to the free block in the future.

[0121] Based on the above embodiments, in some embodiments, data in each target block is migrated to the corresponding free block according to the migration priority corresponding to each target block, including:

[0122] S131: Sets the power consumption value for performing wear leveling in idle mode;

[0123] S132: Determine the priority order of the first, second, and third queues;

[0124] Among them, the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue;

[0125] S133: According to the priority order and power consumption value, write the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue into the corresponding free blocks in sequence.

[0126] To achieve data migration of the target block, the power consumption for wear leveling in idle mode is specifically set, and must not exceed the manufacturer-specified power consumption value. The priority order of the first, second, and third queues is further determined. Specifically, the priority of the first queue is lower than that of the second queue, and the priority of the second queue is lower than that of the third queue.

[0127] It's important to note that the priority order of a queue refers to the order in which target blocks are migrated. Therefore, for a target block, the priority order of its queue determines its migration priority. For example, if the priority of the first queue is lower than that of the second queue, then the migration priority of target blocks in the first queue is lower than that of target blocks in the second queue.

[0128] Furthermore, since the priority of the first queue is lower than that of the second queue, and the priority of the second queue is lower than that of the third queue, the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue are written into the corresponding free blocks according to the priority order and power consumption value, thereby performing garbage collection on each target block.

[0129] It should also be noted that the garbage collection process begins when at least one of the three queues contains a target block and a free block. The garbage collection process ends when none of the three queues contain a target block and / or no free block exists.

[0130] In summary, this embodiment executes wear leveling algorithms with different priorities on the SSD in idle mode, which can complete the migration of target blocks in advance, thereby reducing the performance loss caused by traditional wear leveling during the read and write process.

[0131] Furthermore, to improve wear leveling efficiency, data within the target block can be segmented during garbage collection: the dataset to be migrated is divided into multiple smaller segments, which are then transmitted in parallel. This approach enhances the parallelism of data migration, thereby improving overall migration efficiency. Specifically, by splitting the dataset into multiple segments, multiple transmission tasks can be initiated simultaneously, each responsible for transmitting one segment. Since multiple transmission tasks can execute concurrently, fully utilizing network bandwidth and system resources, the total migration time can be significantly reduced. Moreover, segmented transmission improves the flexibility and fault tolerance of data transmission; even if a transmission task fails, only the segment corresponding to that task needs to be retransmitted, rather than the entire dataset. This approach is suitable for large-scale data migration scenarios, effectively improving migration efficiency and reducing resource waste.

[0132] Considering the migration speed of target block data migration under different priorities, based on the above embodiments, in some embodiments, the data in each target block is migrated to the corresponding free block, including:

[0133] S134: Obtain the preset first bandwidth speed, second bandwidth speed and third bandwidth speed;

[0134] S135: Migrate the data of the first target block in the first queue to the corresponding free block using the first bandwidth speed;

[0135] S136: Migrate the data of the second target block in the second queue to the corresponding free block using the second bandwidth speed;

[0136] S137: Migrate the data of the third target block in the third queue to the corresponding free block using the third bandwidth speed;

[0137] Among them, the first bandwidth speed is less than the second bandwidth speed, and the second bandwidth speed is less than the third bandwidth speed.

[0138] In this embodiment, the bandwidth speed for wear leveling garbage collection varies depending on the priority; while meeting power consumption requirements, higher priority wear leveling occupies relatively more bandwidth. Specifically, a pre-set first bandwidth speed (LowSpeed), a second bandwidth speed (MiddleSpeed), and a third bandwidth speed (HighSpeed) are obtained. It should be noted that the first bandwidth speed (LowSpeed) corresponds to the first queue, the second bandwidth speed (MiddleSpeed) corresponds to the second queue, and the third bandwidth speed (HighSpeed) corresponds to the third queue. The first bandwidth speed (LowSpeed) is less than the second bandwidth speed (MiddleSpeed), and the second bandwidth speed (MiddleSpeed) is less than the third bandwidth speed (HighSpeed).

[0139] During garbage collection, data from the first target block in the first queue is migrated to its corresponding free block using the first bandwidth speed (LowSpeed); data from the second target block in the second queue is migrated to its corresponding free block using the second bandwidth speed (MiddleSpeed); and data from the third target block in the third queue is migrated to its corresponding free block using the third bandwidth speed (HighSpeed). This process utilizes appropriate bandwidth speeds to complete garbage collection for target blocks of different priorities. It should also be noted that the three bandwidth speeds mentioned above represent the maximum bandwidth for the SSD to transition from idle mode to read / write mode. In idle mode, the bandwidth is always IdleSpeed, which is greater than any of the aforementioned bandwidth speeds.

[0140] In practical implementation, if an SSD undergoing wear leveling in idle mode receives a read / write command, in order to avoid affecting normal I / O performance, in some embodiments, the method further includes the following, based on the above embodiments:

[0141] S14: When a read / write command is received, determine whether data migration of the target block is currently being performed; if so, proceed to step S15.

[0142] S15: Reduce the bandwidth speed for performing data migration of the target block;

[0143] S16: Determine whether the data migration of the target block is complete; if so, stop the data migration process.

[0144] Specifically, when an SSD undergoing wear leveling in idle mode receives a read / write command, it determines whether data migration to the target block is currently in progress. If not, the read / write command is executed. If so, to avoid impacting SSD I / O processing and to complete the ongoing garbage collection, the bandwidth speed for migrating the target block is reduced.

[0145] It should be noted that this embodiment does not restrict the method of reducing bandwidth speed. For example, it can directly reduce the speed based on the current bandwidth speed, or it can first determine the bandwidth speed corresponding to the priority of the target block, and then reduce the bandwidth speed to the bandwidth speed corresponding to the next priority. For example, if garbage collection of the second target block of the second queue is currently being performed, the bandwidth speed at this time is the second bandwidth speed MiddleSpeed; to achieve bandwidth reduction, the current bandwidth speed is specifically reduced from the second bandwidth speed MiddleSpeed ​​to the first bandwidth speed LowSpeed.

[0146] Furthermore, to prevent continuous garbage collection from impacting the SSD's read and write processes, it's necessary to determine whether the target block's data migration is complete; if so, the data migration process should be stopped. In other words, once the current target block's data migration is complete, the next data migration step is stopped, even if there are still target blocks in the queue that haven't undergone garbage collection. Further migration cannot proceed until the SSD enters idle mode again, thus minimizing the impact on the SSD's read and write performance.

[0147] In the above embodiments, the wear leveling treatment method has been described in detail. The present invention also provides embodiments of the wear leveling treatment device.

[0148] Figure 2 This is a schematic diagram of a wear leveling device provided in an embodiment of the present invention. The device is applied to a solid-state drive; such as... Figure 2 As shown, the device includes:

[0149] The scanning calculation module 10 is used to scan each block and calculate the erase count and shutdown time of each block;

[0150] Module 11 is used to obtain the erase count threshold and the shutdown time threshold;

[0151] The determination module 12 is used to determine the target block and the free block in each block based on the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold; wherein, the target block is the block containing cold data;

[0152] The migration module 13 is used to migrate the data in each target block to the corresponding idle block according to the migration priority of each target block after entering the idle mode.

[0153] In some embodiments, the acquisition module 11 includes:

[0154] The first acquisition submodule is used to acquire the total erase count and the total number of blocks;

[0155] The first determining submodule is used to determine the quotient of the total erase count and the total number of blocks, so as to determine the average erase count;

[0156] The first generation submodule is used to generate a first erase count threshold, a second erase count threshold, and a third erase count threshold based on the average erase count.

[0157] The first erase count threshold is less than the second erase count threshold, and the second erase count threshold is less than the third erase count threshold.

[0158] In some embodiments, the acquisition module 11 includes:

[0159] The second acquisition submodule is used to obtain the total shutdown time and the number of valid blocks; where valid blocks are readable and writable blocks.

[0160] The second determining submodule is used to determine the quotient of the total shutdown time and the number of valid blocks, in order to determine the average shutdown time;

[0161] The second generation submodule is used to generate a first shutdown time threshold, a second shutdown time threshold, and a third shutdown time threshold based on the average shutdown time.

[0162] Among them, the first closing time threshold is less than the second closing time threshold, and the second closing time threshold is less than the third closing time threshold.

[0163] In some embodiments, the determining module 12 includes:

[0164] The third determination submodule is used to determine the candidate blocks that have reached the capacity limit among the blocks;

[0165] The fourth determination submodule is used to determine the erase count and shutdown time of the candidate blocks;

[0166] The fifth determination submodule is used to determine the candidate block as the first target block when the erase count of the candidate block is not greater than the first erase count threshold, the closing time of the candidate block is not less than the first closing time threshold, and less than the second closing time threshold.

[0167] The first storage submodule is used to put the first target block into the first queue;

[0168] The sixth determination submodule is used to determine the candidate block as the second target block when the erase count of the candidate block is greater than the first erase count threshold and not greater than the second erase count threshold, and the closing time of the candidate block is not less than the second closing time threshold and less than the third closing time threshold.

[0169] The second storage submodule is used to put the second target block into the second queue;

[0170] The seventh determination submodule is used to determine the candidate block as the third target block when the erase count of the candidate block is greater than the second erase count threshold and not greater than the third erase count threshold, and the closing time of the candidate block is not less than the third closing time threshold.

[0171] The third storage submodule is used to put the third target block into the third queue.

[0172] In some embodiments, the determining module 12 includes:

[0173] The traversal submodule is used to iterate through the erase count and close time in each block;

[0174] The eighth determination submodule is used to determine blocks whose corresponding erase count is greater than the third erase count threshold and whose corresponding shutdown time is less than the first shutdown time threshold as free blocks.

[0175] In some embodiments, the migration module 13 includes:

[0176] The settings submodule is used to set the power consumption value for performing wear leveling in idle mode;

[0177] The ninth determination submodule is used to determine the priority order of the first queue, the second queue, and the third queue; wherein the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue.

[0178] The write module is used to write the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue into the corresponding free blocks according to priority order and power consumption value.

[0179] In some embodiments, the migration module 13 includes:

[0180] The third acquisition submodule is used to acquire the pre-set first bandwidth speed, second bandwidth speed and third bandwidth speed;

[0181] The first migration submodule is used to migrate the data of the first target block in the first queue to the corresponding free block using the first bandwidth speed;

[0182] The second migration submodule is used to migrate the data of the second target block in the second queue to the corresponding free block using the second bandwidth speed;

[0183] The third migration submodule is used to migrate the data of the third target block in the third queue to the corresponding free block using the third bandwidth speed.

[0184] Among them, the first bandwidth speed is less than the second bandwidth speed, and the second bandwidth speed is less than the third bandwidth speed.

[0185] In some embodiments, it also includes:

[0186] The first judgment module is used to determine whether data migration of the target block is currently being performed when a read or write command is received; if it is confirmed that data migration of the target block is being performed, the bandwidth speed of the data migration of the target block is reduced.

[0187] The second judgment module is used to determine whether the data migration of the target block is complete; if it is confirmed that the data migration of the target block is complete, the data migration process is stopped.

[0188] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.

[0189] In addition, the present invention also provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the steps of the wear leveling processing method described above.

[0190] Figure 3 This is a schematic diagram of a wear leveling treatment device provided in an embodiment of the present invention. Figure 3 As shown, the wear leveling treatment equipment includes:

[0191] Memory 20 is used to store computer programs;

[0192] The processor 21 is used to implement the steps of the wear leveling processing method mentioned in the above embodiments when executing a computer program.

[0193] The wear leveling device provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.

[0194] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array. The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.

[0195] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the wear leveling processing method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the wear leveling processing method.

[0196] In some embodiments, the wear leveling device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.

[0197] Those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the wear leveling equipment and may include more or fewer components than shown.

[0198] Finally, the present invention also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the steps described in the above method embodiments.

[0199] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present 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 storage medium and executes all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0200] The above provides a detailed description of the wear leveling method, apparatus, device, and medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the invention, and these improvements and modifications also fall within the protection scope of the present invention.

[0201] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A wear leveling treatment method, characterized in that, Applied to solid-state drives; the method includes: Scan each block and calculate the erase count and shutdown time for each block; the shutdown time is the time required for a block to transition from a used state to an idle state. Obtain the erase count threshold and the off time threshold; Based on the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold, target blocks and idle blocks are determined in each block; wherein, the target block is a block containing cold data; After entering idle mode, the data in each target block is migrated to the corresponding idle block according to the migration priority of each target block; Obtaining the erase count threshold includes: Get the total erase count and the total number of blocks; The average erase count is determined by the quotient of the total erase count and the total number of blocks. A first erase count threshold, a second erase count threshold, and a third erase count threshold are generated based on the average erase count. Wherein, the first erase count threshold is less than the second erase count threshold, and the second erase count threshold is less than the third erase count threshold; Obtaining the shutdown time threshold includes: Obtain the total shutdown time and the number of valid blocks; wherein, the valid blocks are readable and writable blocks; The quotient of the total shutdown time and the number of valid blocks is determined to determine the average shutdown time; A first shutdown time threshold, a second shutdown time threshold, and a third shutdown time threshold are generated based on the average shutdown time. Wherein, the first shutdown time threshold is less than the second shutdown time threshold, and the second shutdown time threshold is less than the third shutdown time threshold; during the operation of the solid-state drive, each of the erase count thresholds and each of the shutdown time thresholds change dynamically in real time.

2. The wear equalization treatment method according to claim 1, characterized in that, The target block is determined in each block based on the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold, including: Identify the candidate blocks that have reached their capacity limits from among the existing blocks; Determine the erase count and the shutdown time of the candidate block; When the erase count of the candidate block is not greater than the first erase count threshold, and the shutdown time of the candidate block is not less than the first shutdown time threshold and less than the second shutdown time threshold, the candidate block is determined to be the first target block; Place the first target block into the first queue; When the erase count of the candidate block is greater than the first erase count threshold and not greater than the second erase count threshold, and the shutdown time of the candidate block is not less than the second shutdown time threshold and less than the third shutdown time threshold, the candidate block is determined to be the second target block; Place the second target block into the second queue; When the erase count of the candidate block is greater than the second erase count threshold and not greater than the third erase count threshold, and the shutdown time of the candidate block is not less than the third shutdown time threshold, the candidate block is determined to be the third target block; The third target block is placed into the third queue.

3. The wear equalization treatment method according to claim 2, characterized in that, The free blocks are determined in each block based on the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold, including: Iterate through the erase count and the shutdown time in each block; The blocks whose erase count is greater than the third erase count threshold and whose shutdown time is less than the first shutdown time threshold are identified as the free blocks.

4. The wear equalization treatment method according to claim 2, characterized in that, Based on the migration priority corresponding to each target block, the data in each target block is migrated to the corresponding free block, including: Set the power consumption value for performing wear leveling in the idle mode; Determine the priority order of the first queue, the second queue, and the third queue; wherein the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue; According to the priority order and the power consumption value, the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue are sequentially written into each of the free blocks.

5. The wear equalization treatment method according to claim 4, characterized in that, Migrating data from each of the target blocks to the corresponding free blocks includes: Obtain the pre-set first bandwidth speed, second bandwidth speed, and third bandwidth speed; The data of the first target block in the first queue is migrated to the corresponding free block using the first bandwidth speed; The data of the second target block in the second queue is migrated to the corresponding free block using the second bandwidth speed; The data of the third target block in the third queue is migrated to the corresponding free block using the third bandwidth speed; Wherein, the first bandwidth speed is less than the second bandwidth speed, and the second bandwidth speed is less than the third bandwidth speed.

6. The wear equalization treatment method according to any one of claims 1 to 5, characterized in that, Also includes: When a read / write command is received, it is determined whether data migration of the target block is currently being performed; If it is confirmed that a data migration to the target block is being performed, reduce the bandwidth speed for performing the data migration to the target block; Determine whether the data migration of the target block is complete; If the data migration of the target block is confirmed to be complete, the data migration process is stopped.

7. A wear equalization treatment device, characterized in that, Applied to solid-state drives; the device includes: The scanning calculation module is used to scan each block and calculate the erase count and shutdown time of each block; the shutdown time is the time required for a block to transition from a used state to an idle state. The acquisition module is used to obtain the erase count threshold and the shutdown time threshold; The determination module is used to determine target blocks and free blocks in each block based on the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold; wherein, the target block is a block containing cold data; The migration module is used to migrate the data in each target block to the corresponding idle block according to the migration priority corresponding to each target block after entering the idle mode; The acquisition module includes: The first acquisition submodule is used to acquire the total erase count and the total number of blocks; The first determining submodule is used to determine the quotient of the total erase count and the total number of blocks, so as to determine the average erase count; The first generation submodule is used to generate a first erase count threshold, a second erase count threshold, and a third erase count threshold based on the average erase count. Wherein, the first erase count threshold is less than the second erase count threshold, and the second erase count threshold is less than the third erase count threshold; The second acquisition submodule is used to acquire the total shutdown time and the number of valid blocks; wherein, the valid blocks are readable and writable blocks; The second determining submodule is used to determine the quotient of the total shutdown time and the number of valid blocks, so as to determine the average shutdown time; The second generation submodule is used to generate a first shutdown time threshold, a second shutdown time threshold, and a third shutdown time threshold based on the average shutdown time. Wherein, the first shutdown time threshold is less than the second shutdown time threshold, and the second shutdown time threshold is less than the third shutdown time threshold; during the operation of the solid-state drive, each of the erase count thresholds and each of the shutdown time thresholds change dynamically in real time.

8. A wear leveling treatment device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the wear leveling processing method as described in any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the wear leveling processing method as described in any one of claims 1 to 6.