A method, system, medium and program product for wear leveling of bad blocks of a solid state hard disk

By dividing the storage area of ​​the solid-state drive into sub-regions and establishing a data block rotation link, periodically migrating the broken blocks to areas with low wear levels, the problem of shortening the service life of the solid-state drive is solved, and load balancing and efficient utilization of spare blocks are achieved.

CN119576246BActive Publication Date: 2025-05-13SHENZHEN QINGFEN TINGXIU INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510112792.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-05-13
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

The service life of solid-state drives is shortened due to the generation of bad blocks and uneven wear, and the prior art is difficult to effectively solve this problem.

Method used

By dividing the storage area of ​​the solid-state drive into sub-regions and generating a sub-region distribution table, establishing a data block rotation link and mapping relationship, periodically performing data block rotation operations, and timely migrating the broken blocks to areas with lower wear levels.

Benefits of technology

It realizes partition management and load balancing of storage blocks, extends the service life of solid-state drives, improves the utilization efficiency of spare blocks, and reduces the risk of bad blocks diffusion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576246B_ABST
    Figure CN119576246B_ABST
Patent Text Reader

Abstract

A method, system, medium and program product for wear leveling of bad blocks of a solid-state hard disk, relating to the field of electronic digital data processing, wherein the storage area of ​​a solid-state hard disk is divided into several sub-areas, and a sub-area distribution table is generated; a data block rotation link is established in each sub-area based on the sub-area distribution table and recorded as a rotation sequence table; a data block rotation operation is performed according to a preset cycle, and the wear status of each sub-area is recorded; when a new bad block is detected, the sub-area containing the bad block is marked as a source area to be migrated in the sub-area distribution table; a target area is determined from other sub-areas according to the number of bad blocks and the wear status recorded in the sub-area distribution table, and a mapping relationship between the source area to be migrated and the target area is established; based on the mapping relationship and the rotation sequence table, the data in the sub-area to be migrated is migrated to the target area in the order in the rotation sequence table. The present application improves the utilization efficiency of spare blocks, thereby extending the service life of the solid-state hard disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of electronic digital data processing, and in particular, relates to a method, system, medium and program product for wear leveling of bad blocks of a solid state hard disk. Background Art

[0002] Solid-state drives (SSDs) are a new generation of storage devices that have faster read and write speeds and higher reliability than traditional mechanical hard drives. However, since NAND flash memory cells have a limited number of erase and write cycles, frequent data writes to the same area will cause excessive wear of the area, thereby reducing the service life of the SSD. When bad blocks appear in certain storage areas, if there is no appropriate wear leveling strategy, it will increase the usage burden of other normal areas, further shortening the service life of the SSD.

[0003] In the related art, a spare block area is usually set in the solid-state drive. When a storage block is detected to be a bad block, the bad block is mapped to a good block in the spare block area, and wear leveling is achieved by dynamically allocating write operations to different physical blocks. The problem of excessive wear in local areas is alleviated to a certain extent by replacing spare blocks and dynamically allocating writes.

[0004] However, as the use time of SSDs increases, the generation of bad blocks often shows a certain spatial correlation, that is, after a storage block becomes a bad block, its surrounding area may be subjected to similar usage pressure and is likely to become a bad block in the subsequent process, thereby reducing the utilization efficiency of the spare blocks and shortening the service life of the SSD. Summary of the invention

[0005] The present application provides a method, system, medium and program product for wear leveling of bad blocks of a solid state drive, which are used to improve the utilization efficiency of spare blocks and thus extend the service life of the solid state drive.

[0006] In a first aspect, the present application provides a method for wear leveling of bad blocks of a solid state drive, which divides a storage area of ​​the solid state drive into a plurality of sub-areas and generates a sub-area distribution table, wherein each sub-area includes a preset number of storage blocks and corresponding local spare blocks;

[0007] Based on the sub-area distribution table, a data block rotation link is established in each sub-area and recorded as a rotation sequence table;

[0008] Perform data block rotation operations according to a preset period and record the wear status of each sub-area;

[0009] When a new bad block is detected, the sub-region containing the bad block is marked as a source region to be migrated in the sub-region distribution table;

[0010] According to the number of bad blocks and wear status recorded in the sub-region distribution table, a sub-region with the smallest cumulative wear value is selected from other sub-regions except the sub-region containing the bad blocks as the target region, and a mapping relationship between the source region to be migrated and the target region is established;

[0011] Based on the mapping relationship and the rotation sequence table, the data in the sub-area to be migrated is migrated to the target area according to the order in the rotation sequence table.

[0012] By adopting the above technical solution, the storage area of ​​the solid-state hard disk is divided into sub-areas and a sub-area distribution table is established, so that the partition management of the storage block can be realized, so that each sub-area has an independent local spare block resource. By establishing a data block rotation link in the sub-area and performing periodic rotation operations, the usage load of the storage block can be balanced. When a new bad block is detected, the optimal target area is selected for data migration based on the number of bad blocks and the wear status recorded in the sub-area distribution table, avoiding migrating data to an area with a higher degree of wear. By establishing a mapping relationship between the source area to be migrated and the target area, and migrating data in the order of the rotation sequence table, the continuity of the access mode during the data migration process is improved, the impact of data migration on system performance is reduced, the risk of bad block diffusion is reduced, and the utilization efficiency of spare blocks is improved, thereby extending the service life of the solid-state hard disk.

[0013] In combination with some embodiments of the first aspect, in some embodiments, the storage area of ​​the solid state drive is divided into a plurality of sub-areas, and a sub-area distribution table is generated, specifically including:

[0014] Dividing the storage area of ​​the solid state drive into a plurality of pre-divided sub-areas based on the physical distribution characteristics of the storage blocks;

[0015] Perform cluster analysis on the pre-divided sub-regions and calculate the access frequency and data update rate of the storage blocks in each pre-divided sub-region;

[0016] Reorganize the pre-divided sub-regions according to the access frequency and data update rate, and merge the pre-divided sub-regions with the same access pattern into the target sub-region;

[0017] Allocate local spare blocks to each target sub-region, and the number of local spare blocks is positively correlated with the data update rate of the target sub-region;

[0018] A sub-region distribution table is generated according to the boundary information of the target sub-region and the local spare block allocation result.

[0019] By adopting the above technical solution, pre-division is performed based on the physical distribution characteristics of the storage blocks, and the access frequency and data update rate are calculated through cluster analysis, so that the storage blocks with the same access mode are merged into the same sub-region. By allocating local spare blocks to each sub-region according to the data update rate, the on-demand allocation of spare resources is realized. This regional division method based on access characteristics allows storage blocks with similar access patterns to be centrally managed, reducing the probability of cross-regional data access and migration. The positive correlation allocation method of the number of local spare blocks and the data update rate enables areas with frequent updates to obtain more spare resources, reduces local wear caused by frequent updates, improves the utilization efficiency of storage resources, and extends the service life of the solid-state drive.

[0020] In combination with some embodiments of the first aspect, in some embodiments, establishing a data block rotation link in each sub-area based on the sub-area distribution table and recording it as a rotation sequence table specifically includes:

[0021] Count the number of accesses and the most recent access time of the storage blocks in each sub-area within a preset time window;

[0022] The storage blocks in each sub-area are divided into high-frequency access blocks, medium-frequency access blocks and low-frequency access blocks according to the number of accesses and the most recent access time;

[0023] A data block rotation link is constructed in each sub-area, and a high-frequency access block, a medium-frequency access block and a low-frequency access block respectively form independent ring sub-links in the data block rotation link;

[0024] Setting up data block exchange paths between ring sub-links;

[0025] When the access characteristics of a storage block change, the storage block is migrated to a corresponding level of the ring sub-link through the data block exchange path;

[0026] Calculate the rotation interval of each ring sub-link, where the rotation interval is inversely proportional to the average number of accesses to the storage block in the ring sub-link;

[0027] The structural information of the data block rotation link, the data block exchange path and the rotation interval time are recorded in the rotation sequence table.

[0028] By adopting the above technical solution, the number of accesses and the most recent access time of the storage blocks are counted, the storage blocks are divided into different access frequency levels, and independent ring sub-links are constructed within each level. A data block exchange path is set between the ring sub-links, so that the storage blocks can dynamically adjust their frequency levels according to changes in access characteristics. The design of the rotation interval time being inversely proportional to the average number of accesses allows storage blocks with high access frequencies to obtain more frequent rotation opportunities, achieving refined balancing of access loads and reducing the wear of high-frequency access storage blocks. By dynamically adjusting the frequency level to which the storage blocks belong, the system can adapt to changes in data access patterns and achieve the effect of wear leveling while ensuring access performance.

[0029] In combination with some embodiments of the first aspect, in some embodiments, after migrating the data in the sub-area to be migrated to the target area in the order in the rotation sequence table based on the mapping relationship and the rotation sequence table, the method further includes:

[0030] Combine the original data blocks in the target area with the migrated data blocks and number them, regenerate the rotation link of the target area, and update the rotation sequence table of the target area;

[0031] Mark the remaining normal storage blocks in the source area to be migrated as global spare blocks, and record the physical location information and wear value of the global spare blocks;

[0032] Count the historical migration records of each sub-region in the sub-region distribution table;

[0033] Mark the sub-regions with continuous migration relationships in the historical migration records as migration association groups to obtain a regional grouping information table;

[0034] Calculate the average wear value of the storage blocks in each sub-region, and determine the wear leveling coefficient of each sub-region in combination with the migration association group mark in the sub-region grouping information table;

[0035] Generate a rotation rate adjustment factor for each sub-area based on the wear leveling coefficient, where the adjustment factor is inversely proportional to the wear leveling coefficient;

[0036] Update the rotation time interval in the rotation sequence table of each sub-area according to the adjustment factor;

[0037] When the number of global spare blocks reaches a preset number, the current storage capacity and average wear value of each sub-area are calculated;

[0038] According to the capacity utilization rate and wear leveling requirements of each sub-area, the global spare blocks are allocated according to the reverse balance principle;

[0039] The sub-region distribution table is regenerated based on the spare block allocation result, and the rotation sequence table of each sub-region is adjusted.

[0040] By adopting the above technical solution, the original data blocks and the migrated data blocks in the target area are merged to reorganize the rotation link, and the remaining normal storage blocks in the source area to be migrated are marked as global spare blocks, thereby realizing dynamic adjustment of storage resources. Based on the historical migration records, the regional groups with continuous migration relationships are identified, and the wear leveling coefficient is calculated in combination with the average wear value, and the rotation rate adjustment factor is generated to optimize the rotation time interval. When a sufficient number of global spare blocks are accumulated, the system performs reverse balancing allocation according to the capacity utilization rate and wear leveling requirements of each area, so that the system can achieve a wider range of wear leveling at the regional level. By dynamically adjusting the rotation parameters and spare resource allocation, the system's responsiveness and correction effect to uneven wear are improved.

[0041] In combination with some embodiments of the first aspect, in some embodiments, generating a rotation rate adjustment factor of each sub-region based on the wear leveling coefficient specifically includes:

[0042] Calculate the standard deviation of the storage block wear value in each sub-region;

[0043] Perform weighted correction on the wear leveling coefficient according to the standard deviation to obtain the correction coefficient;

[0044] Calculate an initial adjustment factor of the rotation rate based on the correction factor, where the initial adjustment factor is inversely proportional to the correction factor;

[0045] Count the bad block growth rate of each sub-area within a preset time period, and use the bad block growth rate as a risk factor;

[0046] The initial adjustment factor is multiplied by the risk factor to obtain the rotation rate adjustment factor.

[0047] By adopting the above technical solution, the standard deviation is used to perform weighted correction on the wear leveling coefficient, so that the correction coefficient can take into account both the overall wear level of the region and the internal wear distribution state. When the wear distribution within the region is uneven and the bad blocks grow rapidly, increasing the data block rotation rate by a larger adjustment factor can speed up the wear leveling process and reduce the risk of new bad blocks; conversely, when the wear distribution within the region is uniform and the bad blocks grow slowly, using a smaller adjustment factor to maintain a lower rotation rate can not only maintain the wear leveling state but also reduce unnecessary data migration overhead, thereby improving the efficiency and accuracy of wear leveling.

[0048] In combination with some embodiments of the first aspect, in some embodiments, before allocating the global spare blocks according to the reverse balancing principle based on the capacity utilization rate and wear leveling requirements of each sub-region, the method further includes:

[0049] Calculate the effective data density of each sub-region, where the effective data density is the ratio of non-free storage blocks in the sub-region;

[0050] Count the data update frequency of each sub-area;

[0051] Calculate the spare block requirement of each sub-area based on the effective data density and data update frequency;

[0052] According to the wear value corresponding to the global spare block and the preset wear value interval, the global spare block is divided into several wear levels;

[0053] The number quota of global spare blocks of different wear levels available to each sub-region is determined according to the spare block demand.

[0054] By adopting the above technical solution, the effective data density is combined with the data update frequency to calculate the spare block demand, so that the spare block allocation can take into account the storage pressure and data update load of the region at the same time, and can accurately reflect the actual demand intensity of each region for spare space. The global spare blocks are divided into levels according to the wear value interval, so that spare resources with different wear degrees can be fully utilized. The spare block quantity quota of each region at different wear levels is determined based on the spare block demand, so that the allocation of spare resources can not only meet the spare space quantity requirements of high-demand areas, but also promote wear balancing between regions through the reasonable matching of spare blocks of different wear levels. The spare space allocation strategy can be optimized according to the actual storage characteristics and operating status of each region, the utilization efficiency of spare block resources can be improved, and the differentiated allocation of wear levels can be used to assist in achieving more refined wear balancing control.

[0055] In combination with some embodiments of the first aspect, in some embodiments, determining the number quota of global spare blocks of different wear levels available to each sub-region according to the spare block demand specifically includes:

[0056] Count the number of global spare blocks at each wear level, and calculate the proportion of spare blocks at each wear level;

[0057] Calculate the initial allocation weight based on the spare block demand of each sub-area, where the initial allocation weight is proportional to the spare block demand;

[0058] The initial allocation weight is modified in combination with the current average wear value of each sub-area to obtain a modified allocation weight;

[0059] According to the modified allocation weight and the proportion of the number of spare blocks at each wear level, the number quota of global spare blocks obtained by each sub-region at each wear level is calculated.

[0060] By adopting the above technical solution, the initial allocation weight is calculated based on the spare block demand and corrected in combination with the average wear value of the region, so that the allocation weight can reflect the actual demand intensity and current wear status of the region for spare blocks. The specific quantity quota is calculated using the corrected allocation weight and the proportion of the number of spare blocks of each wear level, ensuring that the allocation of spare blocks meets both the resource supply situation and the demand side characteristics. When the spare block demand of a region is high and the average wear value is low, the region will obtain more spare block quotas with high wear levels; conversely, when the spare block demand of a region is low and the average wear value is high, the region will obtain more spare block quotas with low wear levels, realizing the reasonable allocation of spare resources. While meeting the spare space requirements of each region, the differentiated allocation of spare blocks of different wear levels is used to promote overall wear balancing, thereby improving the reliability and service life of the storage system.

[0061] In the second aspect, an embodiment of the present application provides a bad block wear leveling system for a solid-state hard disk, the bad block wear leveling system for a solid-state hard disk comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and one or more processors call the computer instructions to enable the system to execute the method described in the first aspect and any possible implementation method of the first aspect.

[0062] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a system, causes the system to execute the method described in the first aspect and any possible implementation of the first aspect.

[0063] In a fourth aspect, an embodiment of the present application provides a computer program product, characterized in that when the computer program product runs on a system, the system executes the method described in any possible implementation manner in the first aspect.

[0064] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0065] 1. The present application provides a method for wear leveling of bad blocks of a solid-state hard disk. The storage area of ​​the solid-state hard disk is divided into sub-areas and a sub-area distribution table is established, so that the partition management of the storage blocks can be realized, so that each sub-area has an independent local spare block resource. By establishing a data block rotation link in the sub-area and performing periodic rotation operations, the usage load of the storage block can be balanced. When a new bad block is detected, the optimal target area is selected for data migration based on the number of bad blocks and the wear status recorded in the sub-area distribution table, thereby avoiding migrating data to an area with a higher degree of wear. By establishing a mapping relationship between the source area to be migrated and the target area, and performing data migration in the order of the rotation sequence table, the continuity of the access mode during the data migration process is improved, the impact of data migration on system performance is reduced, the risk of bad block diffusion is reduced, and the utilization efficiency of spare blocks is improved, thereby extending the service life of the solid-state hard disk.

[0066] 2. The present application provides a method for wear leveling of bad blocks in a solid-state hard disk, which merges the original data blocks of the target area with the migrated data blocks to reorganize the rotation link, and marks the remaining normal storage blocks of the source area to be migrated as global spare blocks, thereby realizing dynamic adjustment of storage resources. Based on historical migration records, regional groups with continuous migration relationships are identified, and the wear leveling coefficient is calculated in combination with the average wear value, and a rotation rate adjustment factor is generated to optimize the rotation time interval. When a sufficient number of global spare blocks are accumulated, the system performs reverse balancing allocation according to the capacity utilization rate and wear leveling requirements of each area, so that the system can achieve a wider range of wear leveling at the regional level. By dynamically adjusting the rotation parameters and spare resource allocation, the system's responsiveness and correction effect to uneven wear are improved.

[0067] 3. The present application provides a wear leveling method for bad blocks of solid-state hard disks, which combines effective data density with data update frequency to calculate spare block demand, so that spare block allocation can take into account the storage pressure and data update load of the region at the same time, and can accurately reflect the actual demand intensity of each region for spare space. Global spare blocks are graded according to wear value intervals, so that spare resources with different degrees of wear can be fully utilized. The number quota of spare blocks for each region at different wear levels is determined based on the spare block demand, so that the allocation of spare resources can not only meet the number requirements of spare space in high-demand areas, but also promote wear leveling between regions through the reasonable matching of spare blocks of different wear levels. The spare space allocation strategy can be optimized according to the actual storage characteristics and operating status of each region, the utilization efficiency of spare block resources can be improved, and the differentiated allocation of wear levels can be used to assist in achieving more sophisticated wear leveling control. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] Figure 1 It is a flow chart of a method for wear leveling bad blocks of a solid state drive in an embodiment of the present application.

[0069] Figure 2 It is another flow chart of a method for wear leveling bad blocks of a solid state drive in an embodiment of the present application.

[0070] Figure 3 It is a schematic diagram of the physical device structure of a solid state drive bad block wear leveling system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0071] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations comprising one or more listed items.

[0072] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0073] The following uses an embodiment and combines Figure 1 , a method for wear leveling bad blocks of a solid state drive in an embodiment of the present application is described:

[0074] See also Figure 1 , is a flow chart of a method for wear leveling bad blocks of a solid state drive in an embodiment of the present application.

[0075] S101, dividing the storage area of ​​the solid state drive into a plurality of sub-areas, and generating a sub-area distribution table;

[0076] The system divides the storage area of ​​the solid-state drive into several sub-areas and generates a sub-area distribution table, each of which contains a preset number of storage blocks and corresponding local spare blocks. Specifically: the storage area of ​​the solid-state drive is divided into several pre-divided sub-areas based on the physical distribution characteristics of the storage blocks;

[0077] Perform cluster analysis on the pre-divided sub-regions and calculate the access frequency and data update rate of the storage blocks in each pre-divided sub-region;

[0078] Reorganize the pre-divided sub-regions according to the access frequency and data update rate, and merge the pre-divided sub-regions with the same access pattern into the target sub-region;

[0079] Allocate local spare blocks to each target sub-region, and the number of local spare blocks is positively correlated with the data update rate of the target sub-region;

[0080] A sub-region distribution table is generated according to the boundary information of the target sub-region and the local spare block allocation result.

[0081] This step divides and manages the storage area of ​​the solid-state drive. The system first divides the storage area of ​​the solid-state drive into multiple pre-divided sub-areas based on the physical distribution characteristics of the storage blocks. Then, the system performs cluster analysis on these pre-divided sub-areas and calculates the access frequency and data update rate of the storage blocks in each pre-divided sub-area. Next, the system reorganizes the pre-divided sub-areas according to the access frequency and data update rate, and merges the pre-divided sub-areas with similar access patterns into target sub-areas. Finally, the system allocates local spare blocks to each target sub-area, and the number of local spare blocks is proportional to the data update rate of the target sub-area, and generates a sub-area distribution table based on the boundary information of the target sub-area and the allocation results of the local spare blocks.

[0082] When dividing sub-areas, the system can adopt a variety of specific methods. For example, the system can divide based on the physical address range of the storage block, the capacity of the storage block, the data type of the storage block, and other characteristics. When performing cluster analysis, the system can use machine learning methods such as the K-means clustering algorithm and the hierarchical clustering algorithm to cluster the pre-divided sub-areas according to the access frequency and data update rate of the storage block, and classify the pre-divided sub-areas with similar access patterns into one category. When allocating local spare blocks, the system can set a threshold. When the data update rate of the target sub-area exceeds the threshold, the system allocates more local spare blocks to the target sub-area to cope with frequent data update operations.

[0083] In the process of generating the sub-region distribution table, the system may encounter the problem of insufficient storage capacity. To solve this problem, the system can dynamically adjust the size and number of sub-regions. When the system detects that the storage capacity of a sub-region is insufficient, it can merge the sub-region with the adjacent sub-region, or borrow storage space from other sub-regions. At the same time, the system can also dynamically adjust the granularity of sub-region division according to the usage of the solid-state drive. During periods of frequent data access, the system can divide the storage area into more sub-regions to improve the concurrency of data access; and during periods of less data access, the system can merge sub-regions to reduce management overhead.

[0084] S102, establishing a data block rotation link in each sub-area based on the sub-area distribution table and recording it as a rotation sequence table;

[0085] Based on the sub-area distribution table, the system establishes a data block rotation link in each sub-area and records it as a rotation sequence table, which specifically includes:

[0086] Count the number of accesses and the most recent access time of the storage blocks in each sub-area within a preset time window;

[0087] The storage blocks in each sub-area are divided into high-frequency access blocks, medium-frequency access blocks and low-frequency access blocks according to the number of accesses and the most recent access time;

[0088] A data block rotation link is constructed in each sub-area, and a high-frequency access block, a medium-frequency access block and a low-frequency access block respectively form independent ring sub-links in the data block rotation link;

[0089] Setting up data block exchange paths between ring sub-links;

[0090] When the access characteristics of a storage block change, the storage block is migrated to a corresponding level of the ring sub-link through the data block exchange path;

[0091] Calculate the rotation interval of each ring sub-link, where the rotation interval is inversely proportional to the average number of accesses to the storage block in the ring sub-link;

[0092] The structural information of the data block rotation link, the data block exchange path and the rotation interval time are recorded in the rotation sequence table.

[0093] This step establishes a data block rotation link in each sub-area to manage and optimize the access order of data blocks. The system first counts the number of accesses and the most recent access time of the storage blocks in each sub-area within the preset time window. Then, the system divides the storage blocks in each sub-area into high-frequency access blocks, medium-frequency access blocks and low-frequency access blocks according to the number of accesses and the most recent access time. Next, the system constructs a data block rotation link in each sub-area, and the high-frequency access blocks, medium-frequency access blocks and low-frequency access blocks form independent ring sub-links in the data block rotation link. The system also sets up a data block exchange path between the ring sub-links. When the access characteristics of the storage block change, the storage block can be migrated to the corresponding level of the ring sub-link through the data block exchange path. Finally, the system calculates the rotation interval time of each ring sub-link, and the rotation interval time is inversely proportional to the average number of accesses to the storage block in the ring sub-link, and records the structural information of the data block rotation link, the data block exchange path and the rotation interval time in the rotation sequence table.

[0094] When establishing a data block rotation link, the system can use a variety of specific technologies. For example, the system can use data structures such as linked lists and circular queues to implement circular sub-links. When setting up data block exchange paths, the system can use pointers, indexes, and other methods to establish associations between different circular sub-links. When calculating the rotation interval, the system can use algorithms such as weighted average and exponential smoothing to dynamically adjust the rotation interval based on the historical access situation of the storage block to adapt to changes in data access patterns.

[0095] In the process of establishing the data block rotation link, the system may encounter the problem of link breakage. To solve this problem, the system can introduce a redundancy mechanism and set up multiple backup links for each ring sub-link. When a ring sub-link breaks, the system can automatically switch to the backup link to ensure the integrity of the data block rotation link. At the same time, the system can also regularly check and repair the data block rotation link to promptly discover and resolve abnormal situations in the link.

[0096] S103, performing a data block rotation operation according to a preset period, and recording a wear state of each sub-area;

[0097] The system rotates the data blocks of each sub-area in each preset cycle according to the information in the rotation sequence table. Through regular data block rotation, the access frequency and wear degree of each storage block can be balanced, extending the service life of the solid-state drive. While performing the rotation operation, the system will monitor and record the wear status of each sub-area in real time, including indicators such as the number of erases and writes and the number of bad blocks.

[0098] S104, when a new bad block is detected, the sub-region containing the bad block is marked as a source region to be migrated in the sub-region distribution table;

[0099] When the system detects a new bad block in the SSD, it will find the sub-region containing the bad block in the sub-region distribution table and mark it as the source region to be migrated. This mark indicates that the data in the sub-region needs to be migrated to other sub-regions to avoid the impact of the bad block on data reliability.

[0100] S105, selecting a sub-region with the smallest cumulative wear value from other sub-regions except the sub-region containing the bad blocks as the target region according to the number of bad blocks and the wear status recorded in the sub-region distribution table, and establishing a mapping relationship between the source region to be migrated and the target region;

[0101] After determining the source area to be migrated, the system will select a sub-area with the lowest wear level from other sub-areas as the target area for data migration. Specifically, the system first excludes the sub-areas containing bad blocks, then compares the accumulated wear values ​​of the remaining sub-areas, and selects the sub-area with the smallest wear value as the target area. Next, the system establishes a mapping relationship between the source area to be migrated and the target area to prepare for subsequent data migration.

[0102] When selecting a target area, the system can take into account multiple factors, such as the space utilization of the sub-area, I / O load, etc. For example, the system can give priority to sub-areas with lower space utilization and lighter I / O load as target areas to balance the resource usage of each sub-area. In addition, the system can also set a threshold. When the accumulated wear value of a sub-area exceeds the threshold, it will be marked as a high-risk area and data migration to the high-risk area will be avoided as much as possible.

[0103] S106: Based on the mapping relationship and the rotation sequence table, migrate the data in the sub-region to be migrated to the target region in the order in the rotation sequence table.

[0104] After the mapping relationship between the source area to be migrated and the target area is established, the system starts to perform data migration operations. The system copies the data in the sub-area to be migrated to the target area in sequence according to the order recorded in the rotation sequence table. By migrating in the order of the rotation sequence table, the access locality of the data can be maintained to the maximum extent, reducing the impact of data migration on system performance.

[0105] In the process of migrating data, the system can adopt a variety of optimization strategies. For example, the system can prioritize the migration of hot data with high access frequency and delay the migration of cold data with low access frequency based on the popularity information of the data block. In this way, the migration of hot data can be completed as soon as possible, improving the response speed of the system. In addition, the system can also use idle time to migrate data, such as performing migration operations when the system I / O load is low, to reduce the impact on normal business. At the same time, the system can adopt an incremental migration method, that is, only migrate the incremental data in the sub-area to be migrated, rather than a full copy, to shorten the migration time and reduce system overhead.

[0106] In the above embodiment, the solid state drive storage area is divided into sub-areas and a sub-area distribution table is established, so that the partition management of the storage block can be realized, so that each sub-area has an independent local spare block resource. A data block rotation link is established in the sub-area and a periodic rotation operation is performed, so that the usage load of the storage block can be balanced. When a new bad block is detected, the optimal target area is selected for data migration based on the number of bad blocks and the wear status recorded in the sub-area distribution table, thereby avoiding migrating data to an area with a higher degree of wear. By establishing a mapping relationship between the source area to be migrated and the target area, and performing data migration in the order of the rotation sequence table, the continuity of the access mode during the data migration process is improved, the impact of data migration on system performance is reduced, the risk of bad block diffusion is reduced, and the utilization efficiency of the spare block is improved, thereby extending the service life of the solid state drive.

[0107] The above embodiments have realized the basic bad block wear leveling function, but in order to further improve the wear leveling effect and the overall system performance, the present application also provides another optimized SSD bad block wear leveling method. After the data migration is completed, the method achieves more sophisticated wear leveling control by establishing a migration association group, dynamically adjusting the data block rotation rate, and reasonably allocating global spare blocks. Figure 2 , another SSD bad block wear leveling method in the embodiment of the present application is described:

[0108] See also Figure 2 , is another flow chart of a method for wear leveling bad blocks of a solid state drive in an embodiment of the present application.

[0109] S201, merge the original data blocks in the target area with the migrated data blocks, regenerate the rotation link of the target area, and update the rotation sequence table of the target area;

[0110] After completing the data migration, the system needs to reorganize and manage the target area. First, the system merges the original data blocks in the target area with the data blocks migrated from the source area to be migrated. By merging the numbers, the system can manage the two parts of the data blocks in a unified manner to avoid management difficulties caused by discontinuous numbers. Next, the system regenerates the rotation link of the target area based on the merged data blocks. Due to the introduction of new data blocks, the original rotation link may not meet the data access requirements, so it is necessary to rebuild the rotation link and optimize the access order of the data blocks. Finally, the system updates the rotation sequence table of the target area based on the newly generated rotation link to ensure that subsequent data block rotation operations can be performed in the latest order.

[0111] When merging numbers, the system can use a variety of methods, such as following the physical address order of the data blocks, the logical address order of the data blocks, etc. At the same time, the system can also consider the attribute information of the data blocks, such as the access frequency of the data blocks, the data type of the data blocks, etc., and organize the data blocks with similar attributes together to improve the efficiency of data access. When regenerating the rotation link, the system can use heuristic algorithms, machine learning algorithms and other methods to find the optimal data block access order based on the historical access pattern and current wear status of the data blocks. For example, the system can organize data blocks with similar access frequencies in the same rotation link to reduce the number of switches between data blocks.

[0112] S202, marking the remaining normal storage blocks in the source area to be migrated as global spare blocks, and recording the physical location information and wear value of the global spare blocks;

[0113] After completing data migration, there may still be some normal storage blocks that have not been migrated in the source area to be migrated. In order to make full use of these storage resources, the system marks these remaining normal storage blocks as global spare blocks. Global spare blocks can be used in any sub-area to replace bad blocks or expand storage space. While marking global spare blocks, the system also records the physical location information and current wear value of each global spare block. The physical location information includes the physical address range where the global spare block is located, and the wear value indicates the current wear degree of the global spare block.

[0114] When marking global spare blocks, the system can use data structures such as bitmaps and linked lists to manage global spare blocks. For example, the system can use a bitmap to identify the status of each storage block, and set the position corresponding to the normal storage block in the source area to be migrated to 1, indicating that it is a global spare block. When recording physical location information, the system can use physical address ranges, physical block numbers, etc. to indicate the location of global spare blocks. When recording wear values, the system can use indicators such as erase counts and bit error rates to measure the degree of wear of global spare blocks.

[0115] When using global spare blocks to replace bad blocks, the system may encounter the problem of insufficient spare blocks. To solve this problem, the system can set a minimum threshold for global spare blocks. When the number of global spare blocks is lower than the threshold, the system can select a part of storage blocks from sub-areas with less wear and mark them as global spare blocks to ensure the adequacy of global spare blocks. At the same time, the system can also dynamically adjust the allocation strategy of global spare blocks according to the distribution of bad blocks. For example, for sub-areas with frequent bad blocks, the system can give priority to allocating replacement blocks from global spare blocks; and for sub-areas with fewer bad blocks, the system can reduce the allocation of global spare blocks to improve the utilization of storage space.

[0116] S203, counting the historical migration records of each sub-region in the sub-region distribution table;

[0117] In order to better understand the data migration between sub-areas, the system needs to count the historical migration records in the sub-area distribution table. The historical migration records include the source area, target area, migration time and other information of each data migration. By analyzing the historical migration records, the system can find the migration rules and correlations between sub-areas, providing a basis for subsequent wear leveling control.

[0118] S204, marking the sub-regions with continuous migration relationships in the historical migration records as migration association groups, and obtaining a region grouping information table;

[0119] Based on the statistical results of historical migration records, the system can find that there is frequent data migration between certain sub-areas. If the number of data migrations between two sub-areas exceeds the preset threshold and the migration direction is continuous (that is, the data in area A is always migrated to area B), the system will mark the two sub-areas as a migration association group. The migration association group indicates that these sub-areas have a close association relationship during the data migration process and require unified wear leveling control.

[0120] When marking migration association groups, the system can use graph theory algorithms to treat sub-regions as nodes in the graph and continuous migration relationships as directed edges. By analyzing the connectivity and strong connected components of the graph, migration association groups can be identified. For example, the system can use the Kosaraju algorithm or the Tarjan algorithm to find the strong connected components in the graph, and each strong connected component is a migration association group. After obtaining the migration association group, the system will generate a region grouping information table to record the sub-region numbers contained in each migration association group.

[0121] S205, calculating the average wear value of the storage blocks in each sub-region, and determining the wear leveling coefficient of each sub-region in combination with the migration association group mark in the sub-region grouping information table;

[0122] After obtaining the regional grouping information table, the system needs to evaluate the wear leveling of each sub-region in order to perform targeted wear leveling control. First, the system calculates the average wear value of the storage blocks inside each sub-region as an indicator to measure the overall wear degree of the sub-region. The higher the average wear value, the more serious the wear inside the sub-region.

[0123] Next, the system determines the wear leveling coefficient of each sub-region in combination with the migration association group mark in the region grouping information table. The wear leveling coefficient indicates the priority and control intensity of the sub-region in the wear leveling process. Specifically, if a sub-region belongs to a migration association group and the average wear value of the sub-region is higher than that of other sub-regions in the migration association group, the system will assign a higher wear leveling coefficient to the sub-region, indicating that the sub-region needs to prioritize wear leveling control and increase the wear leveling intensity. On the contrary, if the average wear value of a sub-region is lower than that of other sub-regions in the same group, or the sub-region does not belong to any migration association group, the system will assign a lower wear leveling coefficient to it, indicating that the wear leveling priority of the sub-region is lower.

[0124] When determining the wear leveling coefficient, the system can use a variety of calculation methods, such as weighted average method, proportional scaling method, etc. For example, the system can compare the average wear value of the sub-region with the average wear value of other sub-regions in the migration association group to calculate the wear difference; then, according to the size of the wear difference, linear scaling is performed to obtain the wear leveling coefficient. In addition, the system can also introduce other influencing factors, such as the capacity size of the sub-region, the data type of the sub-region, etc., and obtain a more reasonable wear leveling coefficient by comprehensively considering multiple factors.

[0125] S206, generating a rotation rate adjustment factor for each sub-region based on the wear leveling coefficient;

[0126] The system generates a rotation rate adjustment factor for each sub-area based on the wear leveling coefficient. The adjustment factor is inversely proportional to the wear leveling coefficient, including:

[0127] Calculate the standard deviation of the storage block wear value in each sub-region;

[0128] Perform weighted correction on the wear leveling coefficient according to the standard deviation to obtain the correction coefficient;

[0129] Calculate an initial adjustment factor of the rotation rate based on the correction factor, where the initial adjustment factor is inversely proportional to the correction factor;

[0130] Count the bad block growth rate of each sub-area within a preset time period, and use the bad block growth rate as a risk factor;

[0131] The initial adjustment factor is multiplied by the risk factor to obtain the rotation rate adjustment factor.

[0132] The system generates a rotation rate adjustment factor for each sub-region based on the wear leveling coefficient. The rotation rate adjustment factor indicates the frequency and priority of the data block rotation operation of the sub-region. The adjustment factor is inversely proportional to the wear leveling coefficient, that is, the sub-region with a higher wear leveling coefficient has a lower rotation rate adjustment factor, indicating that the frequency of the data block rotation operation of the sub-region should be reduced to slow down the wear rate.

[0133] When generating the rotation rate adjustment factor, the system first calculates the standard deviation of the storage block wear value in each sub-region. The standard deviation indicates the degree of dispersion of the storage block wear within the sub-region. The larger the standard deviation, the greater the wear difference within the sub-region, and the more frequent data block rotation operations are required to balance the wear within the sub-region. Next, the system performs a weighted correction on the wear leveling coefficient based on the wear leveling coefficient and the standard deviation to obtain the corrected wear leveling coefficient. The corrected wear leveling coefficient comprehensively considers the influencing factors of the wear difference within the sub-region and the wear difference between sub-regions.

[0134] Then, the system calculates the initial adjustment factor of the rotation rate based on the corrected wear leveling coefficient. The initial adjustment factor is inversely proportional to the corrected wear leveling coefficient, that is, the higher the corrected wear leveling coefficient, the lower the initial adjustment factor of the rotation rate. Finally, the system dynamically adjusts the initial adjustment factor of the rotation rate based on the real-time wear status of the sub-area. The system counts the bad block growth rate of each sub-area within a preset time period, uses the bad block growth rate as a risk factor, and multiplies it by the initial adjustment factor of the rotation rate to obtain the final rotation rate adjustment factor. The higher the risk factor, the greater the wear risk of the sub-area, and the rotation rate needs to be further reduced.

[0135] S207, updating the rotation time interval in the rotation sequence table of each sub-area according to the adjustment factor;

[0136] After obtaining the rotation rate adjustment factor of each sub-region, the system updates the rotation time interval in the rotation sequence table according to the adjustment factor. The rotation time interval represents the time interval between two data block rotation operations. The smaller the rotation rate adjustment factor, the lower the frequency of data block rotation operations in the sub-region, and the corresponding rotation time interval should be larger.

[0137] S208, when the number of global spare blocks reaches a preset number, calculating the current storage capacity and average wear value of each sub-region;

[0138] As bad blocks continue to appear, the number of global spare blocks will gradually decrease. When the number of global spare blocks reaches the preset lower limit, the system needs to evaluate the storage capacity and wear status of each sub-area in order to reasonably allocate global spare blocks.

[0139] The system first counts the current storage capacity of each sub-region, including the used storage space and the remaining storage space. Then, the system calculates the average wear value of each sub-region as an indicator to measure the degree of wear of the sub-region. The higher the average wear value, the more serious the wear of the sub-region, and more spare blocks are needed to maintain data reliability.

[0140] S209, allocating the global spare blocks according to the reverse balancing principle based on the capacity utilization rate and wear leveling requirements of each sub-region;

[0141] After obtaining the storage capacity and average wear value of each sub-region, the system allocates global spare blocks to each sub-region based on these two indicators. The allocation of global spare blocks follows the reverse balance principle, that is, the sub-region with higher storage capacity utilization and lower average wear value should be allocated more global spare blocks. This allocation strategy can balance the wear differences between sub-regions and prevent some sub-regions from wearing too quickly, while also meeting the storage capacity requirements of the sub-regions.

[0142] Specifically, the system first calculates the capacity utilization rate and wear leveling requirement value of each sub-region. The higher the capacity utilization rate, the less remaining storage space in the sub-region, and more spare blocks are needed to expand the storage capacity. The wear leveling requirement value comprehensively considers the average wear value and wear leveling coefficient of the sub-region. The lower the wear leveling requirement value, the more serious the wear of the sub-region, and more spare blocks are needed to balance the wear.

[0143] Then, the system calculates the number of global spare blocks that should be allocated to each sub-area based on the capacity utilization rate and the wear leveling requirement value. The calculation formula can be the weighted average of the capacity utilization rate and the wear leveling requirement value, and the weight coefficient can be adjusted according to actual needs. Finally, the system allocates the global spare blocks to each sub-area according to the calculated number and updates the allocation record of the global spare blocks.

[0144] S210: regenerate the sub-region distribution table based on the spare block allocation result, and adjust the rotation sequence table of each sub-region.

[0145] After completing the allocation of global spare blocks, the system needs to update the sub-region distribution table and the rotation sequence table to reflect the changes brought about by the spare block allocation.

[0146] First, the system regenerates the sub-region distribution table based on the allocation results of the spare blocks. The sub-region distribution table records the start address, end address, capacity, number of spare blocks, and other information of each sub-region. Due to the addition of global spare blocks, the storage capacity and number of spare blocks in each sub-region will change, so the relevant fields in the sub-region distribution table need to be updated. The updated sub-region distribution table can accurately reflect the storage space status of each sub-region, providing a basis for subsequent data storage and wear leveling control.

[0147] Next, the system adjusts the rotation sequence list of each sub-region according to the updated sub-region distribution table. The rotation sequence list records the rotation order and time interval of the data blocks in each sub-region. Due to the addition of spare blocks, the number and distribution of data blocks in the sub-region will change, and the original rotation sequence may no longer be applicable. Therefore, the system needs to recalculate the rotation sequence of each sub-region and update the rotation sequence list.

[0148] When adjusting the rotation sequence list, the system needs to consider the location and wear status of the newly added spare blocks. Generally speaking, the newly added spare blocks have a lower degree of wear and should be used to replace severely worn data blocks. Therefore, the system can insert the spare blocks to the front of the rotation sequence to give them priority in the data block rotation operation. At the same time, the system also needs to adjust the rotation time interval to adapt to the new data block distribution. If the number of data blocks in the sub-area increases, the rotation time interval can be extended accordingly; if the wear status of the sub-area is improved, the rotation time interval can also be appropriately shortened.

[0149] In the above embodiment, the original data blocks of the target area are merged with the migrated data blocks to reorganize the rotation link, and the remaining normal storage blocks of the source area to be migrated are marked as global spare blocks, thereby realizing dynamic adjustment of storage resources. Based on the historical migration records, the regional group with continuous migration relationship is identified, and the wear leveling coefficient is calculated in combination with the average wear value, and the rotation rate adjustment factor is generated to optimize the rotation time interval. When a sufficient number of global spare blocks are accumulated, the system performs reverse balancing allocation according to the capacity utilization rate and wear leveling requirements of each area, so that the system can achieve a wider range of wear leveling at the regional level. By dynamically adjusting the rotation parameters and spare resource allocation, the system's responsiveness and correction effect to uneven wear are improved.

[0150] In another embodiment, before step S209, the system calculates the effective data density of each sub-region, where the effective data density is the proportion of non-free storage blocks in the sub-region;

[0151] Count the data update frequency of each sub-area;

[0152] Calculate the spare block requirement of each sub-area based on the effective data density and data update frequency;

[0153] According to the wear value corresponding to the global spare block and the preset wear value interval, the global spare block is divided into several wear levels;

[0154] The number quota of global spare blocks of different wear levels available to each sub-region is determined according to the spare block demand.

[0155] The number quota of global spare blocks of different wear levels available to each sub-region is determined according to the spare block demand, specifically including:

[0156] Count the number of global spare blocks at each wear level, and calculate the proportion of spare blocks at each wear level;

[0157] Calculate the initial allocation weight based on the spare block demand of each sub-area, where the initial allocation weight is proportional to the spare block demand;

[0158] The initial allocation weight is modified in combination with the current average wear value of each sub-area to obtain a modified allocation weight;

[0159] According to the modified allocation weight and the proportion of the number of spare blocks at each wear level, the number quota of global spare blocks obtained by each sub-region at each wear level is calculated.

[0160] Before allocating global spare blocks, the system first conducts a fine-grained evaluation and calculation of the spare block requirements of each sub-region, and determines the number of global spare blocks available to each sub-region at different wear levels based on the wear level of the global spare blocks. This spare block allocation method is more sophisticated and comprehensive than the original allocation strategy, and can better meet the actual needs of each sub-region, improving the rationality and effectiveness of spare block allocation.

[0161] The system calculates the effective data density of each sub-region, that is, the ratio of non-free storage blocks in the sub-region to the total number of storage blocks. The higher the effective data density, the higher the storage space utilization of the sub-region, the fewer free storage blocks available, and the greater the demand for spare blocks.

[0162] The system counts the data update frequency of each sub-region. The data update frequency reflects the degree of dynamic change of data in the sub-region. The higher the data update frequency, the more frequent the data modification and write operations in the sub-region, and the greater the demand for spare blocks. Because frequent data updates accelerate the wear of storage blocks, more spare blocks are needed to replace worn and failed storage blocks.

[0163] The system calculates the spare block requirement of each sub-region based on the effective data density and data update frequency. The spare block requirement comprehensively considers the storage space utilization and data update characteristics of the sub-region, and can more accurately reflect the actual demand of the sub-region for spare blocks. The spare block requirement can be calculated by the weighted average of the effective data density and the data update frequency, and the weight coefficient can be adjusted according to the actual situation.

[0164] The system divides the global spare blocks into several wear levels according to the wear values ​​corresponding to the global spare blocks and the preset wear value range. The wear level indicates the degree of wear of the spare blocks, and different wear levels correspond to different wear value ranges. The higher the wear level, the more serious the wear of the spare blocks and the shorter the usable life. By dividing the wear levels, the system can manage and use the global spare blocks more meticulously, and select spare blocks with appropriate wear levels for allocation according to the wear status of the sub-areas and spare block requirements.

[0165] The system determines the number of global spare blocks of different wear levels available to each sub-region based on the spare block demand. This step refines the spare block allocation process and fully considers the actual needs of the sub-region and the wear status of the global spare blocks.

[0166] In specific implementation, the system counts the number of global spare blocks for each wear level and calculates the proportion of spare blocks at each wear level. The initial allocation weight is calculated based on the spare block demand of each sub-area. The initial allocation weight is proportional to the spare block demand, that is, the sub-area with a higher spare block demand has a larger initial allocation weight and should be allocated more spare blocks. The system corrects the initial allocation weight based on the current average wear value of each sub-area. If the current average wear value of a sub-area is high, it means that the wear of the sub-area is more serious. When allocating spare blocks, its allocation weight should be appropriately reduced to balance the wear differences between sub-areas. The weight obtained after correction is called the corrected allocation weight. The system calculates the quota of global spare blocks obtained by each sub-area at each wear level based on the corrected allocation weight and the proportion of spare blocks at each wear level.

[0167] In the above embodiment, the effective data density is combined with the data update frequency to calculate the spare block demand, so that the spare block allocation can take into account the storage pressure and data update load of the region at the same time, and can accurately reflect the actual demand intensity of each region for spare space. The global spare blocks are divided into levels according to the wear value interval, so that spare resources with different wear degrees can be fully utilized. The spare block quantity quota of each region at different wear levels is determined based on the spare block demand, so that the allocation of spare resources can not only meet the spare space quantity requirements of high-demand areas, but also promote wear balance between regions through the reasonable matching of spare blocks of different wear levels. The spare space allocation strategy can be optimized according to the actual storage characteristics and operating status of each region, the utilization efficiency of spare block resources can be improved, and the differentiated allocation of wear levels can be used to assist in achieving more sophisticated wear balance control.

[0168] The following describes the system in the embodiment of the present invention from the perspective of hardware processing. Figure 3 , which is a schematic diagram of the physical device structure of a solid state drive bad block wear leveling system provided in an embodiment of the present application.

[0169] It should be noted that Figure 3 The structure of the system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0170] like Figure 3 As shown, the system includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 302 or the program loaded from the storage part 308 to the random access memory (RAM) 303, such as executing the method in the above embodiment. In RAM 303, various programs and data required for system operation are also stored. CPU 301, ROM 302 and RAM 303 are connected to each other through a bus 304. Input / output (I / O) interface 305 is also connected to bus 304.

[0171] The following components are connected to the I / O interface 305: an input section 306 including a camera, an infrared sensor, etc.; an output section 307 including a liquid crystal display (LCD) and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed so that a computer program read therefrom is installed into the storage section 308 as needed.

[0172] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 309, and / or installed from a removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, various functions defined in the present invention are performed.

[0173] It should be noted that the computer-readable medium shown in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable computer program. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.

[0174] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. Among them, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0175] As another aspect, the present invention further provides a computer-readable storage medium, which may be included in the system described in the above embodiment; or may exist independently without being assembled into the system. The above storage medium carries one or more computer programs, and when the above one or more computer programs are executed by a processor of a system, the system implements the method provided in the above embodiment.

[0176] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0177] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0178] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0179] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

Claims

1. A method for wear leveling of bad blocks of a solid state drive, characterized in that: include: Dividing the storage area of ​​the solid state drive into a plurality of sub-areas and generating a sub-area distribution table, each of the sub-areas comprising a preset number of storage blocks and corresponding local spare blocks; Based on the sub-area distribution table, a data block rotation link is established in each of the sub-areas and recorded as a rotation sequence table; Performing a data block rotation operation according to a preset period, and recording a wear state of each of the sub-areas; When a newly added bad block is detected, the sub-region containing the bad block is marked as a source region to be migrated in the sub-region distribution table; According to the number of bad blocks and the wear status recorded in the sub-region distribution table, a sub-region with the smallest cumulative wear value is selected from other sub-regions except the sub-region containing the bad blocks as the target region, and a mapping relationship between the source region to be migrated and the target region is established; Based on the mapping relationship and the rotation sequence table, migrate the data in the source area to be migrated to the target area in the order in the rotation sequence table; Combine the original data blocks in the target area with the migrated data blocks and number them, regenerate the rotation link of the target area, and update the rotation sequence table of the target area; Mark the remaining normal storage blocks in the source area to be migrated as global spare blocks, and record the physical location information and wear value of the global spare blocks; Counting historical migration records of each of the sub-regions in the sub-region distribution table; Marking the sub-regions with continuous migration relationships in the historical migration records as migration association groups to obtain a region grouping information table; Calculating the average wear value of the storage blocks in each of the sub-regions, and determining the wear leveling coefficient of each of the sub-regions in combination with the migration association group mark in the sub-region grouping information table; generating a rotation rate adjustment factor for each of the sub-regions based on the wear leveling coefficient, wherein the adjustment factor is inversely proportional to the wear leveling coefficient; Update the rotation time interval in the rotation sequence table of each sub-area according to the adjustment factor; When the number of the global spare blocks reaches a preset number, calculating the current storage capacity and average wear value of each of the sub-areas; Allocating the global spare blocks according to the reverse balancing principle according to the capacity utilization rate and wear leveling requirements of each sub-area; The sub-region distribution table is regenerated based on the spare block allocation result, and the rotation sequence table of each sub-region is adjusted.

2. The method according to claim 1, characterized in that The step of dividing the storage area of ​​the solid state hard disk into a plurality of sub-areas and generating a sub-area distribution table specifically includes: Dividing the storage area of ​​the solid state drive into a plurality of pre-divided sub-areas based on the physical distribution characteristics of the storage blocks; Performing cluster analysis on the pre-divided sub-regions, and calculating the access frequency and data update rate of the storage blocks in each of the pre-divided sub-regions; Reorganize the pre-divided sub-regions according to the access frequency and the data update rate, and merge the pre-divided sub-regions with the same access mode into target sub-regions; Allocating a local spare block to each of the target sub-regions, wherein the number of the local spare blocks is positively correlated with the data update rate of the target sub-region; A sub-region distribution table is generated according to the boundary information of the target sub-region and the local spare block allocation result.

3. The method according to claim 1, characterized in that The step of establishing a data block rotation link in each of the sub-areas based on the sub-area distribution table and recording the data block rotation link as a rotation sequence table specifically includes: Counting the number of accesses and the most recent access time of the storage blocks in each of the sub-areas within a preset time window; Dividing the storage blocks in each of the sub-areas into high-frequency access blocks, medium-frequency access blocks and low-frequency access blocks according to the number of accesses and the most recent access time; A data block rotation link is constructed in each of the sub-areas, wherein the high-frequency access block, the medium-frequency access block and the low-frequency access block respectively form independent ring sub-links in the data block rotation link; Setting a data block exchange path between the ring sub-links; When the access characteristic of the storage block changes, the storage block is migrated to a ring sub-link of a corresponding level through the data block exchange path; Calculating a rotation interval of each of the ring sub-links, wherein the rotation interval is inversely proportional to an average number of accesses to storage blocks in the ring sub-link; The structural information of the data block rotation link, the data block exchange path and the rotation interval time are recorded in the rotation sequence table.

4. The method according to claim 1, characterized in that: The step of generating the rotation rate adjustment factor of each sub-area based on the wear leveling coefficient specifically includes: Calculate the standard deviation of the storage block wear value in each of the sub-areas; Performing weighted correction on the wear leveling coefficient according to the standard deviation to obtain a correction coefficient; Calculating an initial adjustment factor for the rotation rate based on the correction factor, wherein the initial adjustment factor is inversely proportional to the correction factor; Counting the bad block growth rate of each sub-area within a preset time period, and using the bad block growth rate as a risk factor; The initial adjustment factor is multiplied by the risk factor to obtain a rotation rate adjustment factor.

5. The method according to claim 1, characterized in that Before allocating the global spare blocks according to the reverse balancing principle based on the capacity utilization rate and wear leveling requirements of each sub-area, the method further includes: Calculating the effective data density of each of the sub-regions, where the effective data density is the ratio of non-free storage blocks in the sub-region; Counting the data update frequency of each of the sub-areas; Calculating the spare block requirement of each of the sub-areas based on the effective data density and the data update frequency; According to the wear value corresponding to the global spare block and the preset wear value interval, the global spare block is divided into several wear levels; The number quota of global spare blocks of different wear levels available to each of the sub-areas is determined according to the spare block demand.

6. The method according to claim 5, characterized in that The determining, according to the spare block demand, the number quota of global spare blocks of different wear levels available to each sub-region specifically includes: Counting the number of global spare blocks of each wear level, and calculating the proportion of spare blocks of each wear level; Calculating an initial allocation weight based on the spare block requirement of each sub-area, wherein the initial allocation weight is proportional to the spare block requirement; The initial allocation weight is modified in combination with the current average wear value of each sub-area to obtain a modified allocation weight; The global spare block quantity quota obtained by each of the sub-regions at each of the wear levels is calculated according to the modified allocation weight and the proportion of the spare block quantity at each of the wear levels.

7. A bad block wear leveling system for a solid state hard disk, characterized in that: The system comprises: One or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the system to execute the method as described in any one of claims 1-6.

8. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on a system, the system is caused to execute the method according to any one of claims 1 to 6.

9. A computer program product, characterized in that When the computer program product is executed on a system, the system is caused to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Abrasion balance management method for interiors of storage units and distributed storage system

    CN108710472A

  • Solid state disk, wear balancing method thereof and terminal equipment

    CN112817880A